Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r63634 - in sandbox/geometry: boost/geometry/algorithms boost/geometry/extensions/algorithms boost/geometry/extensions/gis/geographic/strategies boost/geometry/extensions/nsphere/algorithms boost/geometry/strategies boost/geometry/strategies/cartesian boost/geometry/strategies/spherical libs/geometry/doc/doxygen_input/pages libs/geometry/test/algorithms libs/geometry/test/strategies
From: barend.gehrels_at_[hidden]
Date: 2010-07-04 17:29:12


Author: barendgehrels
Date: 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
New Revision: 63634
URL: http://svn.boost.org/trac/boost/changeset/63634

Log:
strategy_distance is now better named to services::default_strategy (with version for point and segment)
strategy_tag is now services::tag everywhere

Text files modified:
   sandbox/geometry/boost/geometry/algorithms/comparable_distance.hpp | 10 +-
   sandbox/geometry/boost/geometry/algorithms/distance.hpp | 41 ++++++--------
   sandbox/geometry/boost/geometry/algorithms/length.hpp | 13 +---
   sandbox/geometry/boost/geometry/algorithms/perimeter.hpp | 12 +--
   sandbox/geometry/boost/geometry/algorithms/simplify.hpp | 14 ++--
   sandbox/geometry/boost/geometry/extensions/algorithms/selected.hpp | 7 -
   sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp | 32 +++--------
   sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp | 23 +------
   sandbox/geometry/boost/geometry/extensions/nsphere/algorithms/within.hpp | 7 -
   sandbox/geometry/boost/geometry/strategies/cartesian/distance_projected_point.hpp | 31 +++--------
   sandbox/geometry/boost/geometry/strategies/cartesian/distance_pythagoras.hpp | 27 +--------
   sandbox/geometry/boost/geometry/strategies/distance.hpp | 109 +++++++++++++++------------------------
   sandbox/geometry/boost/geometry/strategies/distance_result.hpp | 6 +
   sandbox/geometry/boost/geometry/strategies/spherical/distance_cross_track.hpp | 35 ++++--------
   sandbox/geometry/boost/geometry/strategies/spherical/distance_haversine.hpp | 25 +-------
   sandbox/geometry/boost/geometry/strategies/tags.hpp | 8 --
   sandbox/geometry/libs/geometry/doc/doxygen_input/pages/doxygen_a_design_rationale.hpp | 22 ++++----
   sandbox/geometry/libs/geometry/test/algorithms/distance.cpp | 2
   sandbox/geometry/libs/geometry/test/strategies/haversine.cpp | 25 +++++---
   sandbox/geometry/libs/geometry/test/strategies/pythagoras.cpp | 12 +++-
   20 files changed, 172 insertions(+), 289 deletions(-)

Modified: sandbox/geometry/boost/geometry/algorithms/comparable_distance.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/comparable_distance.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/comparable_distance.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -44,12 +44,12 @@
         <
             typename boost::mpl::if_c
                 <
- geometry::reverse_dispatch
+ geometry::reverse_dispatch
                         <Geometry1, Geometry2>::type::value,
- typename default_distance_strategy
- <point2_type, point1_type>::type,
- typename default_distance_strategy
- <point1_type, point2_type>::type
+ typename strategy::distance::services::default_strategy
+ <point_tag, point2_type, point1_type>::type,
+ typename strategy::distance::services::default_strategy
+ <point_tag, point1_type, point2_type>::type
>::type
>::type strategy_type;
 

Modified: sandbox/geometry/boost/geometry/algorithms/distance.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/distance.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/distance.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -84,10 +84,9 @@
     static inline typename Strategy::return_type apply(Point const& point,
                 Segment const& segment, Strategy const& strategy)
     {
- typename strategy_distance_segment
+ typename strategy::distance::services::default_strategy
             <
- typename cs_tag<Point>::type,
- typename cs_tag<Segment>::type,
+ segment_tag,
                 Point,
                 typename point_type<Segment>::type
>::type segment_strategy;
@@ -269,12 +268,11 @@
             Linestring const& linestring,
             Strategy const& strategy)
     {
- typedef typename geometry::strategy_distance_segment
+ typedef typename strategy::distance::services::default_strategy
                     <
- typename cs_tag<Point>::type,
- typename cs_tag<Linestring>::type,
- Point,
- typename point_type<Linestring>::type
+ segment_tag,
+ Point,
+ typename point_type<Linestring>::type
>::type ps_strategy_type;
 
         return detail::distance::point_to_range
@@ -323,13 +321,12 @@
             Polygon const& polygon,
             Strategy const& strategy)
     {
- typedef typename geometry::strategy_distance_segment
- <
- typename cs_tag<Point>::type,
- typename cs_tag<Polygon>::type,
- Point,
- typename point_type<Polygon>::type
- >::type ps_strategy_type;
+ typedef typename strategy::distance::services::default_strategy
+ <
+ segment_tag,
+ Point,
+ typename point_type<Polygon>::type
+ >::type ps_strategy_type;
 
         std::pair<return_type, bool>
             dc = detail::distance::point_to_polygon
@@ -442,7 +439,7 @@
                     typename tag<Geometry2>::type,
                     Geometry1,
                     Geometry2,
- typename strategy_tag<Strategy>::type,
+ typename strategy::distance::services::tag<Strategy>::type,
                     Strategy,
                     is_multi<Geometry1>::value,
                     is_multi<Geometry2>::value
@@ -453,7 +450,7 @@
                     typename tag<Geometry2>::type,
                     Geometry1,
                     Geometry2,
- typename strategy_tag<Strategy>::type,
+ typename strategy::distance::services::tag<Strategy>::type,
                     Strategy,
                     is_multi<Geometry1>::value,
                     is_multi<Geometry2>::value
@@ -487,17 +484,15 @@
     typedef typename boost::mpl::if_c
         <
             geometry::reverse_dispatch<Geometry1, Geometry2>::type::value,
- typename strategy_distance
+ typename strategy::distance::services::default_strategy
                 <
- typename cs_tag<point2_type>::type,
- typename cs_tag<point1_type>::type,
+ point_tag,
                     point2_type,
                     point1_type
>::type,
- typename strategy_distance
+ typename strategy::distance::services::default_strategy
                 <
- typename cs_tag<point1_type>::type,
- typename cs_tag<point2_type>::type,
+ point_tag,
                     point1_type,
                     point2_type
>::type

Modified: sandbox/geometry/boost/geometry/algorithms/length.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/length.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/length.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -89,8 +89,8 @@
         iterator_type it = boost::begin(view), end = boost::end(view);
         if(it != end)
         {
- for(iterator_type previous = it++;
- it != end;
+ for(iterator_type previous = it++;
+ it != end;
                     ++previous, ++it)
             {
                 // Add point-point distance using the return type belonging
@@ -162,14 +162,9 @@
 {
     concept::check<Geometry const>();
 
- typedef typename point_type<Geometry>::type point_type;
- typedef typename cs_tag<point_type>::type cs_tag;
- typedef typename strategy_distance
+ typedef typename strategy::distance::services::default_strategy
         <
- cs_tag,
- cs_tag,
- point_type,
- point_type
+ point_tag, typename point_type<Geometry>::type
>::type strategy_type;
 
     return dispatch::length

Modified: sandbox/geometry/boost/geometry/algorithms/perimeter.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/perimeter.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/perimeter.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -47,7 +47,7 @@
 
 template <typename Geometry, typename Strategy>
 struct perimeter<ring_tag, Geometry, Strategy>
- : detail::length::range_length<Geometry, Strategy,
+ : detail::length::range_length<Geometry, Strategy,
     closure<Geometry>::value == open>
 {};
 
@@ -62,7 +62,7 @@
                 <
                     typename ring_type<Polygon>::type,
                     Strategy,
- closure<Polygon>::value == open
+ closure<Polygon>::value == open
>
>
 {};
@@ -90,13 +90,9 @@
     concept::check<Geometry const>();
 
     typedef typename point_type<Geometry>::type point_type;
- typedef typename cs_tag<point_type>::type cs_tag;
- typedef typename strategy_distance
+ typedef typename strategy::distance::services::default_strategy
         <
- cs_tag,
- cs_tag,
- point_type,
- point_type
+ point_tag, point_type
>::type strategy_type;
 
     return dispatch::perimeter

Modified: sandbox/geometry/boost/geometry/algorithms/simplify.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/simplify.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/simplify.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -323,8 +323,10 @@
     concept::check<Geometry>();
 
     typedef typename point_type<Geometry>::type point_type;
- typedef typename default_distance_strategy_segment
- <point_type>::type ds_strategy_type;
+ typedef typename strategy::distance::services::default_strategy
+ <
+ segment_tag, point_type
+ >::type ds_strategy_type;
 
     typedef strategy::simplify::douglas_peucker
         <
@@ -385,13 +387,9 @@
     concept::check<Geometry const>();
     concept::check<point_type>();
 
- typedef typename cs_tag<point_type>::type cs_tag;
- typedef typename strategy_distance_segment
+ typedef typename strategy::distance::services::default_strategy
         <
- cs_tag,
- cs_tag,
- point_type,
- point_type
+ segment_tag, point_type
>::type ds_strategy_type;
 
     typedef strategy::simplify::douglas_peucker

Modified: sandbox/geometry/boost/geometry/extensions/algorithms/selected.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/algorithms/selected.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/algorithms/selected.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -149,12 +149,9 @@
         {
             // Not outside, calculate dot product/square distance to segment.
             // Call corresponding strategy
- typedef typename strategy_distance_segment
+ typedef typename strategy::distance::services::default_strategy
                 <
- typename cs_tag<P>::type,
- typename cs_tag<PS>::type,
- P,
- PS
+ segment_tag, P, PS
>::type strategy_type;
             typedef typename strategy_type::return_type return_type;
 

Modified: sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -39,9 +39,9 @@
     \see http://futureboy.homeip.net/frinksamp/navigation.frink (implementation)
     \see http://www.voidware.com/earthdist.htm (implementation)
 */
-template
+template
 <
- typename P1,
+ typename P1,
     typename P2 = P1
     // calculation_type
>
@@ -75,7 +75,7 @@
         {
             return m_ellipsoid;
         }
-
+
 
     private :
         typedef typename coordinate_type<P1>::type T1;
@@ -126,7 +126,7 @@
 
 
 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-namespace services
+namespace services
 {
 
 template <typename Point1, typename Point2>
@@ -179,31 +179,19 @@
 };
 
 
-} // namespace services
-#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-
-
-}} // namespace strategy::distance
-
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-template <typename P1, typename P2>
-struct strategy_distance<geographic_tag, geographic_tag, P1, P2>
+template <typename Point1, typename Point2>
+struct default_strategy<point_tag, Point1, Point2, geographic_tag, geographic_tag>
 {
- typedef strategy::distance::andoyer<P1, P2> type;
+ typedef strategy::distance::andoyer<Point1, Point2> type;
 };
 
 
-template <typename P1, typename P2>
-struct strategy_tag<strategy::distance::andoyer<P1, P2> >
-{
- typedef strategy_tag_distance_point_point type;
-};
-
+} // namespace services
 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
 
 
+}} // namespace strategy::distance
+
 
 }} // namespace boost::geometry
 

Modified: sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -42,9 +42,9 @@
         - http://futureboy.homeip.net/fsp/colorize.fsp?fileName=navigation.frink
 
 */
-template
+template
 <
- typename Point1,
+ typename Point1,
     typename Point2 = Point1,
     typename CalculationType = void
>
@@ -91,9 +91,9 @@
     typedef return_type promoted_type;
     geometry::detail::ellipsoid m_ellipsoid;
 
- inline return_type calculate(promoted_type const& lon1,
- promoted_type const& lat1,
- promoted_type const& lon2,
+ inline return_type calculate(promoted_type const& lon1,
+ promoted_type const& lat1,
+ promoted_type const& lon2,
                 promoted_type const& lat2) const
     {
         namespace mc = boost::math::constants;
@@ -254,7 +254,6 @@
 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
 
 
-
 // We might add a vincenty-like strategy also for point-segment distance, but to calculate the projected point is not trivial
 
 
@@ -262,18 +261,6 @@
 }} // namespace strategy::distance
 
 
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-
-template <typename Point1, typename Point2>
-struct strategy_tag<strategy::distance::vincenty<Point1, Point2> >
-{
- typedef strategy_tag_distance_point_point type;
-};
-
-
-#endif
-
-
 }} // namespace boost::geometry
 
 

Modified: sandbox/geometry/boost/geometry/extensions/nsphere/algorithms/within.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/nsphere/algorithms/within.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/nsphere/algorithms/within.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -42,12 +42,9 @@
     assert_dimension<C, 2>();
 
     typedef typename point_type<C>::type point_type;
- typedef typename strategy_distance
+ typedef typename strategy::distance::services::default_strategy
         <
- typename cs_tag<P>::type,
- typename cs_tag<point_type>::type,
- P,
- point_type
+ point_tag, P, point_type
>::type strategy_type;
     typedef typename strategy_type::return_type return_type;
 

Modified: sandbox/geometry/boost/geometry/strategies/cartesian/distance_projected_point.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/cartesian/distance_projected_point.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/cartesian/distance_projected_point.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -264,41 +264,28 @@
 };
 
 
-} // namespace services
-#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-
-
-}} // namespace strategy::distance
-
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-
-
 template <typename Point, typename PointOfSegment>
-struct strategy_distance_segment<cartesian_tag, cartesian_tag, Point, PointOfSegment>
+struct default_strategy<segment_tag, Point, PointOfSegment, cartesian_tag, cartesian_tag>
 {
- typedef typename point_type<PointOfSegment>::type segment_point_type;
-
     typedef strategy::distance::projected_point
     <
         Point,
         PointOfSegment,
         void,
- typename strategy_distance
+ typename default_strategy
         <
- cartesian_tag, cartesian_tag, Point, segment_point_type
+ point_tag, Point, PointOfSegment,
+ cartesian_tag, cartesian_tag
>::type
> type;
 };
-#endif
 
 
-template <typename Point, typename PointOfSegment, typename PPStrategy>
-struct strategy_tag<strategy::distance::projected_point<Point, PointOfSegment, PPStrategy> >
-{
- typedef strategy_tag_distance_point_segment type;
-};
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::distance
 
 
 }} // namespace boost::geometry

Modified: sandbox/geometry/boost/geometry/strategies/cartesian/distance_pythagoras.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/cartesian/distance_pythagoras.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/cartesian/distance_pythagoras.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -298,35 +298,18 @@
 };
 
 
-} // namespace services
-#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-
-
-}} // namespace strategy::distance
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
 template <typename Point1, typename Point2>
-struct strategy_distance<cartesian_tag, cartesian_tag, Point1, Point2>
+struct default_strategy<point_tag, Point1, Point2, cartesian_tag, cartesian_tag>
 {
- typedef strategy::distance::pythagoras<Point1, Point2> type;
+ typedef pythagoras<Point1, Point2> type;
 };
 
 
-template <typename Point1, typename Point2>
-struct strategy_tag<strategy::distance::pythagoras<Point1, Point2> >
-{
- typedef strategy_tag_distance_point_point type;
-};
-
-template <typename Point1, typename Point2>
-struct strategy_tag<strategy::distance::comparable::pythagoras<Point1, Point2> >
-{
- typedef strategy_tag_distance_point_point type;
-};
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
 
 
-#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+}} // namespace strategy::distance
 
 
 }} // namespace boost::geometry

Modified: sandbox/geometry/boost/geometry/strategies/distance.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/distance.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/distance.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -10,6 +10,8 @@
 #define BOOST_GEOMETRY_STRATEGIES_DISTANCE_HPP
 
 
+#include <boost/mpl/assert.hpp>
+
 #include <boost/geometry/core/cs.hpp>
 #include <boost/geometry/strategies/tags.hpp>
 
