(geometry: &Geometry)
| 36 | } |
| 37 | |
| 38 | fn implicitly_open_ref(geometry: &Geometry) -> Box<dyn Iterator<Item = Coord> + '_> { |
| 39 | match geometry { |
| 40 | Geometry::Point(_) | Geometry::Line(_) | Geometry::Rect(_) | Geometry::Triangle(_) => { |
| 41 | Box::new(geometry.coords_iter()) |
| 42 | } |
| 43 | Geometry::LineString(ls) => { |
| 44 | let ls = ls.clone(); |
| 45 | Box::new(implicitly_open_linestring(ls)) |
| 46 | } |
| 47 | Geometry::Polygon(p) => { |
| 48 | let p = p.clone(); |
| 49 | let (exterior, interiors) = p.into_inner(); |
| 50 | |
| 51 | let exterior = implicitly_open_linestring(exterior); |
| 52 | let interiors = interiors.into_iter().flat_map(implicitly_open_linestring); |
| 53 | let all_points = exterior.chain(interiors); |
| 54 | Box::new(all_points) |
| 55 | } |
| 56 | // TODO: Is there an alternative implementation of flatten_nested_geometries that could |
| 57 | // operate on an 'impl Iterator<Item = &Geometry>'? |
| 58 | _ => unimplemented!( |
| 59 | "You can't flatten multi-geometries into point clouds without consuming the geometry" |
| 60 | ), |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /// Flatten the given geometries into a point cloud |
| 65 | /// |
nothing calls this directly
no test coverage detected