From e15cbf41a4bdf1034bd3f8d98fd00ec95b1d60ee Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 29 May 2014 14:53:51 +0300 Subject: [PATCH 1/3] [strategies] make default_strategy class commutative with respect to the order of the geometry tags --- .../cartesian/distance_projected_point.hpp | 14 ++++++++++++++ .../cartesian/distance_pythagoras_point_box.hpp | 12 ++++++++++++ .../spherical/distance_cross_track.hpp | 16 ++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp b/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp index 25179ba21..5bcad4fee 100644 --- a/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_projected_point.hpp @@ -251,6 +251,20 @@ struct default_strategy > type; }; +template +struct default_strategy + < + segment_tag, point_tag, PointOfSegment, Point, + cartesian_tag, cartesian_tag, Strategy + > +{ + typedef typename default_strategy + < + point_tag, segment_tag, Point, PointOfSegment, + cartesian_tag, cartesian_tag, Strategy + >::type type; +}; + } // namespace services #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp index 6b05ff014..af55415f8 100644 --- a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp @@ -322,6 +322,18 @@ struct default_strategy typedef pythagoras_point_box<> type; }; +template +struct default_strategy + < + box_tag, point_tag, Box, Point, cartesian_tag, cartesian_tag + > +{ + typedef typename default_strategy + < + point_tag, box_tag, Point, Box, cartesian_tag, cartesian_tag + >::type type; +}; + } // namespace services #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS diff --git a/include/boost/geometry/strategies/spherical/distance_cross_track.hpp b/include/boost/geometry/strategies/spherical/distance_cross_track.hpp index 87fac4811..6ffa4ff7c 100644 --- a/include/boost/geometry/strategies/spherical/distance_cross_track.hpp +++ b/include/boost/geometry/strategies/spherical/distance_cross_track.hpp @@ -306,6 +306,22 @@ struct default_strategy }; +template +struct default_strategy + < + segment_tag, point_tag, PointOfSegment, Point, + spherical_equatorial_tag, spherical_equatorial_tag, + Strategy + > +{ + typedef typename default_strategy + < + point_tag, segment_tag, Point, PointOfSegment, + spherical_equatorial_tag, spherical_equatorial_tag, + Strategy + >::type type; +}; + } // namespace services #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS From 916e9bb4953310ae6d61d3242084d4c05722a9e8 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 29 May 2014 14:54:25 +0300 Subject: [PATCH 2/3] [test][strategies] add compile time check for the default strategy where the geometry tags are reversed --- test/strategies/cross_track.cpp | 5 +++++ test/strategies/projected_point.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/test/strategies/cross_track.cpp b/test/strategies/cross_track.cpp index fe665ea1b..2fe639e30 100644 --- a/test/strategies/cross_track.cpp +++ b/test/strategies/cross_track.cpp @@ -68,6 +68,11 @@ void test_distance( < bg::point_tag, bg::segment_tag, Point, Point >::type cross_track_strategy_type; + + typedef typename bg::strategy::distance::services::default_strategy + < + bg::segment_tag, bg::point_tag, Point, Point + >::type reversed_tags_cross_track_strategy_type; } diff --git a/test/strategies/projected_point.cpp b/test/strategies/projected_point.cpp index 62c611495..64e30f934 100644 --- a/test/strategies/projected_point.cpp +++ b/test/strategies/projected_point.cpp @@ -62,6 +62,11 @@ void test_services() < bg::point_tag, bg::segment_tag, P, PS >::type projected_point_strategy_type; + + typedef typename services::default_strategy + < + bg::segment_tag, bg::point_tag, PS, P + >::type reversed_tags_projected_point_strategy_type; } // 1: normal, calculate distance: From 779e05c29238d66ac2ec965adf1f4591f777776f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Fri, 30 May 2014 15:09:20 +0300 Subject: [PATCH 3/3] [strategies][distance] fix names of template parameters to better reflect the corresponding objects --- .../strategies/cartesian/distance_pythagoras_point_box.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp index 29beb3dc6..95cd48027 100644 --- a/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp +++ b/include/boost/geometry/strategies/cartesian/distance_pythagoras_point_box.hpp @@ -322,15 +322,15 @@ struct default_strategy typedef pythagoras_point_box<> type; }; -template +template struct default_strategy < - box_tag, point_tag, Box, Point, cartesian_tag, cartesian_tag + box_tag, point_tag, BoxPoint, Point, cartesian_tag, cartesian_tag > { typedef typename default_strategy < - point_tag, box_tag, Point, Box, cartesian_tag, cartesian_tag + point_tag, box_tag, Point, BoxPoint, cartesian_tag, cartesian_tag >::type type; };