1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
8 // This file was modified by Oracle on 2021.
9 // Modifications copyright (c) 2021, Oracle and/or its affiliates.
10 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
20 #include <algorithms/test_convert.hpp>
24 template <typename Point1
, typename Point2
>
25 void test_mixed_point_types()
28 check
<Point1
, Point2
>("POINT(1 2)");
31 check
<bg::model::box
<Point1
>, bg::model::box
<Point2
>>("POLYGON((1 2,1 4,3 4,3 2,1 2))");
34 check
<bg::model::segment
<Point1
>, bg::model::segment
<Point2
>>("LINESTRING(1 1,2 2)");
37 check
<bg::model::linestring
<Point1
>, bg::model::linestring
<Point2
>>("LINESTRING(1 1,2 2)");
40 check
<bg::model::ring
<Point1
, true, true>, bg::model::ring
<Point2
, true, true>>(
41 "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,2 2,3 0,1 1))", 4);
42 check
<bg::model::ring
<Point1
, true, true>, bg::model::ring
<Point2
, false, true>>(
43 "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,3 0,2 2,1 1))", 4);
44 check
<bg::model::ring
<Point1
, true, true>, bg::model::ring
<Point2
, true, false>>(
45 "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,2 2,3 0))", 3);
46 check
<bg::model::ring
<Point1
, true, true>, bg::model::ring
<Point2
, false, false>>(
47 "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,3 0,2 2))", 3);
49 check
<bg::model::ring
<Point1
, false, true>, bg::model::ring
<Point2
, true, true>>(
50 "POLYGON((1 1,3 0,2 2,1 1))", "POLYGON((1 1,2 2,3 0,1 1))", 4);
51 check
<bg::model::ring
<Point1
, false, true>, bg::model::ring
<Point2
, false, true>>(
52 "POLYGON((1 1,3 0,2 2,1 1))", "POLYGON((1 1,3 0,2 2,1 1))", 4);
53 check
<bg::model::ring
<Point1
, false, true>, bg::model::ring
<Point2
, true, false>>(
54 "POLYGON((1 1,3 0,2 2,1 1))", "POLYGON((1 1,2 2,3 0))", 3);
55 check
<bg::model::ring
<Point1
, false, true>, bg::model::ring
<Point2
, false, false>>(
56 "POLYGON((1 1,3 0,2 2,1 1))", "POLYGON((1 1,3 0,2 2))", 3);
58 check
<bg::model::ring
<Point1
, true, false>, bg::model::ring
<Point2
, true, true>>(
59 "POLYGON((1 1,2 2,3 0))", "POLYGON((1 1,2 2,3 0,1 1))", 4);
60 check
<bg::model::ring
<Point1
, true, false>, bg::model::ring
<Point2
, false, true>>(
61 "POLYGON((1 1,2 2,3 0))", "POLYGON((1 1,3 0,2 2,1 1))", 4);
62 check
<bg::model::ring
<Point1
, true, false>, bg::model::ring
<Point2
, true, false>>(
63 "POLYGON((1 1,2 2,3 0))", "POLYGON((1 1,2 2,3 0))", 3);
64 check
<bg::model::ring
<Point1
, true, false>, bg::model::ring
<Point2
, false, false>>(
65 "POLYGON((1 1,2 2,3 0))", "POLYGON((1 1,3 0,2 2))", 3);
67 check
<bg::model::ring
<Point1
, false, false>, bg::model::ring
<Point2
, true, true>>(
68 "POLYGON((1 1,3 0,2 2))", "POLYGON((1 1,2 2,3 0,1 1))", 4);
69 check
<bg::model::ring
<Point1
, false, false>, bg::model::ring
<Point2
, false, true>>(
70 "POLYGON((1 1,3 0,2 2))", "POLYGON((1 1,3 0,2 2,1 1))", 4);
71 check
<bg::model::ring
<Point1
, false, false>, bg::model::ring
<Point2
, true, false>>(
72 "POLYGON((1 1,3 0,2 2))", "POLYGON((1 1,2 2,3 0))", 3);
73 check
<bg::model::ring
<Point1
, false, false>, bg::model::ring
<Point2
, false, false>>(
74 "POLYGON((1 1,3 0,2 2))", "POLYGON((1 1,3 0,2 2))", 3);
77 check
<bg::model::polygon
<Point1
, true>, bg::model::polygon
<Point2
, false>>(
78 "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))",
79 "POLYGON((0 0,5 0,5 5,0 5,0 0),(1 1,2 4,3 2,1 1))");
81 check
<bg::model::polygon
<Point1
>, bg::model::polygon
<Point2
, false, false>>(
82 "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))",
83 "POLYGON((0 0,5 0,5 5,0 5,0 0),(1 1,2 4,3 2,1 1))",
84 7); // WKT is closed, polygon is open
85 // (polygon uses ring, so other tests omitted here)
89 check
<bg::model::polygon
<Point1
>, bg::model::ring
<Point2
>>(
90 "POLYGON((1 1,2 2,3 0,1 1))");
92 check
<bg::model::polygon
<Point1
, true>, bg::model::ring
<Point2
, false>>(
93 "POLYGON((1 1,2 2,3 0,1 1))", "POLYGON((1 1,3 0,2 2,1 1))");
95 // Any hole will be omitted going from polygon to ring
96 check
<bg::model::polygon
<Point1
>, bg::model::ring
<Point2
>>(
97 "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))",
98 "POLYGON((0 0,0 5,5 5,5 0,0 0))",
102 check
<Point1
, bg::model::box
<Point2
>>(
103 "POINT(0 0)", "POLYGON((0 0,0 0,0 0,0 0,0 0))", 4);
106 check
<bg::model::segment
<Point1
>, bg::model::linestring
<Point2
>>(
107 "LINESTRING(0 0,1 1)", "LINESTRING(0 0,1 1)", 2);
109 // box -> ring ( <- is NYI)
110 check
<bg::model::box
<Point1
>, bg::model::ring
<Point2
>>(
111 "BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", 5);
113 check
<bg::model::box
<Point1
>, bg::model::ring
<Point2
, false>>(
114 "BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2,0 0))", 5);
116 check
<bg::model::box
<Point1
>, bg::model::ring
<Point2
, true, false>>(
117 "BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0))", 4);
119 check
<bg::model::box
<Point1
>, bg::model::ring
<Point2
, false, false>>(
120 "BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2))", 4);
122 // box -> polygon ( <- is NYI)
123 check
<bg::model::box
<Point1
>, bg::model::polygon
<Point2
>>(
124 "BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", 5);
125 check
<bg::model::box
<Point1
>, bg::model::polygon
<Point2
, false>>(
126 "BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2,0 0))", 5);
127 check
<bg::model::box
<Point1
>, bg::model::polygon
<Point2
, true, false>>(
128 "BOX(0 0,2 2)", "POLYGON((0 0,0 2,2 2,2 0,0 0))",
129 4); // WKT is closed, polygon is open
131 check
<bg::model::box
<Point1
>, bg::model::polygon
<Point2
, false, false>>(
132 "BOX(0 0,2 2)", "POLYGON((0 0,2 0,2 2,0 2,0 0))",
133 4); // WKT is closed, polygon is open
136 template <typename Point1
, typename Point2
>
137 void test_mixed_point_types_3d()
140 check
<Point1
, Point2
>("POINT(1 2 3)");
142 check
<bg::model::segment
<Point1
>, bg::model::segment
<Point2
>>(
143 "LINESTRING(1 2 3,4 5 6)");
146 check
<bg::model::linestring
<Point1
>, bg::model::linestring
<Point2
>>(
147 "LINESTRING(1 2 3,4 5 6,7 8 9)");
150 check
<bg::model::segment
<Point1
>, bg::model::linestring
<Point2
>>(
151 "LINESTRING(1 2 3,4 5 6)", "LINESTRING(1 2 3,4 5 6)", 2);
156 template <typename Point1
, typename Point2
>
157 void test_mixed_types()
159 test_mixed_point_types
<Point1
, Point2
>();
160 test_mixed_point_types
<Point2
, Point1
>();
164 template <typename Point1
, typename Point2
>
165 void test_mixed_types_3d()
167 test_mixed_point_types_3d
<Point1
, Point2
>();
168 test_mixed_point_types_3d
<Point2
, Point1
>();
176 BOOST_CHECK_EQUAL(b
[0], 1);
177 BOOST_CHECK_EQUAL(b
[1], 2);
180 int test_main(int, char* [])
184 bg::model::point
<int, 2, bg::cs::cartesian
>,
185 bg::model::point
<double, 2, bg::cs::cartesian
>
189 boost::tuple
<float, float>,
190 bg::model::point
<float, 2, bg::cs::cartesian
>
194 boost::tuple
<double, double, double>,
195 bg::model::point
<double, 3, bg::cs::cartesian
>