-
Notifications
You must be signed in to change notification settings - Fork 365
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
CoordinateSequence: create using external buffer #747
base: main
Are you sure you want to change the base?
Conversation
68c4355
to
cd43857
Compare
Nice! Would you consider an equivalent for x/y/... stored in seperate buffers? (Ie the qgis model) |
Not really... the only reason this works is because the external buffer is exactly the same shape as the internal buffer. |
What needs to be done to make things "2d-safe"? |
Need to stop reading 3D coordinates ( |
Can we mostly start reading CoordinateXY by reference instead? |
Fair enough -- this might be motivation enough for me to rework how QGIS internally stores these arrays! |
It's always safe to read Simplification and triangulation are good examples...they're 2D algorithms, but they also have this assumption that we're going to preserve |
cd43857
to
720bccf
Compare
720bccf
to
06eb853
Compare
Here's another test I did:
When geometries are copied into GEOS, this takes 100.58 seconds. When geometries are created with no coordinate copies, this takes 100.55 seconds. Not a big win for zero-copy! A second test of a self-join with |
About a 10% gain on To safely apply these changes, we'd need to have C API functions that require padded coordinates check their inputs and automatically copy into a new padded coordinate sequence. (This is easy to do with something like |
As a PostGIS guy, this leaves me cold. The only win is for use cases where they are wrapping and using things like Area() and Length() and Distance() frequently, which... yeah it happens, but as your testing shows, for the "that's too hard to write myself, I need GEOS to do it" use cases, there's no win. I'd vote for GEOS simplicity and letting people write their own easy calculations. And honestly, of course the Rust guys are going to write Rust implementations of Area and Length and Distance! Purity! We saw the same thing with Turf.js and JSTS. |
@@ -2034,7 +2042,24 @@ extern void GEOS_DLL GEOSFree(void *buffer); | |||
extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_create(unsigned int size, unsigned int dims); | |||
|
|||
/** | |||
<<<<<<< HEAD |
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.
merge conflict markers
extern GEOSCoordSequence GEOS_DLL *GEOSCoordSeq_createFromBuffer_r( | ||
GEOSContextHandle_t handle, | ||
double* buf, | ||
unsigned int size, |
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.
shouldn't that be size_t ?
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.
Yes, if the other coordinate sequence functions did not use unsigned int
} | ||
|
||
T* m_buf; | ||
std::uint32_t m_capacity; |
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 not use size_t for m_capacity and m_size ?
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.
The C API uses 32 bits for sizes and incides, I'm doubtful a coordinate sequence with > 1 billion points would function in practice, and I'm trying to be sensitive to the object size of Point
, whose API requires that it be backed by a CoordinateSequence
.
This PR adds methods to create a
CoordinateSequence
backed by an external buffer. Currently this can only be done for XYZ or XYZM sequences until GEOS algorithms are made "2d-safe."