ThinkGeo.com    |     Documentation    |     Premium Support

NauticalChartsFeatureLayer issues in v10

Hi,

I’m trying to load some S-57 nautical chart from NOAA office and I’m getting a rather odd error. I’m using the following code with map units in decimal degrees.

NauticalChartsFeatureLayer nc = new NauticalChartsFeatureLayer(file);
nc.Open();

RectangleShape rect = nc.GetBoundingBox();
FileInfo fi = new FileInfo(file);
LayerOverlay lo = new LayerOverlay();
lo.Layers.Add(fi.Name, nc);
map.Overlays.Add(fi.Name, lo);

The error is as follows. Am I missing a library or is it a v10 issue. The file I am loading is from the HowDoI samples and I can confirm that the sample runs in the HowDoI code which is v12. Interesting, I get a valid extent from the GetBoundingBox.

System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=ThinkGeo.MapSuite
StackTrace:
at ThinkGeo.MapSuite.Layers.RtreeSpatialIndex.0ig=()
at ThinkGeo.MapSuite.Layers.RtreeSpatialIndex.3yg=(Double upperLeftX, Double upperLeftY, Double lowerRightX, Double lowerRightY)
at ThinkGeo.MapSuite.Layers.RtreeSpatialIndex.3yg=(RectangleShape rectangle)
at ThinkGeo.MapSuite.Layers.RtreeSpatialIndex.GetFeatureIdsIntersectingBoundingBoxCore(RectangleShape boundingBox)
at ThinkGeo.MapSuite.Layers.NauticalChartsFeatureSource.Ak8=(RectangleShape boundingBox, IEnumerable1 returningColumnNames) at ThinkGeo.MapSuite.Layers.NauticalChartsFeatureSource.GetFeaturesForDrawingCore(RectangleShape boundingBox, Double screenWidth, Double screenHeight, IEnumerable1 returningColumnNames)
at ThinkGeo.MapSuite.Layers.FeatureSource.GetFeaturesForDrawing(RectangleShape boundingBox, Double screenWidth, Double screenHeight, IEnumerable1 returningColumnNames) at ThinkGeo.MapSuite.Layers.FeatureSource.GetFeaturesForDrawing(RectangleShape boundingBox, Double screenWidth, Double screenHeight, ReturningColumnsType returningColumnNamesType) at ThinkGeo.MapSuite.Layers.NauticalChartsFeatureLayer.DrawCore(GeoCanvas canvas, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.Layers.Layer.uyc=(GeoCanvas canvas, Collection1 labelsInAllLayers) at ThinkGeo.MapSuite.Layers.Layer.Draw(GeoCanvas canvas, Collection1 labelsInAllLayers)
at ThinkGeo.MapSuite.WinForms.LayerOverlay.DrawCore(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.Overlay.lVU=(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.Overlay.Draw(GeoCanvas canvas)
at ThinkGeo.MapSuite.WinForms.WinformsMap.TlU=(IEnumerable`1 drawingOverlays, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.TVU=(RectangleShape drawingExtent, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.bFU=(RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.IRk=(Int32 delayInterval, RectangleShape extent)
at ThinkGeo.MapSuite.WinForms.WinformsMap.Refresh()
at NauticalCharts.Form1.btnNautical_Click(Object sender, EventArgs e) in

Thanks,
Damian

Thanks Damian,
Base on the error. I think you miss the Rtree index. You could use the static method to build index before you do any other operation.

NauticalChartsFeatureLayer.BuildIndexFile(filename);

Thanks

Frank

Hi Frank,

Thanks, yes that’s it.

It’s odd though, the HowDoI sample works without this code.

Regards,
Damian

Thanks Damian,
Yes. HowDoI sample already have the index built. Before you build it you can check see if the file existing. if yes you don’t need build the index. This will give you some enhancement for the performance.

Thanks

Frank

Hi Frank,

That’s just it, there is no index file in the HowDoI sample directory. Not sure why it works without it.

Anyway, I’m all good now.

On a related note, I’m starting to query the column values of the features in these charts. They seem standardized. Is there a key available?

Thanks,
Damian

Thanks Damian,
Here is the xml file. It may help for you.

NauticalCharts.xml (991.4 KB)

Thanks

Frank