]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/relational_operations/disjoint/disjoint.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
6 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
8 // This file was modified by Oracle on 2015.
9 // Modifications copyright (c) 2015, Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
21 #include "test_disjoint.hpp"
23 #include <boost/geometry/geometries/geometries.hpp>
24 #include <boost/geometry/geometries/point_xy.hpp>
25 #include <boost/geometry/strategies/strategies.hpp>
27 #include <test_common/test_point.hpp>
29 #include <algorithms/overlay/overlay_cases.hpp>
31 #include <algorithms/predef_relop.hpp>
37 // Test triangles for polygons/rings, boxes
38 // Note that intersections are tested elsewhere, they don't need
39 // thorough test at this place
40 typedef bg::model::polygon
<P
> polygon
;
41 typedef bg::model::ring
<P
> ring
;
43 // Four times same test with other types
44 test_disjoint
<polygon
, polygon
>("disjoint_simplex_pp", disjoint_simplex
[0], disjoint_simplex
[1], true);
45 test_disjoint
<ring
, polygon
>("disjoint_simplex_rp", disjoint_simplex
[0], disjoint_simplex
[1], true);
46 test_disjoint
<ring
, ring
>("disjoint_simplex_rr", disjoint_simplex
[0], disjoint_simplex
[1], true);
47 test_disjoint
<polygon
, ring
>("disjoint_simplex_pr", disjoint_simplex
[0], disjoint_simplex
[1], true);
49 test_disjoint
<polygon
, polygon
>("ticket_8310a", ticket_8310a
[0], ticket_8310a
[1], false);
50 test_disjoint
<polygon
, polygon
>("ticket_8310b", ticket_8310b
[0], ticket_8310b
[1], false);
51 test_disjoint
<polygon
, polygon
>("ticket_8310c", ticket_8310c
[0], ticket_8310c
[1], false);
54 test_disjoint
<polygon
, polygon
>("touch_simplex_pp", touch_simplex
[0], touch_simplex
[1], false);
56 // Test if within(a,b) returns false for disjoint
57 test_disjoint
<ring
, ring
>("within_simplex_rr1", within_simplex
[0], within_simplex
[1], false);
58 test_disjoint
<ring
, ring
>("within_simplex_rr2", within_simplex
[1], within_simplex
[0], false);
61 typedef bg::model::linestring
<P
> ls
;
62 typedef bg::model::segment
<P
> segment
;
63 test_disjoint
<ls
, ls
>("ls/ls 1", "linestring(0 0,1 1)", "linestring(1 0,0 1)", false);
64 test_disjoint
<ls
, ls
>("ls/ls 2", "linestring(0 0,1 1)", "linestring(1 0,2 1)", true);
65 test_disjoint
<segment
, segment
>("s/s 1", "linestring(0 0,1 1)", "linestring(1 0,0 1)", false);
66 test_disjoint
<segment
, segment
>("s/s 2", "linestring(0 0,1 1)", "linestring(1 0,2 1)", true);
68 // Test degenerate segments (patched by Karsten Ahnert on 2012-07-25)
69 test_disjoint
<segment
, segment
>("s/s 3", "linestring(0 0,0 0)", "linestring(1 0,0 1)", true);
70 test_disjoint
<segment
, segment
>("s/s 4", "linestring(0 0,0 0)", "linestring(0 0,0 0)", false);
71 test_disjoint
<segment
, segment
>("s/s 5", "linestring(0 0,0 0)", "linestring(1 0,1 0)", true);
72 test_disjoint
<segment
, segment
>("s/s 6", "linestring(0 0,0 0)", "linestring(0 1,0 1)", true);
75 test_disjoint
<ls
, ls
>("ls/ls co", "linestring(0 0,2 2)", "linestring(1 1,0 0)", false);
76 // Collinear opposite and equal
77 test_disjoint
<ls
, ls
>("ls/ls co-e", "linestring(0 0,1 1)", "linestring(1 1,0 0)", false);
80 // Degenerate linestrings
82 // Submitted by Zachary on the Boost.Geometry Mailing List, on 2012-01-29
83 std::string
const a
= "linestring(100 10, 0 10)";
84 std::string
const b
= "linestring(50 10, 50 10)"; // one point only, with same y-coordinate
85 std::string
const c
= "linestring(100 10, 100 10)"; // idem, at left side
86 test_disjoint
<ls
, ls
>("dls/dls 1", a
, b
, false);
87 test_disjoint
<ls
, ls
>("dls/dls 2", b
, a
, false);
88 test_disjoint
<segment
, segment
>("ds/ds 1", a
, b
, false);
89 test_disjoint
<segment
, segment
>("ds/ds 2", b
, a
, false);
90 test_disjoint
<ls
, ls
>("dls/dls 1", a
, c
, false);
93 // Linestrings making angles normally ignored
95 // These (non-disjoint) cases
96 // correspond to the test "segment_intersection_collinear"
101 test_disjoint
<ls
, ls
>("n1", "linestring(2 0,0 6)", "linestring(0 0,2 0)", false);
105 test_disjoint
<ls
, ls
>("n7", "linestring(2 0,6 0)", "linestring(6 0,8 0)", false);
107 // Collinear - opposite ('f')
110 test_disjoint
<ls
, ls
>("o1", "linestring(2 0,6 0)", "linestring(2 0,0 0)", false);
114 // Starting in the middle ('s')
119 // a1--------b1----->a2
120 test_disjoint
<ls
, ls
>("case_s", "linestring(0 0,4 0)", "linestring(2 0,2 2)", false);
122 // Collinear, but disjoint
123 test_disjoint
<ls
, ls
>("c-d", "linestring(2 0,6 0)", "linestring(7 0,8 0)", true);
125 // Parallel, disjoint
126 test_disjoint
<ls
, ls
>("c-d", "linestring(2 0,6 0)", "linestring(2 1,6 1)", true);
128 // Error still there until 1.48 (reported "error", was reported to disjoint, so that's why it did no harm)
129 test_disjoint
<ls
, ls
>("case_recursive_boxes_1",
130 "linestring(10 7,10 6)", "linestring(10 10,10 9)", true);
134 // TODO test_disjoint<segment, ls>("s/ls 1", "linestring(0 0,1 1)", "linestring(1 0,0 1)", false);
135 // TODO test_disjoint<segment, ls>("s/ls 2", "linestring(0 0,1 1)", "linestring(1 0,2 1)", true);
136 // TODO test_disjoint<ls, segment>("ls/s 1", "linestring(0 0,1 1)", "linestring(1 0,0 1)", false);
137 // TODO test_disjoint<ls, segment>("ls/s 2", "linestring(0 0,1 1)", "linestring(1 0,2 1)", true);
140 test_disjoint
<ls
, ls
>("col-op", "LINESTRING(5 5,10 10)", "LINESTRING(6 6,3 3)", false);
141 test_disjoint
<ls
, ls
>("col-op", "LINESTRING(5 5,2 8)", "LINESTRING(4 6,7 3)", false);
143 test_disjoint
<ls
, polygon
>("col-op", "LINESTRING(10 10,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
144 test_disjoint
<ls
, polygon
>("col-op", "LINESTRING(9 10,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
146 // assertion failure in 1.57
147 test_disjoint
<ls
, ls
>("point_ll_assert_1_57",
148 "LINESTRING(-2305843009213693956 4611686018427387906, -33 -92, 78 83)",
149 "LINESTRING(31 -97, -46 57, -20 -4)",
154 int test_main(int, char* [])
156 test_all
<bg::model::d2::point_xy
<float> >();
157 test_all
<bg::model::d2::point_xy
<double> >();
160 test_all
<bg::model::d2::point_xy
<ttmath_big
> >();