Skip to content

Commit

Permalink
Add gdal::vector::field_type_to_name
Browse files Browse the repository at this point in the history
  • Loading branch information
ttencate committed Feb 18, 2022
1 parent 6cb085a commit c78d42c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
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

0 comments on commit c78d42c

Please sign in to comment.