Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] setting pixel tolerance too high can break multipolygons #496

Closed
erik opened this issue Feb 22, 2023 · 2 comments · Fixed by #499
Closed

[BUG] setting pixel tolerance too high can break multipolygons #496

erik opened this issue Feb 22, 2023 · 2 comments · Fixed by #499
Labels
bug Something isn't working

Comments

@erik
Copy link
Contributor

erik commented Feb 22, 2023

Describe the bug

Using a combination of Feature.setPixelTolerance(0.5) and Feature.setMinPixelSize(0.1) broke the geometry for this relation, which caused the entire tile to be filled at z11.

Screen Shot 2023-02-22 at 10 21 17

If you look at the relation, the sand and grass polygons are super close to each other (but not touching), so it seems the combination of calls resulted in an invalid simplification.

grafik

In my case, I tested that I can fix the tile by modifying the pixel size and tolerance values, but it seems possible for other multipolygons to have the same issue. The OpenMapTiles profile for example uses the same sequence of calls, and could conceivably run into this.

These changes all independently fixed the issue for me:

  1. Remove the call to setMinPixelSize
  2. Remove the call to setPixelTolerance
  3. Change the pixel tolerance to 0.25

To Reproduce

  • GeoFabrik's new-jersey extract.
  • Create a layer which selects natural=sand polygons.
  • Use the following profile:
    features
      .polygon("test")
      .setPixelTolerance(0.5)
      .setMinPixelSize(0.1)
      .setAttr("id", source.id())
  • Relevant area: 11/40.9405/-74.0947

Commenting out either of setPixelTolerance or setMinPixelSize will fix the issue

Environment (please complete the following information):

  • Hardware: 2019 Macbook Pro
  • OS: MacOS 12.13.1
  • Java version and distribution: openjdk-17
  • Maven version: 3.8.2
@erik erik added the bug Something isn't working label Feb 22, 2023
@msbarry
Copy link
Contributor

msbarry commented Feb 22, 2023

Interesting, looks like it's right on the edge of the buffer of tile at zoom 11, here's the geometry it generates:

POLYGON ((-4 -4, 100.375 -4, 100.5 -3.875, 100.625 -4, 260 -4, 260 260, -4 260, -4 -4))

So it might be an issue with clipping... I've got it reproduced in a unit test, should be able to investigate from there.

@msbarry
Copy link
Contributor

msbarry commented Feb 23, 2023

Put out a proposed fix in #499 - let me know if there are other cases you can think of to test there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants