-
Notifications
You must be signed in to change notification settings - Fork 19
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 geo-traits
reader implementation
#38
Conversation
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 don"t know if checking the NO_DATA for M values is worth doing, maybe we could let that thing to the user (but then it's not clear if that's a good idea)
I think the semantics here are that data producers are expected to produce valid data, so I think we should keep the check for M values. |
geo-traits 0.2 has been released, and I updated this PR to use that. |
src/geo_traits_impl.rs
Outdated
// TODO: is it valid to have NO_DATA here? I would've expected that a `PointM` would | ||
// _always_ have an M coordinate. | ||
// if self.m <= NO_DATA { | ||
// geo_traits::Dimensions::Xy | ||
// } else { | ||
// geo_traits::Dimensions::Xym | ||
// } | ||
geo_traits::Dimensions::Xym |
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 not consistent with the import for &PointM
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 updated this to check if self.m <= NO_DATA
, but I'm not sure if that's the correct behavior. It seems like a PointM
should always have an m
value, because if it didn't have one, it could just be a Point
, right?
f2ddf78
to
ab92ab0
Compare
Thanks for this |
While switching to use this implementation in geoarrow-rs, I realized that I couldn't fully use it directly because the Ideally I'd prefer a method on the already-public So perhaps the best solution is to publicly export the |
Not sure I fully understand this be cause we could have impl Polygon {
pub fn as_geo_trait(self) -> MultiPolygon;
}
impl PolygonM {
pub fn as_geo_trait(self) -> MultiPolygonM;
}
impl PolygonZ {
pub fn as_geo_trait(self) -> MultiPolygonZ;
} Also i'm tempted to make them be methods that returns results instead of panicking And I still think we need to pub expect the wrapper types with have for the geo_traits as it might prevent the user |
Oh, maybe you're right; I'm not sure what I was thinking.
Where do they currently panic?
In general, as long as the user can access something that implements the desired "top-level" trait, I don't think we need to export the concrete structs. In the same way as the WKB crate (I wrote) returns an opaque |
We have a new core
geo
crate:geo-traits
! This enables zero-copy vector data interchange throughout the GeoRust ecosystem.This means that any library out there that accepts
geo-traits
input will just work with shapefile geometries.This PR implements these traits on new-types around shapefile geometry types.
Change list
Point{M,Z}
,MultiPoint{M, Z}
, andPolyLine{M, Z}
.MultiPolygon
type is created to wrap ashapefile::Polygon
. This is a necessity becausegeo_traits::PolygonTrait
makes a distinction between interior and exterior rings. So a bit of pre-processing is needed to ensure that consumers get constant-time coordinate access.MultiPolygon
andPolyline
.Questions
Z
geometry types, since we don't know up front whether they'll haveM
values or not.