-
-
Notifications
You must be signed in to change notification settings - Fork 404
ST_Subdivide #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ST_Subdivide #202
Conversation
So, the pivot is the real vertex closest to the center. And if there is no vertex, it's the center. Yes? Why is this better/faster? That part I'm not intuiting. |
@pramsey correct. It does not create four extra points in case of simple split, but only three, saving one double precision grid snap on diagonal edges, so the polygon can be recombined back with higher precision. For large polygons with detailed boundary it starts splitting off bigger central 4-point boxes than previously, not insisting on them being squares. After that a balanced pivot should be found in second, now smaller, part faster. |
Codecov Report
@@ Coverage Diff @@
## svn-trunk #202 +/- ##
=============================================
- Coverage 79.33% 79.33% -0.01%
=============================================
Files 202 201 -1
Lines 63061 63004 -57
=============================================
- Hits 50032 49982 -50
+ Misses 13029 13022 -7
Continue to review full report at Codecov.
|
So, to get it fixed without bumping geos minimal version we have to fall back on just simple intersection for clipping by box. As a bonus lower versions of geos now support ST_Subdivide too. |
Using full-on intersection doesn't exact a performance penalty? |
liblwgeom/lwgeom.c
Outdated
|
||
static int | ||
lwgeom_subdivide_recursive(const LWGEOM *geom, uint32_t maxvertices, uint32_t depth, LWCOLLECTION *col, const GBOX *clip) | ||
lwgeom_subdivide_recursive(const LWGEOM* geom, uint32_t maxvertices, uint32_t depth, LWCOLLECTION* col) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this deliberately drifts away from the existing coding style?
liblwgeom/lwgeom_geos.c
Outdated
/* we're failing but not losing hope, try make all input valid */ | ||
if (!GEOSisValid(g1) || !GEOSisValid(g2)) | ||
{ | ||
g1 = LWGEOM_GEOS_makeValid(g1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should fail on invalid inputs, not silently run a magic function that may or may not produce a desired result.
@pramsey full intersection still finishes in sane time. Either that, or guaranteed endless loop in geos clipbypox2d. |
Let ST_Subdivide reselect pivot based on current piece geometry and not the original bbox. Split line for large polygons is also shifted to pass through existing point that lets the subdivision converge faster and chop off larger simple boxes.
This PR passes tests on simple cases.
One of unit tests (about inverted geometries) gets stuck on geos internals: