$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r64087 - in sandbox/geometry: boost/geometry/algorithms boost/geometry/strategies boost/geometry/strategies/cartesian libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2010-07-17 06:46:27
Author: barendgehrels
Date: 2010-07-17 06:46:25 EDT (Sat, 17 Jul 2010)
New Revision: 64087
URL: http://svn.boost.org/trac/boost/changeset/64087
Log:
Added Point-Point strategy to default_strategy for Point-segment
Added some MPL assertions
Updated distance tests
Text files modified: 
   sandbox/geometry/boost/geometry/algorithms/distance.hpp                           |    18 +                                       
   sandbox/geometry/boost/geometry/strategies/cartesian/distance_projected_point.hpp |    24 +                                       
   sandbox/geometry/boost/geometry/strategies/cartesian/distance_pythagoras.hpp      |     2                                         
   sandbox/geometry/boost/geometry/strategies/distance.hpp                           |    47 ++++                                    
   sandbox/geometry/boost/geometry/strategies/distance_result.hpp                    |     2                                         
   sandbox/geometry/libs/geometry/test/algorithms/distance.cpp                       |   375 ++++++++++++++++++++++++++------------- 
   sandbox/geometry/libs/geometry/test/algorithms/within.cpp                         |     2                                         
   7 files changed, 327 insertions(+), 143 deletions(-)
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-17 06:46:25 EDT (Sat, 17 Jul 2010)
@@ -91,7 +91,10 @@
             <
                 segment_tag,
                 Point,
-                typename point_type<Segment>::type
+                typename point_type<Segment>::type,
+                typename cs_tag<Point>::type,
+                typename cs_tag<typename point_type<Segment>::type>::type,
+                Strategy
             >::type segment_strategy;
 
         // See remark below.
@@ -125,7 +128,7 @@
             return pp_strategy.apply(point, *boost::begin(range));
         }
 
-        // Create efficient strategy
+        // Create comparable (more efficient) strategy
         typedef typename strategy::distance::services::comparable_type<PSStrategy>::type eps_strategy_type;
         eps_strategy_type eps_strategy = strategy::distance::services::get_comparable<PSStrategy>::apply(ps_strategy);
 
@@ -422,7 +425,7 @@
     \param geometry1 first geometry
     \param geometry2 second geometry
     \param strategy strategy to calculate distance between two points
-    \return the distance (either a double or a distance_result, (convertable to double))
+    \return the distance
     \note The strategy can be a point-point strategy. In case of distance point-line/point-polygon
         it may also be a point-segment strategy.
     \par Example:
@@ -432,6 +435,15 @@
     \line {
     \until }
  */
+
+/*
+Note, in case of a Compilation Error: 
+if you get:
+ - "Failed to specialize function template ..."
+ - "error: no matching function for call to ..."
+for distance, it is probably so that there is no specialization
+for return_type<...> for your strategy.
+*/
 template <typename Geometry1, typename Geometry2, typename Strategy>
 inline typename strategy::distance::services::return_type<Strategy>::type distance(
                 Geometry1 const& geometry1,
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-17 06:46:25 EDT (Sat, 17 Jul 2010)
@@ -266,19 +266,29 @@
 };
 
 
-template <typename Point, typename PointOfSegment>
-struct default_strategy<segment_tag, Point, PointOfSegment, cartesian_tag, cartesian_tag>
+// Get default-strategy for point-segment distance calculation
+// while still have the possibility to specify point-point distance strategy (PPS)
+// It is used in algorithms/distance.hpp where users specify PPS for distance
+// of point-to-segment or point-to-linestring.
+// Convenient for geographic coordinate systems especially.
+template <typename Point, typename PointOfSegment, typename Strategy>
+struct default_strategy<segment_tag, Point, PointOfSegment, cartesian_tag, cartesian_tag, Strategy>
 {
     typedef strategy::distance::projected_point
     <
         Point,
         PointOfSegment,
         void,
-        typename default_strategy
-        <
-            point_tag, Point, PointOfSegment,
-            cartesian_tag, cartesian_tag
-        >::type
+        typename boost::mpl::if_
+            <
+                boost::is_void<Strategy>,
+                typename default_strategy
+                    <
+                        point_tag, Point, PointOfSegment,
+                        cartesian_tag, cartesian_tag
+                    >::type,
+                Strategy
+            >::type
     > type;
 };
 
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-17 06:46:25 EDT (Sat, 17 Jul 2010)
@@ -309,7 +309,7 @@
 
 
 template <typename Point1, typename Point2>
