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

Function test_points

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

Source from the content-addressed store, hash-verified

94
95 #[test]
96 fn test_points() {
97 let wkt = b"POINT(0 0)\nLINESTRING(0 0, 1 1)\nPOINT(2 2)\n";
98 let geometries = read_wkt_geometries(&wkt[..]);
99
100 let graph = node::<_, Undirected>(geometries);
101 assert_eq!(graph.node_count(), 3);
102 assert_eq!(graph.edge_count(), 1);
103
104 let node0 = graph.node_weight(NodeIndex::new(0)).unwrap();
105 let expected0 = Point::new(0.0, 0.0);
106 assert_eq!(node0, &expected0);
107
108 // Geometries aren't handled one at a time in their order in the iterator. Points are
109 // handled, then linestrings, then finally polygons.
110 let node1 = graph.node_weight(NodeIndex::new(1)).unwrap();
111 let expected1 = Point::new(2.0, 2.0);
112 assert_eq!(node1, &expected1);
113
114 let node2 = graph.node_weight(NodeIndex::new(2)).unwrap();
115 let expected2 = Point::new(1.0, 1.0);
116 assert_eq!(node2, &expected2);
117
118 let edge0 = graph.edge_endpoints(EdgeIndex::new(0)).unwrap();
119 let expected0 = (NodeIndex::new(0), NodeIndex::new(2));
120 assert_eq!(edge0, expected0);
121 }
122
123 #[test]
124 fn test_single_linestring() {

Callers

nothing calls this directly

Calls 1

read_wkt_geometriesFunction · 0.85

Tested by

no test coverage detected