-
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
FR: add wrapper for OGR_F_SetFieldNull #427
Comments
To update, that NAN workaround will not work correctly for integers, as it places a very low integer (assuming MIN) in the field instead. Also will not work for string fields. However, setting it as an empty double list does work. |
We should add this, and you can actually add it yourself in the meanwhile (e.g. with an extension trait), but there are two things related things we should figure out:
|
I'm a little embarrassed, after playing around with an extension trait and finding some problems, I realized that the function I really wanted a wrapper for is I'm not sure what unsetting a field does, it led to some random errors like Anyway, here's my trait if anyone else following this wants it:
|
@lnicola , @metasim As it looks like the code in the commit was copied from my suggestion, I think there's been a mistake. Maybe a lack of communication on my part. A comment in my code indicated that a large portion of it was copied from Unless I'm missing something, shouldn't this fix be implemented with a call to fn set_field_null(&self, field_name: &str) -> Result<(),GdalError> {
let field_id = self::field_idx_from_name(field_name)?;
unsafe { gdal_sys::OGR_F_SetFieldNull(self.c_feature(), field_id) };
Ok(())
} (Snippet above has not been checked for errors or tested) |
@nms-scribe you're right, thank you. I was even complaining earlier that |
All of the "get" field functions on Feature return options, so I can know if the value is already null. But I don't see anything in the rust API for setting a field to None that shouldn't have a value, and
OGR_F_UnsetField
is only referenced in the pre-built bindings on a sourcecode search here.My work-around right now is to use
feature.set_field_double(<field_name>,f64::NAN)
but I've only had to do this for double fields so far, so I don't know if this will work for integer, or if it will work in other drivers than geopackage.The text was updated successfully, but these errors were encountered: