manaakiwhenua / vector2dggs

DGGS indexer for vector data
https://pypi.org/project/vector2dggs/
GNU Lesser General Public License v3.0
6 stars 0 forks source link

LinearRing handling #26

Open ChocopieKewpie opened 6 months ago

ChocopieKewpie commented 6 months ago

Katana cutting does not handle LinearRings:

shapely.errors.GEOSException: IllegalArgumentException: Points of LinearRing do not form a closed linestring

alpha-beta-soup commented 6 months ago

I think it should be able to handle them. Can you see one of the offending geometries? It's likely because it's not "closed": for validity, the start and end need to be the same point. See if you can get a WKT version of it.

It might be possible in fact that the act of "katana cutting" is creating an invalid geometry from valid input. However there is code to check and attempt to repair invalid input. As it works recursively, geoetries should remain valid throughout.

alpha-beta-soup commented 6 months ago

https://github.com/manaakiwhenua/vector2dggs/blob/main/vector2dggs/katana.py#L29

Perhaps the normalize should occur before checking validity? I don't know if normalising a geometry collection can create invalid geometries (I'd be surprised if it did).