]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | // Unit Test | |
3 | ||
4 | // Copyright (c) 2010-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 | #include <iostream> | |
11 | #include <string> | |
12 | ||
13 | // If defined, tests are run without rescaling-to-integer or robustness policy | |
14 | // This multi_difference currently contains no tests for double which then fail | |
15 | // #define BOOST_GEOMETRY_NO_ROBUSTNESS | |
16 | ||
17 | //#define HAVE_TTMATH | |
18 | //#define BOOST_GEOMETRY_DEBUG_ASSEMBLE | |
19 | //#define BOOST_GEOMETRY_CHECK_WITH_SQLSERVER | |
20 | ||
21 | //#define BOOST_GEOMETRY_DEBUG_SEGMENT_IDENTIFIER | |
22 | //#define BOOST_GEOMETRY_DEBUG_FOLLOW | |
23 | //#define BOOST_GEOMETRY_DEBUG_TRAVERSE | |
24 | ||
25 | ||
26 | #include "test_difference.hpp" | |
27 | #include <algorithms/test_overlay.hpp> | |
28 | #include <algorithms/overlay/multi_overlay_cases.hpp> | |
29 | ||
30 | #include <boost/geometry/geometries/point_xy.hpp> | |
31 | #include <boost/geometry/geometries/multi_linestring.hpp> | |
32 | #include <boost/geometry/geometries/multi_polygon.hpp> | |
33 | ||
34 | #include <boost/geometry/io/wkt/read.hpp> | |
35 | ||
36 | ||
37 | template <typename MultiPolygon, typename MultiLineString> | |
38 | void test_areal_linear() | |
39 | { | |
40 | typedef typename boost::range_value<MultiPolygon>::type polygon; | |
41 | typedef typename boost::range_value<MultiLineString>::type linestring; | |
42 | typedef typename bg::point_type<polygon>::type point; | |
43 | typedef bg::model::ring<point> ring; | |
44 | ||
45 | test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_1", "LINESTRING(2 0,2 5)", case_multi_simplex[0], 2, 4, 1.30); | |
46 | test_one_lp<linestring, MultiLineString, polygon>("case_p_mls_1", "MULTILINESTRING((2 0,2 5),(3 0,3 5))", case_single_simplex, 3, 6, 2.5); | |
47 | test_one_lp<linestring, MultiLineString, MultiPolygon>("case_mp_mls_1", "MULTILINESTRING((2 0,2 5),(3 0,3 5))", case_multi_simplex[0], 5, 10, 3.1666667); | |
48 | test_one_lp<linestring, MultiLineString, ring>("case_r_mls_1", "MULTILINESTRING((2 0,2 5),(3 0,3 5))", case_single_simplex, 3, 6, 2.5); | |
49 | ||
50 | // Collinear cases, with multiple turn points at the same location | |
51 | test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_2a", "LINESTRING(1 0,1 1,2 1,2 0)", "MULTIPOLYGON(((0 0,0 1,1 1,1 0,0 0)),((1 1,1 2,2 2,2 1,1 1)))", 1, 2, 1.0); | |
52 | test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_2b", "LINESTRING(1 0,1 1,2 1,2 0)", "MULTIPOLYGON(((1 1,1 2,2 2,2 1,1 1)),((0 0,0 1,1 1,1 0,0 0)))", 1, 2, 1.0); | |
53 | ||
54 | test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_3", | |
55 | "LINESTRING(6 6,6 7,7 7,7 6,8 6,8 7,9 7,9 6)", | |
56 | "MULTIPOLYGON(((5 7,5 8,6 8,6 7,5 7)),((6 6,6 7,7 7,7 6,6 6)),((8 8,9 8,9 7,8 7,7 7,7 8,8 8)))", 2, 5, 3.0); | |
57 | ||
58 | return; | |
59 | ||
60 | // TODO: this case contains collinearities and should still be solved | |
61 | test_one_lp<linestring, linestring, MultiPolygon>("case_mp_ls_4", | |
62 | "LINESTRING(0 5,0 6,1 6,1 5,2 5,2 6,3 6,3 5,3 4,3 3,2 3,2 4,1 4,1 3,0 3,0 4)", | |
63 | "MULTIPOLYGON(((0 2,0 3,1 2,0 2)),((2 5,3 6,3 5,2 5)),((1 5,1 6,2 6,2 5,1 5)),((2 3,2 4,3 4,2 3)),((0 3,1 4,1 3,0 3)),((4 3,3 3,3 5,4 5,4 4,4 3)))", 5, 11, 6.0); | |
64 | } | |
65 | ||
66 | ||
67 | template <typename P> | |
68 | void test_all() | |
69 | { | |
70 | typedef bg::model::polygon<P> polygon; | |
71 | typedef bg::model::linestring<P> linestring; | |
72 | typedef bg::model::multi_polygon<polygon> multi_polygon; | |
73 | typedef bg::model::multi_linestring<linestring> multi_linestring; | |
74 | test_areal_linear<multi_polygon, multi_linestring>(); | |
75 | } | |
76 | ||
77 | ||
78 | int test_main(int, char* []) | |
79 | { | |
80 | test_all<bg::model::d2::point_xy<double> >(); | |
81 | ||
82 | #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) | |
83 | test_all<bg::model::d2::point_xy<float> >(); | |
84 | #endif | |
85 | ||
86 | return 0; | |
87 | } |