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

Implement conversions for Line, GeometryCollection, Rect, Triangle #133

Closed
urschrei opened this issue Sep 1, 2020 · 2 comments · Fixed by #136
Closed

Implement conversions for Line, GeometryCollection, Rect, Triangle #133

urschrei opened this issue Sep 1, 2020 · 2 comments · Fixed by #136

Comments

@urschrei
Copy link
Member

urschrei commented Sep 1, 2020

Currently, this causes a run-time panic!(), which is not great. Line, Triangle and Rect should be easy to implement, but what about GeometryCollection?

@urschrei
Copy link
Member Author

urschrei commented Sep 1, 2020

Line maps to GeoJSON LineString
Triangle and Rect map to GeoJSON Polygon
GeometryCollection maps to GeoJSON GeometryCollection

@frewsxcv
Copy link
Member

frewsxcv commented Sep 2, 2020

Relevant code that needs to change:

#[cfg_attr(docsrs, doc(cfg(feature = "geo-types")))]
impl<'a, T> From<&'a geo_types::Geometry<T>> for geometry::Value
where
T: Float,
{
fn from(geometry: &'a geo_types::Geometry<T>) -> Self {
match *geometry {
geo_types::Geometry::Point(ref point) => geometry::Value::from(point),
geo_types::Geometry::MultiPoint(ref multi_point) => geometry::Value::from(multi_point),
geo_types::Geometry::LineString(ref line_string) => geometry::Value::from(line_string),
geo_types::Geometry::MultiLineString(ref multi_line_string) => {
geometry::Value::from(multi_line_string)
}
geo_types::Geometry::Polygon(ref polygon) => geometry::Value::from(polygon),
geo_types::Geometry::MultiPolygon(ref multi_polygon) => {
geometry::Value::from(multi_polygon)
}
_ => panic!("GeometryCollection not allowed"),
}
}
}

We should stop using _ as a matching pattern here and make it exhaustive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants