@@ -58,6 +58,7 @@ TEST_CASE("line geometry", "[NoDB]")
5858 REQUIRE (area (geom) == Approx (0.0 ));
5959 REQUIRE (spherical_area (geom) == Approx (0.0 ));
6060 REQUIRE (length (geom) == Approx (1.41421 ));
61+ REQUIRE (spherical_length (geom) == Approx (156876.14940188668 ).epsilon (0.0000001 ));
6162 REQUIRE (geometry_type (geom) == " LINESTRING" );
6263 REQUIRE (centroid (geom) == geom::geometry_t {geom::point_t {1.5 , 1.5 }});
6364 REQUIRE (geometry_n (geom, 1 ) == geom);
@@ -91,6 +92,7 @@ TEST_CASE("create_linestring from OSM data", "[NoDB]")
9192 REQUIRE (area (geom) == Approx (0.0 ));
9293 REQUIRE (spherical_area (geom) == Approx (0.0 ));
9394 REQUIRE (length (geom) == Approx (1.41421 ));
95+ REQUIRE (spherical_length (geom) == Approx (156876.14940188668 ).epsilon (0.0000001 ));
9496 REQUIRE (geom.get <geom::linestring_t >() ==
9597 geom::linestring_t {{1 , 1 }, {2 , 2 }});
9698 REQUIRE (centroid (geom) == geom::geometry_t {geom::point_t {1.5 , 1.5 }});
@@ -361,3 +363,24 @@ TEST_CASE("geom::simplify of straight line", "[NoDB]")
361363 REQUIRE (l[1 ] == input.get <geom::linestring_t >()[2 ]);
362364 }
363365}
366+
367+ TEST_CASE (" long line length - equator" , " [NoDB]" )
368+ {
369+ geom::geometry_t const geom{geom::linestring_t {{0 , 0 }, {180 , 0 }}};
370+ REQUIRE (length (geom) == Approx (180.0 ));
371+ REQUIRE (spherical_length (geom) == Approx (20003931.458625447 ).epsilon (0.0000001 ));
372+ }
373+
374+ TEST_CASE (" long line length - to pole" , " [NoDB]" )
375+ {
376+ geom::geometry_t const geom{geom::linestring_t {{0 , -90 }, {0 , 90 }}};
377+ REQUIRE (length (geom) == Approx (180.0 ));
378+ REQUIRE (spherical_length (geom) == Approx (20003931.458625447 ).epsilon (0.0000001 ));
379+ }
380+
381+ TEST_CASE (" line length - more points" , " [NoDB]" )
382+ {
383+ geom::geometry_t const geom{geom::linestring_t {{20 , 19.8 }, {20.1 , 19.8 }, {20.2 , 19.9 }}};
384+ REQUIRE (length (geom) == Approx (0.2414213562373079 ));
385+ REQUIRE (spherical_length (geom) == Approx (25718.175297824535 ).epsilon (0.0000001 ));
386+ }
0 commit comments