@@ -18,64 +20,7 @@
 {
 
 
-/*!
- \brief Traits class binding a distance strategy to a (possibly two) coordinate system(s)
- \ingroup distance
- \tparam T1 tag of coordinate system of first point type
- \tparam T2 tag of coordinate system of second point type
- \tparam P1 first point-type
- \tparam P2 second point-type
-*/
-template <typename T1, typename T2, typename P1, typename P2>
-struct strategy_distance
-{
- typedef strategy::not_implemented type;
-};
-
-/*!
- \brief Traits class binding a distance-to-segment strategy to a (possibly two) coordinate system(s)
- \ingroup distance
- \tparam CsTag1 tag of coordinate system of point type
- \tparam CsTag2 tag of coordinate system of segment type, usually same as CsTag1
- \tparam Point point-type
- \tparam PointOfSegment segment-point-type
-*/
-template <typename CsTag1, typename CsTag2, typename Point, typename PointOfSegment>
-struct strategy_distance_segment
-{
- typedef strategy::not_implemented type;
-};
-
-
-
-// New functionality:
-template
-<
- typename Point1,
- typename Point2 = Point1,
- typename Tag1 = typename cs_tag<Point1>::type,
- typename Tag2 = typename cs_tag<Point2>::type
->
-struct default_distance_strategy
-{
- typedef typename strategy_distance<Tag1, Tag2, Point1, Point2>::type type;
-};
-
-template
-<
- typename Point,
- typename PointOfSegment = Point,
- typename Tag1 = typename cs_tag<Point>::type,
- typename Tag2 = typename cs_tag<PointOfSegment>::type
->
-struct default_distance_strategy_segment
-{
- typedef typename strategy_distance_segment<Tag1, Tag2, Point, PointOfSegment>::type type;
-};
-
-
-
-namespace strategy { namespace distance { namespace services
+namespace strategy { namespace distance { namespace services
 {
 
 template <typename Strategy> struct tag {};
@@ -84,20 +29,20 @@
 /*!
     \brief Metafunction delivering a similar strategy with other input point types
 */
-template
+template
 <
- typename Strategy,
- typename Point1,
+ typename Strategy,
+ typename Point1,
     typename Point2
->
+>
 struct similar_type {};
 
-template
+template
 <
- typename Strategy,
- typename Point1,
+ typename Strategy,
+ typename Point1,
     typename Point2
->
+>
 struct get_similar {};
 
 template <typename Strategy> struct comparable_type {};
@@ -106,6 +51,38 @@
 template <typename Strategy> struct result_from_distance {};
 
 
+
+// Default strategy
+
+
+/*!
+ \brief Traits class binding a default strategy for distance
+ to one (or possibly two) coordinate system(s)
+ \ingroup distance
+ \tparam GeometryTag tag (point/segment) for which this strategy is the default
+ \tparam Point1 first point-type
+ \tparam Point2 second point-type
+ \tparam CsTag1 tag of coordinate system of first point type
+ \tparam CsTag2 tag of coordinate system of second point type
+*/
+template
+<
+ typename GeometryTag,
+ typename Point1,
+ typename Point2 = Point1,
+ typename CsTag1 = typename cs_tag<Point1>::type,
+ typename CsTag2 = typename cs_tag<Point2>::type
+>
+struct default_strategy
+{
+ BOOST_MPL_ASSERT_MSG
+ (
+ false, NOT_IMPLEMENTED_FOR_THIS_POINT_TYPE_COMBINATION
+ , (types<Point1, Point2, CsTag1, CsTag2>)
+ );
+};
+
+
 }}} // namespace strategy::distance::services
 
 

Modified: sandbox/geometry/boost/geometry/strategies/distance_result.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/distance_result.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/distance_result.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -25,11 +25,15 @@
         from length, where distance is sqr/sqrt, but length always squared)
 
  */
+
+// TODO: rename to "default_distance_result" or services::default_result
+
 template <typename Geometry1, typename Geometry2>
 struct distance_result
 {
- typedef typename default_distance_strategy
+ typedef typename strategy::distance::services::default_strategy
         <
+ point_tag,
             typename point_type<Geometry1>::type,
             typename point_type<Geometry2>::type
>::type strategy_type;

Modified: sandbox/geometry/boost/geometry/strategies/spherical/distance_cross_track.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/spherical/distance_cross_track.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/spherical/distance_cross_track.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -45,7 +45,7 @@
     typename Point,
     typename PointOfSegment = Point,
     typename CalculationType = void,
- typename Strategy = typename default_distance_strategy<Point>::type
+ typename Strategy = typename services::default_strategy<point_tag, Point>::type
>
 class cross_track
 {
@@ -209,38 +209,29 @@
     }
 };
 
-
-} // namespace services
-#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-
-
-}} // namespace strategy::distance
-
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-
-
-template <typename Point, typename Segment>
-struct strategy_distance_segment<spherical_tag, spherical_tag, Point, Segment>
+template <typename Point, typename PointOfSegment>
+struct default_strategy<segment_tag, Point, PointOfSegment, spherical_tag, spherical_tag>
 {
- typedef strategy::distance::cross_track<Point, Segment> type;
+ typedef strategy::distance::cross_track<Point, PointOfSegment> type;
 };
 
 
 // Use this point-segment for geographic as well. TODO: change this, extension!
 template <typename Point, typename PointOfSegment>
-struct strategy_distance_segment<geographic_tag, geographic_tag, Point, PointOfSegment>
+struct default_strategy<segment_tag, Point, PointOfSegment, geographic_tag, geographic_tag>
 {
     typedef strategy::distance::cross_track<Point, PointOfSegment> type;
 };
 
 
-template <typename Point, typename Segment>
-struct strategy_tag<strategy::distance::cross_track<Point, Segment> >
-{
- typedef strategy_tag_distance_point_segment type;
-};
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+
+}} // namespace strategy::distance
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
 
 
 #endif

Modified: sandbox/geometry/boost/geometry/strategies/spherical/distance_haversine.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/spherical/distance_haversine.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/spherical/distance_haversine.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -278,35 +278,20 @@
 };
 
 
-} // namespace services
-#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-
-
-}} // namespace strategy::distance
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+// Register it as the default for point-types in a spherical coordinate system
 template <typename Point1, typename Point2>
-struct strategy_distance<spherical_tag, spherical_tag, Point1, Point2>
+struct default_strategy<point_tag, Point1, Point2, spherical_tag, spherical_tag>
 {
     typedef strategy::distance::haversine<Point1, Point2> type;
 };
 
 
-template <typename Point1, typename Point2>
-struct strategy_tag<strategy::distance::haversine<Point1, Point2> >
-{
- typedef strategy_tag_distance_point_point type;
-};
 
-template <typename Point1, typename Point2>
-struct strategy_tag<strategy::distance::comparable::haversine<Point1, Point2> >
-{
- typedef strategy_tag_distance_point_point type;
-};
+} // namespace services
+#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
 
 
-#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+}} // namespace strategy::distance
 
 
 }} // namespace boost::geometry

Modified: sandbox/geometry/boost/geometry/strategies/tags.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/tags.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/tags.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -27,17 +27,9 @@
 }
 
 
-
-
-struct strategy_tag_unknown {};
 struct strategy_tag_distance_point_point {};
 struct strategy_tag_distance_point_segment {};
 
-template <typename T>
-struct strategy_tag
-{
- typedef strategy_tag_unknown type;
-};
 
 }} // namespace boost::geometry
 

Modified: sandbox/geometry/libs/geometry/doc/doxygen_input/pages/doxygen_a_design_rationale.hpp
==============================================================================
--- sandbox/geometry/libs/geometry/doc/doxygen_input/pages/doxygen_a_design_rationale.hpp (original)
+++ sandbox/geometry/libs/geometry/doc/doxygen_input/pages/doxygen_a_design_rationale.hpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -450,12 +450,12 @@
 template <typename G1, typename G2>
 double distance(G1 const& g1, G2 const& g2)
 {
- typedef typename strategy_distance
+ typedef typename default_distance_strategy
         <
- typename coordinate_system<G1>::type,
- typename coordinate_system<G2>::type,
             typename point_type<G1>::type,
             typename point_type<G2>::type,
+ typename coordinate_system<G1>::type,
+ typename coordinate_system<G2>::type,
             dimension<G1>::value
>::type strategy;
 
@@ -468,17 +468,17 @@
 }
 \endcode
 
-The strategy_distance mentioned here is a metafunction with specializations for different coordinate systems.
+The default_distance_strategy mentioned here is a metafunction with specializations for different coordinate systems.
 
 \code
-template <typename T1, typename T2, typename P1, typename P2, int D>
-struct strategy_distance
+template <typename P1, typename P2, typename T1, typename T2, int D>
+struct default_distance_strategy
 {
     // undefined; type is not defined
 };
 
 template <typename P1, typename P2, int D>
-struct strategy_distance<cartesian, cartesian, P1, P2, D>
+struct default_distance_strategy<P1, P2, cartesian, cartesian, D>
 {
     typedef pythagoras<P1, P2, D> type;
 };
@@ -489,7 +489,7 @@
 So this is an important step: for spherical or geographical coordinate systems, another strategy (computation method) can be implemented. For spherical coordinate systems we have the haversine formula. So the dispatching traits struct is specialized like this:
 \code
 template <typename P1, typename P2, int D = 2>
-struct strategy_distance<spherical, spherical, P1, P2, D>
+struct default_distance_strategy<P1, P2, spherical, spherical, D>
 {
     typedef haversine<P1, P2> type;
 };
