kothic-js rendering and coastlines

A few small updates to Freemap 0.6, the new experimental version of Freemap using kothic-js rendering, since I last posted. Bridges and railways now appear, but the main feature is coastline. How was this done?

It was quite simple but thought I’d post it here anyway. Firstly, the standard processed_p.shp file used for Mapnik rendering was converted to SQL using the shp2pgsql tool (part of the PostGIS distribution, I believe). This was then imported into the PostGIS database. The server-side script which generates the GeoJSON data for kothic-js was then altered to return the ST_Intersection() of the current bounding box and any coastline polygons in the area. This then returns a square of land in inland areas, or a complex polygon of land in coastal areas.

As is done in Mapnik, the canvas background was set to light blue. The land polygons from the previous step were tagged – arbitrarily – server side with “natural=land”, and then a natural=land rule added to the MapCSS. So pretty straightforward really! The updated code is now in the SVN repository.

In other developments, I have updated Freemap’s PostGIS database with OSM data current as at last weekend. However – and this will impact upon the search facility on the main, current, Mapnik-based Freemap site (0.5) as well as 0.6 – *only* data from certain counties is included. I think I have finally found a way to make Freemap sustainable with kothic-js (so many, many thanks to the kothic team!) but only if I restrict coverage to certain parts of the UK. In Southern England this includes Hampshire, West Sussex, Surrey, Wiltshire and Somerset (but not those parts which used to be Avon); the whole of Wales is covered; and in Northern England, Cheshire, Derbyshire, Lancashire and Cumbria. In this way, I have covered both my local patch and a significant proportion of the national parks and popular walking areas in the rest of England and Wales. I might experiment with adding further counties but I’d prefer to have a Freemap covering some of the UK only and working reasonably well, rather than unsustainably covering the whole country. Chrome still appears to give the best performance.

What of future plans? Freemap 0.5 (the Mapnik version) is now in feature-freeze so no new features will be added, I’m hoping to make 0.6 the default version by the spring.

4 Responses to “kothic-js rendering and coastlines”

  1. moltonel says:

    Just a curious naive question : why have a sea background and land polygons instead of the opposite ? I know the Earth is more oceans than continents, but people usually look at land maps much more often than water, so the overhead of dowloading and rendering those coastline-polygons should be in the least-viewed areas, no ?

  2. admin says:

    Hi, that is the way it is done in OpenStreetMap. The land polygons are taken from the processed_p.shp shapefile generated from OSM coastline data. OSM does not have a pre-built sea polygon. AFAIK, all OSM renderers, certainly the main Mapnik renderer, take this approach.

  3. Komzpa says:

    Having OpenID allowed for comments will be nice :)

    For coastline, in native Kothic serverside (python one, https://github.com/kothic/kothic-js/wiki/json_getter-setup) natural=coastline is used for land. The reason for selection of this tag is that coastline shapefile is generated from natural=coastline lines ;)

    http://code.google.com/p/kothic/source/browse/src/json_getter.py

  4. admin says:

    Yes I noticed that ;-) Just chose natural=land because it seemed the most accurate way of describing it…

    Will try and get OpenID enabled if I have a moment.