Posts

Showing posts with the label Open Street Map

Handy queries and features for Sql Server geography data from OSM

 I'm using SQL for a lot of work on geographic data and here I wanted to share a few of the "not-so-obious" snippets I use when working with OpenStreetMap (OSM) data. When providing data to be parsed as Latitude and Longitude We can use the STRING_AGG function. select w.Id, STRING_AGG( cast(n.Lat as nvarchar(max)) + ' ' + cast(n.Lon as nvarchar(max)), ', ') within group (order by wn.NodeOrder) as LatLon from Way w inner join WayNode wn on wn.WayId = w.Id inner join Node n on n.Id = wn.NodeId group by w.Id This example is based on my working OSM data model (way - waynode -node etc.) The list above will provide a clean list of "lat lon, lat lon ...". But when I need for instancce WKT it can ve altered by switching the "n.Lat" and "n.Lon" above.   Of couse one can use the built-in functions such as: select w.shape.STAsText() as wkt, w.Shape.AsGml() as gml from.... Firstly, I used the agg function to make the sql g...

Minimal example for "Xaml MapControl"

Image
I have mentioned the map control named "Xaml.MapControl" by Clemes Fischer on this blog earlier. This is a very good map control for use in WPF applications and some of the main features are: It can get tiles from many sources such as "Open Street Map", "Bing Maps" and custom sorces by using a url format string. It can also have WMS layers on from different sources, and you may also add your own tile sources or images. You can display UI elements on the map. The mapp add Points, Lines, Elipses and Polygons but you may add xaml-elements yourself to be displayed on your map.  XAML and MVVM support.  Using ItemsControls for multiple elements. Since it is meant to be used in MVVM and XAML it is very flexible. You can provide data for the map by using WPF binding. You can style it with WPF templates and styles. And adjust data by using WPF converters. I wanted to write this post to show the most simple and basic way to get a map in a WPF application. And this i...