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); } } }
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.Meter; // Create the background world maps using vector tiles requested from the ThinkGeo Cloud Service and add it to the map. ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light); mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay); // 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. MrSidRasterLayer jp2000RasterLayer = new MrSidRasterLayer("../../../Data/Jp2/m_3309650_sw_14_1_20160911_20161121.jp2"); layerOverlay.Layers.Add(jp2000RasterLayer); // Set the map view current extent to a slightly zoomed in area of the image. mapView.CurrentExtent = new RectangleShape(-10783910.2966461, 3917274.29233111, -10777309.4670677, 3912119.9131963); // Refresh the map. mapView.Refresh(); }
protected override RasterLayer GetRasterLayer(Uri uri, WorldFileInfo wInfo) { RasterLayer layer = null; if (File.Exists(wInfo.WorldFilePath)) { layer = new MrSidRasterLayer(uri.LocalPath, wInfo.WorldFilePath); } else { layer = new MrSidRasterLayer(uri.LocalPath); } //layer.SafeProcess(() => //{ // if (layer.HasProjectionText) // { // string proj = layer.GetProjectionText(); // if (!proj.Equals(GisEditor.ActiveMap.DisplayProjectionParameters, StringComparison.OrdinalIgnoreCase)) // { // Proj4Projection projection = new Proj4Projection(); // projection.InternalProjectionParametersString = proj; // projection.ExternalProjectionParametersString = GisEditor.ActiveMap.DisplayProjectionParameters; // layer.ImageSource.Projection = projection; // } // } //}); 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); MrSidRasterLayer sidImageLayer = new MrSidRasterLayer(@"..\..\SampleData\Data\world.sid"); sidImageLayer.UpperThreshold = double.MaxValue; sidImageLayer.LowerThreshold = 0; LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("SidImageLayer", sidImageLayer); wpfMap1.Overlays.Add(staticOverlay); wpfMap1.Refresh(); }
private void WpfMap_Loaded(object sender, RoutedEventArgs e) { mapView.MapUnit = GeographyUnit.DecimalDegree; mapView.CurrentExtent = new RectangleShape(-118.098, 84.3, 118.098, -84.3); MrSidRasterLayer sidImageLayer = new MrSidRasterLayer(SampleHelper.Get("world.sid")); sidImageLayer.UpperThreshold = double.MaxValue; sidImageLayer.LowerThreshold = 0; LayerOverlay staticOverlay = new LayerOverlay(); staticOverlay.Layers.Add("SidImageLayer", sidImageLayer); mapView.Overlays.Add(staticOverlay); mapView.Refresh(); }
private void LoadAMrSidImage_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); MrSidRasterLayer sidImageLayer = new MrSidRasterLayer(Samples.RootDirectory + @"Data\world.sid"); sidImageLayer.UpperThreshold = double.MaxValue; sidImageLayer.LowerThreshold = 0; LayerOverlay imageOverlay = new LayerOverlay(); imageOverlay.Layers.Add("SidImageLayer", sidImageLayer); winformsMap1.Overlays.Add(imageOverlay); winformsMap1.Refresh(); }
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. MrSidRasterLayer mrSidRasterLayer = new MrSidRasterLayer("../../../Data/MrSid/World.sid"); layerOverlay.Layers.Add(mrSidRasterLayer); // 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(); }