whosonfirst / go-whosonfirst-geojson-v2

Go tools for working with Who's On First documents
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

All interior rings are treated as holes #17

Open timonmasberg opened 2 years ago

timonmasberg commented 2 years ago

https://github.com/whosonfirst/go-whosonfirst-geojson-v2/blob/968aa5a5a3a9b291dcd6f93ae8204e41116da2e3/geometry/polygon.go#L38

Not all interior rings have to be holes. When an interior ring intersects another interior ring, the intersection is not treated as a hole.

Simple example:

image

{ "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ [ [ 14.897460937499998, 27.21555620902969 ], [ 8.26171875, 19.932041306115536 ], [ 23.90625, 15.792253570362446 ], [ 14.897460937499998, 27.21555620902969 ] ], [ [ 14.1064453125, 24.246964554300924 ], [ 19.2041015625, 17.769612247142653 ], [ 11.1181640625, 19.89072302399691 ], [ 14.1064453125, 24.246964554300924 ] ], [ [ 13.9306640625, 21.94304553343818 ], [ 13.095703125, 20.46818922264095 ], [ 16.611328125, 19.02057711096681 ], [ 13.9306640625, 21.94304553343818 ] ] ] } }

thisisaaronland commented 2 years ago

Thanks for this, you are correct.

Have you found a situation where this occurs in practice? We should account for this regardless but I am pretty sure we didn't (account for it up front) on the grounds that it almost never happens in the context of WOF-related features.

timonmasberg commented 2 years ago

e.g. https://spelunker.whosonfirst.org/id/85682555/

If the point is within Bremen, we will receive Lower Saxony as a hierarchy member. Maybe it is a tradeoff one has to take, since i believe that checking for holes might be expensive.

thisisaaronland commented 2 years ago

Ah, good to know. I will investigate this in the next day or two.

Thanks for the report.

nvkelso commented 2 years ago

Here's an example in the USA:

https://spelunker.whosonfirst.org/id/102084863/

Where Fairfax city is within Fairfax county (both county-level admin, because Virginia), and the "county" courthouse in the "city" is legally the county not the city.