]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/relational_operations/covered_by/covered_by.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
6 // This file was modified by Oracle on 2015.
7 // Modifications copyright (c) 2015 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
15 #include "test_covered_by.hpp"
18 #include <boost/geometry/geometries/geometries.hpp>
19 #include <boost/geometry/geometries/point_xy.hpp>
27 test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true, false);
30 test_ring<P>("POINT(0 0)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false, true);
31 test_ring<P>("POINT(0 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", false, true);
33 // aligned to segment/vertex
34 test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", true, false);
35 test_ring<P>("POINT(1 1)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", true, false);
37 // same polygon, but point on border
38 test_ring<P>("POINT(3 3)", "POLYGON((0 0,0 3,3 3,3 1,2 1,2 0,0 0))", false, true);
39 test_ring<P>("POINT(3 3)", "POLYGON((0 0,0 3,4 3,3 1,2 2,2 0,0 0))", false, true);
42 test_geometry<P, bg::model::polygon<P> >("POINT(2 2)",
43 "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,3 1,3 3,1 3,1 1))", false);
47 typedef bg::model::segment
<P
> seg
;
48 test_geometry
<P
, seg
>("POINT(1 1)", "LINESTRING(0 0, 2 2)", true);
49 test_geometry
<P
, seg
>("POINT(0 0)", "LINESTRING(0 0, 1 1)", true);
50 test_geometry
<P
, seg
>("POINT(1 0)", "LINESTRING(0 0, 1 1)", false);
53 typedef bg::model::linestring
<P
> ls
;
54 test_geometry
<P
, ls
>("POINT(0 0)", "LINESTRING(0 0,1 1,2 2)", true);
55 test_geometry
<P
, ls
>("POINT(3 3)", "LINESTRING(0 0,1 1,2 2)", false);
56 test_geometry
<P
, ls
>("POINT(1 1)", "LINESTRING(0 0,2 2,3 3)", true);
59 typedef bg::model::multi_linestring
<ls
> mls
;
60 test_geometry
<P
, mls
>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1))", true);
61 test_geometry
<P
, mls
>("POINT(0 0)", "MULTILINESTRING((0 0,1 1,2 2),(0 0,0 1),(0 0,1 0))", true);
63 typedef bg::model::box
<P
> box_type
;
65 test_geometry
<P
, box_type
>("POINT(1 1)", "BOX(0 0,2 2)", true);
66 test_geometry
<P
, box_type
>("POINT(0 0)", "BOX(0 0,2 2)", true);
67 test_geometry
<P
, box_type
>("POINT(2 2)", "BOX(0 0,2 2)", true);
68 test_geometry
<P
, box_type
>("POINT(0 1)", "BOX(0 0,2 2)", true);
69 test_geometry
<P
, box_type
>("POINT(1 0)", "BOX(0 0,2 2)", true);
70 test_geometry
<P
, box_type
>("POINT(3 3)", "BOX(0 0,2 2)", false);
72 test_geometry
<box_type
, box_type
>("BOX(1 1,2 2)", "BOX(0 0,3 3)", true);
73 test_geometry
<box_type
, box_type
>("BOX(0 0,3 3)", "BOX(1 1,2 2)", false);
74 test_geometry
<box_type
, box_type
>("BOX(0 0,2 2)", "BOX(0 0,3 3)", true);
75 test_geometry
<box_type
, box_type
>("BOX(1 1,3 3)", "BOX(0 0,3 3)", true);
76 test_geometry
<box_type
, box_type
>("BOX(1 2,3 3)", "BOX(0 0,3 3)", true);
77 test_geometry
<box_type
, box_type
>("BOX(1 1,4 3)", "BOX(0 0,3 3)", false);
83 typedef boost::geometry::model::point
<double, 3, boost::geometry::cs::cartesian
> point_type
;
84 typedef boost::geometry::model::box
<point_type
> box_type
;
85 box_type
box(point_type(0, 0, 0), point_type(4, 4, 4));
86 BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 2, 2), box
), true);
87 BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 4, 2), box
), true);
88 BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 2, 4), box
), true);
89 BOOST_CHECK_EQUAL(bg::covered_by(point_type(2, 2, 5), box
), false);
92 template <typename P1
, typename P2
>
95 typedef boost::geometry::model::polygon
<P1
> polygon_type1
;
96 typedef boost::geometry::model::polygon
<P2
> polygon_type2
;
97 typedef boost::geometry::model::box
<P1
> box_type1
;
98 typedef boost::geometry::model::box
<P2
> box_type2
;
102 boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly1
);
103 boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly2
);
105 box_type1
box1(P1(1, 1), P1(4, 4));
106 box_type2
box2(P2(0, 0), P2(5, 5));
110 BOOST_CHECK_EQUAL(bg::covered_by(p1
, poly2
), true);
111 BOOST_CHECK_EQUAL(bg::covered_by(p2
, poly1
), true);
112 BOOST_CHECK_EQUAL(bg::covered_by(p2
, box1
), true);
113 BOOST_CHECK_EQUAL(bg::covered_by(p1
, box2
), true);
114 BOOST_CHECK_EQUAL(bg::covered_by(box1
, box2
), true);
115 BOOST_CHECK_EQUAL(bg::covered_by(box2
, box1
), false);
121 // Mixing point types and coordinate types
124 boost::geometry::model::d2::point_xy
<double>,
125 boost::geometry::model::point
<double, 2, boost::geometry::cs::cartesian
>
129 boost::geometry::model::d2::point_xy
<float>,
130 boost::geometry::model::point
<double, 2, boost::geometry::cs::cartesian
>
134 boost::geometry::model::d2::point_xy
<int>,
135 boost::geometry::model::d2::point_xy
<double>
140 int test_main( int , char* [] )
142 test_all
<bg::model::d2::point_xy
<int> >();
143 test_all
<bg::model::d2::point_xy
<double> >();
145 //test_spherical<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
151 #if defined(HAVE_TTMATH)
152 test_all
<bg::model::d2::point_xy
<ttmath_big
> >();
153 test_eps
<bg::model::d2::point_xy
<ttmath_big
> >();
154 //test_spherical<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();