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();
MapLayer layer = new MapLayer("Capitals");

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;


Dim osmProvider As New OpenStreetMapProvider()
Dim layer As New MapLayer("Capitals")
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

Figure 2: Sample data table

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