SQL Geospatial Data
RadMap supports binding to SQL Geospatial data. The control 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 the Geospatial data.
The SqlGeospatialDataReader supports the following geometry types:
Point
LineString
Polygon
Triangle
MultiPoint
MultiLineString
MultiPolygon
GeometryCollection
The coordinates for geometries may be 2D (x, y), 3D (x, y, z), 4D (x, y, z, m) with an m value that is part of a linear referencing system or 2D with an m value (x, y, m). However the SqlGeospatialDataReader uses the x and y coordinates only, so that the z and m coordinates will be ignored. The SqlGeospatialDataReader can be used in the InformationLayer.Reader property the same way as the MapShapeReader. The sample code is below:
It allows using the ClearLayer, ExtendedPropertySet, ToolTipFormat, ToolTipTemplate, ToolTipStyle and CoordinateConverter properties the same way they are used in MapShapeReader. Also it supports the PreviewReadCompleted and ReadCompleted events which are used in MapShapeReader.
The SqlGeospatialDataReader class allows using the following data sources:
Domain Service
Wcf Data Service
ADO.NET Entity Data Model
Linq to SQL
DataSet
Telerik OpenAccess Domain Model
Also the SqlGeospatialDataReader can use any custom data class which implements the IEnumerable interface and contains a property with geospatial data in Wkt (Well known text) or Wkb (Well known binary) format. In this case the geospatial property should be a string, byte array or any other type which allows to get geospatial data in Wkt using the ToString() method. Note, the data models in Visual Studio 2010 (except the Telerik OpenAccess Domain Model) do not allow to use native SQL geospatial field types. You will need to create for example appropriate views on the SQL server which converts the native geospatial field to WKT or WKB formatted field. It could be done using the STAsText and STAsBinary stored procedures. A sample view definition is shown:
If you use Entity Data Model, Linq to SQL or Telerik OpenAccess Domain Model in your WPF application, then you can use the following sample XAML code to display your geospatial data:
In our SDK examples repository you can find a runnable example showing how to define a Wkt reader that loads sample data from a collection of Wkt based objects.