-
Notifications
You must be signed in to change notification settings - Fork 342
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
Collection-based CAPI for coverage operations #867
Conversation
I'm thinking about the use use of "is this coverage valid? if not, give me the error locations." Currently that would require performing the validation twice, or requesting the errors and scanning it to see if any is non-empty. Here is a signature that could accommodate the above scenario more directly, without creating a new object type. I'm not sure if I like it or not, curious what others think.
Another idea that I don't love is to have |
I like the optional signature more than I like the two separate ones. |
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.
Thanks for pulling this together @pramsey to contrast with #866
Between the two, this API seems more reasonable for downstream users to implement (purely my own opinion though).
To implement against this, I'd need a bit more info in the docstrings, esp. for simplify. Are geometries below the tolerance simplified out and returned as empty polygons, do they collapse into triangles, etc.
It isn't immediately obvious what to do with the output of the validation step; if I get back MultiLineStrings for invalid edges, what can I do next to make edges valid? I'm assuming this is mostly just for flagging which polygons in the input are not valid and it's entirely up to the caller to figure out what to do next, but thought I'd ask in case the docstring could be expanded a bit to give suggested next steps...
capi/geos_c.h.in
Outdated
* | ||
* \since 3.12 | ||
*/ | ||
extern GEOSGeometry GEOS_DLL * GEOSCoverageSimplify( |
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.
extern GEOSGeometry GEOS_DLL * GEOSCoverageSimplify( | |
extern GEOSGeometry GEOS_DLL * GEOSCoverageSimplifyVW( |
(to allow for suffixes for other simplification methods later)
Ditto above question about what this returns on error.
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.
Ditto above question about what this returns on error.
Should return NULL on error.
Of course, I'm +1 for that idea :). Seems nice and simple, and keeps things a bit more functional. It also works for empty coverage inputs (which have to be handled). |
I agree, this API feels simpler and more familiar (even if less optimal - but beware premature optimization! And we have ideas for improving this in the future). |
More info can be provided. To answer: geometries never disappear, but they may be simplified down to just a triangle.
At the moment, you can do whatever you do now to fix the edges manually. :). The hope is to provide a |
5db0a2b
to
fb4a039
Compare
How do you feel about the current state? |
I like it. Thanks for the discussion and willingness to iterate. |
capi/geos_ts_c.cpp
Outdated
{ | ||
using geos::coverage::CoverageValidator; | ||
|
||
return execute(extHandle, 0, [&]() { |
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.
return execute(extHandle, 0, [&]() { | |
return execute(extHandle, 2, [&]() { |
@@ -2005,6 +2026,7 @@ extern void GEOS_DLL GEOSFree_r( | |||
* This function does not have a reentrant variant and is | |||
* available if `GEOS_USE_ONLY_R_API` is defined. | |||
* \return version string | |||
* \since 2.2 |
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.
Any reason all these since annotations are in this PR?
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.
oops?
This looks good to me too, thanks for iterating on this. Excited to start using this! |
Expose the CoverateSimplifier and CoverageValidator via the CAPI
Add three new functions, ST_CoverageIsValid(geom geometry winset, tolerance float8) ST_CoverageSimplify(geom geometry winset, tolerance float8, simplifyBoundary integer) ST_CoverageUnion(geom geometry set) For the purpose of these functions a "coverage" is a set of polygons with perfectly shared edges (no overlaps or gaps and exact vertex matching). For associated GEOS discussion, see libgeos/geos#867
ST_CoverageIsValid(geom geometry winset, tolerance float8) ST_CoverageSimplify(geom geometry winset, tolerance float8, simplifyBoundary integer) ST_CoverageUnion(geom geometry set) For the purpose of these functions a "coverage" is a set of polygons with perfectly shared edges (no overlaps or gaps and exact vertex matching). For associated GEOS discussion, see libgeos/geos#867
Exposing three coverage functions (global is-valid, is-valid with result collection, and simplify with result collection) using geometry collection as the input and output type.