$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r64095 - in sandbox/geometry: boost/geometry/algorithms boost/geometry/core boost/geometry/extensions/gis/io/wkt boost/geometry/geometries/adapted boost/geometry/geometries/concepts boost/geometry/geometries/concepts/detail libs/geometry/test/algorithms
From: barend.gehrels_at_[hidden]
Date: 2010-07-17 10:02:13
Author: barendgehrels
Date: 2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
New Revision: 64095
URL: http://svn.boost.org/trac/boost/changeset/64095
Log:
Removed "use_std" for linestring / linear_ring because it is not necessary. Default now does "push_back", specialization possible
Plus necessary changes for this.
Also moved stuff from test distance to test_distance.hpp
Added:
   sandbox/geometry/boost/geometry/core/container_access.hpp   (contents, props changed)
   sandbox/geometry/libs/geometry/test/algorithms/test_distance.hpp   (contents, props changed)
Text files modified: 
   sandbox/geometry/boost/geometry/algorithms/append.hpp                            |    69 ++++-------                             
   sandbox/geometry/boost/geometry/algorithms/clear.hpp                             |    47 ++-----                                 
   sandbox/geometry/boost/geometry/core/access.hpp                                  |    58 ----------                              
   sandbox/geometry/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp               |    63 ++++++++---                             
   sandbox/geometry/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp |    26 ++++                                    
   sandbox/geometry/boost/geometry/geometries/adapted/std_as_linestring.hpp         |     5                                         
   sandbox/geometry/boost/geometry/geometries/concepts/detail/check_append.hpp      |    60 ----------                              
   sandbox/geometry/boost/geometry/geometries/concepts/detail/check_clear.hpp       |    61 -----------                             
   sandbox/geometry/boost/geometry/geometries/concepts/linestring_concept.hpp       |    12 -                                       
   sandbox/geometry/boost/geometry/geometries/concepts/ring_concept.hpp             |    14 --                                      
   sandbox/geometry/libs/geometry/test/algorithms/distance.cpp                      |   218 ++++++--------------------------------- 
   11 files changed, 159 insertions(+), 474 deletions(-)
Modified: sandbox/geometry/boost/geometry/algorithms/append.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/append.hpp	(original)
+++ sandbox/geometry/boost/geometry/algorithms/append.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -14,6 +14,7 @@
 #include <boost/type_traits/remove_const.hpp>
 
 #include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/container_access.hpp>
 #include <boost/geometry/core/point_type.hpp>
 #include <boost/geometry/core/tags.hpp>
 
@@ -29,23 +30,8 @@
 namespace detail { namespace append
 {
 
-template <typename Geometry, typename Point, bool UseStd>
-struct append_point {};
-
-template <typename Geometry, typename Point>
-struct append_point<Geometry, Point, true>
-{
-    static inline void apply(Geometry& geometry, Point const& point, int , int )
-    {
-        typename point_type<Geometry>::type point_type;
-
-        copy_coordinates(point, point_type);
-        geometry.push_back(point_type);
-    }
-};
-
 template <typename Geometry, typename Point>
-struct append_point<Geometry, Point, false>
+struct append_point
 {
     static inline void apply(Geometry& geometry, Point const& point,
                 int ring_index, int multi_index)
@@ -55,7 +41,7 @@
     }
 };
 
-template <typename Geometry, typename Range, bool UseStd>
+template <typename Geometry, typename Range>
 struct append_range
 {
     typedef typename boost::range_value<Range>::type point_type;
@@ -68,13 +54,13 @@
              it != boost::end(range);
              ++it)
         {
-            append_point<Geometry, point_type, UseStd>::apply(geometry, *it,
+            traits::append_point<Geometry, point_type>::apply(geometry, *it,
                         ring_index, multi_index);
         }
     }
 };
 
-template <typename Polygon, typename Point, bool Std>
+template <typename Polygon, typename Point>
 struct point_to_poly
 {
     typedef typename ring_type<Polygon>::type range_type;
@@ -84,18 +70,18 @@
     {
         if (ring_index == -1)
         {
-            append_point<range_type, Point, Std>::apply(
+            traits::append_point<range_type, Point>::apply(
                         exterior_ring(polygon), point, -1, -1);
         }
         else if (ring_index < int(num_interior_rings(polygon)))
         {
-            append_point<range_type, Point, Std>::apply(
+            traits::append_point<range_type, Point>::apply(
                         interior_rings(polygon)[ring_index], point, -1, -1);
         }
     }
 };
 
-template <typename Polygon, typename Range, bool Std>
+template <typename Polygon, typename Range>
 struct range_to_poly
 {
     typedef typename ring_type<Polygon>::type ring_type;
@@ -105,12 +91,12 @@
     {
         if (ring_index == -1)
         {
-            append_range<ring_type, Range, Std>::apply(
+            append_range<ring_type, Range>::apply(
                         exterior_ring(polygon), range, -1, -1);
         }
         else if (ring_index < int(num_interior_rings(polygon)))
         {
-            append_range<ring_type, Range, Std>::apply(
+            append_range<ring_type, Range>::apply(
                         interior_rings(polygon)[ring_index], range, -1, -1);
         }
     }
@@ -124,32 +110,32 @@
 namespace dispatch
 {
 
-// (RoP = range or point, Std = use std library)
+// (RoP = range or point = use std library)
 
 // Default case (where RoP will be range/array/etc)
-template <typename Tag, typename TagRoP, typename G, typename RoP, bool Std>
-struct append : detail::append::append_range<G, RoP, Std> {};
+template <typename Tag, typename TagRoP, typename G, typename RoP>
+struct append : detail::append::append_range<G, RoP> {};
 
 // Append a point to any geometry
-template <typename Tag, typename G, typename P, bool Std>
-struct append<Tag, point_tag, G, P, Std>
-    : detail::append::append_point<G, P, Std> {};
+template <typename Tag, typename G, typename P>
+struct append<Tag, point_tag, G, P>
+    : detail::append::append_point<G, P> {};
 
 // Never possible to append anything to a point/box/n-sphere
-template <typename TagRoP, typename Point, typename RoP, bool Std>
-struct append<point_tag, TagRoP, Point, RoP, Std> {};
+template <typename TagRoP, typename Point, typename RoP>
+struct append<point_tag, TagRoP, Point, RoP> {};
 
-template <typename TagRoP, typename Box, typename RoP, bool Std>
-struct append<box_tag, TagRoP, Box, RoP, Std> {};
+template <typename TagRoP, typename Box, typename RoP>
+struct append<box_tag, TagRoP, Box, RoP> {};
 
 
-template <typename Polygon, typename TagRange, typename Range, bool Std>
-struct append<polygon_tag, TagRange, Polygon, Range, Std>
-        : detail::append::range_to_poly<Polygon, Range, Std> {};
+template <typename Polygon, typename TagRange, typename Range>
+struct append<polygon_tag, TagRange, Polygon, Range>
+        : detail::append::range_to_poly<Polygon, Range> {};
 
-template <typename Polygon, typename Point, bool Std>
-struct append<polygon_tag, point_tag, Polygon, Point, Std>
-        : detail::append::point_to_poly<Polygon, Point, Std> {};
+template <typename Polygon, typename Point>
+struct append<polygon_tag, point_tag, Polygon, Point>
+        : detail::append::point_to_poly<Polygon, Point> {};
 
 // Multi-linestring and multi-polygon might either implement traits
 // or use standard...
@@ -180,8 +166,7 @@
             typename tag<Geometry>::type,
             typename tag<RoP>::type,
             ncg_type,
-            RoP,
-            traits::use_std<ncg_type>::value
+            RoP
         >::apply(geometry, range_or_point, ring_index, multi_index);
 }
 
Modified: sandbox/geometry/boost/geometry/algorithms/clear.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/clear.hpp	(original)
+++ sandbox/geometry/boost/geometry/algorithms/clear.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -13,6 +13,7 @@
 #include <boost/type_traits/remove_const.hpp>
 
 #include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/container_access.hpp>
 #include <boost/geometry/core/exterior_ring.hpp>
 #include <boost/geometry/core/interior_rings.hpp>
 
@@ -27,16 +28,7 @@
 {
 
 template <typename Geometry>
-struct use_std_clear
-{
-    static inline void apply(Geometry& geometry)
-    {
-        geometry.clear();
-    }
-};
-
-template <typename Geometry>
-struct use_traits_clear
+struct collection_clear
 {
     static inline void apply(Geometry& geometry)
     {
@@ -69,45 +61,40 @@
 namespace dispatch
 {
 
-template <typename Tag, bool UseStd, typename Geometry>
-struct clear
-{};
-
-// True (default for all geometry types, unless otherwise implemented in traits)
-// uses std::clear
 template <typename Tag, typename Geometry>
-struct clear<Tag, true, Geometry>
-    : detail::clear::use_std_clear<Geometry>
-{};
-
-// If any geometry specializes use_std<Geometry> to false, specialize to use the traits clear.
-template <typename Tag, typename Geometry>
-struct clear<Tag, false, Geometry>
-    : detail::clear::use_traits_clear<Geometry>
+struct clear
 {};
 
 // Point/box/segment do not have clear. So specialize to do nothing.
 template <typename Geometry>
-struct clear<point_tag, true, Geometry>
+struct clear<point_tag, Geometry>
     : detail::clear::no_action<Geometry>
 {};
 
 template <typename Geometry>
-struct clear<box_tag, true, Geometry>
+struct clear<box_tag, Geometry>
     : detail::clear::no_action<Geometry>
 {};
 
 template <typename Geometry>
-struct clear<segment_tag, true, Geometry>
+struct clear<segment_tag, Geometry>
     : detail::clear::no_action<Geometry>
 {};
 
+template <typename Geometry>
+struct clear<linestring_tag, Geometry>
+    : detail::clear::collection_clear<Geometry>
+{};
 
+template <typename Geometry>
+struct clear<ring_tag, Geometry>
+    : detail::clear::collection_clear<Geometry>
+{};
 
 
 // Polygon can (indirectly) use std for clear
 template <typename Polygon>
-struct clear<polygon_tag, true, Polygon>
+struct clear<polygon_tag, Polygon>
     : detail::clear::polygon_clear<Polygon>
 {};
 
@@ -130,10 +117,6 @@
     dispatch::clear
         <
             typename tag<Geometry>::type,
-            traits::use_std
-                <
-                    typename boost::remove_const<Geometry>::type
-                >::value,
             Geometry
         >::apply(geometry);
 }
Modified: sandbox/geometry/boost/geometry/core/access.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/core/access.hpp	(original)
+++ sandbox/geometry/boost/geometry/core/access.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -47,10 +47,10 @@
 {
 
 /// Index of minimum corner of the box.
-const int min_corner = 0;
+int const min_corner = 0;
 
 /// Index of maximum corner of the box.
-const int max_corner = 1;
+int const max_corner = 1;
 
 namespace traits
 {
@@ -86,60 +86,6 @@
 struct indexed_access {};
 
 
-/*!
-\brief Traits class, optional, indicating that the std-library should be used
-\details The default geometry (linestring, ring, multi*) follow std:: for
-    its modifying operations (push_back, clear, size, resize, reserve, etc)
-    If they NOT follow the std:: library they should specialize this traits
-    class
-\ingroup traits
-\par Geometries:
-    - linestring
-    - linear_ring
-\par Specializations should provide:
-    - value (defaults to true)
- */
-template <typename Geometry>
-struct use_std
-{
-    static const bool value = true;
-};
-
-
-/*!
-\brief Traits class, optional, might be implemented to clear a geometry
-\details If a geometry type should not use the std ".clear()"
-    then it can specialize the "use_std" traits class to false,
-    it should then implement (a.o.) clear
-\ingroup traits
-\par Geometries:
-    - linestring
-    - linear_ring
-\par Specializations should provide:
-    - apply
- */
-template <typename Geometry>
-struct clear
-{};
-
-
-/*!
-\brief Traits class, optional, might be implemented to append a point
-\details If a geometry type should not use the std "push_back"
-    then it can specialize the "use_std" traits class to false,
-    it should then implement (a.o.) append_point
-\ingroup traits
-\par Geometries:
-    - linestring
-    - linear_ring
-\par Specializations should provide:
-    - apply
- */
-template <typename Geometry, typename Point>
-struct append_point
-{};
-
-
 } // namespace traits
 
 
Added: sandbox/geometry/boost/geometry/core/container_access.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/core/container_access.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -0,0 +1,80 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_CONTAINER_ACCESS_HPP
+#define BOOST_GEOMETRY_CORE_CONTAINER_ACCESS_HPP
+
+#include <cstddef>
+
+#include <boost/type_traits/remove_const.hpp>
+#include <boost/concept_check.hpp>
+
+#include <boost/geometry/core/coordinate_type.hpp>
+#include <boost/geometry/core/point_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+namespace traits
+{
+
+
+/*!
+\brief Traits class, optional, might be implemented to clear a geometry
+\details If a geometry type should not use the std ".clear()"
+    then it can specialize the "use_std" traits class to false,
+    it should then implement (a.o.) clear
+\ingroup traits
+\par Geometries:
+    - linestring
+    - linear_ring
+\par Specializations should provide:
+    - apply
+ */
+template <typename Geometry>
+struct clear
+{
+    static inline void apply(Geometry& geometry)
+    {
+        geometry.clear();
+    }
+};
+
+
+/*!
+\brief Traits class, optional, might be implemented to append a point
+\details If a geometry type should not use the std "push_back"
+    then it can specialize the "use_std" traits class to false,
+    it should then implement (a.o.) append_point
+\ingroup traits
+\par Geometries:
+    - linestring
+    - linear_ring
+\par Specializations should provide:
+    - apply
+ */
+template <typename Geometry, typename Point>
+struct append_point
+{
+    static inline void apply(Geometry& geometry, Point const& point, int , int )
+    {
+        typename geometry::point_type<Geometry>::type copy;
+        copy_coordinates(point, copy);
+        geometry.push_back(copy);
+    }
+};
+
+
+} // namespace traits
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_CORE_CONTAINER_ACCESS_HPP
Modified: sandbox/geometry/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp	(original)
+++ sandbox/geometry/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -22,6 +22,7 @@
 
 
 #include <boost/geometry/algorithms/assign.hpp>
+#include <boost/geometry/algorithms/append.hpp>
 #include <boost/geometry/algorithms/clear.hpp>
 
 #include <boost/geometry/core/access.hpp>
@@ -229,6 +230,40 @@
     }
 };
 
+
+template <typename Geometry>
+struct container_appender
+{
+    typedef typename geometry::point_type<Geometry>::type point_type;
+    static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
+        std::string const& wkt, Geometry& out)
+    {
+        handle_open_parenthesis(it, end, wkt);
+
+        point_type point;
+
+        // Parse points until closing parenthesis
+
+        while (it != end && *it != ")")
+        {
+            parsing_assigner
+                <
+                    point_type,
+                    0,
+                    dimension<point_type>::value
+                >::apply(it, end, point, wkt);
+
+            geometry::append(out, point);
+            if (it != end && *it == ",")
+            {
+                ++it;
+            }
+        }
+
+        handle_close_parenthesis(it, end, wkt);
+    }
+};
+
 /*!
 \brief Internal, parses a point from a string like this "(x y)"
 \note used for parsing points and multi-points
@@ -252,10 +287,7 @@
     static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
                 std::string const& wkt, Geometry& geometry)
     {
-        container_inserter
-            <
-                typename point_type<Geometry>::type
-            >::apply(it, end, wkt, std::back_inserter(geometry));
+        container_appender<Geometry>::apply(it, end, wkt, geometry);
     }
 };
 
@@ -270,10 +302,7 @@
         // So handle the extra opening/closing parentheses
         // and in between parse using the container-inserter
         handle_open_parenthesis(it, end, wkt);
-        container_inserter
-            <
-                typename point_type<Ring>::type
-            >::apply(it, end, wkt, std::back_inserter(ring));
+        container_appender<Ring>::apply(it, end, wkt, ring);
         handle_close_parenthesis(it, end, wkt);
     }
 };
@@ -288,13 +317,12 @@
 template <typename Polygon>
 struct polygon_parser
 {
+    typedef typename ring_type<Polygon>::type ring_type;
+
     static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
                 std::string const& wkt, Polygon& poly)
     {
-        typedef container_inserter
-            <
-                typename point_type<Polygon>::type
-            > container_inserter;
+        typedef container_appender<ring_type> appender;
 
         handle_open_parenthesis(it, end, wkt);
 
@@ -306,14 +334,13 @@
             // Parse ring
             if (++n == 0)
             {
-                container_inserter::apply(it, end, wkt,
-                        std::back_inserter(exterior_ring(poly)));
+                appender::apply(it, end, wkt, exterior_ring(poly));
             }
             else
             {
                 interior_rings(poly).resize(n);
-                container_inserter::apply(it, end, wkt,
-                        std::back_inserter(interior_rings(poly).back()));
+                appender::apply(it, end, wkt,
+                        interior_rings(poly).back());
             }
 
             if (it != end && *it == ",")
@@ -665,8 +692,8 @@
 \line {
 \until }
 */
-template <typename Point, typename Out>
-inline void read_wkt(std::string const& wkt, Out out)
+template <typename Point, typename OutputIterator>
+inline void read_wkt(std::string const& wkt, OutputIterator out)
 {
     geometry::concept::check<Point>();
 
Modified: sandbox/geometry/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp	(original)
+++ sandbox/geometry/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -22,6 +22,7 @@
 
 #include <boost/array.hpp>
 
+#include <boost/geometry/core/container_access.hpp>
 #include <boost/geometry/core/tag.hpp>
 #include <boost/geometry/core/tags.hpp>
 
@@ -34,12 +35,33 @@
 namespace traits
 {
 
-    template <typename PointType, std::size_t DimensionCount>
-    struct tag< boost::array<PointType, DimensionCount> >
+    template <typename Point, std::size_t PointCount>
+    struct tag< boost::array<Point, PointCount> >
     {
         typedef linestring_tag type;
     };
 
+    // Clear does not exist for a boost::array
+    // It should not be used, and therefore: throw
+    template <typename Point, std::size_t PointCount>
+    struct clear< boost::array<Point, PointCount> >
+    {
+        static inline void apply(boost::array<Point, PointCount>& )
+        {
+        }
+    };
+
+    // Append does not exist for a boost::array
+    // It should not be used, and therefore: throw
+    template <typename Point, std::size_t PointCount, typename Point2>
+    struct append_point< boost::array<Point, PointCount>, Point2 >
+    {
+        static inline void apply(boost::array<Point, PointCount>& ,
+                        Point const& , int , int )
+        {
+        }
+    };
+
 }
 #endif
 
Modified: sandbox/geometry/boost/geometry/geometries/adapted/std_as_linestring.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/adapted/std_as_linestring.hpp	(original)
+++ sandbox/geometry/boost/geometry/geometries/adapted/std_as_linestring.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -25,6 +25,7 @@
 
 
 #include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/container_access.hpp>
 #include <boost/geometry/core/tag.hpp>
 #include <boost/geometry/core/tags.hpp>
 
@@ -51,10 +52,6 @@
     // specialization for an iterator pair (read only)
     template <typename P> struct tag< std::pair<P, P> > : util::std_as_linestring {};
 
-    // Indicate that std::library is not used to add things to std::pair.
-    // Don't implement anything else -> adding points or clearing not possible
-    template <typename P> struct use_std< std::pair<P, P> > : boost::mpl::false_ {};
-
     // specializations for the std:: containers: vector, deque, list
     template <typename P> struct tag< std::vector<P> > : util::std_as_linestring {};
     template <typename P> struct tag< std::deque<P> > : util::std_as_linestring {};
Modified: sandbox/geometry/boost/geometry/geometries/concepts/detail/check_append.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/concepts/detail/check_append.hpp	(original)
+++ sandbox/geometry/boost/geometry/geometries/concepts/detail/check_append.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -1,59 +1 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-//
-// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
-// Copyright Bruno Lalande 2008, 2009
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-
-#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DETAIL_CHECK_APPEND_HPP
-#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DETAIL_CHECK_APPEND_HPP
-
-
-#include <boost/type_traits/remove_const.hpp>
-
-#include <boost/geometry/core/access.hpp>
-
-
-namespace boost { namespace geometry { namespace concept
-{
-
-#ifndef DOXYGEN_NO_DETAIL
-namespace detail
-{
-
-    template <typename Geometry, typename Point, bool UseStd>
-    struct check_append
-    {};
-
-    template <typename Geometry, typename Point>
-    struct check_append<Geometry, Point, true>
-    {
-        static void apply(Geometry& geometry, Point const& p)
-        {
-            geometry.push_back(p);
-        }
-    };
-
-
-    template <typename Geometry, typename Point>
-    struct check_append<Geometry, Point, false>
-    {
-        static void apply(Geometry& geometry, Point const& p)
-        {
-            geometry::traits::append_point
-                <
-                     typename boost::remove_const<Geometry>::type,
-                     Point
-                >::apply(geometry, p, -1, -1);
-        }
-    };
-}
-#endif // DOXYGEN_NO_DETAIL
-
-
-}}} // namespace boost::geometry::concept
-
-
-#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DETAIL_CHECK_APPEND_HPP
+// obsolete
Modified: sandbox/geometry/boost/geometry/geometries/concepts/detail/check_clear.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/concepts/detail/check_clear.hpp	(original)
+++ sandbox/geometry/boost/geometry/geometries/concepts/detail/check_clear.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -1,60 +1 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-//
-// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
-// Copyright Bruno Lalande 2008, 2009
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-
-#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DETAIL_CHECK_CLEAR_HPP
-#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DETAIL_CHECK_CLEAR_HPP
-
-
-#include <boost/type_traits/remove_const.hpp>
-
-#include <boost/geometry/core/access.hpp>
-
-
-namespace boost { namespace geometry { namespace concept
-{
-
-
-#ifndef DOXYGEN_NO_DETAIL
-namespace detail
-{
-
-    template <typename Geometry, bool UseStd>
-    struct check_clear
-    {};
-
-    template <typename Geometry>
-    struct check_clear<Geometry, true>
-    {
-        static void apply(Geometry& geometry)
-        {
-            geometry.clear();
-        }
-    };
-
-
-    template <typename Geometry>
-    struct check_clear<Geometry, false>
-    {
-        static void apply(Geometry& geometry)
-        {
-            geometry::traits::clear
-                <
-                     typename boost::remove_const<Geometry>::type
-                >::apply(geometry);
-        }
-    };
-
-}
-#endif // DOXYGEN_NO_DETAIL
-
-
-}}} // namespace boost::geometry::concept
-
-
-#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_DETAIL_CHECK_CLEAR_HPP
+// obsolete
Modified: sandbox/geometry/boost/geometry/geometries/concepts/linestring_concept.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/concepts/linestring_concept.hpp	(original)
+++ sandbox/geometry/boost/geometry/geometries/concepts/linestring_concept.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -16,12 +16,11 @@
 #include <boost/type_traits/remove_const.hpp>
 
 #include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/container_access.hpp>
 #include <boost/geometry/core/point_type.hpp>
 
 #include <boost/geometry/geometries/concepts/point_concept.hpp>
 
-#include <boost/geometry/geometries/concepts/detail/check_clear.hpp>
-#include <boost/geometry/geometries/concepts/detail/check_append.hpp>
 
 
 namespace boost { namespace geometry { namespace concept
@@ -86,16 +85,11 @@
     BOOST_CONCEPT_USAGE(Linestring)
     {
         // Check if it can be modified
-        static const bool use_std = traits::use_std
-            <
-                typename boost::remove_const<Geometry>::type
-            >::value;
-
         Geometry* ls;
-        detail::check_clear<Geometry, use_std>::apply(*ls);
+        traits::clear<Geometry>::apply(*ls);
 
         point_type* p;
-        detail::check_append<Geometry, point_type, use_std>::apply(*ls, *p);
+        traits::append_point<Geometry, point_type>::apply(*ls, *p, -1, -1);
     }
 #endif
 };
Modified: sandbox/geometry/boost/geometry/geometries/concepts/ring_concept.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/concepts/ring_concept.hpp	(original)
+++ sandbox/geometry/boost/geometry/geometries/concepts/ring_concept.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -16,13 +16,11 @@
 #include <boost/type_traits/remove_const.hpp>
 
 #include <boost/geometry/core/access.hpp>
+#include <boost/geometry/core/container_access.hpp>
 #include <boost/geometry/core/point_type.hpp>
 
 #include <boost/geometry/geometries/concepts/point_concept.hpp>
 
-#include <boost/geometry/geometries/concepts/detail/check_clear.hpp>
-#include <boost/geometry/geometries/concepts/detail/check_append.hpp>
-
 
 namespace boost { namespace geometry { namespace concept
 {
@@ -58,17 +56,11 @@
 
     BOOST_CONCEPT_USAGE(Ring)
     {
-        // Check if it can be modified
-        static const bool use_std = traits::use_std
-            <
-                typename boost::remove_const<Geometry>::type
-            >::value;
-
         Geometry* ring;
-        detail::check_clear<Geometry, use_std>::apply(*ring);
+        traits::clear<Geometry>::apply(*ring);
 
         point_type* p;
-        detail::check_append<Geometry, point_type, use_std>::apply(*ring, *p);
+        traits::append_point<Geometry, point_type>::apply(*ring, *p, -1, -1);
     }
 #endif
 };
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 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -10,16 +10,9 @@
 
 #include <sstream>
 
-#include <boost/mpl/if.hpp>
-#include <geometry_test_common.hpp>
-
-
-#include <boost/geometry/algorithms/distance.hpp>
-#include <boost/geometry/strategies/strategies.hpp>
+#include <algorithms/test_distance.hpp>
 
-#ifndef TEST_ARRAY
-#include <boost/geometry/algorithms/make.hpp>
-#endif
+#include <boost/mpl/if.hpp>
 
 #include <boost/geometry/geometries/geometries.hpp>
 #include <boost/geometry/geometries/adapted/boost_array_as_linestring.hpp>
@@ -31,154 +24,44 @@
 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
-{
-    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));
-    }
-};
-
-
-
-namespace boost { namespace geometry { namespace strategy { namespace distance { namespace services 
-{
-
-template <typename P1, typename P2>
-struct tag<taxicab_distance<P1, P2> >
-{
-    typedef strategy_tag_distance_point_point type;
-};
-
-
-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;
-};
-
-
-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()
 {
     namespace services = bg::strategy::distance::services;
     typedef typename bg::distance_result<P>::type return_type;
 
-    {
-        // Basic, trivial test
+    // Basic, trivial test
 
-        P p1;
-        bg::set<0>(p1, 1);
-        bg::set<1>(p1, 1);
+    P p1;
+    bg::set<0>(p1, 1);
+    bg::set<1>(p1, 1);
 
-        P p2;
-        bg::set<0>(p2, 2);
-        bg::set<1>(p2, 2);
+    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);
+    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;
+    // 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);
+    d = bg::distance(p1, p2, strategy);
+    BOOST_CHECK_CLOSE(d, return_type(1.4142135), 0.001);
 
-        {
-            // Test custom strategy
-            BOOST_CONCEPT_ASSERT( (bg::concept::PointDistanceStrategy<taxicab_distance<P> >) );
+    {
+        // 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>));
+        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);
+        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) );
-        }
+        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
 
@@ -260,7 +143,8 @@
     bg::set<1>(points[1], 3);
 
     P p;
-    bg::set<0>(p, 2); bg::set<1>(p, 1);
+    bg::set<0>(p, 2); 
+    bg::set<1>(p, 1);
 
     return_type d = bg::distance(p, points);
     BOOST_CHECK_CLOSE(d, return_type(0.70710678), 0.001);
@@ -268,49 +152,9 @@
     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);
-
-
-    bg::linestring<P> line;
-    {
-        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_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>
@@ -319,6 +163,18 @@
     test_distance_point<P>();
     test_distance_segment<P>();
     test_distance_linestring<P>();
+
+    test_geometry<P, P>("POINT(1 1)", "POINT(2 2)", sqrt(2.0));
+    test_geometry<P, P>("POINT(0 0)", "POINT(0 3)", 3.0);
+    test_geometry<P, P>("POINT(0 0)", "POINT(4 0)", 4.0);
+    test_geometry<P, P>("POINT(0 3)", "POINT(4 0)", 5.0);
+    test_geometry<P, bg::linestring<P> >("POINT(1 3)", "LINESTRING(1 1,4 4)", sqrt(2.0));
+    test_geometry<P, bg::linestring<P> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
+
+    // This one COMPILES but should THROW
+    //test_geometry<P, boost::array<P, 2> >("POINT(3 1)", "LINESTRING(1 1,4 4)", sqrt(2.0));
+
+    test_geometry<bg::linestring<P>, P>("LINESTRING(1 1,4 4)", "POINT(1 3)", sqrt(2.0));
 }
 
 int test_main(int, char* [])
Added: sandbox/geometry/libs/geometry/test/algorithms/test_distance.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/libs/geometry/test/algorithms/test_distance.hpp	2010-07-17 10:02:12 EDT (Sat, 17 Jul 2010)
@@ -0,0 +1,143 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library) test file
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_TEST_DISTANCE_HPP
+#define BOOST_GEOMETRY_TEST_DISTANCE_HPP
+
+#include <geometry_test_common.hpp>
+
+#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/extensions/gis/io/wkt/read_wkt.hpp>
+#include <boost/geometry/strategies/strategies.hpp>
+
+
+// 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
+{
+    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));
+    }
+};
+
+
+
+namespace boost { namespace geometry { namespace strategy { namespace distance { namespace services 
+{
+
+template <typename P1, typename P2>
+struct tag<taxicab_distance<P1, P2> >
+{
+    typedef strategy_tag_distance_point_point type;
+};
+
+
+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;
+};
+
+
+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 Geometry1, typename Geometry2>
+void test_distance(Geometry1 const& geometry1, 
+            Geometry2 const& geometry2,
+            long double expected_distance)
+{
+    long double distance = boost::geometry::distance(geometry1, geometry2);
+
+#ifdef GEOMETRY_TEST_DEBUG
+    std::ostringstream out;
+    out << typeid(typename boost::geometry::coordinate_type<Geometry1>::type).name()
+        << std::endl
+        << typeid(typename boost::geometry::distance_result<Geometry1>::type).name()
+        << std::endl
+        << "distance : " << boost::geometry::distance(geometry1, geometry2)
+        << std::endl;
+    std::cout << out.str();
+#endif
+
+    BOOST_CHECK_CLOSE(distance, expected_distance, 0.0001);
+}
+
+
+template <typename Geometry1, typename Geometry2>
+void test_geometry(std::string const& wkt1, std::string const& wkt2, double expected_distance)
+{
+    Geometry1 geometry1; 
+    boost::geometry::read_wkt(wkt1, geometry1);
+    Geometry2 geometry2; 
+    boost::geometry::read_wkt(wkt2, geometry2);
+
+    test_distance(geometry1, geometry2, expected_distance);
+}
+
+
+#endif