go-spatial / tegola

Tegola is a Mapbox Vector Tile server written in Go
http://tegola.io/
MIT License
1.3k stars 197 forks source link

Broken/invalid geometries from new geom makevalid function #497

Open olt opened 6 years ago

olt commented 6 years ago

This issue is to collect validation issues with the new geom package (https://github.com/go-spatial/tegola/tree/integrate_geom_makevalid)

I have a GeoPackage with land polygons generated from the OSM coastline. They are quite detailed, (especially in harbors) and split in larger chunks (possible touching clip boundaries). All polygons are be valid according to PostGIS.

processed_p.gpkg.zip tegola.toml.txt

The GeoPackage contains 4 of such land polygons. You should be able to see a lot of broken polygons by zooming in and out. Here are a few areas where I found issues:

http://localhost:9090/#13.51/53.8682/8.7045 http://localhost:9090/#13.88/53.0903/8.768 http://localhost:9090/#14.71/53.1146/8.7318 http://localhost:9090/#13.05/53.3695/8.484 http://localhost:9090/#12.76/53.3367/8.5089

The issues look like: screen shot 2018-08-20 at 11 20 43 screen shot 2018-08-20 at 11 20 52 screen shot 2018-08-20 at 11 23 52

I noticed that the validation issues are non-deterministic. Each reload can give different results. So, the geom package is able to produce valid geometries, just not all the time... :-)

A wild guess: map iteration is random in Go and each for k, v := range map call gives a different result. This might be the source of the randomness.

/cc @gdey

olt commented 6 years ago

It is indeed the random map iteration. I get stable results by sorting the constraints: https://gist.github.com/olt/c0b348d8038ae37f3cbe62c1dea10558

Unfortunately, there are still broken polygons, but at least the issues are consistent. Hope this help!

gdey commented 6 years ago

@olt i’m going to move this issue to the geom package.