distance_se_geo_pl_pl.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Unit Test
  3. // Copyright (c) 2017, 2018, Oracle and/or its affiliates.
  4. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  5. // Licensed under the Boost Software License version 1.0.
  6. // http://www.boost.org/users/license.html
  7. #ifndef BOOST_TEST_MODULE
  8. #define BOOST_TEST_MODULE test_distance_geographic_pointlike_pointlike
  9. #endif
  10. #include <boost/test/included/unit_test.hpp>
  11. #include "test_distance_geo_common.hpp"
  12. #include "test_empty_geometry.hpp"
  13. //===========================================================================
  14. template <typename Point, typename Strategy>
  15. void test_distance_point_point(Strategy const& strategy)
  16. {
  17. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  18. std::cout << std::endl;
  19. std::cout << "point/point distance tests" << std::endl;
  20. #endif
  21. typedef test_distance_of_geometries<Point, Point> tester;
  22. tester::apply("p-p-01",
  23. "POINT(1 1)",
  24. "POINT(0 0)",
  25. strategy.apply(Point(1,1), Point(0,0)),
  26. strategy, true, false, false);
  27. }
  28. //===========================================================================
  29. template <typename Point, typename Strategy>
  30. void test_distance_multipoint_point(Strategy const& strategy)
  31. {
  32. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  33. std::cout << std::endl;
  34. std::cout << "multipoint/point distance tests" << std::endl;
  35. #endif
  36. typedef bg::model::multi_point<Point> multi_point_type;
  37. typedef test_distance_of_geometries<multi_point_type, Point> tester;
  38. tester::apply("mp-p-01",
  39. "MULTIPOINT(1 1,1 2,2 3)",
  40. "POINT(0 0)",
  41. pp_distance<Point>("POINT(0 0)","POINT(1 1)",strategy),
  42. strategy, true, false, false);
  43. tester::apply("mp-p-01",
  44. "MULTIPOINT(0 0,0 2,2 0,2 2)",
  45. "POINT(1.1 1.1)",
  46. pp_distance<Point>("POINT(1.1 1.1)","POINT(2 2)",strategy),
  47. strategy, true, false, false);
  48. }
  49. //===========================================================================
  50. template <typename Point, typename Strategy>
  51. void test_distance_multipoint_multipoint(Strategy const& strategy)
  52. {
  53. #ifdef BOOST_GEOMETRY_TEST_DEBUG
  54. std::cout << std::endl;
  55. std::cout << "multipoint/multipoint distance tests" << std::endl;
  56. #endif
  57. typedef bg::model::multi_point<Point> multi_point_type;
  58. typedef test_distance_of_geometries<multi_point_type, multi_point_type> tester;
  59. tester::apply("mp-mp-01",
  60. "MULTIPOINT(1 1,1 2,2 3)",
  61. "MULTIPOINT(0 0, 0 -1)",
  62. pp_distance<Point>("POINT(0 0)","POINT(1 1)",strategy),
  63. strategy, true, false, false);
  64. }
  65. //===========================================================================
  66. //===========================================================================
  67. //===========================================================================
  68. template <typename Point, typename Strategy>
  69. void test_all_pl_pl(Strategy pp_strategy)
  70. {
  71. test_distance_point_point<Point>(pp_strategy);
  72. test_distance_multipoint_point<Point>(pp_strategy);
  73. test_distance_multipoint_multipoint<Point>(pp_strategy);
  74. test_more_empty_input_pointlike_pointlike<Point>(pp_strategy);
  75. }
  76. BOOST_AUTO_TEST_CASE( test_all_pointlike_pointlike )
  77. {
  78. typedef bg::model::point
  79. <
  80. double, 2,
  81. bg::cs::spherical_equatorial<bg::degree>
  82. > sph_point;
  83. test_all_pl_pl<sph_point>(spherical_pp());
  84. typedef bg::model::point
  85. <
  86. double, 2,
  87. bg::cs::geographic<bg::degree>
  88. > geo_point;
  89. test_all_pl_pl<geo_point>(vincenty_pp());
  90. test_all_pl_pl<geo_point>(thomas_pp());
  91. test_all_pl_pl<geo_point>(andoyer_pp());
  92. test_all_pl_pl<geo_point>(andoyer_pp(stype(5000000,6000000)));
  93. }