Layer DataSource doc

Topics: SharpMap v0.9 / v1.x
Oct 7, 2009 at 10:08 AM

Hi,

I use v0.9 SharpMap (last updates).

I added points to a datasource to plot them. It works fine.

Now, I'd like to access to them : may I do it from Layer DataSource ?

Where can I find documentation on DataSource class please ?

Data seem to be stored in a table... (talking about rows in sample codes...).

 

Thanks,

JL

Coordinator
Oct 7, 2009 at 11:25 AM
Edited Oct 7, 2009 at 2:24 PM

Hi JL Datasource is not a class but rather a property on the Layer of type IProvider.

Valid values of the property include instances of Shapefile, Sql2008, MsSqlSpatial, OleDbPoint etc. So if you know what type fo provider the layer is using you can cast back e.g  

Shapefile shp = layer.DataSource as Shapefile; 

hth jd

Oct 7, 2009 at 1:04 PM

Thanks, it works fine.

 

Layer is composed of SharpMap.Geometries.Point. Here how I access to the stored points :

// Cast in GeometryProvider
SharpMap.Data.Providers.GeometryProvider Prov = Layer.DataSource as SharpMap.Data.Providers.GeometryProvider;

// Cast in List of Points
System.Collections.Generic.IEnumerable<SharpMap.Geometries.Point> pListPoint = Prov.Geometries.Cast<SharpMap.Geometries.Point>();

// Transform in Table
SharpMap.Geometries.Point[] pPointTab = pListPoint.ToArray<SharpMap.Geometries.Point>();