Skip to content
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 gdal::vector::field_type_to_name #258

Merged
merged 1 commit into from Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGES.md
Expand Up @@ -7,9 +7,10 @@

- <https://github.com/georust/gdal/pull/239>

- Add `gdal::vector::geometry_type_to_name`
- Add `gdal::vector::geometry_type_to_name` and `gdal::vector::field_type_to_name`

- <https://github.com/georust/gdal/pull/250>
- <https://github.com/georust/gdal/pull/258>

- **Breaking**: Add `gdal::vector::OwnedLayer`, `gdal::vector::LayerAccess` and `gdal::vector::layer::OwnedFeatureIterator`. This requires importing `gdal::vector::LayerAccess` for using most vector layer methods.

Expand Down
12 changes: 12 additions & 0 deletions src/vector/feature.rs
Expand Up @@ -772,3 +772,15 @@ impl FieldValue {
}
}
}

pub fn field_type_to_name(ty: OGRFieldType::Type) -> String {
let rv = unsafe { gdal_sys::OGR_GetFieldTypeName(ty) };
_string(rv)
}

#[test]
pub fn test_field_type_to_name() {
assert_eq!(field_type_to_name(OGRFieldType::OFTReal), "Real");
// We don't care what it returns when passed an invalid value, just that it doesn't crash.
field_type_to_name(4372521);
}
2 changes: 1 addition & 1 deletion src/vector/mod.rs
Expand Up @@ -26,7 +26,7 @@ mod ops;
pub mod sql;

pub use defn::{Defn, Field, FieldIterator};
pub use feature::{Feature, FieldValue, FieldValueIterator};
pub use feature::{field_type_to_name, Feature, FieldValue, FieldValueIterator};
pub use gdal_sys::{OGRFieldType, OGRwkbGeometryType};
pub use geometry::{geometry_type_to_name, Geometry};
pub use layer::{
Expand Down