Async SQL Geospatial Data Reader
RadMap VisualizationLayer supports async reading from an SQL Geospatial data source. To do this use the AsyncSqlGeospatialDataReader class.
The AsyncSqlGeospatialDataReader allows you to provide an IEnumerable of any object that contains geospatial data in Wkt (Well known text) or Wkb (Well known binary) format. Then you can map a property from the objects that hold the data and the reader will create MapShapeData objects (shapes) based on the fetched information.
Setting up the Reader
AsyncSqlGeospatialDataReader is supported in the map's VisualizationLayer. You can assign it to the Reader property of the layer.
The IEnumerable collection with the geospatial data is provided to the reader via its Source property. And the mapping to the concrete property that holds the geospatial data is created via the GeospatialPropertyName property of the reader.
See the Code Example section of this article for a code sample showing how to setup the data and the reader.
Supported Geometries
The AsyncSqlGeospatialDataReader supports the following geometry types.
Point
LineString
Polygon
Triangle
MultiPoint
MultiLineString
MultiPolygon
GeometryCollection
The geometry coordinates 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 AsyncSqlGeospatialDataReader uses the x and y coordinates only, and the z and m coordinates will be ignored.
Code Example
This section shows how to assemble an example that demonstrates reading Wkt geospatial data.
Example 1: Defining the Wkt model and the data storage
Example 2: Defining the map with the reader and setting it up
Additionally, the ItemTemplate of the VisualizationLayer is set. This will affect only the Point geometries. Instead of the default pin we show a simple ellipse. The MapLayer.HotSpot property allows you to define a HotSpot object that offsets the position of the UIElement by relative portion of its size. In this example X=0.5 means half of the width and Y=0.5 half of the height of the Ellipse. The Ellipse will be centered at the location of the Point geometry.
Example 3: Setting the reader's source in code
Figure 1: RadMap populated with MapShapeData objects via the AsyncSqlGeospatialDataReader
The example is based on the AsyncSqlGeospatialDataReader SDK example.