@@ -23,13 +23,34 @@ TEST_CASE("geometry collection with point", "[NoDB]")
2323 c.add_geometry (geom::geometry_t {geom::point_t {1 , 1 }});
2424
2525 REQUIRE (geometry_type (geom) == " GEOMETRYCOLLECTION" );
26+ REQUIRE (dimension (geom) == 0 );
2627 REQUIRE (num_geometries (geom) == 1 );
2728 REQUIRE (area (geom) == Approx (0.0 ));
2829 REQUIRE (length (geom) == Approx (0.0 ));
29- REQUIRE_THROWS (centroid (geom));
30+ REQUIRE (centroid (geom) == geom:: geometry_t {geom:: point_t { 1 , 1 }} );
3031 REQUIRE (geometry_n (geom, 1 ) == geom::geometry_t {geom::point_t {1 , 1 }});
3132}
3233
34+ TEST_CASE (" geometry collection with multipoint" , " [NoDB]" )
35+ {
36+ geom::geometry_t mpgeom{geom::multipoint_t {}};
37+ auto &mp = mpgeom.get <geom::multipoint_t >();
38+ mp.add_geometry (geom::point_t {1 , 1 });
39+ mp.add_geometry (geom::point_t {1 , 2 });
40+ mp.add_geometry (geom::point_t {2 , 1 });
41+ mp.add_geometry (geom::point_t {2 , 2 });
42+
43+ geom::geometry_t geom{geom::collection_t {}};
44+ auto &c = geom.get <geom::collection_t >();
45+ c.add_geometry (std::move (mpgeom));
46+
47+ REQUIRE (geometry_type (geom) == " GEOMETRYCOLLECTION" );
48+ REQUIRE (dimension (geom) == 0 );
49+ REQUIRE (num_geometries (geom) == 1 );
50+ REQUIRE (area (geom) == Approx (0.0 ));
51+ REQUIRE (centroid (geom) == geom::geometry_t {geom::point_t {1.5 , 1.5 }});
52+ }
53+
3354TEST_CASE (" geometry collection with several geometries" , " [NoDB]" )
3455{
3556 geom::geometry_t geom{geom::collection_t {}};
@@ -40,10 +61,11 @@ TEST_CASE("geometry collection with several geometries", "[NoDB]")
4061 c.add_geometry (geom::geometry_t {geom::point_t {2 , 2 }});
4162
4263 REQUIRE (geometry_type (geom) == " GEOMETRYCOLLECTION" );
64+ REQUIRE (dimension (geom) == 1 );
4365 REQUIRE (num_geometries (geom) == 3 );
4466 REQUIRE (area (geom) == Approx (0.0 ));
4567 REQUIRE (length (geom) == Approx (1.41421 ));
46- REQUIRE_THROWS (centroid (geom));
68+ REQUIRE (centroid (geom) == geom:: geometry_t {geom:: point_t { 1.5 , 1.5 }} );
4769 REQUIRE (geometry_n (geom, 1 ) == geom::geometry_t {geom::point_t {1 , 1 }});
4870 REQUIRE (geometry_n (geom, 2 ) ==
4971 geom::geometry_t {geom::linestring_t {{1 , 1 }, {2 , 2 }}});
@@ -55,23 +77,24 @@ TEST_CASE("create_collection from OSM data", "[NoDB]")
5577 test_buffer_t buffer;
5678 buffer.add_node (" n1 x1 y1" );
5779 buffer.add_way (" w20 Nn1x1y1,n2x2y1,n3x2y2,n4x1y2,n1x1y1" );
58- buffer.add_way (" w21 Nn5x10y10,n6x10y20 " );
80+ buffer.add_way (" w21 Nn5x10y10,n6x10y11 " );
5981 buffer.add_relation (" r30 Mw20@" );
6082
6183 auto const geom = geom::create_collection (buffer.buffer ());
6284
6385 REQUIRE (geometry_type (geom) == " GEOMETRYCOLLECTION" );
86+ REQUIRE (dimension (geom) == 1 );
6487 REQUIRE (num_geometries (geom) == 3 );
6588
6689 auto const &c = geom.get <geom::collection_t >();
6790 REQUIRE (c[0 ] == geom::geometry_t {geom::point_t {1 , 1 }});
6891 REQUIRE (c[1 ] == geom::geometry_t {geom::linestring_t {
6992 {1 , 1 }, {2 , 1 }, {2 , 2 }, {1 , 2 }, {1 , 1 }}});
70- REQUIRE (c[2 ] == geom::geometry_t {geom::linestring_t {{10 , 10 }, {10 , 20 }}});
93+ REQUIRE (c[2 ] == geom::geometry_t {geom::linestring_t {{10 , 10 }, {10 , 11 }}});
7194
7295 REQUIRE (area (geom) == Approx (0.0 ));
73- REQUIRE (length (geom) == Approx (14 .0 ));
74- REQUIRE_THROWS (centroid (geom));
96+ REQUIRE (length (geom) == Approx (5 .0 ));
97+ REQUIRE (centroid (geom) == geom:: geometry_t {geom:: point_t { 3.2 , 3.3 }} );
7598}
7699
77100TEST_CASE (" create_collection from no OSM data returns null geometry" , " [NoDB]" )
@@ -82,6 +105,7 @@ TEST_CASE("create_collection from no OSM data returns null geometry", "[NoDB]")
82105 auto const geom = geom::create_collection (buffer.buffer ());
83106
84107 REQUIRE (geometry_type (geom) == " NULL" );
108+ REQUIRE (dimension (geom) == 0 );
85109 REQUIRE (num_geometries (geom) == 0 );
86110}
87111
0 commit comments