Polygon shards (#105)

* Put all of this back in geometry.cpp for conflict resolution

* Stabilize line simplification to behave the same regardless of winding

* Round instead of truncating when clipping lines

* Restore non-Wagyu polygon clipping from prior to 2fdec7d2

* Make it round, not truncate, which reverts the last commit's test diffs

* Clip in floating point, not integers, which makes no difference

* Track nodes added at tile edges during clipping

* Scale geometry up before wagyu to prevent changes from precision loss

* Actually do the shared edge detection

* Fix cases where nodes were not being added at the tile boundary

* One more place I should have rounded

* Narrow down where the discrepancy comes in

* Revert "Narrow down where the discrepancy comes in"

This reverts commit 221c4c5fc0ac9a6567e091c6a94b3d87dc8ade83.

* Another attempt to narrow it down

* The discrepancy seems to be introduced in reordering. No obvious bug

* Was still truncating instead of rounding in projection

* Also makes no difference...

* Just forget that line reversal exists for a minute

* Just reversal no coalescing

* Try clipping in integers instead of floating point

* Don't simplify after coalescing if they said no simplification

* Check whether behavior is consistent with intentional simplification

* Replace more floating point with integer

* Are these three features enough to demonstrate the problem?

* Add a few more nearby borders

* All the features that touch tile 6/16/23

* Stay in integers in line simplification

* More attempts to solve failures to simplify consistently

* Fix most of the overflow errors

* Fix known cases of integer overflow

* All the tests change again

* Pull clipping and scaling code back out into clip.cpp

* Resolve the test conflicts

* Stabilize choice of which three points to keep with different windings

* Almost right, I think!

* Fix collapse of islands to shards

* Self-intersections in the same feature don't count

* Revert "Self-intersections in the same feature don't count"

This reverts commit e04b19916e.

* Don't scale down geometry if we are going to look for shared nodes

* Fix the missing multiply that was keeping simplification from happening

* Fix one more opportunity for overflow

* Somehow I deleted this test?

* Lost this test too

* Clean up debugging printfs

* Restore code sequence from main to make it reviewable

* Remove unneeded rounding

* Update documentation

* This test is no longer useful

* Back to floating point Douglas-Peucker to fix undersimplification

* Try an older ubuntu

* Revert "Try an older ubuntu"

This reverts commit 13fefacfd7.

* Log OS info

* Remove tests that are no longer needed

* Oops, did need that one after all

* Fix the arm vs x86 discrepancy?

* Try another quantization

* Cleanup from review

* Add a test for the actual purpose of this PR
This commit is contained in:
Erica Fischer
2023-09-14 16:51:38 -07:00
committed by GitHub
parent dee40802fd
commit 390771f855
113 changed files with 25649 additions and 23189 deletions
+10 -10
View File
@@ -15,10 +15,10 @@
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.966797, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.966751 ], [ 0.000000, 0.000000 ], [ -0.966797, 0.000000 ], [ -0.966797, 0.966751 ], [ 0.000000, 0.966751 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.966797, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.000000 ], [ 0.000000, -0.966751 ], [ -0.966797, -0.966751 ], [ -0.966797, 0.000000 ], [ 0.000000, 0.000000 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.966797, 0.966751 ], [ 0.966797, 0.000000 ], [ 0.000000, 0.000000 ], [ 0.000000, 0.966751 ], [ 0.966797, 0.966751 ] ] ] } }
@@ -49,10 +49,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -1.010742, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 1.010690 ], [ 0.000000, 0.000000 ], [ -1.010742, 0.000000 ], [ -1.010742, 1.010690 ], [ 0.000000, 1.010690 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -1.010742, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -1.010742, 0.000000 ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.000000, 1.010690 ] ] } }
@@ -97,10 +97,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 1, "y": 1 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.988770, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.988720 ], [ 0.000000, 0.000000 ], [ -0.988770, 0.000000 ], [ -0.988770, 0.988720 ], [ 0.000000, 0.988720 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.988770, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -0.988770, 0.000000 ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.000000, 0.988720 ] ] } }
@@ -147,10 +147,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 3, "x": 3, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.999705 ], [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ], [ -0.999756, 0.999705 ], [ 0.000000, 0.999705 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.000000, 0.999705 ] ] } }
@@ -207,10 +207,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 4, "x": 7, "y": 7 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.999705 ], [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ], [ -0.999756, 0.999705 ], [ 0.000000, 0.999705 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.999705 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ] ] } }
+10 -10
View File
@@ -16,10 +16,10 @@
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.966797, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.966751 ], [ 0.000000, 0.000000 ], [ -0.966797, 0.000000 ], [ -0.966797, 0.966751 ], [ 0.000000, 0.966751 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.966797, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.000000 ], [ 0.000000, -0.966751 ], [ -0.966797, -0.966751 ], [ -0.966797, 0.000000 ], [ 0.000000, 0.000000 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.966797, 0.966751 ], [ 0.966797, 0.000000 ], [ 0.000000, 0.000000 ], [ 0.000000, 0.966751 ], [ 0.966797, 0.966751 ] ] ] } }
@@ -50,10 +50,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -1.010742, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 1.010690 ], [ 0.000000, 0.000000 ], [ -1.010742, 0.000000 ], [ -1.010742, 1.010690 ], [ 0.000000, 1.010690 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -1.010742, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -1.010742, 0.000000 ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.000000, 1.010690 ] ] } }
@@ -98,10 +98,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 1, "y": 1 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.988770, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.988720 ], [ 0.000000, 0.000000 ], [ -0.988770, 0.000000 ], [ -0.988770, 0.988720 ], [ 0.000000, 0.988720 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.988770, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -0.988770, 0.000000 ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.000000, 0.988720 ] ] } }
@@ -148,10 +148,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 3, "x": 3, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.999705 ], [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ], [ -0.999756, 0.999705 ], [ 0.000000, 0.999705 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.000000, 0.999705 ] ] } }
@@ -208,10 +208,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 4, "x": 7, "y": 7 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.999705 ], [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ], [ -0.999756, 0.999705 ], [ 0.000000, 0.999705 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.999705 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ] ] } }
+10 -10
View File
@@ -15,10 +15,10 @@
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 0, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.966797, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.966751 ], [ 0.000000, 0.000000 ], [ -0.966797, 0.000000 ], [ -0.966797, 0.966751 ], [ 0.000000, 0.966751 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.966797, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.000000 ], [ 0.000000, -0.966751 ], [ -0.966797, -0.966751 ], [ -0.966797, 0.000000 ], [ 0.000000, 0.000000 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.966797, 0.966751 ], [ 0.966797, 0.000000 ], [ 0.000000, 0.000000 ], [ 0.000000, 0.966751 ], [ 0.966797, 0.966751 ] ] ] } }
@@ -49,10 +49,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 1, "x": 0, "y": 0 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -1.010742, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 1.010690 ], [ 0.000000, 0.000000 ], [ -1.010742, 0.000000 ], [ -1.010742, 1.010690 ], [ 0.000000, 1.010690 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -1.010742, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -1.010742, 0.000000 ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.000000, 1.010690 ] ] } }
@@ -97,10 +97,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 2, "x": 1, "y": 1 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.988770, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.988720 ], [ 0.000000, 0.000000 ], [ -0.988770, 0.000000 ], [ -0.988770, 0.988720 ], [ 0.000000, 0.988720 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.988770, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -0.988770, 0.000000 ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.000000, 0.988720 ] ] } }
@@ -147,10 +147,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 3, "x": 3, "y": 3 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.999705 ], [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ], [ -0.999756, 0.999705 ], [ 0.000000, 0.999705 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ 0.000000, 0.999705 ] ] } }
@@ -207,10 +207,10 @@
,
{ "type": "FeatureCollection", "properties": { "zoom": 4, "x": 7, "y": 7 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "in", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0.000000, 0.999705 ], [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ], [ -0.999756, 0.999705 ], [ 0.000000, 0.999705 ] ] ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ -0.999756, 0.000000 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "Point", "coordinates": [ 0.000000, 0.999705 ] } }
,
{ "type": "Feature", "properties": { }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000000 ], [ -0.999756, 0.000000 ] ] } }