Exemple #1
0
        private void TestForm_Load(object sender, EventArgs e)
        {
            //Sets the MapUnit and Extent of the Map.
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-100.4, 50, -60, -10);

            //Adds the ECW
            EcwRasterLayer ecwImageLayer = new EcwRasterLayer(@"..\..\Data\World.ecw");

            ecwImageLayer.UpperThreshold = double.MaxValue;
            ecwImageLayer.LowerThreshold = 0;
            LayerOverlay imageOverlay = new LayerOverlay();

            imageOverlay.Layers.Add("EcwImageLayer", ecwImageLayer);
            winformsMap1.Overlays.Add(imageOverlay);

            //Sets the events of TrackOverlay
            winformsMap1.TrackOverlay.TrackStarted += new EventHandler <TrackStartedTrackInteractiveOverlayEventArgs>(TrackStarted);
            winformsMap1.TrackOverlay.MouseMoved   += new EventHandler <MouseMovedTrackInteractiveOverlayEventArgs>(MouseMoved);
            winformsMap1.TrackOverlay.TrackEnded   += new EventHandler <TrackEndedTrackInteractiveOverlayEventArgs>(TrackEnded);

            groupBoxInfo.Visible = false;

            winformsMap1.Refresh();
        }
Exemple #2
0
        private void AddRasterLayers(IEnumerable <string> fileNames)
        {
            foreach (string fileName in fileNames)
            {
                try
                {
                    string layerName = new FileInfo(fileName).Name;

                    if (!((LayerOverlay)winformsMap1.Overlays[0]).Layers.Contains(layerName))
                    {
                        RasterLayer rasterLayer = null;
                        switch (Path.GetExtension(fileName).ToUpperInvariant())
                        {
                        case ".SID":
                            rasterLayer = new MrSidRasterLayer(fileName);
                            break;

                        case ".ECW":
                            rasterLayer = new EcwRasterLayer(fileName);
                            break;

                        case ".JP2":
                            rasterLayer = new Jpeg2000RasterLayer(fileName);
                            break;

                        case ".BMP":
                        case ".JPG":
                        case ".JPEG":
                        case ".GIF":
                        case ".TIFF":
                        case ".TIF":
                            rasterLayer = new GdiPlusRasterLayer(fileName);
                            break;

                        default:
                            break;
                        }

                        if (rasterLayer != null && ExplorerHelper.ValidateRasterLayer(rasterLayer))
                        {
                            rasterLayer.Name = layerName;
                            winformsMap1.Overlays[0].Lock.EnterWriteLock();
                            try
                            {
                                ((LayerOverlay)winformsMap1.Overlays[0]).Layers.Add(layerName, rasterLayer);
                            }
                            finally
                            {
                                winformsMap1.Overlays[0].Lock.ExitWriteLock();
                            }
                            SetupThemeItem(rasterLayer);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, ex.GetType().ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, (MessageBoxOptions)0);
                }
            }
        }
        protected override RasterLayer GetRasterLayer(Uri uri)
        {
            EcwRasterLayer layer = null;

            layer = new EcwRasterLayer(uri.LocalPath);

            return(layer);
        }
        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
            wpfMap1.CurrentExtent = new RectangleShape(-118.098, 84.3, 118.098, -84.3);

            EcwRasterLayer ecwImageLayer = new EcwRasterLayer(@"..\..\SampleData\Data\World.ecw");
            ecwImageLayer.UpperThreshold = double.MaxValue;
            ecwImageLayer.LowerThreshold = 0;

            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.Layers.Add("EcwImageLayer", ecwImageLayer);
            wpfMap1.Overlays.Add(staticOverlay);

            wpfMap1.Refresh();
        }
        protected override RasterLayer GetRasterLayer(Uri uri, WorldFileInfo wInfo)
        {
            EcwRasterLayer layer = null;

            if (File.Exists(wInfo.WorldFilePath))
            {
                layer = new EcwRasterLayer(uri.LocalPath, wInfo.WorldFilePath);
            }
            else
            {
                layer = new EcwRasterLayer(uri.LocalPath);
            }

            return(layer);
        }
        private void MapView_Loaded(object sender, RoutedEventArgs e)
        {
            mapView.MapUnit = GeographyUnit.DecimalDegree;
            mapView.CurrentExtent = new RectangleShape(-180, 90, 180, -90);

            EcwRasterLayer ecwImageLayer = new EcwRasterLayer(SampleHelper.Get("World.ecw"));
            ecwImageLayer.UpperThreshold = double.MaxValue;
            ecwImageLayer.LowerThreshold = 0;

            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.Layers.Add("EcwImageLayer", ecwImageLayer);
            mapView.Overlays.Add(staticOverlay);

            mapView.Refresh();
        }
        private void CreateASpatialIndexForAShapeFileLayer_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-111.7875, 92.0859375, 148.36875, -93.5390625);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            EcwRasterLayer worldImageLayer = new EcwRasterLayer(Samples.RootDirectory + @"Data\World.ecw");

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.shp");

            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.StartCap = DrawingLineCap.Round;
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.EndCap   = DrawingLineCap.Round;
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer usStatesLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\USStates.shp");

            usStatesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.State2;
            usStatesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.StartCap = DrawingLineCap.Round;
            usStatesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer worldCapitalsLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\WorldCapitals.shp");

            worldCapitalsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = PointStyles.Capital3;
            worldCapitalsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer worldCapitalsLabelsLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\WorldCapitals.shp");

            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle                       = TextStyles.Capital3("city_name");
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen               = new GeoPen(GeoColor.StandardColors.White, 2);
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen.StartCap      = DrawingLineCap.Round;
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen.EndCap        = DrawingLineCap.Round;
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.SuppressPartialLabels = true;
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel                    = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay();

            staticOverlay.Layers.Add("WorldImageLayer", worldImageLayer);
            staticOverlay.Layers.Add("WorldLayer", worldLayer);
            staticOverlay.Layers.Add("USStatesLayer", usStatesLayer);
            staticOverlay.Layers.Add("WorldCapitals", worldCapitalsLayer);
            staticOverlay.Layers.Add("WorldCapitalsLabels", worldCapitalsLabelsLayer);
            winformsMap1.Overlays.Add(staticOverlay);

            winformsMap1.Refresh();
        }
        private void LoadAnEcwImage_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-118.098, 84.3, 118.098, -84.3);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            EcwRasterLayer ecwImageLayer = new EcwRasterLayer(Samples.RootDirectory + @"Data\World.ecw");

            ecwImageLayer.UpperThreshold = double.MaxValue;
            ecwImageLayer.LowerThreshold = 0;

            LayerOverlay imageOverlay = new LayerOverlay();

            imageOverlay.Layers.Add("EcwImageLayer", ecwImageLayer);
            winformsMap1.Overlays.Add(imageOverlay);

            winformsMap1.Refresh();
        }
