]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // Unit Test | |
3 | ||
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. | |
7 | ||
8 | // This file was modified by Oracle on 2015. | |
9 | // Modifications copyright (c) 2015, Oracle and/or its affiliates. | |
10 | ||
11 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
12 | ||
13 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
14 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
15 | ||
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) | |
19 | ||
20 | ||
21 | #include "test_disjoint.hpp" | |
22 | ||
23 | #include <boost/geometry/geometries/geometries.hpp> | |
24 | #include <boost/geometry/geometries/point_xy.hpp> | |
25 | #include <boost/geometry/strategies/strategies.hpp> | |
26 | ||
27 | #include <test_common/test_point.hpp> | |
28 | ||
29 | #include <algorithms/overlay/overlay_cases.hpp> | |
30 | ||
31 | #include <algorithms/predef_relop.hpp> | |
32 | ||
33 | ||
34 | template <typename P> | |
35 | void test_all() | |
36 | { | |
37 | typedef bg::model::box<P> box; | |
38 | ||
39 | test_disjoint<P, P>("pp1", "point(1 1)", "point(1 1)", false); | |
40 | test_disjoint<P, P>("pp2", "point(1 1)", "point(1.001 1)", true); | |
41 | ||
42 | // left-right | |
43 | test_disjoint<box, box>("bb1", "box(1 1, 2 2)", "box(3 1, 4 2)", true); | |
44 | test_disjoint<box, box>("bb2", "box(1 1, 2 2)", "box(2 1, 3 2)", false); | |
45 | test_disjoint<box, box>("bb3", "box(1 1, 2 2)", "box(2 2, 3 3)", false); | |
46 | test_disjoint<box, box>("bb4", "box(1 1, 2 2)", "box(2.001 2, 3 3)", true); | |
47 | ||
48 | // up-down | |
49 | test_disjoint<box, box>("bb5", "box(1 1, 2 2)", "box(1 3, 2 4)", true); | |
50 | test_disjoint<box, box>("bb6", "box(1 1, 2 2)", "box(1 2, 2 3)", false); | |
51 | // right-left | |
52 | test_disjoint<box, box>("bb7", "box(1 1, 2 2)", "box(0 1, 1 2)", false); | |
53 | test_disjoint<box, box>("bb8", "box(1 1, 2 2)", "box(0 1, 1 2)", false); | |
54 | ||
55 | // point-box | |
56 | test_disjoint<P, box>("pb1", "point(1 1)", "box(0 0, 2 2)", false); | |
57 | test_disjoint<P, box>("pb2", "point(2 2)", "box(0 0, 2 2)", false); | |
58 | test_disjoint<P, box>("pb3", "point(2.0001 2)", "box(1 1, 2 2)", true); | |
59 | test_disjoint<P, box>("pb4", "point(0.9999 2)", "box(1 1, 2 2)", true); | |
60 | ||
61 | // box-point (to test reverse compiling) | |
62 | test_disjoint<box, P>("bp1", "box(1 1, 2 2)", "point(2 2)", false); | |
63 | ||
64 | // Test triangles for polygons/rings, boxes | |
65 | // Note that intersections are tested elsewhere, they don't need | |
66 | // thorough test at this place | |
67 | typedef bg::model::polygon<P> polygon; | |
68 | typedef bg::model::ring<P> ring; | |
69 | ||
70 | // Testing overlap (and test compiling with box) | |
71 | test_disjoint<polygon, polygon>("overlaps_box_pp", overlaps_box[0], overlaps_box[1], false); | |
72 | test_disjoint<box, polygon>("overlaps_box_bp", overlaps_box[0], overlaps_box[1], false); | |
73 | test_disjoint<box, ring>("overlaps_box_br", overlaps_box[0], overlaps_box[1], false); | |
74 | test_disjoint<polygon, box>("overlaps_box_pb", overlaps_box[1], overlaps_box[0], false); | |
75 | test_disjoint<ring, box>("overlaps_box_rb", overlaps_box[1], overlaps_box[0], false); | |
76 | ||
77 | test_disjoint<P, ring>("point_ring1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); | |
78 | test_disjoint<P, ring>("point_ring2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); | |
79 | test_disjoint<P, ring>("point_ring3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); | |
80 | test_disjoint<P, polygon>("point_polygon1", "POINT(0 0)", "POLYGON((0 0,3 3,6 0,0 0))", false); | |
81 | test_disjoint<P, polygon>("point_polygon2", "POINT(3 1)", "POLYGON((0 0,3 3,6 0,0 0))", false); | |
82 | test_disjoint<P, polygon>("point_polygon3", "POINT(0 3)", "POLYGON((0 0,3 3,6 0,0 0))", true); | |
83 | ||
84 | test_disjoint<ring, P>("point_ring2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); | |
85 | test_disjoint<polygon, P>("point_polygon2", "POLYGON((0 0,3 3,6 0,0 0))", "POINT(0 0)", false); | |
86 | ||
87 | ||
88 | // Problem described by Volker/Albert 2012-06-01 | |
89 | test_disjoint<polygon, box>("volker_albert_1", | |
90 | "POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))", | |
91 | "BOX(1941 2066, 2055 2166)", false); | |
92 | ||
93 | test_disjoint<polygon, box>("volker_albert_2", | |
94 | "POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))", | |
95 | "BOX(1941 2066, 2055 2166)", false); | |
96 | } | |
97 | ||
98 | ||
99 | template <typename P> | |
100 | void test_3d() | |
101 | { | |
102 | typedef bg::model::box<P> box; | |
103 | ||
104 | test_disjoint<P, P>("pp 3d 1", "point(1 1 1)", "point(1 1 1)", false); | |
105 | test_disjoint<P, P>("pp 3d 2", "point(1 1 1)", "point(1.001 1 1)", true); | |
106 | ||
107 | test_disjoint<box, box>("bb1", "box(1 1 1, 2 2 2)", "box(3 1 1, 4 2 1)", true); | |
108 | test_disjoint<box, box>("bb2", "box(1 1 1, 2 2 2)", "box(2 1 1, 3 2 1)", false); | |
109 | test_disjoint<box, box>("bb3", "box(1 1 1, 2 2 2)", "box(2 2 1, 3 3 1)", false); | |
110 | test_disjoint<box, box>("bb4", "box(1 1 1, 2 2 2)", "box(2.001 2 1, 3 3 1)", true); | |
111 | ||
112 | } | |
113 | ||
114 | ||
115 | int test_main(int, char* []) | |
116 | { | |
117 | test_all<bg::model::d2::point_xy<float> >(); | |
118 | ||
119 | test_all<bg::model::d2::point_xy<double> >(); | |
120 | ||
7c673cae FG |
121 | test_3d<bg::model::point<double, 3, bg::cs::cartesian> >(); |
122 | ||
123 | return 0; | |
124 | } |