[OSM-dev] Converting OSM Mapnik stylesheet to Cascadenik or Carto

Igor Brejc igor.brejc at gmail.com
Sat Jul 30 17:21:51 BST 2011


Great work and thanks for the detailed info.

One comment/question: from your description (using Mapnik) and from looking
at the json_getter.py I conclude you rely Osm2pgsql DB schema. I mentioned
earlier that I didn't want to limit Maperitive to using this flattened
schema, but would also try to support the "original" OSM DB schema (or even
some other derived schema). The main reason is that IMHO flattening of OSM
data  produces some loss of information which is vital for creating high
quality maps.

Example: Osm2pgsql flattens bus route relations into one or more chunks of
consecutive ways. But in order to render a bus network (like this one
http://www.harvestersway.co.uk/images/location_busmap.jpg), one would need
to reconstruct a graph of all the bus routes, which can have several routes
(relations) share the same way, and each relation can consist of several
ways. So it's a many-to-many relationship, which would be difficult to
reconstruct from this flattened schema.

So my question is: how would you go about implementing MapCSS support for an
"original" schema, if at all? This is why I expressed concerns about
performance, since I don't see an efficient way of fetching the data using a
declarative map styling.

Igor

On Fri, Jul 29, 2011 at 11:42 PM, Komяpa <me at komzpa.net> wrote:

> >> It is rather easy to produce SQL queries that will take out of the
> >> database only data referred by stylesheet. In fact that's already done
> >> in both Komap and Kothic.
> > I don't doubt you do, however I would have to know a little more about
> your
> > solution to comment.
>
> Sure.
>
> Everything is open source and you're free to fix something if you find
> some mistakes.
> Mostly in python, SQL and javascript.
>
> We still use mapnik for rendering, but Mapnik stylesheets are hell,
> and mapnik is quite limited, so we
> wanted solution that will let us change the renderer without making
> people rewrite stylesheets. At the
> moment when we started Carto wasn't on the horizon, Cascadenik was too
> mapnik-bound, and there was
> MapCSS supported by (at least then) Halcyon, Kothic, Ceyx. Rendered
> images were quite nice, so I
> implemented mapcss translator, named Komap. It heavily uses Kothic
> MapCSS parser, and its SQL query generator.
>
> Komap isn't a full-featured MapCSS-to-mapnik translator: it doesn't
> handle eval() (as there's no eval() in mapnik and
> it wasn't worth implementing eval-to-SQL translator, though it's
> possible), and it doesn't handle cascading, as enabling
> cascading in mapnik0.7 leads to 100+mb stylesheets with rules like "if
> it's highway=bus_stop, but not a shop, not a
> place, not ... - do this. if it's highway=bus_stop, and a shop in the
> same time, and not a place, and not... - do slightly different thing".
>
> (If you'd like to experiment more with cascading-enabled Komap, it's
> checked into its own branch, although I don't really try to make it
> work any more.)
>
> Even with those limitations, it lets me write one and the same
> stylesheet for Mapnik, Kothic JS, and Potlatch 2, which is impossible
> now in Carto or Cascadenik.
>
> Kothic JS was made as an attempt to break client/server-side rendering
> barrier. It's server part (json_getter) is also
> heavily based on Kothic MapCSS parser, and selects (and generalizes,
> which is a lot more computationally harder) only features referred by
> stylesheet.
> It's not currently used in production environment, although it can
> handle everything we need already - the only thing we're waiting for
> is Mozilla and Google
> to fix their browsers to let it render data faster.
>
> Now, links to code and things:
>
> http://code.google.com/p/kothic/source/browse/src/komap.py - Komap;
> http://code.google.com/p/kothic/source/browse/src/make_postgis_style.py
> - dumb script to make default.style for osm2pgsql that will refer only
> tags used in given mapcss stylesheet;
> http://code.google.com/p/kothic/source/browse/src/json_getter.py - a
> tool that generates generalized tiles for Kothic JS;
>
> http://code.google.com/p/kothic/source/browse/src/styles/osmosnimki-maps.mapcss
> - mapcss stylesheet, used by us when rendering OSM for kosmosnimki.ru;
> http://kothic.org/js/ - firebug it and see generalization on lower zoom
> levels;
>
> Also, you may have a look at OSM layer on http://maps.kosmosnimki.ru/.
> There's also "English" link in right-upper corner that will switch
> labels on the map into latin.
>
>
> --
> Darafei "Komяpa" Praliaskouski
> OSM BY Team
> xmpp:me at komzpa.net mailto:me at komzpa.net
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20110730/33b4023d/attachment.html>


More information about the dev mailing list