]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | // Boost.Geometry |
2 | // Unit Test Helper | |
3 | ||
4 | // Copyright (c) 2018-2019 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | ||
1e59de90 TL |
6 | // This file was modified by Oracle on 2020-2022. |
7 | // Modifications copyright (c) 2020-2022 Oracle and/or its affiliates. | |
8 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
9 | ||
92f5a8d4 TL |
10 | // Use, modification and distribution is subject to the Boost Software License, |
11 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
12 | // http://www.boost.org/LICENSE_1_0.txt) | |
13 | ||
14 | ||
15 | #ifndef BOOST_GEOMETRY_TEST_BUFFER_GEO_HPP | |
16 | #define BOOST_GEOMETRY_TEST_BUFFER_GEO_HPP | |
17 | ||
18 | #include "test_buffer.hpp" | |
19 | ||
20 | template | |
21 | < | |
22 | typename Geometry, | |
23 | typename GeometryOut, | |
24 | typename JoinStrategy, | |
25 | typename EndStrategy | |
26 | > | |
27 | void test_one_geo(std::string const& caseid, | |
28 | std::string const& wkt, | |
29 | JoinStrategy const& join_strategy, EndStrategy const& end_strategy, | |
30 | int expected_count, int expected_holes_count, double expected_area, | |
31 | double distance_left, ut_settings settings = ut_settings(), | |
32 | double distance_right = same_distance) | |
33 | { | |
34 | Geometry input_geometry; | |
35 | bg::read_wkt(wkt, input_geometry); | |
36 | bg::correct(input_geometry); | |
37 | ||
38 | bg::strategy::buffer::side_straight side_strategy; | |
39 | bg::strategy::buffer::distance_asymmetric | |
40 | < | |
41 | typename bg::coordinate_type<Geometry>::type | |
42 | > distance_strategy(distance_left, | |
43 | bg::math::equals(distance_right, same_distance) | |
44 | ? distance_left : distance_right); | |
45 | ||
46 | // Use the appropriate strategy for geographic points | |
47 | bg::strategy::buffer::geographic_point_circle<> circle_strategy(settings.points_per_circle); | |
48 | ||
49 | // Use Thomas strategy to calculate geographic area, because it is | |
50 | // the most precise (unless scale of buffer is only around 1 meter) | |
1e59de90 TL |
51 | // TODO: If area is for calculation of the orientation of points in a ring |
52 | // and accuracy is an issue, then instead calculate_point_order should | |
53 | // probably be used instead of area. | |
54 | bg::strategies::buffer::geographic | |
55 | < | |
56 | bg::strategy::thomas, bg::srs::spheroid<long double>, long double | |
57 | > strategy; | |
92f5a8d4 TL |
58 | |
59 | bg::model::multi_polygon<GeometryOut> buffer; | |
60 | ||
61 | test_buffer<GeometryOut> | |
62 | (caseid, buffer, input_geometry, | |
63 | join_strategy, end_strategy, | |
64 | distance_strategy, side_strategy, circle_strategy, | |
1e59de90 | 65 | strategy, |
92f5a8d4 TL |
66 | expected_count, expected_holes_count, expected_area, |
67 | settings); | |
68 | } | |
69 | ||
70 | template | |
71 | < | |
72 | typename Geometry, | |
73 | typename GeometryOut, | |
74 | typename JoinStrategy, | |
75 | typename EndStrategy | |
76 | > | |
77 | void test_one_geo(std::string const& caseid, std::string const& wkt, | |
78 | JoinStrategy const& join_strategy, EndStrategy const& end_strategy, | |
79 | double expected_area, | |
80 | double distance_left, ut_settings const& settings = ut_settings(), | |
81 | double distance_right = same_distance) | |
82 | { | |
83 | test_one_geo<Geometry, GeometryOut>(caseid, wkt, join_strategy, end_strategy, | |
84 | -1 ,-1, expected_area, | |
85 | distance_left, settings, distance_right); | |
86 | } | |
87 | ||
88 | ||
89 | #endif |