polygon-clipping
polygon-clipping copied to clipboard
common geometry positioning that fails [Unable to find segment...]
Was able to make the geometry simpler. I am using OpenStreetMaps ocean data that is broken into pieces and then tilizing them. So for every tile I have to stitch/union the ocean back together. In other words, I get this error practically every tile.
Consider the geometry:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
0.3989625786890032,
1.009765625
],
[
0.3989625786890032,
1.0052647693815202
],
[
0.396484375,
1.005525034038334
],
[
0.396484375,
1.009765625
],
[
0.3989625786890032,
1.009765625
]
]
],
[
[
[
0.396484375,
1.0055334123783004
],
[
0.3989625786890032,
1.0052731441301153
],
[
0.3989625786890032,
0.9831177462616355
],
[
0.3966402491889224,
0.9823941008295243
],
[
0.396484375,
1.0055334123783004
]
]
],
[
[
[
0.39895258134328715,
0.9831211850799448
],
[
0.39895258134328704,
1.0052740239230125
],
[
0.43091071349190757,
1.0029868318833317
],
[
0.43091071349190746,
0.9830924015448479
],
[
0.39895258134328715,
0.9831211850799448
]
]
],
[
[
[
0.43090028201911246,
0.9830812272092494
],
[
0.43090028201911246,
1.0029874138408128
],
[
0.447265625,
1.0023217069607695
],
[
0.4309719323819078,
0.9831579787871001
],
[
0.43090028201911246,
0.9830812272092494
]
]
],
[
[
[
0.39895258134328704,
1.0052656491622696
],
[
0.39895258134328704,
1.009765625
],
[
0.43091071349190746,
1.009765625
],
[
0.43091071349190746,
1.00297848871728
],
[
0.39895258134328704,
1.0052656491622696
]
]
],
[
[
[
0.43090028201911235,
1.0029790706667183
],
[
0.43090028201911246,
1.009765625
],
[
0.447265625,
1.009765625
],
[
0.447265625,
1.0023133729892386
],
[
0.43090028201911235,
1.0029790706667183
]
]
]
]
}
}
]
}
For this package, anytime a piece is surrounded on "five" sides, it will fail. The top middle in this case fails.
Found an even simpler example. Seems I was wrong? It might have to do with a line intersecting the other polygon at an end/start point of two connecting lines rather than on a line.
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "MultiPolygon",
"coordinates": [[
[
[
0.333984375,
0.9345515074448101
],
[
0.3382814280319275,
0.9338850203871748
],
[
0.3382814280319275,
0.933884863940738
],
[
0.33828620813379007,
0.9338842789776549
],
[
0.36819452088818627,
0.930224260981806
],
[
0.36819452088818627,
0.947265625
],
[
0.333984375,
0.947265625
],
[
0.333984375,
0.9345515074448101
]
]
],
[
[
[
0.333984375,
0.9084637498721961
],
[
0.33829087072221165,
0.9078295884995246
],
[
0.33829087072221153,
0.9338918862375188
],
[
0.333984375,
0.934559848622665
],
[
0.333984375,
0.9084637498721961
]
]
]
]
}
}
]
}