This project has moved. For the latest updates, please go here.

Failed to load Text information from ENC File, using OGR provider.

Topics: General Topics
Feb 26, 2015 at 8:27 AM
i am using SharpMap 1.1, and use function "initializeS57(float angle) from "\WinFormSamples\OgrSample.cs" to load ENC files, and it loads successfully in my applicaiton but unfortunately without any textual information, but when I load this same ENC file with globalmapper software, all textual information is also displayed.

what is wrong or something that I am missing in my code. Snapshots of both SharpMap and GlobalMapper are attached for demonstration. source code of "initalizeS57" function is also attached

please help me in this regard.
private static Map InitializeS57(float angle)

        //Initialize a new map of size 'imagesize'
        Map map = new Map();

        //Set the datasource to a shapefile in the App_data folder
        Ogr provider;
            provider = new Ogr("GeoData/S57/US5TX51M.000");
        catch (TypeInitializationException ex)
            if (ex.Message == "The type initializer for 'OSGeo.OGR.Ogr' threw an exception.")
                throw new Exception(
                        "The application threw a PINVOKE exception. You probably need to copy the unmanaged dll's to your bin directory. They are a part of fwtools {0}. You can download it from:",

        VectorLayer lay;
        Random rnd = new Random(9);
        for (Int32 i = provider.NumberOfLayers - 1; i >= 0; i--)
            Ogr prov = new Ogr("GeoData/S57/US5TX51M.000", i);
            if (!prov.IsFeatureDataLayer) continue;
            string name = prov.LayerName;
            System.Diagnostics.Debug.WriteLine(string.Format("Layer {0}: {1}", i, name));
            //if (provider.GeometryType )
            lay = new VectorLayer(string.Format("Layer_{0}", name), prov);
            if (prov.OgrGeometryTypeString.IndexOf("Polygon") > 0)
                lay.Style.Fill =
                    new SolidBrush(Color.FromArgb(150, Convert.ToInt32(rnd.NextDouble() * 255),
                                                  Convert.ToInt32(rnd.NextDouble() * 255),
                                                  Convert.ToInt32(rnd.NextDouble() * 255)));
                lay.Style.Outline =
                    new Pen(
                        Color.FromArgb(150, Convert.ToInt32(rnd.NextDouble() * 255),
                                       Convert.ToInt32(rnd.NextDouble() * 255),
                                       Convert.ToInt32(rnd.NextDouble() * 255)),
                        Convert.ToInt32(rnd.NextDouble() * 3));
                lay.Style.EnableOutline = true;
                lay.Style.Line =
                    new Pen(
                        Color.FromArgb(150, Convert.ToInt32(rnd.NextDouble()*255),
                                       Convert.ToInt32(rnd.NextDouble()*255), Convert.ToInt32(rnd.NextDouble()*255)),
        _ogrSampleDataset = "S-57";

        Matrix mat = new Matrix();
        mat.RotateAt(angle, map.WorldToImage(map.Center));
        map.MapTransform = mat;

        return map;
ENC loaded with GlobalMapper software tool...


ENC loaded with test application using SharpMap 1.1

Feb 26, 2015 at 12:02 PM
again, you have to add a LabelLayer for the information you want to display.

If I'm not mistaken, the S52/S57 ENC spec as a rigid information about which feature has to be displayed how at what zoom level, so it might make sense to create a custom ENC layer, that has that information at hand.

If you have a look at the other examples in the WinFormSamples project, you will find a lot of information about how to set up label layers.
Feb 28, 2015 at 3:08 PM
Thanks for your response, I will try to resolve problem soon.
Mar 1, 2015 at 8:05 PM
Hi FObermaier,
        Thank you very much for your support. Problem resolved as per your guidance