1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland.
6 // Copyright (c) 2014-2018, Oracle and/or its affiliates.
8 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Licensed under the Boost Software License version 1.0.
12 // http://www.boost.org/users/license.html
14 #ifndef BOOST_TEST_MODULE
15 #define BOOST_TEST_MODULE test_is_valid_geo
21 #include <boost/test/included/unit_test.hpp>
23 #include "test_is_valid.hpp"
25 #include <boost/geometry/core/coordinate_type.hpp>
27 #include <boost/geometry/algorithms/correct.hpp>
28 #include <boost/geometry/algorithms/intersection.hpp>
29 #include <boost/geometry/algorithms/reverse.hpp>
32 BOOST_AUTO_TEST_CASE( test_is_valid_geo_polygon
)
34 typedef bg::model::point
<double, 2, bg::cs::geographic
<bg::degree
> > pt
;
35 typedef bg::model::polygon
<pt
, false> G
;
37 typedef validity_tester_geo_areal
<false> tester
;
38 typedef test_valid
<tester
, G
> test
;
40 test::apply("p01", "POLYGON((-1 -1, 1 -1, 1 1, -1 1, -1 -1),(-0.5 -0.5, -0.5 0.5, 0.0 0.0, -0.5 -0.5),(0.0 0.0, 0.5 0.5, 0.5 -0.5, 0.0 0.0))", true);
43 template <typename Poly
, typename Spheroid
>
44 void test_valid_s(std::string
const& wkt
,
48 bg::strategy::intersection::geographic_segments
<> is(sph
);
49 bg::strategy::area::geographic
<> as(sph
);
55 BOOST_CHECK(bg::is_valid(p
, is
) == expected_result
);
58 BOOST_AUTO_TEST_CASE( test_is_valid_epsg4053_polygon
)
60 typedef bg::model::point
<double, 2, bg::cs::geographic
<bg::degree
> > pt
;
61 typedef bg::model::polygon
<pt
, false> po
;
63 bg::srs::spheroid
<double> epsg4053(6371228, 6371228);
64 bg::srs::spheroid
<double> wgs84
;
66 // NOTE: the orientation is different in these CSes,
67 // in one of them the polygon is corrected before passing it into is_valid()
69 test_valid_s
<po
>("POLYGON((-148 -68,178 -74,76 0,-148 -68))", wgs84
, true);
70 test_valid_s
<po
>("POLYGON((-148 -68,178 -74,76 0,-148 -68))", epsg4053
, true);
72 test_valid_s
<po
>("POLYGON((-152 -54,-56 43,142 -52,-152 -54))", wgs84
, true);
73 test_valid_s
<po
>("POLYGON((-152 -54,-56 43,142 -52,-152 -54))", epsg4053
, true);