systemed / tilemaker

Make OpenStreetMap vector tiles without the stack
https://tilemaker.org/
Other
1.48k stars 231 forks source link

Vector Tile has POLYGON has ring with too few points. #143

Closed Lee858 closed 9 months ago

Lee858 commented 4 years ago

I’m converting data that contains polygons that represent public land ownership. The parcels are often large with inner polygons. The data has already been scrubbed for intersecting polygons, intersecting points, too few elements and small objects. I’m using klokantech/tileserver-mapnik to view the map in a browser with a stylesheet that I created.

I’m using Docker for Windows and I first pulled ablondeau/tilemaker. It ran quickly and made a lot of mistakes. Properties between polygons were transposed and the shapes of the polygons just weren’t right.

I then pulled osmtw/tilemaker which states it’s from this repository. It took about 14 hours to run. The final zoom level, 14 renders perfectly. I found a missing polygon that wasn’t exceptionally complex but it was comprised of two outer polygons. At zoom level 13 and lower, some of the tiles aren’t returned and the tileserver displays the error: “Error: Vector Tile has POLYGON has ring with too few points. It is not valid according to v2 of VT spec.”

Any advice on resolving this?

Am I running the most recent version by using osmtw/tilemaker?

systemed commented 4 years ago

The most recent version is the one in this repository, systemed/tilemaker . The Docker build is not formally supported but you're welcome to try it and report any failures you encounter.

Do you have a link to the data you're trying?

Incidentally, the best way to speed up Tilemaker is to run with the command-line switch --combine 0.

Lee858 commented 4 years ago

What is the correct syntax for installing the Docker image? I keep ending up with Repository & Tag = none.

Lee858 commented 4 years ago

The attached is a small subset of the data that exhibits the problem. I made an mbtiles with the current build and there's a new error in addition to the previous. "Error: Vector Tile has POLYGON with first ring clockwise. It is not valid according to v2 of VT spec."

One observation, a multipolygon containing two outer polygons omitted the second polygon when creating the mbtiles. They share points at 32.92049,-116.67762 and 32.92015,-116.68697.

polygons.zip

systemed commented 4 years ago

Thanks - will take a look when I've got a moment.

systemed commented 4 years ago

Do you have a working MBGL style that I can test this with (to save having to reverse engineer one)?

Lee858 commented 4 years ago

Attached. PolygonStyle.zip

systemed commented 4 years ago

I'm working through this but it's worth noting that you have several invalid geometries in your source data. For example:

I think there are probably things we can do to make tilemaker more tolerant here, but I'd suggest that you try cleaning up the data first (not sure what you're using to create it?) which might help isolate what the tilemaker-specific issues actually are.

systemed commented 4 years ago

Tilemaker will now tell you about any invalid geometries in the source data. You can optionally be told about invalid geometries in the output by using the --verbose flag.

Lee858 commented 4 years ago

I don't understand why the nested inner members are an issue when they're different objects that would be rendered separately.

My primary problem seems to be polygons that touch themselves. Tilemaker is interpreting these as intersections. The software that I'm using for editing and validation doesn't see touching as an intersection. It seems to prefer touching polygons over creating additional nested polygons when subtracting one polygon from another. I've attached a screenshot with two examples that can be achieved by touching or nesting. The top arrow would be an outer-inner-outer when nested.

TouchingPolygons

systemed commented 4 years ago

Tilemaker uses Boost::Geometry internally and hence its definition of what’s a valid shape, which is based on the OGC standard. References:

https://www.boost.org/doc/libs/1_63_0/libs/geometry/doc/html/geometry/reference/algorithms/is_valid/is_valid_2_with_failure_value.html

https://www.boost.org/doc/libs/1_63_0/libs/geometry/doc/html/geometry/reference/enumerations/validity_failure_type.html

Lee858 commented 4 years ago

Thanks for helping with this. I can write some code to nest the touching polygons.

systemed commented 4 years ago

No problem. Let me know if any further issues!

Lee858 commented 4 years ago

I used QGIS to identify problem data then wrote code to clean it up. Tilemaker build no longer displays any errors that point to specific relations. There are errors when writing tiles for each of the Zoom levels.
"Output multipolygon has disconnected interior (contains polygons whose interiors are not disjoint)"

When I view the data using tileserver-mapnik, the logs display a number of errors with the tile directory and filename. Most are in in zoom levels 10 and 11. I opened up some of the offending PBF tiles using QGIS then ran the Check Validity on them. There are spikes and intersections from simplification. I checked the source data for the offending objects and they're valid.

I copied the offending objects to a separate file then created tiles from it. Tilemaker build doesn't display any errors. If you open the PBF tiles with QGIS then run Check Validity, it shows the spikes and intersections.

Sample attached. I can provide more if needed.

Thanks

SamplePolygons.zip