Edit this page

SQL Geospatial Reader

SqlGeospatialDataReader allows generating map shapes from any IEnumerable instance (for example a row collection) which contains a property with geospatial data in Wkt (Well known text) or Wkb (Well known binary) format. The Source property and the GeospatialPropertyName property are used to specify the IEnumerable instance and the name of the property which contains Geospatial data.

Figure 1: SQL Geospatial Reader

map-file-readers-sql-geospatial-reader 001

Using SqlGeospatialDataReader


OpenStreetMapProvider osmProvider = new OpenStreetMapProvider();
this.radMap1.Providers.Add(osmProvider);
MapLayer layer = new MapLayer("Capitals");
this.radMap1.Layers.Add(layer);

BindingSource source = new BindingSource();
source.DataSource = dt;

SqlGeospatialDataReader datareader = new SqlGeospatialDataReader();
datareader.Source = source;
datareader.GeospatialPropertyName = "Geometry";

List<MapVisualElement> elements = datareader.Read(source, "Geometry", true, null);
foreach (var item in elements)
{
    item.BorderColor = Color.YellowGreen;
}

this.radMap1.Layers["Capitals"].AddRange(elements);

Dim osmProvider As New OpenStreetMapProvider()
Me.radMap1.Providers.Add(osmProvider)
Dim layer As New MapLayer("Capitals")
Me.radMap1.Layers.Add(layer)
Dim source As New BindingSource()
source.DataSource = dt
Dim datareader As New SqlGeospatialDataReader()
datareader.Source = source
datareader.GeospatialPropertyName = "Geometry"
Dim elements As List(Of MapVisualElement) = datareader.Read(source, "Geometry", True, Nothing)
For Each item As MapVisualElement In elements
    item.BorderColor = Color.YellowGreen
Next
Me.radMap1.Layers("Capitals").AddRange(elements)

Figure 2: Sample data table

map-file-readers-sql-geospatial-reader 002

Was this article helpful? Yes No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy