gdal: `Geometry::get_point_vec()` returns empty `Vec`
I’m unable to access get the points of any GDAL Geometry
instance I create. The following will fail at the last test:
#[test]
fn test_get_points() -> std::result::Result<(), GdalError> {
let sample = "/vsicurl/https://gist.githubusercontent.com/metasim/15fb05bbe76c1d7e5583033f2b6757f7/raw/fac8b385b733f50f0b7a1466db03e7918084b4a1/test.geojson";
let ds = Dataset::open(sample)?;
let layer = ds.layer(0)?;
let feature = layer.feature(0).unwrap();
let geom = feature.geometry();
assert_eq!(geom.geometry_count(), 1);
assert!(geom.area() > 0.);
assert_eq!(geom.geometry_type(), gdal_sys::OGRwkbGeometryType::wkbPolygon);
assert!(geom.json()?.contains("Polygon"));
let points = geom.get_point_vec();
assert!(!points.is_empty());
Ok(())
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (15 by maintainers)
I don’t think it makes sense to return points from all the rings together. I think the first ring is the exterior of the polygon, while the others are “holes”.
We should try match the GDAL API:
Notice how:
GetPoints
is fallibleGetGeometryRef
get_unowned_geometry
and thedon't keep this object for long
comment in its implementation; the return type is logically a&'self Geometry
, since the ring is owned by the polygon.@lnicola @rmanoka Wondering if either of you have advice to share on the appropriate route to take with the above. I think the
GeometryRef
approach is working.Also, see
geo_to_gdal.rs
andgdal_to_geo.rs
. Those two files were an awesome reference to accessing inner structures using our bindings.Very helpful to know where to go for a “reference implementation”. Thanks! 😃