@@ -612,11 +612,11 @@
 {
     typedef typename point_type<G1>::type P1;
     typedef typename point_type<G2>::type P2;
- typedef typename strategy_distance
+ typedef typename default_distance_strategy
         <
+ P1, P2,
             typename cs_tag<P1>::type,
- typename cs_tag<P2>::type,
- P1, P2
+ typename cs_tag<P2>::type
>::type S;
 
     typedef typename S::return_type type;

Modified: sandbox/geometry/libs/geometry/test/algorithms/distance.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/distance.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/distance.cpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -56,7 +56,7 @@
     {
         namespace services = boost::geometry::strategy::distance::services;
 
- typedef typename boost::geometry::default_distance_strategy<P>::type strategy_type;
+ typedef typename services::default_strategy<boost::geometry::point_tag, P>::type strategy_type;
         typedef typename services::comparable_type<strategy_type>::type comparable_strategy_type;
 
         strategy_type strategy;

Modified: sandbox/geometry/libs/geometry/test/strategies/haversine.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/strategies/haversine.cpp (original)
+++ sandbox/geometry/libs/geometry/test/strategies/haversine.cpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -66,7 +66,6 @@
 template <typename Point>
 void test_all()
 {
-
     // earth to unit-sphere -> divide by earth circumference, then it is from 0-1,
     // then multiply with 2 PI, so effectively just divide by earth radius
     double e2u = 1.0 / average_earth_radius;
@@ -88,6 +87,15 @@
 template <typename P1, typename P2, typename CalculationType>
 void test_services()
 {
+ namespace bgsd = bg::strategy::distance;
+ namespace services = bg::strategy::distance::services;
+
+ {
+
+ // Compile-check if there is a strategy for this type
+ typedef services::default_strategy<bg::point_tag, P1, P2>::type haversine_strategy_type;
+ }
+
     P1 p1;
     bg::assign(p1, 4, 52);
 
@@ -102,10 +110,6 @@
     double const expected_lower = 460.0 * km;
     double const expected_higher = 470.0 * km;
 
-
-
- namespace bgsd = bg::strategy::distance;
- namespace services = bg::strategy::distance::services;
     // 1: normal, calculate distance:
 
     typedef bgsd::haversine<P1, P2, CalculationType> strategy_type;
@@ -162,6 +166,7 @@
     BOOST_CHECK(dist_lower < result && result < dist_higher);
 }
 
+/****
 template <typename P, typename Strategy>
 void time_compare_s(int const n)
 {
@@ -230,7 +235,7 @@
     std::cout << "Check: " << s << " Time: " << diff << std::endl;
     return diff;
 }
-
+***/
 
 int test_main(int, char* [])
 {
@@ -239,10 +244,10 @@
     test_all<bg::point<float, 2, bg::cs::spherical<bg::degree> > >();
     test_all<bg::point<double, 2, bg::cs::spherical<bg::degree> > >();
 
- double t1 = time_sqrt(20000);
- double t2 = time_normal(20000);
- std::cout << "Factor: " << (t1 / t2) << std::endl;
- time_compare<bg::point<double, 2, bg::cs::spherical<bg::radian> > >(10000);
+ //double t1 = time_sqrt(20000);
+ //double t2 = time_normal(20000);
+ //std::cout << "Factor: " << (t1 / t2) << std::endl;
+ //time_compare<bg::point<double, 2, bg::cs::spherical<bg::radian> > >(10000);
 
 #if defined(HAVE_TTMATH)
     typedef ttmath::Big<1,4> tt;

Modified: sandbox/geometry/libs/geometry/test/strategies/pythagoras.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/strategies/pythagoras.cpp (original)
+++ sandbox/geometry/libs/geometry/test/strategies/pythagoras.cpp 2010-07-04 17:29:06 EDT (Sun, 04 Jul 2010)
@@ -109,6 +109,15 @@
 template <typename P1, typename P2, typename CalculationType>
 void test_services()
 {
+ namespace bgsd = boost::geometry::strategy::distance;
+ namespace services = boost::geometry::strategy::distance::services;
+
+ {
+
+ // Compile-check if there is a strategy for this type
+ typedef services::default_strategy<bg::point_tag, P1, P2>::type pythagoras_strategy_type;
+ }
+
 
     P1 p1;
     bg::assign(p1, 1, 2, 3);
@@ -119,9 +128,6 @@
     double const sqr_expected = 3*3 + 3*3 + 3*3; // 27
     double const expected = sqrt(sqr_expected); // sqrt(27)=5.1961524227
 
-
- namespace bgsd = boost::geometry::strategy::distance;
- namespace services = boost::geometry::strategy::distance::services;
     // 1: normal, calculate distance:
 
     typedef bgsd::pythagoras<P1, P2, CalculationType> strategy_type;


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk