S-57 Presentation

Topics: SharpMap v0.9 / v1.x
Apr 29, 2014 at 9:00 AM
Is there a way in SharpMap to display S-57 data with the S-52 presentation scheme?

I have a quick sample running for S-57 data using an Ogr provider and a vector layer. Works fine, but as expected its just simple points, polygons, and lines compared to the presentation on an ECDIS

var p = new SharpMap.Data.Providers.Ogr(path, i);
if (!p.IsFeatureDataLayer) continue;
var v = new VectorLayer("" + i, p);
v.MaxVisible = 30;
Apr 29, 2014 at 10:47 AM
You need to make sure that the s57 csv files are in the gdal_data path.
Which version of SharpMap do you use? If you use a fairly recent version it should be deployed and configured with the nuget packages.
Apr 29, 2014 at 11:28 AM
Edited Apr 29, 2014 at 11:39 AM
Yes the s57 csv files are in my config file path "FWToolsGdalData". I am using version 1.1 from nuget.
Apr 29, 2014 at 1:59 PM
If you use SharpMap.Extensions package you should have Gdal and Gdal.Native packages included with your application.
This means there should be a x86 and x64 and share subfolder in your bin folder. The share subfolder should contain the s57 csv files that are to be used.
If that is not the case, there is sth wrong.

Have a look at the WinFormSamples project. It has a S57 OGR sample that breaks an s57 file down in all its layers.
Apr 29, 2014 at 2:34 PM
I did have the folders but not the csv files. I copied them but same result.

I noticed in the OGR sample that its assigning random colors to polygons and lines, the points are circles as opposed to the S57 specification(S52 I suppose).

Is there a way other than manually setting the layer styles for each S57 feature type? For example land areas have a default color according to the S52 spec.
Apr 29, 2014 at 5:27 PM
Oh sorry, I misinterpreted your question. You do get more than three layers out of the S57 file, but the styling is not correct?

In that case there is no predefined set of styles for SharpMap v0.9/1.0. I happen to know someone who did that for SharpMap v2 (deprecated), perhaps he can share his work.
Apr 29, 2014 at 5:36 PM
Thanks, if you have any samples or contact information it would be appreciated.
May 5, 2014 at 12:57 AM
Hey rmathew2

I managed to get something that was really close to S-52 working several years ago. There are a few things I did differently though as we were creating a simple map system for use over water, more like google maps, and not a full S-52 implementation. One thing I did was that I merged all charts for the same purpose into a single table. So I had tables for features 1 - 6. This was to reduce the number of db calls to draw anything as Otherwise there is something like 100 layers? Then i just ordered the features by the display order that S-52 states.

The reason that I used SharpMap 2.0 code base was that it had a rasterizer interface that allowed me to implement the custom rules for a feature. Some features required drawing multiple things, so I used this interface to create composite rasterizers. This took the feature, looked up the rasterize rule for the feature, and then executed it. The functions in one of the documents that I cannot find right now is what I implemented using this rasterizer interface. I Also had a convention by naming the rasterizer by the name in the standard document, then like the ASP MVC conventions, based on the render rule for the feature, I could create a rasterizer by finding the type name.

There was also a text file that has all the symbols in a type of vector language and also the render functions to call for features? I wrote something that created WPF resources like brushes and bitmaps etc. Then I could find these using the keys like LANDA etc. So the app startup processed all those files and created all the lookups for all the resource, and also the render rules in that file for the feature types built the composite rasterizers.

The things that I could not do.
  • There is a rule for changing the outline of some features depending on the accuracy of the feature. This should not be a problem with charts that are purchased, but this field is stored as property of the geometry in the S57 file, and is lost when converted to an OGC IGeometry object.
  • The thick black safety line that is to be drawn between depth areas where it changes from safe to not safe. I couldn't find an easy way to use the out of the box object model to solve that problem. But it just a software issue as they say.
This is the majority that I can remember. I havent seen the code in a number of years and no longer will be able to.
May 5, 2014 at 12:10 PM
Thanks for the info pdiddy. I was planning to write code to draw each individual feature type. I assume the document you are referring to is one of those files bundled in the GDAL data folder. I will check it out.

Based on the amount of effort involved, I have been starting to lean towards ESRI for my current requirement. This sounds like an interesting contribution to make to SharpMap in the future though, I think I will consider proposing a change down the line.