-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add Geometry::set_points, change Geometry::get_points to use OGR_G_GetPoints #604
base: master
Are you sure you want to change the base?
Conversation
This is also a small bit of groundwork to make harmonizing the index types (as discussed in #600 ) a little less annoying. |
thoughts? @lnicola |
I'm not sure I follow. GDAL doesn't know (or care) if you have a
Slices are aligned, but the bigger issue is that #[repr(C)]
struct PointXyz(f32, f32, f32); ( So the simplest would probably be to pass in a Can of 🪱s indeed 😀. |
Fair enough.
Nvm, i get what you mean... hmmm |
We could start adding geometry types (shame |
I think both Maybe the simplest is to offer something like: geom.get_points(&mut Vec::<f32>::new(), CoordinateLayout::XyzXyz); // there's probably a better name
geom.get_points(&mut Vec::<f32>::new(), CoordinateLayout::XxYyZz); It doesn't offer the full power of the C API, but it's still useful. We could even fit |
This might actually be a neat way to go about it if we want to avoid adding our own geometry types. Since It would, however, still be quite annoying for the end-user to |
Yeah, I updated my comment about this exactly when you posted yours. We could even do
Only a little, right? And there's also |
It certainly beats having to cook up our own For all the |
In any case, I propose we postpone (no need to close) this for a later time. I'd like to get a new release out of the door soon (maybe after 3.10.1 comes out in the next couple of days). |
Very well, I'll be cooking with gas in the meantime. |
@lnicola reasonably happy with this as a first go at it. Not sure how I'll go about strangely ordered coordinates (if that's even necessary) but feel free to take a peek when you want to. Edit: Not my proudest git history, but I'll stop touching things for now. |
f2d3a63
to
bea5eeb
Compare
assert_eq!( | ||
line_points, | ||
vec![0.0, 1.0, 1.0, 0.0, 0.0, 2.0, 0.0, 0.25, 0.5, 0.0, 0.5, 1.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.
Reasonably sure I'm thorough enough with these test-cases? The pointer manipulation does get a little scary, so idk if more are warranted.
XxYyMm = 0b01011, | ||
|
||
XyzmXyzm = 0b11111, | ||
XxYyZzMm = 0b01111, |
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.
Pretty sure this selection of layouts is sufficient? The bitmask was simple enough, though it isn't terribly flexible in case we want to add a Custom
variant and would likely need an overhaul.
src/vector/geometry.rs
Outdated
length as usize | ||
/// For some geometry types, like polygons, that don't consist of points, Err will be returned | ||
/// and `out_points` will only be resized. | ||
pub fn get_points(&self, out_points: &mut Vec<f64>, layout: CoordinateLayout) -> Result<usize> { |
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.
Perhaps take &mut [f64]
instead? Would require additional checks to avoid segv, but I think being more general might be better. Eg. allowing for fixed slices as opposed to just Vecs (though perhaps that isn't especially useful?).
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.
I went ahead and implemented this change, though dissenting opinions are welcome and I wouldn't mind reverting.
CHANGES.md
if knowledge of this change could be valuable to users.The PR has since expanded in scope, check the edit history and earlier discussion for additional context/scheming.
This PR adds
Geometry::set_points
, changesGeometry::get_points
to use OGR_G_GetPoints and creates theCoordinateLayout
to describe the layout of the in/output data for both of these methods.This also removes
Geometry::get_points_zm
since it has been made redundant by a generalized coordinate layout enum, and could make implementing conversions to/fromgeo_traits
somewhat easier.