Monday, March 21, 2016

Experimenting some more with map layers

One of the new nice features of Maps 3.20 is the ability of loading map layers in GeoJSON, KML, and GPX formats.
As I wrote about earlier, I have been experimenting with transit routing support. For that I have been using OpenTripPlanner, which has a notion of ”routers” (or “graphs“ as it could also be refered too) being discrete graphs consisting of nodes and connecting paths (such as transit routes) making up separate transit networks.
I thought it might be useful to get a visual picture of the sample data, so I got the idea of building a little tool that pulls the router information from a running OTP instance and generates a GeoJSON representation.

The code can be found here: https://github.com/mlundblad/otp-routers-to-geojson

This script, which by the way is my second case of using GJS as a scripting language, is rather simple and just takes as the one and only argument a URL to a running OTP instance (i.e. http://localhost:8080/otp when running a local server on your machine) and writes the output on stdout.

The script will skip any case where the graph's bounding polygon only consists of two points (not sure if that really would happen in reality).

Loading a generated layer into Maps can result in something like this:


The big diamond-shaped graph is probably the result of some malformed data, as that stems from the national transit feed from Estonia.

I hope you find this useful! :-)

No comments:

Post a Comment