-
Notifications
You must be signed in to change notification settings - Fork 94
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 Wrapper for GDALVectorTranslate(ogr2ogr) #536
base: master
Are you sure you want to change the base?
Conversation
use crate::utils::_path_to_c_string; | ||
|
||
/// Path or Dataset to store Vectors or Raster | ||
pub enum DatasetDestination { |
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.
Not sure, but maybe DestinationDataset
sounds a little better?
} | ||
} | ||
} | ||
} |
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: missing trailing newline.
@@ -0,0 +1,8 @@ | |||
#[cfg(all(major_ge_3, minor_ge_1))] | |||
mod vector_translate; |
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.
This is available since 2.1, not 3.1, isn't it?
pub use vector_translate::{ | ||
vector_translate, | ||
VectorTranslateOptions | ||
}; |
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.
Missing trailing newline.
}; | ||
use gdal_sys::{GDALVectorTranslate, GDALVectorTranslateOptions, GDALVectorTranslateOptionsFree}; | ||
use libc::c_char; | ||
use crate::programs::destination::DatasetDestination; |
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.
This should be pub use
, otherwise you can't call vector_translate
.
/// See [GDALVectorTranslateOptionsNew]. | ||
/// | ||
/// [GDALVectorTranslateOptionsNew]: https://gdal.org/api/gdal_utils.html#_CPPv429GDALVectorTranslateOptionsNewPPcP35GDALVectorTranslateOptionsForBinary | ||
pub fn new<S:Into<Vec<u8>>,I:IntoIterator<Item=S>>(args:I)->Result<Self>{ |
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.
Please run cargo fmt
.
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 know you mirrored multi_dim_translate
, but https://docs.rs/gdal/latest/gdal/cpl/struct.CslStringList.html might be nicer to use here, especially since fn new<S:Into<Vec<u8>>,I:IntoIterator<Item=S>>(args:I)->Result<Self>
can look a little scary.
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.
It‘s excellent advice to use CslString
instead of fn new<S:Into<Vec<u8>>,I:IntoIterator<Item=S>>(args:I)->Result<Self>
, and I will make some modifications to this section.
CHANGES.md
if knowledge of this change could be valuable to users.This PR add Wrapper for GDALVectorTranslate which is the equivalent of the ogr2ogr (https://gdal.org/programs/ogr2ogr.html) utility(https://gdal.org/api/gdal_utils.html#_CPPv419GDALVectorTranslatePKc12GDALDatasetHiP12GDALDatasetHPK26GDALVectorTranslateOptionsPi).
Also, I changed MultiDimTranslateDestination enum to DatasetDestination