1

I would like to extend the Stamen Toner map style (https://github.com/stamen/toner-carto/) with a layer to render piers (Way:area,man_made=pier).

I managed to install tilemill on Ubuntu (https://tilemill-project.github.io/tilemill/docs/linux-install/) and also was able to render the resulting XML style with a separate Mapnik install (https://switch2osm.org/serving-tiles/manually-building-a-tile-server-ubuntu-22-04-lts/).

The layer definitions / postgis queries seem to be made in https://github.com/stamen/toner-carto/blob/master/toner.yml

What would be the correct entry to create a piers layer and style it with e.g.

#piers{
  line-width: 0.25;
  polygon-fill: @color_physical_bright;
  line-color: @color_administrative_lowzoom;
}

1 Answer 1

0

If you follow the instructions on installing Tilemill and toner-carto, only polyline piers will be in the database (mapped to table osm_roads with class='man_made').

For Tilemill, osm2pgsql loads the OSM data extract into the database using the default.style.

toner-carto's Makefile employs imposm with the included imposm3_mapping.json to populate the database from the extract. It maps "man_made:pier" to the class column, but there's also the filter

    "filters": {
        "exclude_tags": [
            ["area", "yes"]
        ]
    },

So querying select * from osm_roads where class='man_made' reveals Ways in my OSM extract that are not "area" but may be piers.

These are not rendered in Toner (hence this question).

But they can be easily added and queried (in Editor, the "Layers" icon is at the bottom left corner):

Adding a layer piers with the above query and the style

#piers{
  line-color: #ff0000;
  line-width: 5;
}

finally shows an effect.

However, these are only open/closed Ways (Polyline), not Area (Polygon).

To get the Area piers into the database, I have extended imposm3_mapping.json with a modified definition of roads (keeping all fields for now since I don't know whether they are required):

"piers": {
          "fields": [
              {
                  "type": "id",
                  "name": "osm_id",
                  "key": null
              },
              {
                  "type": "geometry",
                  "name": "geometry",
                  "key": null
              },
              {
                  "type": "string",
                  "name": "highway",
                  "key": "highway"
              },
              {
                  "type": "string",
                  "name": "railway",
                  "key": "railway"
              },
              {
                  "type": "string",
                  "name": "name",
                  "key": "name"
              },
              {
                  "type": "boolint",
                  "name": "tunnel",
                  "key": "tunnel"
              },
              {
                  "type": "boolint",
                  "name": "bridge",
                  "key": "bridge"
              },
              {
                  "type": "direction",
                  "name": "oneway",
                  "key": "oneway"
              },
              {
                  "type": "string",
                  "name": "ref",
                  "key": "ref"
              },
              {
                  "type": "wayzorder",
                  "name": "z_order",
                  "key": "layer"
              },
              {
                  "type": "string",
                  "name": "access",
                  "key": "access"
              },
              {
                  "type": "string",
                  "name": "service",
                  "key": "service"
              },
              {
                  "type": "mapping_key",
                  "name": "class",
                  "key": null
              }
          ],
          "type": "polygon",
          "mappings": {
              "piers": {
                  "mapping": {
                      "man_made": [
                          "pier"
                      ]
                  }
              }
          }

resulting in a osm_piers table which Tilemill can query as a piers layer with SELECT * FROM osm_piers and style with

#piers{
  polygon-fill: #ff0000;
}

So the next question is how to handle both types, "linestring" and "polygon". It seems overly complicated to create a table for each, I suspect there is a better way. On the other hand, they should be styled differently, otherwise open polylines would be filled incorrectly. It's probably also possible to query these from planet_osm_ways directly, depending on the data extract import method.

Any comments on how to improve this are appreciated!

2
  • From TileMill docs: > Layers are rendered in order starting at the bottom of the layers list moving up. You can adjust the position of each layer in the stack by clicking and draggin on its geometry icon.
    – handle
    Jun 7 at 11:55
  • Changes to the TileMill Layers are not saved, so they need to be added to e.g. toner.yml (reverse order).
    – handle
    Jun 7 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.