]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/geometry/test/algorithms/buffer/buffer_countries.cpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2014-2019 Barend Gehrels, Amsterdam, the Netherlands.
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)
10 #include "test_buffer.hpp"
13 template <typename MultiPolygon
>
14 std::string
read_from_file(std::string
const& filename
)
17 std::ifstream
in(filename
.c_str());
21 std::getline(in
, line
);
24 typename
boost::range_value
<MultiPolygon
>::type pol
;
25 bg::read_wkt(line
, pol
);
29 std::ostringstream out
;
32 out
<< std::fixed
<< std::setprecision(19) << bg::wkt(mp
);
35 BOOST_CHECK(! out
.str().empty());
48 select ST_GeomFromText((insert WKT here from data),0) as p1
50 select 10 as w,ST_NumGeometries(p1),ST_Area(ST_Buffer(p1, 10.0 * 1000, 25)),ST_NumGeometries(ST_Buffer(p1, 10.0 * 1000, 25))from viewy
51 union all select 20 as w,ST_NumGeometries(p1),ST_Area(ST_Buffer(p1, 20.0 * 1000, 25)),ST_NumGeometries(ST_Buffer(p1, 20.0 * 1000, 25))from viewy
52 union all select 50 as w,ST_NumGeometries(p1),ST_Area(ST_Buffer(p1, 50.0 * 1000, 25)),ST_NumGeometries(ST_Buffer(p1, 50.0 * 1000, 25))from viewy
53 union all select 100 as w,ST_NumGeometries(p1),ST_Area(ST_Buffer(p1, 100.0 * 1000, 25)),ST_NumGeometries(ST_Buffer(p1, 100.0 * 1000, 25))from viewy
54 union all select -10 as w,ST_NumGeometries(p1),ST_Area(ST_Buffer(p1, -10.0 * 1000, 25)),ST_NumGeometries(ST_Buffer(p1, -10.0 * 1000, 25))from viewy
55 union all select -20 as w,ST_NumGeometries(p1),ST_Area(ST_Buffer(p1, -20.0 * 1000, 25)),ST_NumGeometries(ST_Buffer(p1, -20.0 * 1000, 25))from viewy
56 union all select -50 as w,ST_NumGeometries(p1),ST_Area(ST_Buffer(p1, -50.0 * 1000, 25)),ST_NumGeometries(ST_Buffer(p1, -50.0 * 1000, 25))from viewy
57 union all select -100 as w,ST_NumGeometries(p1),ST_Area(ST_Buffer(p1, -100.0 * 1000, 25)),ST_NumGeometries(ST_Buffer(p1, -100.0 * 1000, 25))from viewy
59 Checked are 10,20,50,100 kilometer, inflate/deflate
61 But for many, in the unit tests below, distance of 1,2,5 k are kept too
62 because they could cause self-intersections in the past
64 Values are not identical. We might check area with less precision.
123 template <typename MP
, typename P
>
124 void test_one(std::string
const& caseid
, std::string
const& wkt
, double expected_area
, double distance
,
125 ut_settings settings
= ut_settings())
127 bg::strategy::buffer::join_round
join_round(100);
128 bg::strategy::buffer::end_flat end_flat
;
130 // Test with a high tolerance, even a difference of 1000 is only ~1.0e-6%
132 settings
.tolerance
= 10000.0;
134 #if ! defined(BOOST_GEOMETRY_USE_RESCALING)
135 // in case robustness policies are changed, areas should be adapted
136 settings
.tolerance
= boost::starts_with(caseid
, "no") ? 200000.0 : 100000.0;
139 test_one
<MP
, P
>(caseid
, wkt
, join_round
, end_flat
,
140 expected_area
, distance
* 1000.0, settings
);
144 template <bool Clockwise
, typename P
>
147 typedef bg::model::polygon
<P
, Clockwise
> pt
;
148 typedef bg::model::multi_polygon
<pt
> mpt
;
150 std::string base_folder
= "data/";
151 std::string gr
= read_from_file
<mpt
>(base_folder
+ "gr.wkt");
152 std::string it
= read_from_file
<mpt
>(base_folder
+ "it.wkt");
153 std::string nl
= read_from_file
<mpt
>(base_folder
+ "nl.wkt");
154 std::string no
= read_from_file
<mpt
>(base_folder
+ "no.wkt");
155 std::string uk
= read_from_file
<mpt
>(base_folder
+ "uk.wkt");
157 test_one
<mpt
, pt
>("gr10", gr
, 336279815682, 10);
158 test_one
<mpt
, pt
>("gr20", gr
, 442317491749, 20);
159 test_one
<mpt
, pt
>("gr50", gr
, 680442278645, 50);
160 test_one
<mpt
, pt
>("gr100", gr
, 910474621215, 100);
162 test_one
<mpt
, pt
>("gr10", gr
, 139313156846, -10);
163 test_one
<mpt
, pt
>("gr20", gr
, 96991350242, -20);
164 test_one
<mpt
, pt
>("gr50", gr
, 31391928002, -50);
165 test_one
<mpt
, pt
>("gr100", gr
, 2035400805, -100);
167 test_one
<mpt
, pt
>("it1", it
, 569862998347, 1);
168 test_one
<mpt
, pt
>("it2", it
, 579239208963, 2);
169 test_one
<mpt
, pt
>("it5", it
, 607625463736, 5);
170 test_one
<mpt
, pt
>("it10", it
, 655018578530, 10);
171 test_one
<mpt
, pt
>("it20", it
, 749353305743, 20);
172 test_one
<mpt
, pt
>("it50", it
, 1018323115670, 50);
173 test_one
<mpt
, pt
>("it100", it
, 1436451405439, 100);
175 test_one
<mpt
, pt
>("it1", it
, 551474421881, -1);
176 test_one
<mpt
, pt
>("it2", it
, 542617730624, -2);
177 test_one
<mpt
, pt
>("it5", it
, 517402445790, -5);
178 test_one
<mpt
, pt
>("it10", it
, 477945510429, -10);
179 test_one
<mpt
, pt
>("it20", it
, 404693983797, -20);
180 test_one
<mpt
, pt
>("it50", it
, 238748449624, -50);
181 test_one
<mpt
, pt
>("it100", it
, 69768648896, -100);
182 test_one
<mpt
, pt
>("it200", it
, 0, -200);
184 test_one
<mpt
, pt
>("nl1", nl
, 97391170774, 1);
185 test_one
<mpt
, pt
>("nl2", nl
, 100816707832, 2);
186 test_one
<mpt
, pt
>("nl5", nl
, 110239801028, 5);
187 test_one
<mpt
, pt
>("nl10", nl
, 123408274536, 10);
188 test_one
<mpt
, pt
>("nl20", nl
, 145046915403, 20);
189 test_one
<mpt
, pt
>("nl50", nl
, 201207309002, 50);
190 test_one
<mpt
, pt
>("nl100", nl
, 303300936340, 100);
192 test_one
<mpt
, pt
>("nl1", nl
, 90095050333, -1);
193 test_one
<mpt
, pt
>("nl2", nl
, 86601861798, -2);
194 test_one
<mpt
, pt
>("nl5", nl
, 77307843754, -5);
195 test_one
<mpt
, pt
>("nl10", nl
, 64668870425, -10);
196 test_one
<mpt
, pt
>("nl20", nl
, 46683531062, -20);
197 test_one
<mpt
, pt
>("nl50", nl
, 10244523910, -50);
198 test_one
<mpt
, pt
>("nl100", nl
, 0, -100);
200 test_one
<mpt
, pt
>("no1", no
, 1819566570720, 1);
201 test_one
<mpt
, pt
>("no2", no
, 1865041238129, 2, ut_settings::ignore_validity());
202 test_one
<mpt
, pt
>("no5", no
, 1973615533600, 5);
203 test_one
<mpt
, pt
>("no10", no
, 2102034240506, 10);
204 test_one
<mpt
, pt
>("no20", no
, 2292171257647, 20);
205 test_one
<mpt
, pt
>("no50", no
, 2725475403816, 50);
206 test_one
<mpt
, pt
>("no100", no
, 3374987120112, 100);
208 test_one
<mpt
, pt
>("no1", no
, 1725145487969, -1);
209 test_one
<mpt
, pt
>("no2", no
, 1678942603503, -2);
210 test_one
<mpt
, pt
>("no5", no
, 1547329249723, -5);
211 test_one
<mpt
, pt
>("no10", no
, 1361198873951, -10);
212 test_one
<mpt
, pt
>("no20", no
, 1089847815351, -20);
213 test_one
<mpt
, pt
>("no50", no
, 649622162382, -50);
214 test_one
<mpt
, pt
>("no100", no
, 306739133606, -100);
216 test_one
<mpt
, pt
>("uk1", uk
, 733080790315, 1);
217 test_one
<mpt
, pt
>("uk2", uk
, 749555939251, 2);
218 test_one
<mpt
, pt
>("uk5", uk
, 793752660191, 5);
219 test_one
<mpt
, pt
>("uk10", uk
, 857682286960, 10);
220 test_one
<mpt
, pt
>("uk20", uk
, 970488082763, 20);
221 test_one
<mpt
, pt
>("uk50", uk
, 1247830325401, 50);
222 test_one
<mpt
, pt
>("uk100", uk
, 1659861958875, 100);
224 test_one
<mpt
, pt
>("uk1", uk
, 699378146599, -1);
225 test_one
<mpt
, pt
>("uk2", uk
, 683086442146, -2);
226 test_one
<mpt
, pt
>("uk5", uk
, 637325279340, -5);
227 test_one
<mpt
, pt
>("uk10", uk
, 572556625332, -10);
228 test_one
<mpt
, pt
>("uk20", uk
, 479258129205, -20);
229 test_one
<mpt
, pt
>("uk50", uk
, 274828071591, -50);
230 test_one
<mpt
, pt
>("uk100", uk
, 78205461294, -100);
233 int test_main(int, char* [])
235 BoostGeometryWriteTestConfiguration();
237 test_all
<true, bg::model::point
<default_test_type
, 2, bg::cs::cartesian
> >();
239 #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_ORDER)
240 test_all
<false, bg::model::point
<default_test_type
, 2, bg::cs::cartesian
> >();
243 #if defined(BOOST_GEOMETRY_TEST_FAILURES)
244 BoostGeometryWriteExpectedFailures(1, BG_NO_FAILURES
, 2, BG_NO_FAILURES
);