-struct default_strategy<point_tag, Point1, Point2, cartesian_tag, cartesian_tag>
+struct default_strategy<point_tag, Point1, Point2, cartesian_tag, cartesian_tag, void>
 {
     typedef pythagoras<Point1, Point2> type;
 };
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-17 06:46:25 EDT (Sat, 17 Jul 2010)
@@ -23,8 +23,15 @@
 namespace strategy { namespace distance { namespace services
 {
 
+
 template <typename Strategy> struct tag {};
-template <typename Strategy> struct return_type {};
+template <typename Strategy> struct return_type 
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY, (types<Strategy>)
+        );
+};
 
 
 /*!
@@ -36,7 +43,14 @@
     typename Point1,
     typename Point2
 >
-struct similar_type {};
+struct similar_type 
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY
+            , (types<Strategy, Point1, Point2>)
+        );
+};
 
 template
 <
@@ -44,10 +58,30 @@
     typename Point1,
     typename Point2
 >
-struct get_similar {};
+struct get_similar 
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY
+            , (types<Strategy, Point1, Point2>)
+        );
+};
 
-template <typename Strategy> struct comparable_type {};
-template <typename Strategy> struct get_comparable {};
+template <typename Strategy> struct comparable_type 
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY, (types<Strategy>)
+        );
+};
+
+template <typename Strategy> struct get_comparable 
+{
+    BOOST_MPL_ASSERT_MSG
+        (
+            false, NOT_IMPLEMENTED_FOR_THIS_STRATEGY, (types<Strategy>)
+        );
+};
 
 template <typename Strategy> struct result_from_distance {};
 
@@ -75,7 +109,8 @@
     typename Point1,
     typename Point2 = Point1,
     typename CsTag1 = typename cs_tag<Point1>::type,
-    typename CsTag2 = typename cs_tag<Point2>::type
+    typename CsTag2 = typename cs_tag<Point2>::type,
+    typename UnderlyingStrategy = void
 >
 struct default_strategy
 {
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-17 06:46:25 EDT (Sat, 17 Jul 2010)
@@ -28,7 +28,7 @@
 
 // TODO: rename to "default_distance_result" or services::default_result
 
-template <typename Geometry1, typename Geometry2>
+template <typename Geometry1, typename Geometry2 = Geometry1>
 struct distance_result
 {
     typedef typename strategy::distance::services::return_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-17 06:46:25 EDT (Sat, 17 Jul 2010)
@@ -6,7 +6,7 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-//#define TEST_ARRAY
+#define TEST_ARRAY
 
 #include <sstream>
 
@@ -28,185 +28,312 @@
 #include <test_common/test_point.hpp>
 
 
-template <typename P>
-void test_distance_result()
+namespace bg = boost::geometry;
+
+
+// Define a custom distance strategy
+// For this one, the "taxicab" distance, 
+// see http://en.wikipedia.org/wiki/Taxicab_geometry
+
+// For a point-point-distance operation, one typename Point is enough.
+// For a point-segment-distance operation, there is some magic inside
+// using another point type and casting if necessary. Therefore,
+// two point-types are necessary.
+template <typename P1, typename P2 = P1>
+struct taxicab_distance
 {
-    typedef typename boost::geometry::distance_result<P, P>::type distance_type;
+    static inline typename boost::geometry::coordinate_type<P1>::type apply(
+                    P1 const& p1, P2 const& p2) 
+    {
+        using boost::geometry::get;
+        using boost::geometry::math::abs;
+        return abs(get<0>(p1) - get<1>(p2))
+            + abs(get<1>(p1) - get<1>(p2));
+    }
+};
 
-#ifndef TEST_ARRAY
-    P p1 = boost::geometry::make<P>(0, 0);
-    P p2 = boost::geometry::make<P>(3, 0);
-    P p3 = boost::geometry::make<P>(0, 4);
-#else
-    P p1, p2, p3;
-    boost::geometry::set<0>(p1, 0); boost::geometry::set<1>(p1, 0);
-    boost::geometry::set<0>(p2, 3); boost::geometry::set<1>(p2, 0);
-    boost::geometry::set<0>(p3, 0); boost::geometry::set<1>(p3, 4);
-#endif
 
-    distance_type dr12 = boost::geometry::distance(p1, p2);
-    distance_type dr13 = boost::geometry::distance(p1, p3);
-    distance_type dr23 = boost::geometry::distance(p2, p3);
 
-    BOOST_CHECK_CLOSE(double(dr12), 3.000, 0.001);
-    BOOST_CHECK_CLOSE(double(dr13), 4.000, 0.001);
-    BOOST_CHECK_CLOSE(double(dr23), 5.000, 0.001);
+namespace boost { namespace geometry { namespace strategy { namespace distance { namespace services 
+{
 
-    // COMPARABLE TESTS
-    {
-        namespace services = boost::geometry::strategy::distance::services;
+template <typename P1, typename P2>
+struct tag<taxicab_distance<P1, P2> >
+{
+    typedef strategy_tag_distance_point_point 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;
-        comparable_strategy_type comparable_strategy = services::get_comparable<strategy_type>::apply(strategy);
-        distance_type comparable = services::result_from_distance<comparable_strategy_type>::apply(comparable_strategy, 3);
+template <typename P1, typename P2>
+struct return_type<taxicab_distance<P1, P2> >
+{
+    typedef typename coordinate_type<P1>::type type;
+};
+
+
+template<typename P1, typename P2, typename PN1, typename PN2>
+struct similar_type<taxicab_distance<P1, P2>, PN1, PN2>
+{
+    typedef taxicab_distance<PN1, PN2> type;
+};
 
-        BOOST_CHECK_CLOSE(double(comparable), 9.000, 0.001);
 
-        // COMPILATION TESTS (probably obsolete...)
-        if (comparable == dr12) {};
-        if (comparable < dr12) {};
-        if (comparable > dr12) {};
-
-        // Check streamability
-        std::ostringstream s;
-        s << comparable;
-
-        // Check comparisons with plain double
-        double d = 3.0;
-        if (dr12 == d) {};
-        if (dr12 < d) {};
-        if (dr12 > d) {};
+template<typename P1, typename P2, typename PN1, typename PN2>
+struct get_similar<taxicab_distance<P1, P2>, PN1, PN2>
+{
+    static inline typename similar_type
+        <
+            taxicab_distance<P1, P2>, PN1, PN2
+        >::type apply(taxicab_distance<P1, P2> const& )
+    {
+        return taxicab_distance<PN1, PN2>();
     }
-}
+};
+
+template <typename P1, typename P2>
+struct comparable_type<taxicab_distance<P1, P2> >
+{
+    typedef taxicab_distance<P1, P2> type;
+};
+
+template <typename P1, typename P2>
+struct get_comparable<taxicab_distance<P1, P2> >
+{
+    static inline taxicab_distance<P1, P2> apply(taxicab_distance<P1, P2> const& input)
+    {
+        return input;
+    }
+};
+
+template <typename P1, typename P2>
+struct result_from_distance<taxicab_distance<P1, P2> >
+{
+    template <typename T>
+    static inline typename coordinate_type<P1>::type apply(taxicab_distance<P1, P2> const& , T const& value)
+    {
+        return value;
+    }
+};
+
+
+}}}}} // namespace boost::geometry::strategy::distance::services
+
+
+
 
 template <typename P>
 void test_distance_point()
 {
-    P p1;
-    boost::geometry::set<0>(p1, 1);
-    boost::geometry::set<1>(p1, 1);
-
-    P p2;
-    boost::geometry::set<0>(p2, 2);
-    boost::geometry::set<1>(p2, 2);
+    namespace services = bg::strategy::distance::services;
+    typedef typename bg::distance_result<P>::type return_type;
+
+    {
+        // Basic, trivial test
+
+        P p1;
+        bg::set<0>(p1, 1);
+        bg::set<1>(p1, 1);
+
+        P p2;
+        bg::set<0>(p2, 2);
+        bg::set<1>(p2, 2);
+
+        return_type d = bg::distance(p1, p2);
+        BOOST_CHECK_CLOSE(d, return_type(1.4142135), 0.001);
+
+        // Test specifying strategy manually
+        typename services::default_strategy<bg::point_tag, P>::type strategy;
+
+        d = bg::distance(p1, p2, strategy);
+        BOOST_CHECK_CLOSE(d, return_type(1.4142135), 0.001);
 
-    double d = boost::geometry::distance(p1, p2);
-    BOOST_CHECK_CLOSE(d, 1.4142135, 0.001);
+        {
+            // Test custom strategy
+            BOOST_CONCEPT_ASSERT( (bg::concept::PointDistanceStrategy<taxicab_distance<P> >) );
+
+            typedef typename services::return_type<taxicab_distance<P> >::type cab_return_type;
+            BOOST_MPL_ASSERT((boost::is_same<cab_return_type, typename bg::coordinate_type<P>::type>));
+
+            taxicab_distance<P> tcd;
+            cab_return_type d = bg::distance(p1, p2, tcd);
+
+            BOOST_CHECK( bg::math::abs(d - cab_return_type(2)) <= cab_return_type(0.01) );
+        }
+    }
+
+
+    {
+        // 3-4-5 angle
+        P p1, p2, p3;
+        bg::set<0>(p1, 0); bg::set<1>(p1, 0);
+        bg::set<0>(p2, 3); bg::set<1>(p2, 0);
+        bg::set<0>(p3, 0); bg::set<1>(p3, 4);
+
+        return_type dr12 = bg::distance(p1, p2);
+        return_type dr13 = bg::distance(p1, p3);
+        return_type dr23 = bg::distance(p2, p3);
+
+        BOOST_CHECK_CLOSE(dr12, return_type(3), 0.001);
+        BOOST_CHECK_CLOSE(dr13, return_type(4), 0.001);
+        BOOST_CHECK_CLOSE(dr23, return_type(5), 0.001);
+    }
+
+
+    {
+        // test comparability
+
+        typedef typename services::default_strategy<bg::point_tag, P>::type strategy_type;
+        typedef typename services::comparable_type<strategy_type>::type comparable_strategy_type;
+
+        strategy_type strategy;
+        comparable_strategy_type comparable_strategy = services::get_comparable<strategy_type>::apply(strategy);
+        return_type comparable = services::result_from_distance<comparable_strategy_type>::apply(comparable_strategy, 3);
+
+        BOOST_CHECK_CLOSE(comparable, return_type(9), 0.001);
+    }
 }
 
 template <typename P>
 void test_distance_segment()
 {
-    typedef typename boost::geometry::coordinate_type<P>::type coordinate_type;
+    typedef typename bg::distance_result<P>::type return_type;
+    typedef typename bg::coordinate_type<P>::type coordinate_type;
 
-    P s1; boost::geometry::set<0>(s1, 2); boost::geometry::set<1>(s1, 2);
-    P s2; boost::geometry::set<0>(s2, 3); boost::geometry::set<1>(s2, 3);
+    P s1; bg::set<0>(s1, 1); bg::set<1>(s1, 1);
+    P s2; bg::set<0>(s2, 4); bg::set<1>(s2, 4);
 
     // Check points left, right, projected-left, projected-right, on segment
-    P p1; boost::geometry::set<0>(p1, 0); boost::geometry::set<1>(p1, 0);
-    P p2; boost::geometry::set<0>(p2, 4); boost::geometry::set<1>(p2, 4);
-    P p3; boost::geometry::set<0>(p3, coordinate_type(2.4)); boost::geometry::set<1>(p3, coordinate_type(2.6));
-    P p4; boost::geometry::set<0>(p4, coordinate_type(2.6)); boost::geometry::set<1>(p4, coordinate_type(2.4));
-    P p5; boost::geometry::set<0>(p5, 2.5); boost::geometry::set<1>(p5, 2.5);
-
-    const boost::geometry::segment<const P> seg(s1, s2);
-
-    double d1 = boost::geometry::distance(p1, seg); BOOST_CHECK_CLOSE(d1, 2.8284271, 0.001);
-    double d2 = boost::geometry::distance(p2, seg); BOOST_CHECK_CLOSE(d2, 1.4142135, 0.001);
-    double d3 = boost::geometry::distance(p3, seg); BOOST_CHECK_CLOSE(d3, 0.141421, 0.001);
-    double d4 = boost::geometry::distance(p4, seg); BOOST_CHECK_CLOSE(d4, 0.141421, 0.001);
-    double d5 = boost::geometry::distance(p5, seg); BOOST_CHECK_CLOSE(d5, 0.0, 0.001);
-
-    // Reverse case
-    double dr1 = boost::geometry::distance(seg, p1); BOOST_CHECK_CLOSE(dr1, d1, 0.001);
-    double dr2 = boost::geometry::distance(seg, p2); BOOST_CHECK_CLOSE(dr2, d2, 0.001);
+    P p1; bg::set<0>(p1, 0); bg::set<1>(p1, 1);
+    P p2; bg::set<0>(p2, 1); bg::set<1>(p2, 0);
+    P p3; bg::set<0>(p3, 3); bg::set<1>(p3, 1);
+    P p4; bg::set<0>(p4, 1); bg::set<1>(p4, 3);
+    P p5; bg::set<0>(p5, 3); bg::set<1>(p5, 3);
+
+    bg::segment<P const> const seg(s1, s2);
+
+    return_type d1 = bg::distance(p1, seg); 
+    return_type d2 = bg::distance(p2, seg); 
+    return_type d3 = bg::distance(p3, seg); 
+    return_type d4 = bg::distance(p4, seg); 
+    return_type d5 = bg::distance(p5, seg); 
+
+    BOOST_CHECK_CLOSE(d1, return_type(1), 0.001);
+    BOOST_CHECK_CLOSE(d2, return_type(1), 0.001);
+    BOOST_CHECK_CLOSE(d3, return_type(1.4142135), 0.001);
+    BOOST_CHECK_CLOSE(d4, return_type(1.4142135), 0.001);
+    BOOST_CHECK_CLOSE(d5, return_type(0), 0.001);
+
+    // Reverse case: segment/point instead of point/segment
+    return_type dr1 = bg::distance(seg, p1); 
+    return_type dr2 = bg::distance(seg, p2); 
+
+    BOOST_CHECK_CLOSE(dr1, d1, 0.001);
+    BOOST_CHECK_CLOSE(dr2, d2, 0.001);
+
+    // Test specifying strategy manually:
+    // 1) point-point-distance
+    typename bg::strategy::distance::services::default_strategy<bg::point_tag, P>::type pp_strategy;
+    d1 = bg::distance(p1, seg, pp_strategy); 
+    BOOST_CHECK_CLOSE(d1, return_type(1), 0.001);
+
+    // 2) point-segment-distance
+    typename bg::strategy::distance::services::default_strategy<bg::segment_tag, P>::type ps_strategy;
+    d1 = bg::distance(p1, seg, ps_strategy); 
+    BOOST_CHECK_CLOSE(d1, return_type(1), 0.001);
+
+    // 3) custom point strategy
+    taxicab_distance<P> tcd;
+    return_type d = bg::distance(p1, seg, tcd);
+    BOOST_CHECK_CLOSE(d1, return_type(1), 0.001);
 }
 
+
 template <typename P>
 void test_distance_linestring()
 {
-    typedef typename boost::geometry::coordinate_type<P>::type coordinate_type;
+    typedef typename bg::distance_result<P>::type return_type;
 
     boost::array<P, 2> points;
-    boost::geometry::set<0>(points[0], 1);
-    boost::geometry::set<1>(points[0], 1);
-    boost::geometry::set<0>(points[1], 3);
-    boost::geometry::set<1>(points[1], 3);
+    bg::set<0>(points[0], 1);
+    bg::set<1>(points[0], 1);
+    bg::set<0>(points[1], 3);
+    bg::set<1>(points[1], 3);
 
-#ifndef TEST_ARRAY
-    P p = boost::geometry::make<P>(2, 1);
-#else
     P p;
-    boost::geometry::set<0>(p, 2); boost::geometry::set<1>(p, 1);
-#endif
+    bg::set<0>(p, 2); bg::set<1>(p, 1);
 
-    double d = boost::geometry::distance(p, points);
-    BOOST_CHECK_CLOSE(d, 0.70710678, 0.001);
+    return_type d = bg::distance(p, points);
+    BOOST_CHECK_CLOSE(d, return_type(0.70710678), 0.001);
 
-#ifndef TEST_ARRAY
-    p = boost::geometry::make<P>(5, 5);
-#else
-    boost::geometry::set<0>(p, 5); boost::geometry::set<1>(p, 5);
-#endif
-    d = boost::geometry::distance(p, points);
-    BOOST_CHECK_CLOSE(d, 2.828427, 0.001);
+    bg::set<0>(p, 5); bg::set<1>(p, 5);
+    d = bg::distance(p, points);
+    BOOST_CHECK_CLOSE(d, return_type(2.828427), 0.001);
 
 
-    boost::geometry::linestring<P> line;
-#ifndef TEST_ARRAY
-    line.push_back(boost::geometry::make<P>(1,1));
-    line.push_back(boost::geometry::make<P>(2,2));
-    line.push_back(boost::geometry::make<P>(3,3));
-#else
+    bg::linestring<P> line;
     {
         P lp;
-        boost::geometry::set<0>(lp, 1); boost::geometry::set<1>(lp, 1); line.push_back(lp);
-        boost::geometry::set<0>(lp, 2); boost::geometry::set<1>(lp, 2); line.push_back(lp);
-        boost::geometry::set<0>(lp, 3); boost::geometry::set<1>(lp, 3); line.push_back(lp);
+        bg::set<0>(lp, 1); bg::set<1>(lp, 1); line.push_back(lp);
+        bg::set<0>(lp, 2); bg::set<1>(lp, 2); line.push_back(lp);
+        bg::set<0>(lp, 3); bg::set<1>(lp, 3); line.push_back(lp);
     }
-#endif
 
-#ifndef TEST_ARRAY
-    p = boost::geometry::make<P>(5, 5);
-#else
-    boost::geometry::set<0>(p, 5); boost::geometry::set<1>(p, 5);
-#endif
+    bg::set<0>(p, 5); bg::set<1>(p, 5);
 
-    d = boost::geometry::distance(p, line);
-    BOOST_CHECK_CLOSE(d, 2.828427, 0.001);
+    d = bg::distance(p, line);
+    BOOST_CHECK_CLOSE(d, return_type(2.828427), 0.001);
 
-    // Reverse case
-    d = boost::geometry::distance(line, p);
-    BOOST_CHECK_CLOSE(d, 2.828427, 0.001);
+    // Reverse case: line/point instead of point/line
+    d = bg::distance(line, p);
+    BOOST_CHECK_CLOSE(d, return_type(2.828427), 0.001);
 }
 
+
+template <typename P>
+void test_distance_ring()
+{
+    typedef typename bg::distance_result<P>::type return_type;
+
+    bg::linear_ring<P> ring;
+    {
+        P lp;
+        bg::set<0>(lp, 1); bg::set<1>(lp, 1); line.push_back(lp);
+        bg::set<0>(lp, 2); bg::set<1>(lp, 2); line.push_back(lp);
+        bg::set<0>(lp, 3); bg::set<1>(lp, 3); line.push_back(lp);
+    }
+
+    bg::set<0>(p, 5); bg::set<1>(p, 5);
+
+    d = bg::distance(p, line);
+    BOOST_CHECK_CLOSE(d, return_type(2.828427), 0.001);
+
+    // Reverse case: line/point instead of point/line
+    d = bg::distance(line, p);
+    BOOST_CHECK_CLOSE(d, return_type(2.828427), 0.001);
+}
+
+
 template <typename P>
 void test_all()
 {
-    test_distance_result<P>();
     test_distance_point<P>();
-//    test_distance_segment<P>();
-#ifndef TEST_ARRAY
-    //test_distance_linestring<P>();
-#endif
+    test_distance_segment<P>();
+    test_distance_linestring<P>();
 }
 
 int test_main(int, char* [])
 {
 #ifdef TEST_ARRAY
-    test_all<int[2]>();
-    test_all<float[2]>();
-    test_all<double[2]>();
-    test_all<test::test_point>(); // located here because of 3D
+    //test_all<int[2]>();
+    //test_all<float[2]>();
+    //test_all<double[2]>();
+    //test_all<test::test_point>(); // located here because of 3D
 #endif
 
-    test_all<boost::geometry::point_xy<int> >();
+    test_all<bg::point_xy<int> >();
     test_all<boost::tuple<float, float> >();
-    test_all<boost::geometry::point_xy<float> >();
-    test_all<boost::geometry::point_xy<double> >();
+    test_all<bg::point_xy<float> >();
+    test_all<bg::point_xy<double> >();
 
     return 0;
 }
Modified: sandbox/geometry/libs/geometry/test/algorithms/within.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/within.cpp	(original)
+++ sandbox/geometry/libs/geometry/test/algorithms/within.cpp	2010-07-17 06:46:25 EDT (Sat, 17 Jul 2010)
@@ -77,5 +77,5 @@
     test_all<boost::geometry::point_xy<boost::numeric_adaptor::gmp_value_type> >();
 #endif
 
-        return 0;
+    return 0;
 }