-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Labels
enhancement 🚀New feature or requestNew feature or requestgood first issue 👶Good for newcomersGood for newcomers
Description
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 in h3-pg but, rather how the h3 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:
- All of the geometries that caused these issues fail
ST_IsValid(). - Using
ST_MakeValid()turns them in bow ties.
Test case:
{
"type": "Polygon",
"coordinates": [
[
[-148.5, 29.1],
[-148.5, 63.9],
[-72.5, 29.1],
[-72.5, 63.9],
[-148.5, 29.1]
]
]
}WITH h3_cells AS (
SELECT h3_polygon_to_cells(
ST_GeomFromGeoJSON('{
"type": "Polygon",
"coordinates": [
[
[-148.5, 29.1],
[-148.5, 63.9],
[-72.5, 29.1],
[-72.5, 63.9],
[-148.5, 29.1]
]
]
}'),
7
) AS cells
)
SELECT COUNT(1)
FROM h3_cells;
# count = 2,364,092Solution:
- It might make sense to update the documentation or examples to include a call to
ST_IsValid()... or a warning that invalid geometries could return millions of hex ids?
Upstream issue:
Metadata
Metadata
Assignees
Labels
enhancement 🚀New feature or requestNew feature or requestgood first issue 👶Good for newcomersGood for newcomers