-
Notifications
You must be signed in to change notification settings - Fork 353
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
ENH: add GEOSGeom_transformXY to C API #563
Conversation
Benchmark against a more manual version of transforming coordinates (see
I didn't put a lot of effort into optimizing the more manual approach (get ring, get sequence, update each x,y individually, build ring, build geometry), but it is pretty typical of how that might be approached using the C API. |
So...easier and faster. Nice! I have to hold the compiler's hand a bit in devirtualization to get numbers like yours (see dbaston@b5710e2). What compiler are you using?
without above commit
|
I'm on MacOS 10.15; I believe I'm using
|
Resolves #560
Allows caller to provide a callback function to transform x,y values of all cordinates in a geometry and return a new geometry; z values are unchanged.
Many thanks to @dbaston for providing >95% of the implementation in #560; I mostly tweaked a few things and added tests / benchmarks.
I diverged a bit from the direction suggested in #560, specifically:
XY
suffix on the function names (GEOSGeom_transformXY
,GEOSTransformXYCallback
); I think this provides a very clear signal to the user that these apply only to x,y coordinates and helps avoid future ambiguity if an XYZ form is ever added. This follows the precedent for some of the other XY coordinate sequence getters / setters. As a user of the library, theXY
suffix has been helpful and appreciated.GEOSSTRtree_query
, etcGEOSTransformXYCallback
return 1 on success, 0 on failure like several other functions in the C API. Notably, it diverges fromGEOSQueryCallback
which isvoid
andGEOSDistanceCallback
which is 0 on success and nonzero otherwise (which I found a bit confusing). We need a clear way to signal from this callback in case of error. If appropriate, we can make this match the precedent ofGEOSDistanceCallback
.