]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // Unit Test | |
3 | ||
4 | // Copyright (c) 2013-2015 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | ||
6 | // Use, modification and distribution is subject to the Boost Software License, | |
7 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
8 | // http://www.boost.org/LICENSE_1_0.txt) | |
9 | ||
10 | ||
11 | #include <boost/geometry.hpp> | |
12 | #include <boost/geometry/geometries/geometries.hpp> | |
13 | #include <boost/geometry/geometries/point_xy.hpp> | |
14 | ||
15 | #include "test_difference.hpp" | |
16 | ||
17 | ||
18 | template <typename P, bool ClockWise, bool Closed> | |
19 | void test_spikes_in_ticket_8364() | |
20 | { | |
21 | ut_settings ignore_validity; | |
22 | ignore_validity.test_validity = false; | |
23 | ||
24 | // See: https://svn.boost.org/trac/boost/ticket/8364 | |
25 | //_TPolygon<T> polygon( "MULTIPOLYGON(((1031 1056,3232 1056,3232 2856,1031 2856)))" ); | |
26 | //polygon -= _TPolygon<T>( "MULTIPOLYGON(((1032 1458,1032 1212,2136 2328,3234 2220,3234 2412,2136 2646)))" ); | |
27 | //polygon -= _TPolygon<T>( "MULTIPOLYGON(((1032 1764,1032 1458,2136 2646,3234 2412,3234 2532,2136 2790)))" ); | |
28 | // RESULTS OF ABOVE IS USED IN STEP 3 BELOW | |
29 | //polygon -= _TPolygon<T>( "MULTIPOLYGON(((1032 2130,1032 1764,2052 2712)),((3234 2580,2558 2690,3234 2532)),((2558 2690,2136 2790,2052 2712,2136 2760)))" ); USED IN STEP 3 | |
30 | //polygon -= _TPolygon<T>( "MULTIPOLYGON(((1032 2556,1032 2130,1778 2556)),((3234 2580,2136 2760,1778 2556,3234 2556)))" ); USED IN STEP 4 | |
31 | // NOTE: polygons below are closed and clockwise | |
32 | ||
33 | typedef typename bg::coordinate_type<P>::type ct; | |
34 | typedef bg::model::polygon<P, ClockWise, Closed> polygon; | |
35 | typedef bg::model::multi_polygon<polygon> multi_polygon; | |
36 | ||
37 | // The difference of polygons below result in a spike. The spike should be there, it is also generated in ttmath, | |
38 | // and (e.g.) in SQL Server. However, using int-coordinates, the spike makes the polygon invalid. Therefore it is now (since August 2013) checked and removed. | |
39 | ||
b32b8144 FG |
40 | #ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS |
41 | // TODO: commented working at ii/validity, this changes the area slightly, to be checked | |
7c673cae FG |
42 | // So using int's, the spike is removed automatically. Therefore there is one polygon less, and less points. Also area differs |
43 | test_one<polygon, multi_polygon, multi_polygon>("ticket_8364_step3", | |
44 | "MULTIPOLYGON(((3232 2532,2136 2790,1032 1764,1032 1458,1032 1212,2136 2328,3232 2220,3232 1056,1031 1056,1031 2856,3232 2856,3232 2532)))", | |
45 | "MULTIPOLYGON(((1032 2130,2052 2712,1032 1764,1032 2130)),((3234 2580,3234 2532,2558 2690,3234 2580)),((2558 2690,2136 2760,2052 2712,2136 2790,2558 2690)))", | |
46 | 2, | |
47 | if_typed<ct, int>(19, 22), | |
48 | if_typed<ct, int>(2775595.5, 2775256.487954), // SQL Server: 2775256.47588724 | |
49 | 3, | |
50 | -1, // don't check point-count | |
51 | if_typed<ct, int>(7893.0, 7810.487954), // SQL Server: 7810.48711165739 | |
52 | if_typed<ct, int>(1, 5), | |
53 | -1, | |
54 | if_typed<ct, int>(2783349.5, 2775256.487954 + 7810.487954), | |
55 | ignore_validity); | |
b32b8144 | 56 | #endif |
7c673cae FG |
57 | |
58 | test_one<polygon, multi_polygon, multi_polygon>("ticket_8364_step4", | |
59 | "MULTIPOLYGON(((2567 2688,2136 2790,2052 2712,1032 2130,1032 1764,1032 1458,1032 1212,2136 2328,3232 2220,3232 1056,1031 1056,1031 2856,3232 2856,3232 2580,2567 2688)))", | |
60 | "MULTIPOLYGON(((1032 2556,1778 2556,1032 2130,1032 2556)),((3234 2580,3234 2556,1778 2556,2136 2760,3234 2580)))", | |
61 | 1, | |
b32b8144 | 62 | if_typed<ct, int>(20, 20), |
7c673cae FG |
63 | if_typed<ct, int>(2615783.5, 2616029.559567), // SQL Server: 2616029.55616044 |
64 | 1, | |
65 | if_typed<ct, int>(9, 11), | |
66 | if_typed<ct, int>(161133.5, 161054.559567), // SQL Server: 161054.560110092 | |
67 | if_typed<ct, int>(1, 2), | |
b32b8144 | 68 | if_typed<ct, int>(28, 31), |
7c673cae FG |
69 | if_typed<ct, int>(2776875.5, 2616029.559567 + 161054.559567), |
70 | ignore_validity); | |
71 | } | |
72 | ||
73 | template <typename P, bool ClockWise, bool Closed> | |
74 | void test_spikes_in_ticket_8365() | |
75 | { | |
76 | // See: https://svn.boost.org/trac/boost/ticket/8365 | |
77 | // NOTE: polygons below are closed and clockwise | |
78 | ||
79 | typedef typename bg::coordinate_type<P>::type ct; | |
80 | typedef bg::model::polygon<P, ClockWise, Closed> polygon; | |
81 | typedef bg::model::multi_polygon<polygon> multi_polygon; | |
82 | ||
83 | test_one<polygon, multi_polygon, multi_polygon>("ticket_8365_step2", | |
84 | "MULTIPOLYGON(((971 2704,971 1402,4640 1402,3912 1722,3180 2376,3912 1884,4643 1402,5395 1402,5395 3353,971 3353,971 2865,1704 3348)))", | |
85 | "MULTIPOLYGON(((5388 1560,4650 1722,3912 1884,4650 1398)),((2442 3186,1704 3348,966 2700,1704 3024)))", | |
86 | if_typed<ct, int>(2, 2), | |
87 | if_typed<ct, int>(21, 21), | |
88 | if_typed<ct, int>(7975092.5, 7975207.6047877), // SQL Server: | |
89 | 2, | |
90 | -1, | |
91 | if_typed<ct, int>(196.5, 197.1047877), // SQL Server: | |
92 | if_typed<ct, int>(3, 4), | |
93 | -1, | |
94 | if_typed<ct, int>(7975092.5 + 196.5, 7975207.6047877 + 197.1047877)); | |
95 | } | |
96 | ||
97 | ||
98 | ||
99 | ||
100 | ||
101 | int test_main(int, char* []) | |
102 | { | |
103 | test_spikes_in_ticket_8364<bg::model::d2::point_xy<double>, true, true>(); | |
104 | test_spikes_in_ticket_8364<bg::model::d2::point_xy<double>, false, false>(); | |
105 | test_spikes_in_ticket_8365<bg::model::d2::point_xy<double>, true, true>(); | |
106 | test_spikes_in_ticket_8365<bg::model::d2::point_xy<double>, false, false>(); | |
107 | ||
108 | test_spikes_in_ticket_8364<bg::model::d2::point_xy<int>, true, true>(); | |
109 | test_spikes_in_ticket_8364<bg::model::d2::point_xy<int>, false, false>(); | |
110 | test_spikes_in_ticket_8365<bg::model::d2::point_xy<int>, true, true >(); | |
111 | test_spikes_in_ticket_8365<bg::model::d2::point_xy<int>, false, false >(); | |
112 | ||
113 | #ifdef HAVE_TTMATH | |
114 | std::cout << "Testing TTMATH" << std::endl; | |
115 | test_spikes_in_ticket_8364<bg::model::d2::point_xy<ttmath_big>, true, true>(); | |
116 | test_spikes_in_ticket_8365<bg::model::d2::point_xy<ttmath_big>, true, true>(); | |
117 | #endif | |
118 | ||
119 | return 0; | |
120 | } | |
121 |