-
Notifications
You must be signed in to change notification settings - Fork 96
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 union operation for geometry #379
Conversation
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.
@zredb Thank you for the contribution!
Could you please add documentation to union
, similar to intersection
?
Also, I'm not seeing an update to |
unsafe { | ||
let ogr_geom = gdal_sys::OGR_G_Union(self.c_geometry(), other.c_geometry()); | ||
if ogr_geom.is_null() { | ||
return None; |
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 haven't tested, but it might be possible to return a proper error here?
But then I'm not sure what we should do in the !has_gdal_ptr()
case...
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.
According to gdal's document, when an error occurs, the return value is null, so here we return None, which seems to be consistent with gdal.
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.
Yeah, but in most cases GDAL will set an error code and message like here, even without documenting it explicitly.
But indeed, this doesn't seem to be done in a consistent fashion.
src/vector/ops/set.rs
Outdated
|
||
let inter = inter.unwrap(); | ||
|
||
assert_eq!(inter.area(), 135.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.
I think we have some assert_almost_eq
helper somewhere.
.gitignore
Outdated
@@ -8,3 +8,4 @@ | |||
GPATH | |||
GTAGS | |||
GRTAGS | |||
/setenv.bat |
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.
Do we want this? In the long run every contributor might end up with a script like that, but with a different name.
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.
Setenv is just my own configuration. I have removed it from gitignore.
add change log to CHANGES.md
.gitignore
Outdated
@@ -7,4 +7,4 @@ | |||
# gtags | |||
GPATH | |||
GTAGS | |||
GRTAGS | |||
GRTAGS |
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.
Nit: your IDE is eating final newlines.
src/vector/ops/set.rs
Outdated
/// | ||
/// # Returns | ||
/// Some(Geometry) if both Geometries contain pointers | ||
/// None if either geometry is missing the gdal pointer, or there is an 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.
/// None if either geometry is missing the gdal pointer, or there is an error. | |
/// None if either geometry is missing the GDAL pointer, or there is an error. |
src/vector/ops/set.rs
Outdated
/// | ||
/// # Returns | ||
/// Some(Geometry) if both Geometries contain pointers | ||
/// None if either geometry is missing the gdal pointer, or there is an 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.
/// None if either geometry is missing the gdal pointer, or there is an error. | |
/// `None` if either geometry is missing the gdal pointer, or there is an 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.
I note that the documentation for intersection
isn't that great. The docs in predicates.rs
is closer to the mark. Would be great if you can bring it to that level, but if you can't I'll do a separate PR to normalize it.
src/vector/ops/set.rs
Outdated
/// otherwise the result might be wrong. | ||
/// | ||
/// # Returns | ||
/// Some(Geometry) if both Geometries contain pointers |
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.
/// Some(Geometry) if both Geometries contain pointers | |
/// `Some(geometry)` if both Geometries contain pointers |
? 😄
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.
If it's not too much of a hassle, would you mind squashing?
I think I would, but what does "squaring" mean? English is not my first language, so I don't quite understand what "squaring" really means. |
Squashing, as in merging the 5 commits into a single one. Something like: $ git reset @~5 # 5 commits before, or git reset 1dbc60215033caee1f99d933ae11354f70bc5f0e, the last commit before your changes
$ git commit -a
$ git status # make sure everything looks fine
$ git log # make sure everything looks fine
$ git push -f (these commands reset your branch to the commit before your changes, leave your changes uncommitted in the working directory, then make a new commit with them) But you don't need to worry about it. I'll let metasim take another look before merging. |
bors r+ |
Build succeeded: |
394: Updated `set.rs` docs to be more consistent with those in `predicates.rs`. r=metasim a=metasim - [X] I agree to follow the project's [code of conduct](https://github.com/georust/gdal/blob/master/CODE_OF_CONDUCT.md). - [X] I added an entry to `CHANGES.md` if knowledge of this change could be valuable to users. --- <img width="974" alt="image" src="https://user-images.githubusercontent.com/131013/236706192-fad8a481-5cc4-476d-9429-eedf66d419b8.png"> Context: #379 (comment) Co-authored-by: Simeon H.K. Fitch <[email protected]>
CHANGES.md
if knowledge of this change could be valuable to users.This is my first time to commit code to this repository. I see that vecotr only has an intersection operation at present, so I try to add a union operation to it. If it can be accepted, I will add other operations in the same way later.