()
| 204 | |
| 205 | #[test] |
| 206 | fn test_triangulate_unit_square() { |
| 207 | let wkt = b"POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))"; |
| 208 | let geometries: Vec<_> = read_wkt_geometries(&wkt[..]).collect(); |
| 209 | let points = flatten_geometries_into_points_ref(geometries.iter()); |
| 210 | |
| 211 | let triangulation = triangulate(points).unwrap(); |
| 212 | |
| 213 | let triangles: Vec<_> = triangulation.triangles().collect(); |
| 214 | assert_eq!(triangles.len(), 2); |
| 215 | assert_eq!( |
| 216 | triangles[0], |
| 217 | geo::Triangle::new( |
| 218 | geo::Coord { x: 0., y: 0. }, |
| 219 | geo::Coord { x: 0., y: 1. }, |
| 220 | geo::Coord { x: 1., y: 1. }, |
| 221 | ) |
| 222 | ); |
| 223 | assert_eq!( |
| 224 | triangles[1], |
| 225 | geo::Triangle::new( |
| 226 | geo::Coord { x: 1., y: 1. }, |
| 227 | geo::Coord { x: 1., y: 0. }, |
| 228 | geo::Coord { x: 0., y: 0. }, |
| 229 | ) |
| 230 | ); |
| 231 | |
| 232 | assert_eq!(triangulation.lines().count(), 6); |
| 233 | |
| 234 | let wkt = b"POLYGON((1 1, 1 0, 0 0, 0 1, 1 1))"; // same polygon, same winding, different starting point |
| 235 | let geometries: Vec<_> = read_wkt_geometries(&wkt[..]).collect(); |
| 236 | let hull = triangulation.hull(); |
| 237 | assert_eq!(geo::Geometry::Polygon(hull), geometries[0]); |
| 238 | } |
| 239 | |
| 240 | #[test] |
| 241 | fn test_graph() { |
nothing calls this directly
no test coverage detected