onthegomap / planetiler

Flexible tool to build planet-scale vector tilesets from OpenStreetMap data fast
Apache License 2.0
1.38k stars 110 forks source link

Unrecognized field `min_tile_cover_size` [BUG] #961

Closed quincylvania closed 2 months ago

quincylvania commented 2 months ago

I'm trying to use a custom schema something like this:

sources:
  osm:
    type: osm
    local_path: data/sources/planet.osm.pbf
layers:
  - id: trail_poi
    features:
      - source: osm
        geometry: polygon_centroid_if_convex
        min_zoom: 4
        min_tile_cover_size: 0.2
        include_when:
          leisure:
            - park
        attributes:
          - key: leisure
            tag_value: leisure

But when I try to use min_tile_cover_size I run into this error:

Exception in thread "main" java.lang.IllegalArgumentException: Unrecognized field "min_tile_cover_size" (class com.onthegomap.planetiler.custommap.configschema.FeatureItem), not marked as ignorable (8 known properties: "min_zoom", "include_when", "geometry", "attributes", "source", "max_zoom", "exclude_when", "min_size"])

I guess the value is probably missing from configschema/FeatureItem.java? It's listed in configschema/AttributeDefinition.java, possibly that's a mistake? Not sure exactly what's going on.

msbarry commented 2 months ago

It looks like the docs and json schema are wrong here. There's a min_tile_cover_size tag on attribute definitions that exclude adding the attribute to features when they are too small, and a min_size tag (in tile pixels) on features to not include them when they are too small. You should be able to just switch to min_size to get this working.

We should update the docs/json schema but also they should probably each just have a min_size tag with a way to specify whether the unit is pixels, tiles, etc... it's kind of strange to have a unit of "tiles" on attribute features and "pixels" on entire features.

quincylvania commented 2 months ago

Oh okay, I thought min_size was in absolute meters or something since the units aren't given. It's not clear to me what it means by "below the maximum zoom-level of the map". But if the value is relative to the tile size then that will work for my use case :)

msbarry commented 2 months ago

Ah yeah the default unit is "tile pixels" which might be a little counter-intuitive. Ideally I think you should be able to express min_size (or max_size) in an absolute unit like meters, acres, hectares, miles or also in a unit that varies by zoom level like pixels or tiles.

msbarry commented 2 months ago

"below the maximum zoom-level of the map".

For most maps this is zoom=14 but if you run with --maxzoom=10 then it will be 10. Setting min_size=1 filters-out features below 1 pixel in size up z=maxzoom-1, but at z=maxzoom it lets through all features since the client will overzoom tiles at that highest zoom level.

quincylvania commented 2 months ago

@msbarry Thanks for the clarifications!