MCPcopy Create free account
hub / github.com/Notgnoshi/generative / test_polygonize

Function test_polygonize

generative/noding/mod.rs:231–255  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

229
230 #[test]
231 fn test_polygonize() {
232 let wkt = b"GEOMETRYCOLLECTION( LINESTRING(2 0, 2 8), LINESTRING(6 0, 6 8), LINESTRING(0 2, 8 2), LINESTRING(0 6, 8 6))";
233 let geoms = read_wkt_geometries(&wkt[..]);
234 let graph = node::<_, Undirected>(geoms);
235
236 let (polygons, dangles) = polygonize(&graph);
237 assert_eq!(polygons.len(), 1);
238 assert_eq!(dangles.len(), 8);
239
240 let expected: Polygon =
241 Polygon::try_from_wkt_str("POLYGON((2 2, 2 6, 6 6, 6 2, 2 2))").unwrap();
242 assert_eq!(polygons[0], expected);
243
244 let expected = [
245 LineString::try_from_wkt_str("LINESTRING(6 6, 8 6)").unwrap(),
246 LineString::try_from_wkt_str("LINESTRING(6 2, 8 2)").unwrap(),
247 LineString::try_from_wkt_str("LINESTRING(6 6, 6 8)").unwrap(),
248 LineString::try_from_wkt_str("LINESTRING(6 0, 6 2)").unwrap(),
249 LineString::try_from_wkt_str("LINESTRING(2 6, 2 8)").unwrap(),
250 LineString::try_from_wkt_str("LINESTRING(2 0, 2 2)").unwrap(),
251 LineString::try_from_wkt_str("LINESTRING(2 6, 0 6)").unwrap(),
252 LineString::try_from_wkt_str("LINESTRING(2 2, 0 2)").unwrap(),
253 ];
254 assert_eq!(dangles, expected);
255 }
256}

Callers

nothing calls this directly

Calls 2

read_wkt_geometriesFunction · 0.85
polygonizeFunction · 0.70

Tested by

no test coverage detected