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

Reduce usage of let GeoType(a) = b #84

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ mod tests {
fn convert_empty_geometrycollection() {
let w_geometrycollection = GeometryCollection(vec![]).as_item();
let g_geometrycollection: geo_types::GeometryCollection<f64> =
geo_types::GeometryCollection(vec![]);
geo_types::GeometryCollection::default();
assert_eq!(
geo_types::Geometry::GeometryCollection(g_geometrycollection),
w_geometrycollection.try_into().unwrap()
Expand Down
20 changes: 7 additions & 13 deletions src/towkt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ fn g_linestring_to_w_linestring<T>(g_linestring: &geo_types::LineString<T>) -> L
where
T: CoordFloat,
{
let &geo_types::LineString(ref g_points) = g_linestring;
g_points_to_w_linestring(g_points)
g_points_to_w_linestring(&g_linestring.0)
}

fn g_points_to_w_linestring<T>(g_coords: &[geo_types::Coordinate<T>]) -> LineString<T>
Expand All @@ -84,8 +83,7 @@ where
{
let mut w_lines = vec![];
for g_line in g_lines {
let &geo_types::LineString(ref g_points) = g_line;
w_lines.push(g_points_to_w_linestring(g_points));
w_lines.push(g_points_to_w_linestring(&g_line.0));
}
w_lines
}
Expand Down Expand Up @@ -115,7 +113,7 @@ where
let mut poly_lines = vec![];

// Outer
let &geo_types::LineString(ref outer_points) = outer_line;
let outer_points = &outer_line.0;
if !outer_points.is_empty() {
poly_lines.push(g_points_to_w_linestring(outer_points));
}
Expand All @@ -131,17 +129,15 @@ fn g_mpoint_to_w_mpoint<T>(g_mpoint: &geo_types::MultiPoint<T>) -> MultiPoint<T>
where
T: CoordFloat,
{
let &geo_types::MultiPoint(ref g_points) = g_mpoint;
let w_points = g_points_to_w_points(g_points);
let w_points = g_points_to_w_points(&g_mpoint.0);
MultiPoint(w_points)
}

fn g_mline_to_w_mline<T>(g_mline: &geo_types::MultiLineString<T>) -> MultiLineString<T>
where
T: CoordFloat,
{
let &geo_types::MultiLineString(ref g_lines) = g_mline;
let w_lines = g_lines_to_w_lines(g_lines);
let w_lines = g_lines_to_w_lines(&g_mline.0);
MultiLineString(w_lines)
}

Expand All @@ -160,18 +156,16 @@ fn g_mpolygon_to_w_mpolygon<T>(g_mpolygon: &geo_types::MultiPolygon<T>) -> Multi
where
T: CoordFloat,
{
let &geo_types::MultiPolygon(ref g_polygons) = g_mpolygon;
let w_polygons = g_polygons_to_w_polygons(g_polygons);
let w_polygons = g_polygons_to_w_polygons(&g_mpolygon.0);
MultiPolygon(w_polygons)
}

fn g_geocol_to_w_geocol<T>(g_geocol: &geo_types::GeometryCollection<T>) -> GeometryCollection<T>
where
T: CoordFloat,
{
let &geo_types::GeometryCollection(ref g_geoms) = g_geocol;
let mut w_geoms = vec![];
for g_geom in g_geoms {
for g_geom in g_geocol.0.iter() {
let w_geom = g_geom_to_w_geom(g_geom);
w_geoms.push(w_geom);
}
Expand Down