1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2020, Oracle and/or its affiliates.
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
10 #ifndef BOOST_TEST_MODULE
11 #define BOOST_TEST_MODULE test_intersection_pointlike_areal
17 #include <boost/test/included/unit_test.hpp>
19 #include "../test_set_ops_pointlike.hpp"
21 #include <boost/geometry/geometries/multi_point.hpp>
22 #include <boost/geometry/geometries/multi_polygon.hpp>
23 #include <boost/geometry/geometries/point.hpp>
24 #include <boost/geometry/geometries/polygon.hpp>
25 #include <boost/geometry/geometries/ring.hpp>
27 typedef bg::model::point
<double, 2, bg::cs::cartesian
> Pt
;
28 typedef bg::model::polygon
<Pt
> Po
;
29 typedef bg::model::ring
<Pt
> R
;
30 typedef bg::model::multi_point
<Pt
> MPt
;
31 typedef bg::model::multi_polygon
<Po
> MPo
;
33 BOOST_AUTO_TEST_CASE( test_intersection_point_ring
)
35 typedef test_set_op_of_pointlike_geometries
37 Pt
, R
, MPt
, bg::overlay_intersection
42 from_wkt
<Pt
>("POINT(0 0)"),
43 from_wkt
<R
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))"),
44 from_wkt
<MPt
>("MULTIPOINT(0 0)")
49 from_wkt
<Pt
>("POINT(1 1)"),
50 from_wkt
<R
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))"),
51 from_wkt
<MPt
>("MULTIPOINT(1 1)")
56 from_wkt
<Pt
>("POINT(6 6)"),
57 from_wkt
<R
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))"),
58 from_wkt
<MPt
>("MULTIPOINT()")
63 BOOST_AUTO_TEST_CASE( test_intersection_point_polygon
)
65 typedef test_set_op_of_pointlike_geometries
67 Pt
, Po
, MPt
, bg::overlay_intersection
72 from_wkt
<Pt
>("POINT(0 0)"),
73 from_wkt
<Po
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 3 1, 3 3, 1 3, 0 0))"),
74 from_wkt
<MPt
>("MULTIPOINT(0 0)")
79 from_wkt
<Pt
>("POINT(1 1)"),
80 from_wkt
<Po
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 3 1, 3 3, 1 3, 0 0))"),
81 from_wkt
<MPt
>("MULTIPOINT()")
86 from_wkt
<Pt
>("POINT(3 3)"),
87 from_wkt
<Po
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 3 1, 3 3, 1 3, 0 0))"),
88 from_wkt
<MPt
>("MULTIPOINT(3 3)")
93 from_wkt
<Pt
>("POINT(4 4)"),
94 from_wkt
<Po
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 3 1, 3 3, 1 3, 0 0))"),
95 from_wkt
<MPt
>("MULTIPOINT(4 4)")
100 from_wkt
<Pt
>("POINT(6 6)"),
101 from_wkt
<Po
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 3 1, 3 3, 1 3, 0 0))"),
102 from_wkt
<MPt
>("MULTIPOINT()")
107 BOOST_AUTO_TEST_CASE( test_intersection_point_multipolygon
)
109 typedef test_set_op_of_pointlike_geometries
111 Pt
, MPo
, MPt
, bg::overlay_intersection
116 from_wkt
<Pt
>("POINT(0 0)"),
117 from_wkt
<MPo
>("MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 4 1, 4 4, 1 4, 0 0)),((0 0, 1 2, 2 2, 2 1, 0 0)))"),
118 from_wkt
<MPt
>("MULTIPOINT(0 0)")
123 from_wkt
<Pt
>("POINT(1 1)"),
124 from_wkt
<MPo
>("MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 4 1, 4 4, 1 4, 0 0)),((0 0, 1 2, 2 2, 2 1, 0 0)))"),
125 from_wkt
<MPt
>("MULTIPOINT(1 1)")
130 from_wkt
<Pt
>("POINT(2 2)"),
131 from_wkt
<MPo
>("MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 4 1, 4 4, 1 4, 0 0)),((0 0, 1 2, 2 2, 2 1, 0 0)))"),
132 from_wkt
<MPt
>("MULTIPOINT(2 2)")
137 from_wkt
<Pt
>("POINT(3 3)"),
138 from_wkt
<MPo
>("MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 4 1, 4 4, 1 4, 0 0)),((0 0, 1 2, 2 2, 2 1, 0 0)))"),
139 from_wkt
<MPt
>("MULTIPOINT()")
143 BOOST_AUTO_TEST_CASE( test_intersection_multipoint_ring
)
145 typedef test_set_op_of_pointlike_geometries
147 MPt
, R
, MPt
, bg::overlay_intersection
152 from_wkt
<MPt
>("MULTIPOINT(0 0, 1 1, 6 6)"),
153 from_wkt
<R
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))"),
154 from_wkt
<MPt
>("MULTIPOINT(0 0, 1 1)")
159 BOOST_AUTO_TEST_CASE( test_intersection_multipoint_polygon
)
161 typedef test_set_op_of_pointlike_geometries
163 MPt
, Po
, MPt
, bg::overlay_intersection
168 from_wkt
<MPt
>("MULTIPOINT(0 0, 1 1, 3 3, 4 4, 6 6)"),
169 from_wkt
<Po
>("POLYGON((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 3 1, 3 3, 1 3, 0 0))"),
170 from_wkt
<MPt
>("MULTIPOINT(0 0, 3 3, 4 4)")
175 BOOST_AUTO_TEST_CASE( test_intersection_multipoint_multipolygon
)
177 typedef test_set_op_of_pointlike_geometries
179 MPt
, MPo
, MPt
, bg::overlay_intersection
184 from_wkt
<MPt
>("MULTIPOINT(0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6)"),
185 from_wkt
<MPo
>("MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0),(0 0, 4 1, 4 4, 1 4, 0 0)),((0 0, 1 2, 2 2, 2 1, 0 0)))"),
186 // NOTE: This is caused by the fact that intersection(MPt, MPt)
187 // used internally does not filter duplicates out.
188 from_wkt
<MPt
>("MULTIPOINT(0 0, 0 0, 1 1, 2 2, 4 4, 5 5)")