Exemple #9
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

            LayerOverlay overlay = new LayerOverlay();

            //To resolve issue that we cannot run the executable by double click it on linux, we need to find out the absolute path by reflection.
            string baseDirectory    = System.AppDomain.CurrentDomain.BaseDirectory;
            string ecwLayerFileName = Path.GetFullPath(Path.Combine(baseDirectory, "../../App_Data/World.ecw"));

            EcwRasterLayer ecwRasterLayer = new EcwRasterLayer(ecwLayerFileName);

            overlay.Layers.Add(ecwRasterLayer);

            winformsMap1.Overlays.Add(overlay);

            ecwRasterLayer.Open();
            winformsMap1.CurrentExtent = ecwRasterLayer.GetBoundingBox();

            winformsMap1.Refresh();
        }
Exemple #10
0
        private void Form_Load(object sender, EventArgs e)
        {
            // It is important to set the map unit first to either feet, meters or decimal degrees.
            mapView.MapUnit = GeographyUnit.DecimalDegree;

            // Create a new overlay that will hold our new layer and add it to the map.
            LayerOverlay layerOverlay = new LayerOverlay();

            mapView.Overlays.Add(layerOverlay);

            // Create the new layer and dd the layer to the overlay we created earlier.
            EcwRasterLayer ecwRasterLayer = new EcwRasterLayer("../../../Data/Ecw/World.ecw");

            layerOverlay.Layers.Add(ecwRasterLayer);

            // Set the map view current extent to a slightly zoomed in area of the image.
            mapView.CurrentExtent = new RectangleShape(-90.5399054799761, 68.8866552710533, 57.5181302343096, -43.7137911575181);

            // Refresh the map.
            mapView.Refresh();
        }
        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap1.MapUnit = GeographyUnit.Meter;
            wpfMap1.CurrentExtent = new RectangleShape(-10000000, 10000000, 10000000, -10000000);

            EcwRasterLayer ecwImageLayer = new EcwRasterLayer(@"..\..\SampleData\Data\World.ecw");
            ecwImageLayer.UpperThreshold = double.MaxValue;
            ecwImageLayer.LowerThreshold = 0;

            ManagedProj4Projection proj4 = new ManagedProj4Projection();
            proj4.InternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString();
            proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(3857);

            ecwImageLayer.ImageSource.Projection = proj4;

            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.Layers.Add("EcwImageLayer", ecwImageLayer);
            wpfMap1.Overlays.Add(staticOverlay);

            wpfMap1.Refresh();
        }
        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
            wpfMap1.CurrentExtent = new RectangleShape(-111.7875, 92.0859375, 148.36875, -93.5390625);

            EcwRasterLayer worldImageLayer = new EcwRasterLayer(@"..\..\SampleData\Data\World.ecw");

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\Countries02.shp");
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.StartCap = DrawingLineCap.Round;
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.EndCap = DrawingLineCap.Round;
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer usStatesLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\USStates.shp");
            usStatesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.State2;
            usStatesLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.StartCap = DrawingLineCap.Round;
            usStatesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer worldCapitalsLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\WorldCapitals.shp");
            worldCapitalsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital3;
            worldCapitalsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer worldCapitalsLabelsLayer = new ShapeFileFeatureLayer(@"..\..\SampleData\Data\WorldCapitals.shp");
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.Capital3("city_name");
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 2);
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen.StartCap = DrawingLineCap.Round;
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.HaloPen.EndCap = DrawingLineCap.Round;
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.SuppressPartialLabels = true;
            worldCapitalsLabelsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay worldOverlay = new LayerOverlay();
            worldOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)));
            worldOverlay.Layers.Add("WorldImageLayer", worldImageLayer);
            worldOverlay.Layers.Add("WorldLayer", worldLayer);
            worldOverlay.Layers.Add("USStatesLayer", usStatesLayer);
            worldOverlay.Layers.Add("WorldCapitals", worldCapitalsLayer);
            worldOverlay.Layers.Add("WorldCapitalsLabels", worldCapitalsLabelsLayer);
            wpfMap1.Overlays.Add("WorldOverlay", worldOverlay);

            wpfMap1.Refresh();
        }