test_buffer_geo.hpp 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. // Boost.Geometry
  2. // Unit Test Helper
  3. // Copyright (c) 2018-2019 Barend Gehrels, Amsterdam, the Netherlands.
  4. // Use, modification and distribution is subject to the Boost Software License,
  5. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_GEOMETRY_TEST_BUFFER_GEO_HPP
  8. #define BOOST_GEOMETRY_TEST_BUFFER_GEO_HPP
  9. #include "test_buffer.hpp"
  10. template
  11. <
  12. typename Geometry,
  13. typename GeometryOut,
  14. typename JoinStrategy,
  15. typename EndStrategy
  16. >
  17. void test_one_geo(std::string const& caseid,
  18. std::string const& wkt,
  19. JoinStrategy const& join_strategy, EndStrategy const& end_strategy,
  20. int expected_count, int expected_holes_count, double expected_area,
  21. double distance_left, ut_settings settings = ut_settings(),
  22. double distance_right = same_distance)
  23. {
  24. Geometry input_geometry;
  25. bg::read_wkt(wkt, input_geometry);
  26. bg::correct(input_geometry);
  27. bg::strategy::buffer::side_straight side_strategy;
  28. bg::strategy::buffer::distance_asymmetric
  29. <
  30. typename bg::coordinate_type<Geometry>::type
  31. > distance_strategy(distance_left,
  32. bg::math::equals(distance_right, same_distance)
  33. ? distance_left : distance_right);
  34. // Use the appropriate strategy for geographic points
  35. bg::strategy::buffer::geographic_point_circle<> circle_strategy(settings.points_per_circle);
  36. // Use Thomas strategy to calculate geographic area, because it is
  37. // the most precise (unless scale of buffer is only around 1 meter)
  38. bg::strategy::area::geographic
  39. <
  40. bg::strategy::thomas, 5,
  41. bg::srs::spheroid<long double>, long double
  42. > area_strategy;
  43. bg::model::multi_polygon<GeometryOut> buffer;
  44. test_buffer<GeometryOut>
  45. (caseid, buffer, input_geometry,
  46. join_strategy, end_strategy,
  47. distance_strategy, side_strategy, circle_strategy,
  48. area_strategy,
  49. expected_count, expected_holes_count, expected_area,
  50. settings);
  51. }
  52. template
  53. <
  54. typename Geometry,
  55. typename GeometryOut,
  56. typename JoinStrategy,
  57. typename EndStrategy
  58. >
  59. void test_one_geo(std::string const& caseid, std::string const& wkt,
  60. JoinStrategy const& join_strategy, EndStrategy const& end_strategy,
  61. double expected_area,
  62. double distance_left, ut_settings const& settings = ut_settings(),
  63. double distance_right = same_distance)
  64. {
  65. test_one_geo<Geometry, GeometryOut>(caseid, wkt, join_strategy, end_strategy,
  66. -1 ,-1, expected_area,
  67. distance_left, settings, distance_right);
  68. }
  69. #endif