planetiler icon indicating copy to clipboard operation
planetiler copied to clipboard

[Feature] Typo-tolerance for `__all__` and `__any__`

Open zstadler opened this issue 10 months ago • 3 comments

Describe the bug I'm unable to use '${ feature.point_along_line(0) != feature.point_along_line(1) }' in an include_when expression.

Following this Slack discussion and PR #1163

To Reproduce

The YAML schema below defines 3 layers:

  • pier_not_closed is expected to capture all piers that are not a closed line
  • pier_closed is expected to capture all piers that are a closed line
  • pier_all is expected to capture all piers regardless of their closeness
  1. Save the following schema in pier.yaml
schema_name: pier
schema_description: Example of "is_closed"-like expressions in `include_when`
attribution: <a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>
args:
  area:
    description: Geofabrik area to download
    default: monaco
  osm_url:
    description: OSM URL to download
    default: '${ args.area == "planet" ? "aws:latest" : ("geofabrik:" + args.area) }'

sources:
  osm:
    type: osm
    url: '${ args.osm_url }'

layers:

- id: pier_not_closed
  features:
  - source: osm
    geometry: line
    include_when:
    - __all___:
      - man_made: pier
      - '${ feature.point_along_line(0) != feature.point_along_line(1) }'

- id: pier_closed
  features:
  - source: osm
    geometry: line
    include_when:
    - __all___:
      - man_made: pier
      - '${ feature.point_along_line(0) == feature.point_along_line(1) }'

- id: pier_all
  features:
  - source: osm
    geometry: line
    include_when:
      - man_made: pier
  1. Run using the latest Planetiler docker version currently available
docker run --rm -v "$(pwd):/w" -w /w ghcr.io/onthegomap/planetiler@sha256:2d3a4bd0b8ba16250d21b127d2e03b96f2517a9a3f99769b40ce27df760ad14e pier.yaml --output pier.pmtiles --download
  1. The log file says both pier_not_closed and pier_closed layers are empty:
0:00:04 DEB [archive] - Max tile sizes
           z11   z12   z13   z14   all
 pier_all   41    41    41    41    41
full tile   41    41    41    41    41
  gzipped   63    63    63    63    63
  1. The log file says the pier_all layer has 1 feature in each of the 4 tiles produced
0:00:04 DEB [archive] -     # tiles: 4
0:00:04 DEB [archive] -  # features: 4

Most likely, the feature is way 879006855 - a closed way that does not have an area=yes attribute

Expected behavior

  • For the current mapping of Monaco, having one closed pier way, I would expect pier_closed to have the same contents as pier_all.
  • Generally, i would expect each feature in pier_all to appear in either pier_not_closed or pier_closed.

Environment:

  • Hardware: Lenovo Legion
  • OS: WSL
  • Java version and distribution: As used in the docker image
  • Maven version: As used in the docker image

zstadler avatar Feb 01 '25 14:02 zstadler

It looks like you have an extra underscore at the end of __all___ - what happens if you remove that?

msbarry avatar Feb 02 '25 01:02 msbarry

You're absolutely right! I wish that there was a syntax error of some sort on such a typing error.

When using __all__, the output is as expected:

             z11   z12   z13   z14   all
   pier_all   41    41    41    41    41
pier_closed   44    44    44    44    44
  full tile   85    85    85    85    85
    gzipped   78    78    78    78    78

and

0:00:04 DEB [archive] -     # tiles: 4
0:00:04 DEB [archive] -  # features: 8

zstadler avatar Feb 02 '25 07:02 zstadler

IMO, a syntax error would be just fine.

zstadler avatar May 19 '25 12:05 zstadler