Visar inlägg med etikett OGC-standards. Visa alla inlägg
Visar inlägg med etikett OGC-standards. Visa alla inlägg

måndag 17 juli 2017

Extended geospatial routing service in Bing Maps?

Sometimes GIS are complicated. Especially when it comes to access to data. I remember when I was building a dynamic routing engine based on PostGIS and data from Navteq. The dynamic part consisted of different vehicles behaving different in traffic. For example a truck or bus doesn't behave in the same way as a motorcycle or car. And moreover there can be obstacles, for example height and weight on bridges or the curve is too narrow. Most of the routing engines today are fast - not dynamic, or dynamic and less fast. 

However, after discussed with a good friend about the secret keys to routing, using most of networks SQL indexes skills, adding some routing tricks we manage to make it pretty fast and dynamic, for the time being (2011). But it was hard to make it scale. Routing is CPU heavy and there are no rights and wrongs when it comes to routing. For example, the best route can be the shortest, fastest, safest or maybe most beautiful! 

Isochrones 

During that time I also played with isochrones. An isochrone is the routing extent, for example 50 km from a given point. Not just a circle. In every case 50 km radius covering a bigger area than the corresponding isochrone. I have seen many municipalities using radius for example for the fire department. However, project Nanjing addresses that issue.

Radius and Isochrone showing approximately 60 km from
Sundsvall, Sweden
Projects as Nanjing are important making complicated use cases available for the public. Many organizations doesn't have the knowledge, fundings etc to pull this off. Using real distances, or time to calculate coverage or use it for further processing. I hope many other data providers with API:s will consider taking a GeoJSON as an argument. In that way, it will be possible to from a GeoJSON as one criteria among others. Project Wollongong from Microsoft probably makes that behind the scenes. 

After trying the Nanjing API for the first time I was a bit surprised. I expected a GeoJSON as response, but it was a JSON with geographical information. It is not a big thing and it is easy to serialize - but I was surprised. My experience is to use standards whenever it possible. And in this case sending geographical information as JSON I use GeoJSON. The projects API is pretty straight forward to use and there are examples in a handful of languages.

However project Nanjing as a really new cool useful geospatial feature available for preview as today. I hope it will be part of the Bing Maps platform since it address an important useful feature.

There are several others project available for preview and a presentation on channel9.

onsdag 21 juni 2017

Pogo Rent 3000

Background

The aim of the article is to give and idea how to build robust GIS applications build on .Net and Bing Maps.
Pogo Rent 3000 is a fictional company that hires pogo sticks round the world. As a consultant, I am asked to help implement GIS functionality to their web site and to where ever it gives value. Through a couple of posts I will show how to address this in a pragmatic way. For start the company wants to show a basic map with great Pogo parks in northern Sweden.
The aim of this article is to describe the implementation of Pogo Rent 3000. The idea of this project is to provide a solid implementation of a GIS project based on Bing Maps. The techniques and framework used are well known and provide a robust foundation for GIS applications.
I strongly recommend using standard formats for communication with GIS backend is really importance and cannot be stated enough. The application also showing an example of an endpoint that simulates a Web Feature Service (WFS from OGC, see http://www.opengeospatial.org/standards/wfs) or included in the code as a GeoServiceController. OGC formats and protocol gives flexibility and maintainability.

Application structure

The application is structured the simplest way possible and providing a robust platform to extend the system later on. I build a classic 3-tier application.

UI Tier

On top there is Bing Maps V8, it is one of the best map client out there as today. It provides a straight forward, documented API. More over a set of spatial function like measuring and a set of modules. A module is functionality you can extend the web client with. For example, with GeoJSON, (http://geojson.org) support. The small script that is needed is, for convenience, written in TypeScript. GeoJSON is an OGC standard since 2016. This means we can add in other datasets from other sources without worrying about the format as long as it is GeoJSON.
With the GeoJSON module it is super easy to parse the JSON from the server.
let primitives = Microsoft.Maps.GeoJson.read(geoJSONtext) as Array;

Service Tier

As service tier I have a Asp.NET Web API. This tier is boosted with Net Topology Suit (NTS, https://github.com/NetTopologySuite/NetTopologySuite) which provide a rich set of GIS operations. NTS is great for adding spatial functions to the application. It also provides GeoJSON support. With this in place we have the possibility to serve OGC formats.

Data Tier

In this example we use a single text file as data source. The source is a GeoJSON file. I could of course easily just accessed GeoJSON file directly through a GET request from the client but for demo purpose I actually read and parse the file with NTS. The data tier also have an interface. The idea with the interface is that it should be easy to add other data sources, for example SQL Server.
Reading GeoJSON with NTS is really simple, here is a snippet from the application:
var reader = new NetTopologySuite.IO.GeoJsonReader();
var features = reader.Read<FeatureCollection>(data);
     
Data is the GeoJSON. It will parse the json into an object which we can spatial filter, manipulate compare or do other operations.

Wrap up

With the techniques and framework in place, it is pretty straight forward to implement. The implementation is as simple as possible and it provides possibility to extend the PogoRent3000 system. To summarize, building a GIS application is not different than building any 3-tier application.

A demo application is online here.

And the code is here 

A special thanks to SoulSolutions.