plepe / pgmapcss

PGMapCSS is a library for PostgreSQL/PostGIS which works between an osm2pgsql based database and Mapnik (and maybe other renderers). It processes database (usually OpenStreetMap) objects according to MapCSS rules and calculates resulting colors, widths and other properties for Symbolizers, even geometric modifications.
GNU Affero General Public License v3.0
35 stars 8 forks source link

Rendering only within limited area / different rules for geographical areas #131

Open Skippern opened 8 years ago

Skippern commented 8 years ago

As I am working on a Brazilian only style, I would like to see it only render the rules within the boundaries of Brazil, and maybe a much simpler different rule outside of that territory. Currently I cannot find any sane way to do this.

plepe commented 8 years ago

Sorry for late answer, my time is currently rather limited :(

You could do:

area[osm:id=r1234] intersects node,
area[osm:id=r1234] intersects way,
area[osm:id=r1234] intersects area {
  set .in1234;
}

way[highway] {
  color: red;
}
way.in1234[highway] {
  color: blue;
  width: 2;
}

This would assign to all objects within the relation 1234 (that should be the multipolygon of the Brazilian borders) the class .in1234, which you can check in later rules. E.g. all highway-ways will be painted blue within r1234, and red on all others (to be exact, ways which cross the border will also be painted blue).

As no properties which force a rendering of the node, way or relation in question (the right part of the "intersects") are assigned, this query won't be executed for all nodes, ways and relations in question, but only those which match queries later-on.

This is not an optimal solution though, because the check will be executed for all queried objects.

Also, even if some objects won't be displayed outside of Brazil, it will still be queried for and checked if it is inside Brazil and then discarded.

Skippern commented 8 years ago

Interesting solution, but I fear it will require a lot of resources for an area so big, specially if combined with other national rules (i.e. unique highway template for all south American countries).

What about rules for limiting the rendered area? For a Brazilian specific map, actually it would be interesting to ignore tiles not intercepting with Brazil boundary relation.