Skip to content

Add support for extendable layer schema #377

Open
@nyurik

Description

@nyurik

As discussed in openmaptiles/openmaptiles#1252, we need a way for users to extend which fields to include with a layer without modifying the actual code. Instead, users will modify the main yaml file (i.e. openmaptiles.yaml) to specify needed changes.

tileset:
  layers:
    # ...
    - file: layers/transportation/transportation.yaml
      add_tags:
          maxspeed:
            description: Original value of [`maxspeed`](http://wiki.openstreetmap.org/wiki/Key:maxspeed) tag, if exists.
          maxheight:
            description: Original value of [`maxheight`](http://wiki.openstreetmap.org/wiki/Key:maxheight) tag, if exists.
          tracktype:
            description: Original value of [`tracktype`](http://wiki.openstreetmap.org/wiki/Key:tracktype) tag, if exists.
  # ...

The above would only work for layers that expose tags HSTORE field at the top SQL layer, and have a magic keyword as part of its SQL statement. Resulting layer modifications:

Please update the following sections with the exact specification, or add comments with proposals:

Imposm mapping file

TODO: what changes should tools do to the mapping file(s), and how should tools determine which file/table/key should be modified

Add field declarations

Layer specification is updated dynamically: new fields with their descriptions are added to the layer.fields map.
TODO: decide if we should support values param, and if so, how.
TODO: decide if we want to support updates to existing fields, for example adding more enum values to class. Is this needed at all? E.g. if we add a value to transportation class, it will not be straightforward to change which of them are included in z12

Update main SQL statement

TODO: We currently use %%FIELD_MAPPING: class %% for SQL modifications. We could use something similar here, e.g. introduce a new %%CUSTOM_TAGS%%? Replacement might be in the form NULLIF(tags->'maxspeed', '') AS "maxspeed",, or we may want to allow users to provide their own SQL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions