ThinkGeo.com    |     Documentation    |     Premium Support

Problem with ECW Raster Layer in version 10

Hi,
Recently I’d migrated to MapSuiteWPFDesktop Ver 10. The migration process was went well except for EcwRasterLayer. Previously in ver 9 all my ECW files can be loaded without any problem. Is there anything that I miss out or any changes that I need to do in ver 10?

Below are the codes that I use:

private void LoadMap_MapInfoECW(string filename, ListecwFiles)
{
try
{
MainMap.MapUnit = GeographyUnit.DecimalDegree;

            //World Map Shape                
            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(string.Format(@"{0}\Countries02\{1}", MapDataPath, "Countries02.shp"));
            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(0xFF, 252, 188, 63));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;                              

            LayerOverlay baseMapOverlay = (LayerOverlay)MainMap.Overlays["BaseMapOverlay"];
            baseMapOverlay.TileType = TileType.MultipleTile;
            baseMapOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)));
            baseMapOverlay.Layers.Add("WorldLayer", worldLayer);                

            if (ecwFiles.Count > 0)
            {
                for (int x = 0; x < ecwFiles.Count; x++)
                {
                    if (File.Exists(string.Format(@"{0}{1}", MapDataPath, ecwFiles[x])))
                    {
                                                                                
                        EcwRasterLayer ecwLayer = new EcwRasterLayer();
                        ecwLayer.DrawingException += new EventHandler<DrawingExceptionLayerEventArgs>(ecwLayer_DrawingException);
                        ecwLayer.DrawingExceptionMode = DrawingExceptionMode.DrawException;
                        
                        ecwLayer.PathFilename = string.Format(@"{0}{1}", MapDataPath, ecwFiles[x]);
                                                    
                        baseMapOverlay.Layers.Add(string.Format("{0}_{1}", filename, x.ToString()), ecwLayer);
                        
                        //this.DisplayErrorMessage("LoadMap_MapInfoECW", ecwLayer.PathFilename);
                    }                        
                }
            }

            foreach (Layer layer in baseMapOverlay.Layers)
            {
                layer.Transparency = Convert.ToSingle(layerTransparency.Value);
            }

            txtSelectedBaseMap.Text = MapInfoGSTFileNameSelected;
            
            //MainMap.Refresh();
        }
        catch (Exception exception)
        {
            this.DisplayErrorMessage("LoadMap_MapInfoECW", exception.Message);                
        }
    }

    void ecwLayer_DrawingException(object sender, DrawingExceptionLayerEventArgs e)
    {
        e.Canvas.Clear(new GeoSolidBrush(GeoColor.FromArgb(128, 255, 192, 203)));            
        System.Drawing.Bitmap tempImage = new System.Drawing.Bitmap(string.Format("{0}\\ErrorImage.png", MapDataPath));
        MemoryStream stream = new MemoryStream();
        tempImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
        stream.Seek(0, SeekOrigin.Begin);
        tempImage.Dispose();
        e.Canvas.DrawScreenImageWithoutScaling(new GeoImage(stream), e.Canvas.Width / 2, e.Canvas.Height / 2, DrawingLevel.LabelLevel, 0, 0, 0);
        e.Cancel = true;
    } 

Attached are the ecw files sample. I can’t upload all files due to upload size limitation.

MAL_553.zip (2.4 MB)MAL_645.zip (2.4 MB)

Hi Basyirun,

I just create a simple sample with V10, both of your 2 files can be loaded succeed.

Please try my sample.

8665.zip.001.zip (2.9 MB)

8665.zip.002.zip (1.9 MB)

Please remove the latest .zip like this:

Then you can get the sample.

Regards,

Don

Thanks Don. I’ll give it a try and update later.

Hi Basyirun,

Any question please let us know.

Regards,

Don