none
WPF Map Control sql geometry data

    Question

  • I have an existing WPF application that has geometry data stored in sql server 2008 r2. There are also some shape files that are used, but I can import these into SQL server if needed. I would like to use the new WPF Map Control to display the various geometry data sets as layers that can be turned on and off. What is required to query the SQL database and display the results as a layer in the WPF map control?

    Shane Gilbert

    Monday, June 25, 2012 10:11 PM

Answers

  • If you are willing to use some newer technology then take a look at this article: http://rbrundritt.wordpress.com/2012/06/08/entity-framework-5-bing-maps-wpf/ In this article I use Entity Framework 5 and to query a spatial database.

    Alternatively, if you are using older technology you can use standard SQL tools in WPF to connect directly to the Database and query the data. The Spatial Data can be handled using the Spatial types dll that can be used in .NET.


    http://rbrundritt.wordpress.com

    Tuesday, June 26, 2012 10:26 AM
  • The Geometry class is nearly identical to the Geography class. There is a couple of ways to do this.

    One is to convert the Geometry objects to Geography objects. This can easily be done by first making sure the geometry is valid, then using the binary of the geometry to create a geography object.  It might make sense to add a new column to your database and generate the geography data there.

    Another method is to use STX in place of the Long property and STY in place of the Lat property in the code that parses the geometry/geography into a map shape.


    http://rbrundritt.wordpress.com

    Thursday, March 20, 2014 10:53 AM

All replies

  • If you are willing to use some newer technology then take a look at this article: http://rbrundritt.wordpress.com/2012/06/08/entity-framework-5-bing-maps-wpf/ In this article I use Entity Framework 5 and to query a spatial database.

    Alternatively, if you are using older technology you can use standard SQL tools in WPF to connect directly to the Database and query the data. The Spatial Data can be handled using the Spatial types dll that can be used in .NET.


    http://rbrundritt.wordpress.com

    Tuesday, June 26, 2012 10:26 AM
  • This example is helpful. I was able to get the sample code to run and now I want to add in some of my data. I ran across my first road block in that my data uses the geometry data type and not the geography data type. So I am working through how to build a MapPolygon from a SQL Geometry data field.

    Shane Gilbert

    Friday, June 29, 2012 7:57 PM
  • Shane,

    I am also looking out for drawing the Geometry data rather Geospatial data over a map control in WPF. Would be helpful if you can share the solution you used.

    Wednesday, March 19, 2014 11:59 PM
  • The Geometry class is nearly identical to the Geography class. There is a couple of ways to do this.

    One is to convert the Geometry objects to Geography objects. This can easily be done by first making sure the geometry is valid, then using the binary of the geometry to create a geography object.  It might make sense to add a new column to your database and generate the geography data there.

    Another method is to use STX in place of the Long property and STY in place of the Lat property in the code that parses the geometry/geography into a map shape.


    http://rbrundritt.wordpress.com

    Thursday, March 20, 2014 10:53 AM
  • Hi Ricky,

    I am still unable to follow the suggestion.

    The problem statement is:- I have geometry data in SQL Server (AutoCAD DWG file -> ESRI Shape Files via FME -> SQL geometry data using Shape2SQL) and SSRS map control is handling it very nicely but because the control has limitations in Zoomin/Pan the customer is not convinced and we have to look out for alternates. I tried converting the shape files to geography data type through FME tool by Safe but it can not proceed without knowing the source files coordinate system.

    I learned Bing maps APIs but almost all of the samples/examples points to use Geography data rather geometry and that makes sense also. Everything on a map should resolve to some type of lat/long.

    We are open for custom development and my question is - is there any out of the box control in WPF/Silverlight stack which can read and draw geometry shapes from SQL server and render them over the web with the interactivity (zooming/panning) such as provided by Bing Maps control. As per my understanding it should be a canvas control as we want to render a shape rather a map.

    Regards

    Ratish

    Saturday, April 05, 2014 11:17 AM
  • Simply use the Well Known Text and the Bing Maps Spatial Toolbox: http://mapstoolbox.codeplex.com/

    The Well Known Text is always the same regardless if the data is a geometry or a geography. Alternatively, if you know the coordinates are using the WGS84 datum, standard used by online maps and GPS devices, then the spatial reference identifier (SRID) to use in SQL for geography data is 4326.


    http://rbrundritt.wordpress.com

    Monday, April 14, 2014 11:59 AM