-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use new TZM geo-types instead the custom WKT ones #91
Comments
One point of friction is |
I think we can simply add another enum for that, treating an empty point, 2d point, and 3d point as separate cases. The only issue I see is if wkt has multiple types of points in the same geometry |
Can you spell that out for me a bit more? What would this deserialize to?
|
To support empty types in WKT, we could either implement if let WktEmpty(g) = Wkt::from_str("POINT EMPTY").unwrap() {
// g is a geo_types::Geometry<NoValue>(geo_types::Point<NoValue>(...))
} |
Hmm... I'm not sure I understand your suggestion. To dig in a bit, I kind of get how But we need to know what all three of the generic params are before we start parsing.
We can't say both simultaneously:
I think you understand that - I'm just not sure the entirety of what you're proposing. Is it a bigger api change, something like this?:
|
@michaelkirk you are correct - I am proposing a slightly bigger parsing API change - an enum wrapping generic typing variation. Naming is TBD. pub enum Wkt<T: CoordNum> {
Empty(Geometry<NoValue>),
Geo2D(Geometry<T>),
Geo2DM(Geometry<T, NoValue, T>),
Geo3D(Geometry<T, T>),
Geo3DM(Geometry<T, T, T>),
}
// This declaration would be identical to what it is now (slightly changed here for viewing)
impl<T: CoordNum + FromStr + Default> FromStr for Wkt<T> {
type Err = &'static str;
fn from_str(wkt_str: &str) -> Result<Self, Self::Err> {
todo!()
}
} |
What member of the |
That's a good question - would this be a legal WKT and/or do we want to support such cases? |
One (bad?) option could be some sort of a boxing variant, e.g. in case of mixed type. I am not a Rust expert just yet, so this is outside of my expertise/comfort zone for now. pub enum Wkt<T: CoordNum> {
Empty(Geometry<NoValue>),
Geo2D(Geometry<T>),
Geo2DM(Geometry<T, NoValue, T>),
Geo3D(Geometry<T, T>),
Geo3DM(Geometry<T, T, T>),
Boxed(<magic>), // <-- some sort of a trait-based boxed value?
} |
Whoops, that example I gave was invalid WKT. I forgot that MultiLineStrings don't tag each individual LINESTRING... I've updated it with a corollary that we do support today:
It's kind of an edge case, but I do think these kinds of degenerate geometries exist in the wild, and that it's nice to support them where reasonable. |
I guess my point is that it really seems like |
Once (if) the new
geo-types
with 3dM support is merged, I think wkt can migrate to use them directly, instead of having its own duplicate set of types. This should improve performance (no extra transformation), and simplify code - one set of types for everything.The 3dM types require proper generics (either concrete float type or a
NoValue
empty struct). We could represent it with a newWkt
enum instead of the existingpub struct Wkt<T> { pub item: Geometry<T> }
.NoValue
might need to be updated to support allCoordNum
requirements.The text was updated successfully, but these errors were encountered: