Open jmealo opened 1 month ago
We can definitely handle this more nicely. Principally I'm trying to keep the base h3
extension as close to upstream as possible, instead using the h3-pg
extension as a friendlier PostGIS wrapper around those. So I would be open to checking validity or using ST_MakeValid
when calling the h3-pg
functions.
@zachasme: The issue I ran into with my particular geometries is that ST_MakeValid()
was returning huge bowties, that would still create what I assume to be millions of hexes at higher resolutions. I'm not 100% sure what the correct behavior is. I'm pushing to add ST_IsValid() constraints or triggers to our tables that store geometry/geography.
I would be okay with adding a flag to the postgis variants of polygon_to_cells
that either enables or disables running ST_IsValid on inputs. What do you think of that solution?
@zachasme: I think that could make sense. I got pulled off this but will be revisiting it in the next few weeks.
Thoughts:
ST_IsValid()
... should the flag default to ON by default?I would be OK with providing a flag, if it defaults to ON. We should verify that checking a flag at runtime isn't more expensive than calling ST_IsValid()
🤔 .
Issue:
I've found that calling
h3_polygon_to_cells
with invalid geometries can result in as many as 2.3 million hex_ids being returned at a resolution of 7. This is not a bug inh3-pg
but, rather how theh3
library handles invalid geometries. It's unclear whether we can guard against this, or should at the very least provide documentation/warnings about the issues and workarounds to mitigate them.Cause:
ST_IsValid()
.ST_MakeValid()
turns them in bow ties.Test case:
Solution:
ST_IsValid()
... or a warning that invalid geometries could return millions of hex ids?Upstream issue:
https://github.com/uber/h3/issues/926