Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57069 - in sandbox/ggl/formal_review_request/boost/ggl: algorithms algorithms/detail algorithms/overlay core extensions/gis/io/wkt geometries geometries/adapted geometries/register iterators multi/algorithms multi/algorithms/detail multi/core multi/util strategies util
From: barend.gehrels_at_[hidden]
Date: 2009-10-22 11:25:22


Author: barendgehrels
Date: 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
New Revision: 57069
URL: http://svn.boost.org/trac/boost/changeset/57069

Log:
Various update/fixes for a.o. length, perimeter, area, for_each, return types
Added:
   sandbox/ggl/formal_review_request/boost/ggl/algorithms/detail/calculate_sum.hpp (contents, props changed)
   sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/for_each.hpp
      - copied, changed from r56825, /sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/foreach.hpp
   sandbox/ggl/formal_review_request/boost/ggl/multi/util/
   sandbox/ggl/formal_review_request/boost/ggl/multi/util/as_range.hpp (contents, props changed)
   sandbox/ggl/formal_review_request/boost/ggl/multi/util/write_dsv.hpp (contents, props changed)
   sandbox/ggl/formal_review_request/boost/ggl/strategies/area_result.hpp (contents, props changed)
   sandbox/ggl/formal_review_request/boost/ggl/strategies/length_result.hpp (contents, props changed)
Removed:
   sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/foreach.hpp
Text files modified:
   sandbox/ggl/formal_review_request/boost/ggl/algorithms/area.hpp | 84 +++-------
   sandbox/ggl/formal_review_request/boost/ggl/algorithms/detail/calculate_null.hpp | 6
   sandbox/ggl/formal_review_request/boost/ggl/algorithms/for_each.hpp | 315 +++++++++++++++++++++++++--------------
   sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersection.hpp | 3
   sandbox/ggl/formal_review_request/boost/ggl/algorithms/length.hpp | 75 +++++---
   sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/intersection_point.hpp | 10
   sandbox/ggl/formal_review_request/boost/ggl/algorithms/perimeter.hpp | 74 +++-----
   sandbox/ggl/formal_review_request/boost/ggl/core/access.hpp | 121 +++++++++-----
   sandbox/ggl/formal_review_request/boost/ggl/core/reverse_dispatch.hpp | 2
   sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/read_wkt.hpp | 1
   sandbox/ggl/formal_review_request/boost/ggl/geometries/adapted/c_array.hpp | 30 +-
   sandbox/ggl/formal_review_request/boost/ggl/geometries/adapted/tuple.hpp | 94 +++++++----
   sandbox/ggl/formal_review_request/boost/ggl/geometries/box.hpp | 67 ++++---
   sandbox/ggl/formal_review_request/boost/ggl/geometries/nsphere.hpp | 42 ++--
   sandbox/ggl/formal_review_request/boost/ggl/geometries/point.hpp | 67 ++++++--
   sandbox/ggl/formal_review_request/boost/ggl/geometries/point_xy.hpp | 45 ++---
   sandbox/ggl/formal_review_request/boost/ggl/geometries/register/point.hpp | 34 ++-
   sandbox/ggl/formal_review_request/boost/ggl/geometries/segment.hpp | 89 ++++++----
   sandbox/ggl/formal_review_request/boost/ggl/iterators/base.hpp | 1
   sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/area.hpp | 22 ++
   sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/detail/multi_sum.hpp | 15 -
   sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/for_each.hpp | 300 ++++++++++++-------------------------
   sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/length.hpp | 29 ++-
   sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/perimeter.hpp | 28 ++
   sandbox/ggl/formal_review_request/boost/ggl/multi/core/tags.hpp | 36 ++++
   sandbox/ggl/formal_review_request/boost/ggl/strategies/distance_result.hpp | 20 ++
   sandbox/ggl/formal_review_request/boost/ggl/util/write_dsv.hpp | 114 ++++++++-----
   27 files changed, 946 insertions(+), 778 deletions(-)

Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/area.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/area.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/area.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -10,10 +10,10 @@
 #define GGL_ALGORITHMS_AREA_HPP
 
 #include <boost/concept/requires.hpp>
+#include <boost/mpl/if.hpp>
 #include <boost/range/functions.hpp>
 #include <boost/range/metafunctions.hpp>
 
-#include <ggl/algorithms/detail/calculate_null.hpp>
 
 #include <ggl/core/point_order.hpp>
 #include <ggl/core/exterior_ring.hpp>
@@ -22,7 +22,11 @@
 #include <ggl/core/concepts/point_concept.hpp>
 #include <ggl/core/concepts/nsphere_concept.hpp>
 
+#include <ggl/algorithms/detail/calculate_null.hpp>
+#include <ggl/algorithms/detail/calculate_sum.hpp>
+
 #include <ggl/strategies/strategies.hpp>
+#include <ggl/strategies/area_result.hpp>
 
 #include <ggl/util/loop.hpp>
 #include <ggl/util/math.hpp>
@@ -149,43 +153,6 @@
 };
 
 
-// Area of a polygon, either clockwise or anticlockwise
-template<typename Polygon, order_selector Order, typename Strategy>
-class polygon_area
-{
- typedef typename Strategy::return_type type;
-
-public:
- static inline type apply(Polygon const& poly,
- Strategy const& strategy)
- {
- assert_dimension<Polygon, 2>();
-
- typedef ring_area
- <
- typename ring_type<Polygon>::type,
- Order,
- Strategy
- > ring_area_type;
-
- typedef typename boost::range_const_iterator
- <
- typename interior_type<Polygon>::type
- >::type iterator_type;
-
- type a = ring_area_type::apply(exterior_ring(poly), strategy);
-
- for (iterator_type it = boost::begin(interior_rings(poly));
- it != boost::end(interior_rings(poly)); ++it)
- {
- // Add ring-area (area of hole should be negative
- // (because other order))
- a += ring_area_type::apply(*it, strategy);
- }
- return a;
- }
-};
-
 }} // namespace detail::area
 
 #endif // DOXYGEN_NO_DETAIL
@@ -205,39 +172,44 @@
 
 template <typename Geometry, order_selector Order, typename Strategy>
 struct area<box_tag, Geometry, Order, Strategy>
- : detail::area::box_area<Geometry, Strategy> {};
+ : detail::area::box_area<Geometry, Strategy>
+{};
 
 
 template <typename Geometry, order_selector Order, typename Strategy>
 struct area<nsphere_tag, Geometry, Order, Strategy>
- : detail::area::circle_area<Geometry, Strategy> {};
+ : detail::area::circle_area<Geometry, Strategy>
+{};
 
 
 // Area of ring currently returns area of closed rings but it might be argued
 // that it is 0.0, because a ring is just a line.
 template <typename Geometry, order_selector Order, typename Strategy>
 struct area<ring_tag, Geometry, Order, Strategy>
- : detail::area::ring_area<Geometry, Order, Strategy> {};
+ : detail::area::ring_area<Geometry, Order, Strategy>
+{};
 
-template <typename Geometry, order_selector Order, typename Strategy>
-struct area<polygon_tag, Geometry, Order, Strategy>
- : detail::area::polygon_area<Geometry, Order, Strategy> {};
+template <typename Polygon, order_selector Order, typename Strategy>
+struct area<polygon_tag, Polygon, Order, Strategy>
+ : detail::calculate_polygon_sum
+ <
+ typename Strategy::return_type,
+ Polygon,
+ Strategy,
+ detail::area::ring_area
+ <
+ typename ring_type<Polygon>::type,
+ Order,
+ Strategy
+ >
+ >
+ //: detail::area::polygon_area<Geometry, Order, Strategy>
+{};
 
 } // namespace dispatch
 #endif // DOXYGEN_NO_DISPATCH
 
 
-template <typename Geometry>
-struct area_result
-{
- typedef typename point_type<Geometry>::type point_type;
- typedef typename strategy_area
- <
- typename cs_tag<point_type>::type,
- point_type
- >::type strategy_type;
- typedef typename strategy_type::return_type return_type;
-};
 
 /*!
     \brief Calculate area of a geometry
@@ -251,7 +223,7 @@
     \return the area
  */
 template <typename Geometry>
-inline typename area_result<Geometry>::return_type area(Geometry const& geometry)
+inline typename area_result<Geometry>::type area(Geometry const& geometry)
 {
     typedef typename area_result<Geometry>::strategy_type strategy_type;
 

Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/detail/calculate_null.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/detail/calculate_null.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/detail/calculate_null.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -16,12 +16,12 @@
 namespace detail
 {
 
-template<typename ReturnValue, typename Geometry, typename Strategy>
+template<typename ReturnType, typename Geometry, typename Strategy>
 struct calculate_null
 {
- static inline ReturnValue apply(Geometry const& , Strategy const&)
+ static inline ReturnType apply(Geometry const& , Strategy const&)
     {
- return ReturnValue();
+ return ReturnType();
     }
 };
 

Added: sandbox/ggl/formal_review_request/boost/ggl/algorithms/detail/calculate_sum.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/detail/calculate_sum.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,51 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
+#define GGL_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP
+
+namespace ggl
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
+template
+<
+ typename ReturnType,
+ typename Polygon,
+ typename Strategy,
+ typename Policy
+>
+struct calculate_polygon_sum
+{
+ static inline ReturnType apply(Polygon const& poly, Strategy const& strategy)
+ {
+ ReturnType sum = Policy::apply(exterior_ring(poly), strategy);
+
+ for (typename boost::range_const_iterator
+ <
+ typename interior_type<Polygon>::type
+ >::type it = boost::begin(interior_rings(poly));
+ it != boost::end(interior_rings(poly));
+ ++it)
+ {
+ sum += Policy::apply(*it, strategy);
+ }
+ return sum;
+ }
+};
+
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+} // namespace ggl
+
+#endif // GGL_ALGORITHMS_DETAIL_CALCULATE_SUM_HPP

Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/for_each.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/for_each.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/for_each.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -21,13 +21,16 @@
 #include <algorithm>
 
 #include <boost/concept/requires.hpp>
+#include <boost/mpl/if.hpp>
 #include <boost/range/functions.hpp>
 #include <boost/range/metafunctions.hpp>
 
 #include <ggl/core/exterior_ring.hpp>
 #include <ggl/core/interior_rings.hpp>
+#include <ggl/core/is_multi.hpp>
 #include <ggl/core/concepts/point_concept.hpp>
 #include <ggl/geometries/segment.hpp>
+#include <ggl/iterators/vertex_iterator.hpp>
 
 namespace ggl
 {
@@ -35,146 +38,160 @@
 #ifndef DOXYGEN_NO_DETAIL
 namespace detail { namespace for_each {
 
-template <typename P, typename F>
-struct fe_point
+
+// There is probably something in boost type_traits
+// or MPL with this functionality
+template <typename Type, bool IsConst>
+struct c_nc
 {
- static inline F for_each_const_point(P const& p, F f)
- {
- f(p);
- return (f);
- }
+ typedef typename boost::mpl::if_c
+ <
+ IsConst,
+ const Type,
+ Type
+ >::type type;
+};
+
+// Utility to adapt a boost-range for const/non const
+template <typename Range, bool IsConst>
+struct c_nc_range
+{
+ typedef typename boost::mpl::if_c
+ <
+ IsConst,
+ typename boost::range_const_iterator<Range>::type,
+ typename boost::range_iterator<Range>::type
+ >::type type;
+};
 
- static inline F for_each_point(P& p, F f)
+
+template <typename Point, typename Functor, bool IsConst>
+struct fe_point_per_point
+{
+ static inline Functor apply(
+ typename c_nc<Point, IsConst>::type& point, Functor f)
     {
- f(p);
- return (f);
+ f(point);
+ return f;
     }
 };
 
-template <typename R, typename F>
-struct fe_range
+template <typename Point, typename Functor, bool IsConst>
+struct fe_point_per_segment
 {
- static inline F for_each_const_point(R const& range, F f)
+ static inline Functor apply(
+ typename c_nc<Point, IsConst>::type& point, Functor f)
     {
- return (std::for_each(boost::begin(range), boost::end(range), f));
+ return f;
     }
+};
 
- static inline F for_each_point(R& range, F f)
+template <typename Range, typename Functor, bool IsConst>
+struct fe_range_per_point
+{
+ static inline Functor apply(
+ typename c_nc<Range, IsConst>::type& range,
+ Functor f)
     {
         return (std::for_each(boost::begin(range), boost::end(range), f));
     }
+};
 
- static inline F for_each_const_segment(R const& range, F f)
+template <typename Range, typename Functor, bool IsConst>
+struct fe_range_per_segment
+{
+ static inline Functor apply(
+ typename c_nc<Range, IsConst>::type& range,
+ Functor f)
     {
- typedef typename boost::range_const_iterator<R>::type iterator_type;
-
- iterator_type it = boost::begin(range);
- iterator_type previous = it++;
- while(it != boost::end(range))
- {
- segment<typename point_type<R>::type> s(*previous, *it);
- f(s);
- previous = it++;
- }
+ typedef typename ggl::vertex_iterator<Range, IsConst>::type iterator_type;
 
- return (f);
- }
-
- static inline F for_each_segment(R& range, F f)
- {
- typedef typename boost::range_iterator<R>::type iterator_type;
+ typedef typename c_nc
+ <
+ typename point_type<Range>::type, IsConst
+ >::type point_type;
 
         iterator_type it = boost::begin(range);
         iterator_type previous = it++;
         while(it != boost::end(range))
         {
- segment<typename point_type<R>::type> s(*previous, *it);
+ segment<point_type> s(*previous, *it);
             f(s);
             previous = it++;
         }
 
- return (f);
+ return f;
     }
 };
 
-template <typename P, typename F>
-struct fe_polygon
+
+template <typename Polygon, typename Functor, bool IsConst>
+struct fe_polygon_per_point
 {
- static inline F for_each_const_point(P const& poly, F f)
+ static inline Functor apply(
+ typename c_nc<Polygon, IsConst>::type& poly,
+ Functor f)
     {
- typedef typename ring_type<P>::type ring_type;
- typedef typename boost::range_const_iterator
+ typedef typename c_nc_range
             <
- typename interior_type<P>::type
+ typename interior_type<Polygon>::type,
+ IsConst
>::type iterator_type;
 
- f = fe_range<ring_type, F>::for_each_const_point(exterior_ring(poly), f);
+ typedef fe_range_per_point
+ <
+ typename ring_type<Polygon>::type,
+ Functor,
+ IsConst
+ > per_ring;
+
+ f = per_ring::apply(exterior_ring(poly), f);
 
         for (iterator_type it = boost::begin(interior_rings(poly));
- it != boost::end(interior_rings(poly)); it++)
+ it != boost::end(interior_rings(poly));
+ ++it)
         {
- f = fe_range<ring_type, F>::for_each_const_point(*it, f);
+ f = per_ring::apply(*it, f);
         }
 
- return (f);
+ return f;
     }
 
- static inline F for_each_point(P& poly, F f)
- {
- typedef typename ring_type<P>::type ring_type;
- typedef typename boost::range_iterator
- <
- typename interior_type<P>::type
- >::type iterator_type;
-
- f = fe_range<ring_type, F>::for_each_point(exterior_ring(poly), f);
-
- for (iterator_type it = boost::begin(interior_rings(poly));
- it != boost::end(interior_rings(poly)); it++)
- {
- f = fe_range<ring_type, F>::for_each_point(*it, f);
- }
+};
 
- return (f);
- }
 
- static inline F for_each_const_segment(P const& poly, F f)
+template <typename Polygon, typename Functor, bool IsConst>
+struct fe_polygon_per_segment
+{
+ static inline Functor apply(
+ typename c_nc<Polygon, IsConst>::type& poly,
+ Functor f)
     {
- typedef typename ring_type<P>::type ring_type;
- typedef typename boost::range_const_iterator
+ typedef typename c_nc_range
             <
- typename interior_type<P>::type
+ typename interior_type<Polygon>::type,
+ IsConst
>::type iterator_type;
 
- f = fe_range<ring_type, F>::for_each_const_segment(exterior_ring(poly), f);
-
- for (iterator_type it = boost::begin(interior_rings(poly));
- it != boost::end(interior_rings(poly)); it++)
- {
- f = fe_range<ring_type, F>::for_each_const_segment(*it, f);
- }
-
- return (f);
- }
-
- static inline F for_each_segment(P& poly, F f)
- {
- typedef typename ring_type<P>::type ring_type;
- typedef typename boost::range_iterator
+ typedef fe_range_per_segment
             <
- typename interior_type<P>::type
- >::type iterator_type;
+ typename ring_type<Polygon>::type,
+ Functor,
+ IsConst
+ > per_ring;
 
- f = fe_range<ring_type, F>::for_each_segment(exterior_ring(poly), f);
+ f = per_ring::apply(exterior_ring(poly), f);
 
         for (iterator_type it = boost::begin(interior_rings(poly));
- it != boost::end(interior_rings(poly)); it++)
+ it != boost::end(interior_rings(poly));
+ ++it)
         {
- f = fe_range<ring_type, F>::for_each_segment(*it, f);
+ f = per_ring::apply(*it, f);
         }
 
- return (f);
+ return f;
     }
+
 };
 
 }} // namespace detail::for_each
@@ -185,20 +202,69 @@
 namespace dispatch
 {
 
-template <typename T, typename G, typename F>
-struct for_each {};
+template
+<
+ typename Tag,
+ bool IsMulti,
+ typename Geometry,
+ typename Functor,
+ bool IsConst
+>
+struct for_each_point {};
+
+template <typename Point, typename Functor, bool IsConst>
+struct for_each_point<point_tag, false, Point, Functor, IsConst>
+ : detail::for_each::fe_point_per_point<Point, Functor, IsConst>
+{};
+
+template <typename Linestring, typename Functor, bool IsConst>
+struct for_each_point<linestring_tag, false, Linestring, Functor, IsConst>
+ : detail::for_each::fe_range_per_point<Linestring, Functor, IsConst>
+{};
+
+template <typename Ring, typename Functor, bool IsConst>
+struct for_each_point<ring_tag, false, Ring, Functor, IsConst>
+ : detail::for_each::fe_range_per_point<Ring, Functor, IsConst>
+{};
+
+template <typename Polygon, typename Functor, bool IsConst>
+struct for_each_point<polygon_tag, false, Polygon, Functor, IsConst>
+ : detail::for_each::fe_polygon_per_point<Polygon, Functor, IsConst>
+{};
 
-template <typename P, typename F>
-struct for_each<point_tag, P, F> : detail::for_each::fe_point<P, F> {};
 
-template <typename L, typename F>
-struct for_each<linestring_tag, L, F> : detail::for_each::fe_range<L, F> {};
 
-template <typename R, typename F>
-struct for_each<ring_tag, R, F> : detail::for_each::fe_range<R, F> {};
 
-template <typename P, typename F>
-struct for_each<polygon_tag, P, F> : detail::for_each::fe_polygon<P, F> {};
+template
+<
+ typename Tag,
+ bool IsMulti,
+ typename Geometry,
+ typename Functor,
+ bool IsConst
+>
+struct for_each_segment {};
+
+template <typename Point, typename Functor, bool IsConst>
+struct for_each_segment<point_tag, false, Point, Functor, IsConst>
+ : detail::for_each::fe_point_per_segment<Point, Functor, IsConst>
+{};
+
+template <typename Linestring, typename Functor, bool IsConst>
+struct for_each_segment<linestring_tag, false, Linestring, Functor, IsConst>
+ : detail::for_each::fe_range_per_segment<Linestring, Functor, IsConst>
+{};
+
+template <typename Ring, typename Functor, bool IsConst>
+struct for_each_segment<ring_tag, false, Ring, Functor, IsConst>
+ : detail::for_each::fe_range_per_segment<Ring, Functor, IsConst>
+{};
+
+template <typename Polygon, typename Functor, bool IsConst>
+struct for_each_segment<polygon_tag, false, Polygon, Functor, IsConst>
+ : detail::for_each::fe_polygon_per_segment<Polygon, Functor, IsConst>
+{};
+
 
 } // namespace dispatch
 #endif // DOXYGEN_NO_DISPATCH
@@ -210,17 +276,17 @@
     \param f functor to use
     \details Calls the functor the specified \b const geometry
 */
-template<typename G, typename F>
-inline F for_each_point(G const& geometry, F f)
+template<typename Geometry, typename Functor>
+inline Functor for_each_point(Geometry const& geometry, Functor f)
 {
- typedef typename dispatch::for_each
+ return dispatch::for_each_point
         <
- typename tag<G>::type,
- G,
- F
- >::for_each_const_point for_each_type;
-
- return for_each_type(geometry, f);
+ typename tag<Geometry>::type,
+ is_multi<Geometry>::type::value,
+ Geometry,
+ Functor,
+ true
+ >::apply(geometry, f);
 }
 
 /*!
@@ -230,10 +296,17 @@
     \param f functor to use
     \details Calls the functor for the specified geometry
 */
-template<typename G, typename F>
-inline F for_each_point(G& geometry, F f)
+template<typename Geometry, typename Functor>
+inline Functor for_each_point(Geometry& geometry, Functor f)
 {
- return (dispatch::for_each<typename tag<G>::type, G, F>::for_each_point(geometry, f));
+ return dispatch::for_each_point
+ <
+ typename tag<Geometry>::type,
+ is_multi<Geometry>::type::value,
+ Geometry,
+ Functor,
+ false
+ >::apply(geometry, f);
 }
 
 /*!
@@ -243,10 +316,17 @@
     \param f functor to use
     \details Calls the functor all \b const segments of the specified \b const geometry
 */
-template<typename G, typename F>
-inline F for_each_segment(const G& geometry, F f)
+template<typename Geometry, typename Functor>
+inline Functor for_each_segment(Geometry const& geometry, Functor f)
 {
- return (dispatch::for_each<typename tag<G>::type, G, F>::for_each_const_segment(geometry, f));
+ return dispatch::for_each_segment
+ <
+ typename tag<Geometry>::type,
+ is_multi<Geometry>::type::value,
+ Geometry,
+ Functor,
+ true
+ >::apply(geometry, f);
 }
 
 
@@ -257,10 +337,17 @@
     \param f functor to use
     \details Calls the functor all segments of the specified geometry
 */
-template<typename G, typename F>
-inline F for_each_segment(G& geometry, F f)
+template<typename Geometry, typename Functor>
+inline Functor for_each_segment(Geometry& geometry, Functor f)
 {
- return (dispatch::for_each<typename tag<G>::type, G, F>::for_each_segment(geometry, f));
+ return dispatch::for_each_segment
+ <
+ typename tag<Geometry>::type,
+ is_multi<Geometry>::type::value,
+ Geometry,
+ Functor,
+ false
+ >::apply(geometry, f);
 }
 
 } // namespace ggl

Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersection.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersection.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersection.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -11,6 +11,9 @@
 
 #include <deque>
 
+#include <boost/mpl/if.hpp>
+
+
 #include <ggl/algorithms/intersection_linestring.hpp>
 
 #include <ggl/algorithms/overlay/get_intersection_points.hpp>

Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/length.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/length.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/length.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -22,6 +22,7 @@
 #include <ggl/core/cs.hpp>
 #include <ggl/core/concepts/point_concept.hpp>
 #include <ggl/strategies/strategies.hpp>
+#include <ggl/strategies/length_result.hpp>
 
 /*!
 \defgroup length length calculation
@@ -39,6 +40,8 @@
 namespace ggl
 {
 
+
+
 #ifndef DOXYGEN_NO_DETAIL
 namespace detail { namespace length {
 
@@ -46,7 +49,8 @@
 template<typename Segment, typename Strategy>
 struct segment_length
 {
- static inline double apply(Segment const& segment, Strategy const& strategy)
+ static inline typename length_result<Segment>::type apply(
+ Segment const& segment, Strategy const& strategy)
     {
         // BSG 10 APR 2009
         // TODO: the segment concept has to be such that it is easy to return a point from it.
@@ -62,21 +66,12 @@
 template<typename Range, typename Strategy>
 struct range_length
 {
- static inline double apply(Range const& range, Strategy const& strategy)
- {
- typedef typename ggl::coordinate_type<Range>::type coordinate_type;
-
- // Because result is square-rooted, for integer, the cast should
- // go to double and NOT to T
- typedef typename
- boost::mpl::if_c
- <
- boost::is_integral<coordinate_type>::type::value,
- double,
- coordinate_type
- >::type calculation_type;
+ typedef typename length_result<Range>::type return_type;
 
- calculation_type sum = 0.0;
+ static inline return_type apply(
+ Range const& range, Strategy const& strategy)
+ {
+ return_type sum = return_type();
 
         typedef typename boost::range_const_iterator<Range>::type iterator_type;
         iterator_type it = boost::begin(range);
@@ -103,26 +98,39 @@
 {
 
 
-template <typename Tag, typename G, typename S>
-struct length : detail::calculate_null<double, G, S>
+template <typename Tag, typename Geometry, typename Strategy>
+struct length : detail::calculate_null
+ <
+ typename length_result<Geometry>::type,
+ Geometry,
+ Strategy
+ >
 {};
 
 
-template <typename G, typename S>
-struct length<linestring_tag, G, S>
- : detail::length::range_length<G, S>
+template <typename Geometry, typename Strategy>
+struct length<linestring_tag, Geometry, Strategy>
+ : detail::length::range_length<Geometry, Strategy>
 {};
 
 
 // RING: length is currently 0.0 but it might be argued that it is the "perimeter"
-template <typename G, typename S>
-struct length<segment_tag, G, S> : detail::length::segment_length<G, S>
+
+
+template <typename Geometry, typename Strategy>
+struct length<segment_tag, Geometry, Strategy>
+ : detail::length::segment_length<Geometry, Strategy>
 {};
 
 
 } // namespace dispatch
 #endif // DOXYGEN_NO_DISPATCH
 
+
+
+
+
+
 /*!
     \brief Calculate length of a geometry
     \ingroup length
@@ -135,10 +143,11 @@
     \line {
     \until }
  */
-template<typename G>
-inline double length(const G& geometry)
+template<typename Geometry>
+inline typename length_result<Geometry>::type length(
+ Geometry const& geometry)
 {
- typedef typename point_type<G>::type point_type;
+ typedef typename point_type<Geometry>::type point_type;
     typedef typename cs_tag<point_type>::type cs_tag;
     typedef typename strategy_distance
         <
@@ -150,8 +159,8 @@
 
     return dispatch::length
         <
- typename tag<G>::type,
- G,
+ typename tag<Geometry>::type,
+ Geometry,
             strategy_type
>::apply(geometry, strategy_type());
 }
@@ -170,10 +179,16 @@
     \line {
     \until }
  */
-template<typename G, typename S>
-inline double length(G const& geometry, S const& strategy)
+template<typename Geometry, typename Strategy>
+inline typename length_result<Geometry>::type length(
+ Geometry const& geometry, Strategy const& strategy)
 {
- return dispatch::length<typename tag<G>::type, G, S>::apply(geometry, strategy);
+ return dispatch::length
+ <
+ typename tag<Geometry>::type,
+ Geometry,
+ Strategy
+ >::apply(geometry, strategy);
 }
 
 } // namespace ggl

Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/intersection_point.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/intersection_point.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/intersection_point.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -209,21 +209,19 @@
         typedef point_tag type;
     };
 
- template <typename P>
- struct access<ggl::detail::intersection::intersection_point<P> >
+ template <typename P, std::size_t Dimension>
+ struct access<ggl::detail::intersection::intersection_point<P>, Dimension>
     {
- template <int Index>
         static inline typename coordinate_type<P>::type get(
                 ggl::detail::intersection::intersection_point<P> const& p)
         {
- return ggl::get<Index>(p.point);
+ return ggl::get<Dimension>(p.point);
         }
 
- template <int Index>
         static inline void set(ggl::detail::intersection::intersection_point<P>& p,
                 typename coordinate_type<P>::type const& value)
         {
- ggl::set<Index>(p.point, value);
+ ggl::set<Dimension>(p.point, value);
         }
     };
 

Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/perimeter.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/perimeter.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/perimeter.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -15,10 +15,15 @@
 #include <boost/range/functions.hpp>
 #include <boost/range/metafunctions.hpp>
 
-#include <ggl/algorithms/length.hpp>
 #include <ggl/core/cs.hpp>
 #include <ggl/core/concepts/point_concept.hpp>
 #include <ggl/strategies/strategies.hpp>
+#include <ggl/strategies/length_result.hpp>
+
+#include <ggl/algorithms/length.hpp>
+#include <ggl/algorithms/detail/calculate_null.hpp>
+#include <ggl/algorithms/detail/calculate_sum.hpp>
+
 
 /*!
 \defgroup perimeter perimeter calculation
@@ -28,58 +33,38 @@
 namespace ggl
 {
 
-#ifndef DOXYGEN_NO_DETAIL
-namespace detail { namespace perimeter {
-
-template<typename R, typename S>
-struct range_perimeter : detail::length::range_length<R, S>
-{
-};
-
-// might be merged with "range_area" with policy to sum/subtract interior rings
-template<typename Polygon, typename S>
-struct polygon_perimeter
-{
- static inline double apply(Polygon const& poly, S const& strategy)
- {
- typedef typename ring_type<Polygon>::type ring_type;
- typedef typename boost::range_const_iterator
- <
- typename interior_type<Polygon>::type
- >::type iterator_type;
-
- double sum = std::abs(range_perimeter<ring_type, S>::apply(exterior_ring(poly), strategy));
-
- for (iterator_type it = boost::begin(interior_rings(poly));
- it != boost::end(interior_rings(poly)); it++)
- {
- sum += std::abs(range_perimeter<ring_type, S>::apply(*it, strategy));
- }
- return sum;
- }
-};
-
-}} // namespace detail:;perimeter
-#endif // DOXYGEN_NO_DETAIL
-
-
 #ifndef DOXYGEN_NO_DISPATCH
 namespace dispatch
 {
 
 // Default perimeter is 0.0, specializations implement calculated values
 template <typename Tag, typename Geometry, typename Strategy>
-struct perimeter : detail::calculate_null<double, Geometry, Strategy>
+struct perimeter : detail::calculate_null
+ <
+ typename length_result<Geometry>::type,
+ Geometry,
+ Strategy
+ >
 {};
 
 template <typename Geometry, typename Strategy>
 struct perimeter<ring_tag, Geometry, Strategy>
- : detail::perimeter::range_perimeter<Geometry, Strategy>
+ : detail::length::range_length<Geometry, Strategy>
 {};
 
-template <typename Geometry, typename Strategy>
-struct perimeter<polygon_tag, Geometry, Strategy>
- : detail::perimeter::polygon_perimeter<Geometry, Strategy>
+template <typename Polygon, typename Strategy>
+struct perimeter<polygon_tag, Polygon, Strategy>
+ : detail::calculate_polygon_sum
+ <
+ typename length_result<Polygon>::type,
+ Polygon,
+ Strategy,
+ detail::length::range_length
+ <
+ typename ring_type<Polygon>::type,
+ Strategy
+ >
+ >
 {};
 
 
@@ -97,7 +82,8 @@
     \return the perimeter
  */
 template<typename Geometry>
-inline double perimeter(Geometry const& geometry)
+inline typename length_result<Geometry>::type perimeter(
+ Geometry const& geometry)
 {
     typedef typename point_type<Geometry>::type point_type;
     typedef typename cs_tag<point_type>::type cs_tag;
@@ -126,7 +112,8 @@
     \return the perimeter
  */
 template<typename Geometry, typename Strategy>
-inline double perimeter(Geometry const& geometry, Strategy const& strategy)
+inline typename length_result<Geometry>::type perimeter(
+ Geometry const& geometry, Strategy const& strategy)
 {
     return dispatch::perimeter
         <
@@ -139,3 +126,4 @@
 } // namespace ggl
 
 #endif // GGL_ALGORITHMS_PERIMETER_HPP
+

Modified: sandbox/ggl/formal_review_request/boost/ggl/core/access.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/core/access.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/core/access.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -33,29 +33,30 @@
     \par Geometries:
         - point
         - n-sphere (circle,sphere) for their center
- \par Specializations should provide:
- - static inline T get<I>(const G&)
- - static inline void set<I>(G&, const T&)
- \tparam G geometry
+ \par Specializations should provide, per Dimension
+ - static inline T get(const G&)
+ - static inline void set(G&, T const&)
+ \tparam Geometry geometry-type
+ \tparam Dimension dimension to access
 */
-template <typename G>
+template <typename Geometry, std::size_t Dimension>
 struct access {};
 
 
 /*!
     \brief Traits class defining "get" and "set" to get and set point coordinate values
- \tparam G geometry (box, segment)
- \tparam I index (min_corner/max_corner for box, 0/1 for segment)
- \tparam D dimension
+ \tparam Geometry geometry (box, segment)
+ \tparam Index index (min_corner/max_corner for box, 0/1 for segment)
+ \tparam Dimension dimension
     \par Geometries:
         - box
         - segment
     \par Specializations should provide:
         - static inline T get(const G&)
- - static inline void set(G&, const T&)
+ - static inline void set(G&, T const&)
     \ingroup traits
 */
-template <typename G, std::size_t I, std::size_t D>
+template <typename Geometry, std::size_t Index, std::size_t Dimension>
 struct indexed_access {};
 
 
@@ -72,7 +73,7 @@
     \par Specializations should provide:
         - value (defaults to true)
  */
-template <typename G>
+template <typename Geometry>
 struct use_std
 {
     static const bool value = true;
@@ -84,69 +85,95 @@
 #ifndef DOXYGEN_NO_DISPATCH
 namespace core_dispatch
 {
-template <typename Tag, typename G, typename T, std::size_t D>
+
+template
+<
+ typename Tag,
+ typename Geometry,
+ typename
+ CoordinateType, std::size_t Dimension
+>
 struct access
 {
     //static inline T get(const G& ) {}
- //static inline void set(G& g, const T& value) {}
+ //static inline void set(G& g, T const& value) {}
 };
 
-template <typename Tag, typename G, typename T, std::size_t I, std::size_t D>
+template
+<
+ typename Tag,
+ typename Geometry,
+ typename CoordinateType,
+ std::size_t Index,
+ std::size_t Dimension
+>
 struct indexed_access
 {
     //static inline T get(const G& ) {}
- //static inline void set(G& g, const T& value) {}
+ //static inline void set(G& g, T const& value) {}
 };
 
-template <typename P, typename T, std::size_t D>
-struct access<point_tag, P, T, D>
+template <typename Point, typename CoordinateType, std::size_t Dimension>
+struct access<point_tag, Point, CoordinateType, Dimension>
 {
- static inline T get(const P& p)
+ static inline CoordinateType get(Point const& point)
     {
- return traits::access<P>::template get<D>(p);
+ return traits::access<Point, Dimension>::get(point);
     }
- static inline void set(P& p, const T& value)
+ static inline void set(Point& p, CoordinateType const& value)
     {
- traits::access<P>::template set<D>(p, value);
+ traits::access<Point, Dimension>::set(p, value);
     }
 };
 
-template <typename S, typename T, std::size_t D>
-struct access<nsphere_tag, S, T, D>
+template <typename Nsphere, typename CoordinateType, std::size_t Dimension>
+struct access<nsphere_tag, Nsphere, CoordinateType, Dimension>
 {
- static inline T get(const S& s)
+ static inline CoordinateType get(Nsphere const& nsphere)
     {
- return traits::access<S>::template get<D>(s);
+ return traits::access<Nsphere, Dimension>::get(nsphere);
     }
- static inline void set(S& s, const T& value)
+ static inline void set(Nsphere& s, CoordinateType const& value)
     {
- traits::access<S>::template set<D>(s, value);
+ traits::access<Nsphere, Dimension>::set(s, value);
     }
 };
 
-template <typename B, typename T, std::size_t I, std::size_t D>
-struct indexed_access<box_tag, B, T, I, D>
+template
+<
+ typename Box,
+ typename CoordinateType,
+ std::size_t Index,
+ std::size_t Dimension
+>
+struct indexed_access<box_tag, Box, CoordinateType, Index, Dimension>
 {
- static inline T get(const B& b)
+ static inline CoordinateType get(Box const& box)
     {
- return traits::indexed_access<B, I, D>::get(b);
+ return traits::indexed_access<Box, Index, Dimension>::get(box);
     }
- static inline void set(B& b, const T& value)
+ static inline void set(Box& b, CoordinateType const& value)
     {
- traits::indexed_access<B, I, D>::set(b, value);
+ traits::indexed_access<Box, Index, Dimension>::set(b, value);
     }
 };
 
-template <typename S, typename T, std::size_t I, std::size_t D>
-struct indexed_access<segment_tag, S, T, I, D>
+template
+<
+ typename Segment,
+ typename CoordinateType,
+ std::size_t Index,
+ std::size_t Dimension
+>
+struct indexed_access<segment_tag, Segment, CoordinateType, Index, Dimension>
 {
- static inline T get(const S& segment)
+ static inline CoordinateType get(Segment const& segment)
     {
- return traits::indexed_access<S, I, D>::get(segment);
+ return traits::indexed_access<Segment, Index, Dimension>::get(segment);
     }
- static inline void set(S& segment, const T& value)
+ static inline void set(Segment& segment, CoordinateType const& value)
     {
- traits::indexed_access<S, I, D>::set(segment, value);
+ traits::indexed_access<Segment, Index, Dimension>::set(segment, value);
     }
 };
 
@@ -188,10 +215,10 @@
 
     typedef core_dispatch::access
         <
- typename tag<G>::type,
- ncg_type,
- typename coordinate_type<ncg_type>::type,
- D
+ typename tag<G>::type,
+ ncg_type,
+ typename coordinate_type<ncg_type>::type,
+ D
> coord_access_type;
 
     return coord_access_type::get(geometry);
@@ -217,10 +244,10 @@
 
     typedef core_dispatch::access
         <
- typename tag<G>::type,
- ncg_type,
- typename coordinate_type<ncg_type>::type,
- D
+ typename tag<G>::type,
+ ncg_type,
+ typename coordinate_type<ncg_type>::type,
+ D
> coord_access_type;
 
     coord_access_type::set(geometry, value);

Modified: sandbox/ggl/formal_review_request/boost/ggl/core/reverse_dispatch.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/core/reverse_dispatch.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/core/reverse_dispatch.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -12,7 +12,7 @@
 
 
 #include <boost/type_traits.hpp>
-
+#include <boost/mpl/if.hpp>
 #include <boost/mpl/greater.hpp>
 
 #include <ggl/core/geometry_id.hpp>

Modified: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/read_wkt.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/read_wkt.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/read_wkt.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -15,6 +15,7 @@
 
 #include <boost/algorithm/string.hpp>
 #include <boost/concept/requires.hpp>
+#include <boost/mpl/if.hpp>
 #include <boost/range/functions.hpp>
 #include <boost/range/metafunctions.hpp>
 

Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/adapted/c_array.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/adapted/c_array.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/adapted/c_array.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -48,31 +48,31 @@
 #endif // DOXYGEN_NO_DETAIL
 
 // Assign the point-tag, preventing arrays of points getting a point-tag
-template <typename T, std::size_t N>
-struct tag<T[N]> : detail::c_array_tag<boost::is_arithmetic<T>::value> {};
+template <typename CoordinateType, std::size_t DimensionCount>
+struct tag<CoordinateType[DimensionCount]>
+ : detail::c_array_tag<boost::is_arithmetic<CoordinateType>::value> {};
 
-template <typename T, std::size_t N>
-struct coordinate_type<T[N]>
+template <typename CoordinateType, std::size_t DimensionCount>
+struct coordinate_type<CoordinateType[DimensionCount]>
 {
- typedef T type;
+ typedef CoordinateType type;
 };
 
-template <typename T, std::size_t N>
-struct dimension<T[N]>: boost::mpl::int_<N> {};
+template <typename CoordinateType, std::size_t DimensionCount>
+struct dimension<CoordinateType[DimensionCount]>: boost::mpl::int_<DimensionCount> {};
 
-template <typename T, std::size_t N>
-struct access<T[N]>
+template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
+struct access<CoordinateType[DimensionCount], Dimension>
 {
- template <std::size_t I>
- static inline T get(const T p[N])
+ static inline CoordinateType get(const CoordinateType p[DimensionCount])
     {
- return p[I];
+ return p[Dimension];
     }
 
- template <std::size_t I>
- static inline void set(T p[N], const T& value)
+ static inline void set(CoordinateType p[DimensionCount],
+ CoordinateType const& value)
     {
- p[I] = value;
+ p[Dimension] = value;
     }
 };
 

Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/adapted/tuple.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/adapted/tuple.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/adapted/tuple.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -24,72 +24,92 @@
 {
 
 // boost::tuple, 2D
-template <typename T>
-struct coordinate_type<boost::tuple<T, T> >
+template <typename CoordinateType>
+struct coordinate_type<boost::tuple<CoordinateType, CoordinateType> >
 {
- typedef T type;
+ typedef CoordinateType type;
 };
 
-template <typename T>
-struct dimension<boost::tuple<T, T> > : boost::mpl::int_<2> {};
-
-template <typename T>
-struct access<boost::tuple<T, T> >
+template <typename CoordinateType>
+struct dimension<boost::tuple<CoordinateType, CoordinateType> >
+ : boost::mpl::int_<2>
+{};
+
+template <typename CoordinateType, std::size_t Dimension>
+struct access
+ <
+ boost::tuple<CoordinateType, CoordinateType>,
+ Dimension
+ >
 {
- template <int I>
- static inline T get(const boost::tuple<T, T>& p)
+ static inline CoordinateType get(
+ boost::tuple<CoordinateType, CoordinateType> const& point)
     {
- return p.get<I>();
+ return point.template get<Dimension>();
     }
 
- template <int I>
- static inline void set(boost::tuple<T, T>& p, const T& value)
+ static inline void set(boost::tuple<CoordinateType, CoordinateType>& point,
+ CoordinateType const& value)
     {
- p.get<I>() = value;
+ point.template get<Dimension>() = value;
     }
 };
 
-template <typename T>
-struct tag<boost::tuple<T, T> >
+template <typename CoordinateType>
+struct tag<boost::tuple<CoordinateType, CoordinateType> >
 {
     typedef point_tag type;
 };
 
 // boost::tuple, 3D
-template <typename T>
-struct coordinate_type<boost::tuple<T, T, T> >
-{
- typedef T type;
-};
-
-template <typename T>
-struct dimension<boost::tuple<T, T, T> > : boost::mpl::int_<3> {};
-
-template <typename T>
-struct access<boost::tuple<T, T, T> >
-{
- template <int I>
- static inline T get(const boost::tuple<T, T, T>& p)
+template <typename CoordinateType>
+struct coordinate_type
+ <
+ boost::tuple<CoordinateType, CoordinateType, CoordinateType>
+ >
+{
+ typedef CoordinateType type;
+};
+
+template <typename CoordinateType>
+struct dimension<boost::tuple<CoordinateType, CoordinateType, CoordinateType> >
+ : boost::mpl::int_<3>
+{};
+
+template <typename CoordinateType, std::size_t Dimension>
+struct access
+ <
+ boost::tuple<CoordinateType, CoordinateType, CoordinateType>,
+ Dimension
+ >
+{
+ static inline CoordinateType get(
+ boost::tuple
+ <
+ CoordinateType, CoordinateType, CoordinateType
+ > const& point)
     {
- return p.get<I>();
+ return point.template get<Dimension>();
     }
 
- template <int I>
- static inline void set(boost::tuple<T, T, T>& p, const T& value)
+ static inline void set(
+ boost::tuple<CoordinateType, CoordinateType, CoordinateType>& point,
+ CoordinateType const& value)
     {
- p.get<I>() = value;
+ point.template get<Dimension>() = value;
     }
 };
 
-template <typename T>
-struct tag<boost::tuple<T, T, T> >
+template <typename CoordinateType>
+struct tag<boost::tuple<CoordinateType, CoordinateType, CoordinateType> >
 {
     typedef point_tag type;
 };
 
 // The library user has
 // 1) either to specify the coordinate system using a traits class
-// 2) or include <ggl/geometries/adapted/tuple__at_.hpp> where @=cartesian,geographic,...
+// 2) or include <ggl/geometries/adapted/tuple__at_.hpp>
+// where @=cartesian,geographic,...
 
 } // namespace traits
 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS

Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/box.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/box.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/box.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -25,16 +25,16 @@
     rectangle is used, use linear_ring or polygon.
     \note Boxes are for selections and for calculating the envelope of geometries. Not all algorithms
     are implemented for box. Boxes are also used in Spatial Indexes.
- \tparam P point type. The box takes a point type as template parameter.
+ \tparam Point point type. The box takes a point type as template parameter.
     The point type can be any point type.
     It can be 2D but can also be 3D or more dimensional.
     The box can also take a latlong point type as template parameter.
  */
 
-template<typename P>
+template<typename Point>
 class box
 {
- BOOST_CONCEPT_ASSERT( (concept::Point<P>) );
+ BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
 
 public:
 
@@ -43,22 +43,22 @@
     /*!
         \brief Constructor taking the minimum corner point and the maximum corner point
     */
- inline box(P const& min_corner, P const& max_corner)
+ inline box(Point const& min_corner, Point const& max_corner)
     {
         copy_coordinates(min_corner, m_min_corner);
         copy_coordinates(max_corner, m_max_corner);
     }
 
- inline P const& min_corner() const { return m_min_corner; }
- inline P const& max_corner() const { return m_max_corner; }
+ inline Point const& min_corner() const { return m_min_corner; }
+ inline Point const& max_corner() const { return m_max_corner; }
 
- inline P& min_corner() { return m_min_corner; }
- inline P& max_corner() { return m_max_corner; }
+ inline Point& min_corner() { return m_min_corner; }
+ inline Point& max_corner() { return m_max_corner; }
 
 private:
 
- P m_min_corner;
- P m_max_corner;
+ Point m_min_corner;
+ Point m_max_corner;
 };
 
 
@@ -67,38 +67,47 @@
 namespace traits
 {
 
-template <typename P>
-struct tag< box<P> >
+template <typename Point>
+struct tag<box<Point> >
 {
     typedef box_tag type;
 };
 
-template <typename P>
-struct point_type<box<P> >
+template <typename Point>
+struct point_type<box<Point> >
 {
- typedef P type;
+ typedef Point type;
 };
 
-template <typename P, std::size_t C, std::size_t D>
-struct indexed_access<box<P>, C, D>
+template <typename Point, std::size_t Dimension>
+struct indexed_access<box<Point>, min_corner, Dimension>
 {
- typedef box<P> box_type;
+ typedef typename ggl::coordinate_type<Point>::type coordinate_type;
 
- static inline typename ggl::coordinate_type<box_type>::type get(box_type const& b)
+ static inline coordinate_type get(box<Point> const& b)
     {
- return (C == min_corner ? ggl::get<D>(b.min_corner()) : ggl::get<D>(b.max_corner()));
+ return ggl::get<Dimension>(b.min_corner());
     }
 
- static inline void set(box_type& b, typename ggl::coordinate_type<box_type>::type const& value)
+ static inline void set(box<Point>& b, coordinate_type const& value)
     {
- if (C == min_corner)
- {
- ggl::set<D>(b.min_corner(), value);
- }
- else
- {
- ggl::set<D>(b.max_corner(), value);
- }
+ ggl::set<Dimension>(b.min_corner(), value);
+ }
+};
+
+template <typename Point, std::size_t Dimension>
+struct indexed_access<box<Point>, max_corner, Dimension>
+{
+ typedef typename ggl::coordinate_type<Point>::type coordinate_type;
+
+ static inline coordinate_type get(box<Point> const& b)
+ {
+ return ggl::get<Dimension>(b.max_corner());
+ }
+
+ static inline void set(box<Point>& b, coordinate_type const& value)
+ {
+ ggl::set<Dimension>(b.max_corner(), value);
     }
 };
 

Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/nsphere.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/nsphere.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/nsphere.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -70,53 +70,51 @@
 namespace traits
 {
 
-template <typename P, typename T>
-struct tag< nsphere<P, T> >
+template <typename Point, typename RadiusType>
+struct tag< nsphere<Point, RadiusType> >
 {
     typedef nsphere_tag type;
 };
 
-template <typename P, typename T>
-struct point_type<nsphere<P, T> >
+template <typename Point, typename RadiusType>
+struct point_type<nsphere<Point, RadiusType> >
 {
- typedef P type;
+ typedef Point type;
 };
 
-template <typename P, typename T>
-struct radius_type<nsphere<P, T> >
+template <typename Point, typename RadiusType>
+struct radius_type<nsphere<Point, RadiusType> >
 {
- typedef T type;
+ typedef RadiusType type;
 };
 
-template <typename P, typename T>
-struct access<nsphere<P, T> >
+template <typename Point, typename CoordinateType, std::size_t Dimension>
+struct access<nsphere<Point, CoordinateType>, Dimension>
 {
- typedef nsphere<P, T> nsphere_type;
+ typedef nsphere<Point, CoordinateType> nsphere_type;
 
- template <std::size_t D>
- static inline typename ggl::coordinate_type<nsphere_type>::type get(nsphere_type const& s)
+ static inline CoordinateType get(nsphere_type const& s)
     {
- return ggl::get<D>(s.center());
+ return ggl::get<Dimension>(s.center());
     }
 
- template <std::size_t D>
- static inline void set(nsphere_type& s, typename ggl::coordinate_type<nsphere_type>::type const& value)
+ static inline void set(nsphere_type& s, CoordinateType const& value)
     {
- ggl::set<D>(s.center(), value);
+ ggl::set<Dimension>(s.center(), value);
     }
 };
 
-template <typename P, typename T>
-struct radius_access<nsphere<P, T>, T, 0>
+template <typename Point, typename RadiusType>
+struct radius_access<nsphere<Point, RadiusType>, RadiusType, 0>
 {
- typedef nsphere<P, T> nsphere_type;
+ typedef nsphere<Point, RadiusType> nsphere_type;
 
- static inline T get(nsphere_type const& s)
+ static inline RadiusType get(nsphere_type const& s)
     {
         return s.radius();
     }
 
- static inline void set(nsphere_type& s, T const& value)
+ static inline void set(nsphere_type& s, RadiusType const& value)
     {
         s.radius(value);
     }

Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/point.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/point.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/point.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -80,40 +80,69 @@
 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
 namespace traits
 {
-template <typename T, std::size_t D, typename C>
-struct tag<point<T, D, C> >
+template
+<
+ typename CoordinateType,
+ std::size_t DimensionCount,
+ typename CoordinateSystem
+>
+struct tag<point<CoordinateType, DimensionCount, CoordinateSystem> >
 {
     typedef point_tag type;
 };
 
-template<typename T, std::size_t D, typename C>
-struct coordinate_type<point<T, D, C> >
+template
+<
+ typename CoordinateType,
+ std::size_t DimensionCount,
+ typename CoordinateSystem
+>
+struct coordinate_type<point<CoordinateType, DimensionCount, CoordinateSystem> >
 {
- typedef T type;
+ typedef CoordinateType type;
 };
 
-template<typename T, std::size_t D, typename C>
-struct coordinate_system<point<T, D, C> >
+template
+<
+ typename CoordinateType,
+ std::size_t DimensionCount,
+ typename CoordinateSystem
+>
+struct coordinate_system<point<CoordinateType, DimensionCount, CoordinateSystem> >
 {
- typedef C type;
+ typedef CoordinateSystem type;
 };
 
-template<typename T, std::size_t D, typename C>
-struct dimension<point<T, D, C> > : boost::mpl::int_<D> {};
-
-template<typename T, std::size_t D, typename C>
-struct access<point<T, D, C> >
+template
+<
+ typename CoordinateType,
+ std::size_t DimensionCount,
+ typename CoordinateSystem
+>
+struct dimension<point<CoordinateType, DimensionCount, CoordinateSystem> >
+ : boost::mpl::int_<DimensionCount>
+{};
+
+template
+<
+ typename CoordinateType,
+ std::size_t DimensionCount,
+ typename CoordinateSystem,
+ std::size_t Dimension
+>
+struct access<point<CoordinateType, DimensionCount, CoordinateSystem>, Dimension>
 {
- template <std::size_t I>
- static inline T get(point<T, D, C> const& p)
+ static inline CoordinateType get(
+ point<CoordinateType, DimensionCount, CoordinateSystem> const& p)
     {
- return p.template get<I>();
+ return p.template get<Dimension>();
     }
 
- template <std::size_t I>
- static inline void set(point<T, D, C>& p, T const& value)
+ static inline void set(
+ point<CoordinateType, DimensionCount, CoordinateSystem>& p,
+ CoordinateType const& value)
     {
- p.template set<I>(value);
+ p.template set<Dimension>(value);
     }
 };
 

Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/point_xy.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/point_xy.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/point_xy.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -50,13 +50,6 @@
     /// Set y-value
     inline void y(T const& v)
     { this->template set<1>(v); }
-
- /// Compare two points
- //inline bool operator<(point_xy const& other) const
- //{
- // return math::equals(x(), other.x()) ? y() < other.y() : x() < other.x();
- //}
-
 };
 
 // Adapt the point_xy to the concept
@@ -64,40 +57,42 @@
 namespace traits
 {
 
-template <typename T, typename C>
-struct tag<point_xy<T, C> >
+template <typename CoordinateType, typename CoordinateSystem>
+struct tag<point_xy<CoordinateType, CoordinateSystem> >
 {
     typedef point_tag type;
 };
 
-template<typename T, typename C>
-struct coordinate_type<point_xy<T, C> >
+template<typename CoordinateType, typename CoordinateSystem>
+struct coordinate_type<point_xy<CoordinateType, CoordinateSystem> >
 {
- typedef T type;
+ typedef CoordinateType type;
 };
 
-template<typename T, typename C>
-struct coordinate_system<point_xy<T, C> >
+template<typename CoordinateType, typename CoordinateSystem>
+struct coordinate_system<point_xy<CoordinateType, CoordinateSystem> >
 {
- typedef C type;
+ typedef CoordinateSystem type;
 };
 
-template<typename T, typename C>
-struct dimension<point_xy<T, C> > : boost::mpl::int_<2> {};
+template<typename CoordinateType, typename CoordinateSystem>
+struct dimension<point_xy<CoordinateType, CoordinateSystem> >
+ : boost::mpl::int_<2>
+{};
 
-template<typename T, typename C>
-struct access<point_xy<T, C> >
+template<typename CoordinateType, typename CoordinateSystem, std::size_t Dimension>
+struct access<point_xy<CoordinateType, CoordinateSystem>, Dimension >
 {
- template <std::size_t I>
- static inline T get(point_xy<T, C> const& p)
+ static inline CoordinateType get(
+ point_xy<CoordinateType, CoordinateSystem> const& p)
     {
- return p.template get<I>();
+ return p.template get<Dimension>();
     }
 
- template <std::size_t I>
- static inline void set(point_xy<T, C>& p, T const& value)
+ static inline void set(point_xy<CoordinateType, CoordinateSystem>& p,
+ CoordinateType const& value)
     {
- p.template set<I>(value);
+ p.template set<Dimension>(value);
     }
 };
 

Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/register/point.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/register/point.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/register/point.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -12,7 +12,8 @@
 
 
 
-// This file implements a "macro party", nevertheless very useful for registration of custom geometry types
+// This file implements a "macro party",
+// for registration of custom geometry types
 
 #ifndef DOXYGEN_NO_SPECIALIZATIONS
 
@@ -23,23 +24,23 @@
     template<> struct dimension<Point> : boost::mpl::int_<Dim> {}; \
     template<> struct coordinate_type<Point> { typedef CoordinateType type; }; \
     template<> struct coordinate_system<Point> { typedef CoordinateSystem type; }; \
- template<int I> struct Point##accessor {};
+ template<std::size_t Dimension> struct Point##accessor {};
 
 
 // Non Const version
 #define GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, CoordinateType) \
- template<> struct access<Point> { \
- template <int I> \
- static inline CoordinateType get(const Point& p) { return Point##accessor<I>::get(p); } \
- template <int I> \
- static inline void set(Point& p, const CoordinateType& value) { Point##accessor<I>::set(p, value); } \
+ template<std::size_t Dimension> struct access<Point, Dimension> { \
+ static inline CoordinateType get(Point const& p) \
+ { return Point##accessor<Dimension>::get(p); } \
+ static inline void set(Point& p, CoordinateType const& value) \
+ { Point##accessor<Dimension>::set(p, value); } \
     };
 
 // Const version
 #define GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, CoordinateType) \
- template<> struct access<Point> { \
- template <int I> \
- static inline CoordinateType get(const Point& p) { return Point##accessor<I>::get(p); } \
+ template<std::size_t Dimension> struct access<Point, Dimension> { \
+ static inline CoordinateType get(Point const& p) \
+ { return Point##accessor<Dimension>::get(p); } \
     };
 
 
@@ -49,8 +50,8 @@
 #define GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESSOR(Point, Dim, CoordinateType, Get, Set) \
     template<> struct Point##accessor< Dim > \
     { \
- static inline CoordinateType get(const Point& p) { return p. Get; } \
- static inline void set(Point& p, const CoordinateType& value) { p. Set = value; } \
+ static inline CoordinateType get(Point const& p) { return p. Get; } \
+ static inline void set(Point& p, CoordinateType const& value) { p. Set = value; } \
     };
 
 
@@ -58,7 +59,8 @@
 #define GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESSOR_CONST(Point, Dim, CoordinateType, Get) \
     template<> struct Point##accessor< Dim > \
     { \
- static inline CoordinateType get(const Point& p) { return p. Get; } \
+ static inline CoordinateType get(Point const& p) \
+ { return p. Get; } \
     };
 
 
@@ -66,8 +68,10 @@
 #define GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESSOR_GET_SET(Point, Dim, CoordinateType, Get, Set) \
     template<> struct Point##accessor< Dim > \
     { \
- static inline CoordinateType get(const Point& p) { return p. Get (); } \
- static inline void set(Point& p, const CoordinateType& value) { p. Set ( value ); } \
+ static inline CoordinateType get(Point const& p) \
+ { return p. Get (); } \
+ static inline void set(Point& p, CoordinateType const& value) \
+ { p. Set ( value ); } \
     };
 
 

Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/segment.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/segment.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/segment.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -21,38 +21,40 @@
 {
 
 /*!
-\brief Class segment: small containing two (templatized) point references
+\brief Class segment: small class containing two (templatized) point references
 \ingroup Geometry
 \details From Wikipedia: In geometry, a line segment is a part of a line that is bounded
  by two distinct end points, and contains every point on the line between its end points.
 \note The structure is like std::pair, and can often be used interchangeable.
-So points are public available. We cannot derive from std::pair<P&, P&> because of
-reference assignments. Points are not const and might be changed by the algorithm
-(used in intersection_linestring).
-\tparam P point type of the segment
+Difference is that it refers to points, does not have points.
+\note Like std::pair, points are public available.
+\note type is const or non const, so ggl::segment<P> or ggl::segment<const P>
+\note We cannot derive from std::pair<P&, P&> because of
+reference assignments.
+\tparam ConstOrNonConstPoint point type of the segment, maybe a point or a const point
 */
-template<typename P>
-struct segment
+template<typename ConstOrNonConstPoint>
+class segment
 {
-private:
-
- BOOST_CONCEPT_ASSERT( (typename boost::mpl::if_
- <
- boost::is_const<P>,
- concept::ConstPoint<P>,
- concept::Point<P>
- >
+ BOOST_CONCEPT_ASSERT( (
+ typename boost::mpl::if_
+ <
+ boost::is_const<ConstOrNonConstPoint>,
+ concept::Point<ConstOrNonConstPoint>,
+ concept::ConstPoint<ConstOrNonConstPoint>
+ >
     ) );
 
-public:
+ typedef ConstOrNonConstPoint point_type;
 
- typedef P point_type;
+public:
 
- P& first;
- P& second;
+ point_type& first;
+ point_type& second;
 
- inline segment(P& p1, P& p2)
- : first(p1), second(p2)
+ inline segment(point_type& p1, point_type& p2)
+ : first(p1)
+ , second(p2)
     {}
 };
 
@@ -61,39 +63,50 @@
 namespace traits
 {
 
-template <typename P>
-struct tag< segment<P> >
+template <typename ConstOrNonConstPoint>
+struct tag<segment<ConstOrNonConstPoint> >
 {
     typedef segment_tag type;
 };
 
-template <typename P>
-struct point_type<segment<P> >
+template <typename ConstOrNonConstPoint>
+struct point_type<segment<ConstOrNonConstPoint> >
+{
+ typedef ConstOrNonConstPoint type;
+};
+
+template <typename ConstOrNonConstPoint, std::size_t Dimension>
+struct indexed_access<segment<ConstOrNonConstPoint>, 0, Dimension>
 {
- typedef P type;
+ typedef segment<ConstOrNonConstPoint> segment_type;
+ typedef typename ggl::coordinate_type<segment_type>::type coordinate_type;
+
+ static inline coordinate_type get(segment_type const& s)
+ {
+ return ggl::get<Dimension>(s.first);
+ }
+
+ static inline void set(segment_type& s, coordinate_type const& value)
+ {
+ ggl::set<Dimension>(s.first, value);
+ }
 };
 
-template <typename P, std::size_t I, std::size_t D>
-struct indexed_access<segment<P>, I, D>
+
+template <typename ConstOrNonConstPoint, std::size_t Dimension>
+struct indexed_access<segment<ConstOrNonConstPoint>, 1, Dimension>
 {
- typedef segment<P> segment_type;
+ typedef segment<ConstOrNonConstPoint> segment_type;
     typedef typename ggl::coordinate_type<segment_type>::type coordinate_type;
 
     static inline coordinate_type get(segment_type const& s)
     {
- return (I == 0 ? ggl::get<D>(s.first) : ggl::get<D>(s.second));
+ return ggl::get<Dimension>(s.second);
     }
 
     static inline void set(segment_type& s, coordinate_type const& value)
     {
- if (I == 0)
- {
- ggl::set<D>(s.first, value);
- }
- else
- {
- ggl::set<D>(s.second, value);
- }
+ ggl::set<Dimension>(s.second, value);
     }
 };
 

Modified: sandbox/ggl/formal_review_request/boost/ggl/iterators/base.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/iterators/base.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/iterators/base.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -12,6 +12,7 @@
 #include <boost/iterator.hpp>
 #include <boost/iterator/iterator_adaptor.hpp>
 #include <boost/iterator/iterator_categories.hpp>
+#include <boost/mpl/if.hpp>
 
 #ifndef DOXYGEN_NO_DETAIL
 namespace ggl { namespace detail { namespace iterators {

Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/area.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/area.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/area.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -19,12 +19,22 @@
 #ifndef DOXYGEN_NO_DISPATCH
 namespace dispatch
 {
- template <typename MultiGeometry, order_selector Order, typename Strategy>
- struct area<multi_polygon_tag, MultiGeometry, Order, Strategy>
- : detail::multi_sum<double, MultiGeometry, Strategy,
- detail::area::polygon_area<
- typename boost::range_value<MultiGeometry>::type, Order, Strategy> >
- {};
+template <typename MultiGeometry, order_selector Order, typename Strategy>
+struct area<multi_polygon_tag, MultiGeometry, Order, Strategy>
+ : detail::multi_sum
+ <
+ typename Strategy::return_type,
+ MultiGeometry,
+ Strategy,
+ area
+ <
+ polygon_tag,
+ typename boost::range_value<MultiGeometry>::type,
+ Order,
+ Strategy
+ >
+ >
+{};
 
 
 } // namespace dispatch

Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/detail/multi_sum.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/detail/multi_sum.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/detail/multi_sum.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -20,21 +20,20 @@
 
 template
 <
- typename T,
+ typename ReturnType,
     typename MultiGeometry,
     typename Strategy,
     typename Policy
>
 struct multi_sum
 {
- static inline T apply(MultiGeometry const& geometry, Strategy const& strategy)
+ static inline ReturnType apply(MultiGeometry const& geometry, Strategy const& strategy)
     {
- typedef typename boost::range_const_iterator
- <
- MultiGeometry
- >::type iterator_type;
- T sum = T();
- for (iterator_type it = boost::begin(geometry);
+ ReturnType sum = ReturnType();
+ for (typename boost::range_const_iterator
+ <
+ MultiGeometry
+ >::type it = boost::begin(geometry);
             it != boost::end(geometry);
             ++it)
         {

Copied: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/for_each.hpp (from r56825, /sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/foreach.hpp)
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/foreach.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/for_each.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -1,222 +1,126 @@
 // Generic Geometry Library
 //
 // Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_MULTI_FOREACH_HPP
-#define GGL_MULTI_FOREACH_HPP
+#ifndef GGL_MULTI_ALGORITHMS_FOR_EACH_HPP
+#define GGL_MULTI_ALGORITHMS_FOR_EACH_HPP
 
-#include <vector>
 
-#include <ggl/algorithms/for_each.hpp>
-
-FIX ME it is not yet adapted to tag-dispatching
-
-
-namespace ggl
-{
-
-template<typename MP, typename F>
-inline F for_each_point_multi_point(MP& mp, F f)
-{
- return (for_each_point_container(mp, f));
-}
-
-template<typename ML, typename F>
-inline F for_each_point_multi_linestring(ML& ml, F f)
-{
- for (typename ML::iterator it = ml.begin(); it != ml.end(); it++)
- {
- f = for_each_point_linestring(*it, f);
- }
- return (f);
-}
-
-template<typename MY, typename F>
-inline F for_each_point_multi_polygon(MY& mp, F f)
-{
- for (typename MY::iterator it = mp.begin(); it != mp.end(); it++)
- {
- f = for_each_point_polygon(*it, f);
- }
- return (f);
-}
-
-
-
-
-template<typename MP, typename F>
-inline F for_each_point_multi_point(const MP& mp, F f)
-{
- return (for_each_point_container(mp, f));
-}
-
-
-template<typename ML, typename F>
-inline F for_each_point_multi_linestring(const ML& ml, F f)
-{
- for (typename ML::const_iterator it = ml.begin(); it != ml.end(); it++)
- {
- f = for_each_point_linestring(*it, f);
- }
- return (f);
-}
-
-template<typename MY, typename F>
-inline F for_each_point_multi_polygon(const MY& mp, F f)
-{
- for (typename MY::const_iterator it = mp.begin(); it != mp.end(); it++)
- {
- f = for_each_point_polygon(*it, f);
- }
- return (f);
-}
-
-
-
-template<typename ML, typename F>
-inline F for_each_segment_multi_linestring(ML& ml, F f)
-{
- for (typename ML::iterator it = ml.begin(); it != ml.end(); it++)
- {
- f = for_each_segment_linestring(*it, f);
- }
- return (f);
-}
-
-template<typename MY, typename F>
-inline F for_each_segment_multi_polygon(MY& mp, F f)
-{
- for (typename MY::iterator it = mp.begin(); it != mp.end(); it++)
- {
- f = for_each_segment_polygon(*it, f);
- }
- return (f);
-}
-
-
-
-
-
-
-template<typename ML, typename F>
-inline F for_each_segment_multi_linestring(const ML& ml, F f)
-{
- for (typename ML::const_iterator it = ml.begin(); it != ml.end(); it++)
- {
- f = for_each_segment_linestring(*it, f);
- }
- return (f);
-}
+#include <ggl/multi/core/tags.hpp>
+#include <ggl/multi/core/is_multi.hpp>
+#include <ggl/multi/core/point_type.hpp>
 
-template<typename MY, typename F>
-inline F for_each_segment_multi_polygon(const MY& mp, F f)
-{
- for (typename MY::const_iterator it = mp.begin(); it != mp.end(); it++)
- {
- f = for_each_segment_polygon(*it, f);
- }
- return (f);
-}
-
-
-
-
-
-
-template<typename P,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(multi_point<P, V, A>& mp, F f)
-{
- return (for_each_point_multi_point(mp, f));
-}
-
-template<typename L,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(multi_linestring<L, V, A>& ml, F f)
-{
- return (for_each_point_multi_linestring(ml, f));
-}
-
-template<typename Y,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(multi_polygon<Y, V, A>& mp, F f)
-{
- return (for_each_point_multi_polygon(mp, f));
-}
-
-
-
-
-template<typename P,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(const multi_point<P, V, A>& mp, F f)
-{
- return (for_each_point_multi_point(mp, f));
-}
-
-template<typename L,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(const multi_linestring<L, V, A>& ml, F f)
-{
- return (for_each_point_multi_linestring(ml, f));
-}
-
-
-template<typename Y,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(const multi_polygon<Y, V, A>& mp, F f)
-{
- return (for_each_point_multi_polygon(mp, f));
-}
 
+#include <ggl/algorithms/for_each.hpp>
 
 
 
-template<typename L,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_segment(multi_linestring<L, V, A>& ml, F f)
+namespace ggl
 {
- return (for_each_segment_multi_linestring(ml, f));
-}
 
-template<typename Y,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_segment(multi_polygon<Y, V, A>& mp, F f)
-{
- return (for_each_segment_multi_polygon(mp, f));
-}
 
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace for_each {
 
+// Implementation of multi, for both point and segment,
+// just calling the single version.
+template
+<
+ typename MultiGeometry,
+ typename Functor,
+ bool IsConst,
+ typename Policy
+>
+struct for_each_multi
+{
+ static inline Functor apply(
+ typename c_nc<MultiGeometry, IsConst>::type& multi,
+ Functor f)
+ {
+ typedef typename c_nc_range
+ <
+ MultiGeometry,
+ IsConst
+ >::type iterator_type;
+
+ for(iterator_type it = boost::begin(multi);
+ it != boost::end(multi);
+ ++it)
+ {
+ f = Policy::apply(*it, f);
+ }
+ return f;
+ }
+};
+
+
+}} // namespace detail::for_each
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template
+<
+ typename MultiTag,
+ typename MultiGeometry,
+ typename Functor,
+ bool IsConst
+>
+struct for_each_point<MultiTag, true, MultiGeometry, Functor, IsConst>
+ : detail::for_each::for_each_multi
+ <
+ MultiGeometry,
+ Functor,
+ IsConst,
+ // Specify the dispatch of the single-version as policy
+ for_each_point
+ <
+ typename single_tag<MultiTag>::type,
+ false,
+ typename boost::range_value<MultiGeometry>::type,
+ Functor,
+ IsConst
+ >
+ >
+{};
+
+
+template
+<
+ typename MultiTag,
+ typename MultiGeometry,
+ typename Functor,
+ bool IsConst
+>
+struct for_each_segment<MultiTag, true, MultiGeometry, Functor, IsConst>
+ : detail::for_each::for_each_multi
+ <
+ MultiGeometry,
+ Functor,
+ IsConst,
+ // Specify the dispatch of the single-version as policy
+ for_each_segment
+ <
+ typename single_tag<MultiTag>::type,
+ false,
+ typename boost::range_value<MultiGeometry>::type,
+ Functor,
+ IsConst
+ >
+ >
+{};
 
 
-template<typename L,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_segment(const multi_linestring<L, V, A>& ml, F f)
-{
- return (for_each_segment_multi_linestring(ml, f));
-}
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
 
-template<typename Y,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_segment(const multi_polygon<Y, V, A>& mp, F f)
-{
- return (for_each_segment_multi_polygon(mp, f));
-}
 } // namespace ggl
 
 
-#endif // GGL_MULTI_FOREACH_HPP
+#endif // GGL_MULTI_ALGORITHMS_FOR_EACH_HPP

Deleted: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/foreach.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/foreach.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
+++ (empty file)
@@ -1,222 +0,0 @@
-// Generic Geometry Library
-//
-// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_MULTI_FOREACH_HPP
-#define GGL_MULTI_FOREACH_HPP
-
-#include <vector>
-
-#include <ggl/algorithms/for_each.hpp>
-
-FIX ME it is not yet adapted to tag-dispatching
-
-
-namespace ggl
-{
-
-template<typename MP, typename F>
-inline F for_each_point_multi_point(MP& mp, F f)
-{
- return (for_each_point_container(mp, f));
-}
-
-template<typename ML, typename F>
-inline F for_each_point_multi_linestring(ML& ml, F f)
-{
- for (typename ML::iterator it = ml.begin(); it != ml.end(); it++)
- {
- f = for_each_point_linestring(*it, f);
- }
- return (f);
-}
-
-template<typename MY, typename F>
-inline F for_each_point_multi_polygon(MY& mp, F f)
-{
- for (typename MY::iterator it = mp.begin(); it != mp.end(); it++)
- {
- f = for_each_point_polygon(*it, f);
- }
- return (f);
-}
-
-
-
-
-template<typename MP, typename F>
-inline F for_each_point_multi_point(const MP& mp, F f)
-{
- return (for_each_point_container(mp, f));
-}
-
-
-template<typename ML, typename F>
-inline F for_each_point_multi_linestring(const ML& ml, F f)
-{
- for (typename ML::const_iterator it = ml.begin(); it != ml.end(); it++)
- {
- f = for_each_point_linestring(*it, f);
- }
- return (f);
-}
-
-template<typename MY, typename F>
-inline F for_each_point_multi_polygon(const MY& mp, F f)
-{
- for (typename MY::const_iterator it = mp.begin(); it != mp.end(); it++)
- {
- f = for_each_point_polygon(*it, f);
- }
- return (f);
-}
-
-
-
-template<typename ML, typename F>
-inline F for_each_segment_multi_linestring(ML& ml, F f)
-{
- for (typename ML::iterator it = ml.begin(); it != ml.end(); it++)
- {
- f = for_each_segment_linestring(*it, f);
- }
- return (f);
-}
-
-template<typename MY, typename F>
-inline F for_each_segment_multi_polygon(MY& mp, F f)
-{
- for (typename MY::iterator it = mp.begin(); it != mp.end(); it++)
- {
- f = for_each_segment_polygon(*it, f);
- }
- return (f);
-}
-
-
-
-
-
-
-template<typename ML, typename F>
-inline F for_each_segment_multi_linestring(const ML& ml, F f)
-{
- for (typename ML::const_iterator it = ml.begin(); it != ml.end(); it++)
- {
- f = for_each_segment_linestring(*it, f);
- }
- return (f);
-}
-
-template<typename MY, typename F>
-inline F for_each_segment_multi_polygon(const MY& mp, F f)
-{
- for (typename MY::const_iterator it = mp.begin(); it != mp.end(); it++)
- {
- f = for_each_segment_polygon(*it, f);
- }
- return (f);
-}
-
-
-
-
-
-
-template<typename P,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(multi_point<P, V, A>& mp, F f)
-{
- return (for_each_point_multi_point(mp, f));
-}
-
-template<typename L,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(multi_linestring<L, V, A>& ml, F f)
-{
- return (for_each_point_multi_linestring(ml, f));
-}
-
-template<typename Y,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(multi_polygon<Y, V, A>& mp, F f)
-{
- return (for_each_point_multi_polygon(mp, f));
-}
-
-
-
-
-template<typename P,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(const multi_point<P, V, A>& mp, F f)
-{
- return (for_each_point_multi_point(mp, f));
-}
-
-template<typename L,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(const multi_linestring<L, V, A>& ml, F f)
-{
- return (for_each_point_multi_linestring(ml, f));
-}
-
-
-template<typename Y,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_point(const multi_polygon<Y, V, A>& mp, F f)
-{
- return (for_each_point_multi_polygon(mp, f));
-}
-
-
-
-
-template<typename L,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_segment(multi_linestring<L, V, A>& ml, F f)
-{
- return (for_each_segment_multi_linestring(ml, f));
-}
-
-template<typename Y,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_segment(multi_polygon<Y, V, A>& mp, F f)
-{
- return (for_each_segment_multi_polygon(mp, f));
-}
-
-
-
-
-template<typename L,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_segment(const multi_linestring<L, V, A>& ml, F f)
-{
- return (for_each_segment_multi_linestring(ml, f));
-}
-
-template<typename Y,
- template<typename,typename> class V, template<typename> class A,
- typename F>
-inline F for_each_segment(const multi_polygon<Y, V, A>& mp, F f)
-{
- return (for_each_segment_multi_polygon(mp, f));
-}
-} // namespace ggl
-
-
-#endif // GGL_MULTI_FOREACH_HPP

Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/length.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/length.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/length.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -1,26 +1,39 @@
 // Generic Geometry Library
 //
 // Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_MULTI_LENGTH_HPP
-#define GGL_MULTI_LENGTH_HPP
+#ifndef GGL_MULTI_ALGORITHMS_LENGTH_HPP
+#define GGL_MULTI_ALGORITHMS_LENGTH_HPP
 
 #include <ggl/algorithms/length.hpp>
+#include <ggl/multi/core/tags.hpp>
 #include <ggl/multi/algorithms/detail/multi_sum.hpp>
 
 namespace ggl
 {
+
 #ifndef DOXYGEN_NO_DISPATCH
 namespace dispatch
 {
- template <typename MG, typename S>
- struct length<multi_linestring_tag, MG, S>
- : detail::multi_sum<double, MG, S,
- detail::length::range_length<typename boost::range_value<MG>::type, S> > {};
+
+template <typename MultiLinestring, typename Strategy>
+struct length<multi_linestring_tag, MultiLinestring, Strategy>
+ : detail::multi_sum
+ <
+ typename length_result<MultiLinestring>::type,
+ MultiLinestring,
+ Strategy,
+ detail::length::range_length
+ <
+ typename boost::range_value<MultiLinestring>::type,
+ Strategy
+ >
+ >
+{};
+
 
 } // namespace dispatch
 #endif
@@ -29,4 +42,4 @@
 } // namespace ggl
 
 
-#endif // GGL_MULTI_LENGTH_HPP
+#endif // GGL_MULTI_ALGORITHMS_LENGTH_HPP

Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/perimeter.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/perimeter.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/perimeter.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -6,10 +6,13 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef GGL_MULTI_PERIMETER_HPP
-#define GGL_MULTI_PERIMETER_HPP
+#ifndef GGL_MULTI_ALGORITHMS_PERIMETER_HPP
+#define GGL_MULTI_ALGORITHMS_PERIMETER_HPP
 
 #include <ggl/algorithms/perimeter.hpp>
+
+#include <ggl/multi/core/tags.hpp>
+
 #include <ggl/multi/algorithms/detail/multi_sum.hpp>
 
 namespace ggl
@@ -18,10 +21,21 @@
 #ifndef DOXYGEN_NO_DISPATCH
 namespace dispatch
 {
- template <typename MG, typename S>
- struct perimeter<multi_polygon_tag, MG, S>
- : detail::multi_sum<double, MG, S,
- detail::perimeter::polygon_perimeter<typename boost::range_value<MG>::type, S> > {};
+template <typename MultiPolygon, typename Strategy>
+struct perimeter<multi_polygon_tag, MultiPolygon, Strategy>
+ : detail::multi_sum
+ <
+ typename length_result<MultiPolygon>::type,
+ MultiPolygon,
+ Strategy,
+ perimeter
+ <
+ polygon_tag,
+ typename boost::range_value<MultiPolygon>::type,
+ Strategy
+ >
+ >
+{};
 
 } // namespace dispatch
 #endif
@@ -30,4 +44,4 @@
 } // namespace ggl
 
 
-#endif // GGL_MULTI_PERIMETER_HPP
+#endif // GGL_MULTI_ALGORITHMS_PERIMETER_HPP

Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/core/tags.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/core/tags.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/core/tags.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -10,6 +10,8 @@
 #ifndef GGL_MULTI_CORE_TAGS_HPP
 #define GGL_MULTI_CORE_TAGS_HPP
 
+#include <ggl/core/tags.hpp>
+
 namespace ggl
 {
 
@@ -25,6 +27,40 @@
 /// OGC Geometry Collection identifying tag
 struct geometry_collection_tag {};
 
+
+
+
+/*!
+ \brief Meta-function to get for a tag of a multi-geometry
+ the tag of the corresponding single-geometry
+*/
+template <typename Tag>
+struct single_tag
+{};
+
+#ifndef DOXYGEN_NO_DETAIL
+
+template <>
+struct single_tag<multi_point_tag>
+{
+ typedef point_tag type;
+};
+
+template <>
+struct single_tag<multi_linestring_tag>
+{
+ typedef linestring_tag type;
+};
+
+template <>
+struct single_tag<multi_polygon_tag>
+{
+ typedef polygon_tag type;
+};
+
+#endif
+
+
 } // namespace ggl
 
 #endif // GGL_MULTI_CORE_TAGS_HPP

Added: sandbox/ggl/formal_review_request/boost/ggl/multi/util/as_range.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/util/as_range.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,40 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_MULTI_UTIL_AS_RANGE_HPP
+#define GGL_MULTI_UTIL_AS_RANGE_HPP
+
+
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <ggl/multi/core/is_multi.hpp>
+
+#include <ggl/util/as_range.hpp>
+
+namespace ggl {
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct as_range_type<Tag, true, Geometry>
+{
+ typedef typename ggl::as_range_type
+ <
+ typename boost::range_value<Geometry>::type
+ > type;
+};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+} // namespace ggl
+
+#endif // GGL_MULTI_UTIL_AS_RANGE_HPP

Added: sandbox/ggl/formal_review_request/boost/ggl/multi/util/write_dsv.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/util/write_dsv.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,66 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_MULTI_UTIL_WRITE_DSV_HPP
+#define GGL_MULTI_UTIL_WRITE_DSV_HPP
+
+#include <ggl/util/write_dsv.hpp>
+
+
+
+namespace ggl
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace dsv {
+
+
+template <typename Geometry>
+struct dsv_multi
+{
+ template <typename Char, typename Traits>
+ static inline void apply(std::basic_ostream<Char, Traits>& os,
+ Geometry const& geometry,
+ dsv_settings const& settings)
+ {
+ os << settings.list_open;
+
+ typedef typename range_const_iterator<MultiGeometry>::type iterator;
+ for(iterator it = begin(multi); it != end(multi); ++it)
+ {
+ os << ggl::dsv(*it);
+ }
+ os << settings.list_close;
+ }
+};
+
+
+
+
+}} // namespace detail::dsv
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch {
+
+
+template <typename Tag, typename Geometry>
+struct dsv<Tag, true, Geometry>
+ : detail::dsv::dsv_multi<Geometry>
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+
+} // namespace ggl
+
+#endif // GGL_MULTI_UTIL_WRITE_DSV_HPP

Added: sandbox/ggl/formal_review_request/boost/ggl/strategies/area_result.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/area_result.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,44 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_AREA_RESULT_HPP
+#define GGL_AREA_RESULT_HPP
+
+
+#include <ggl/core/coordinate_type.hpp>
+#include <ggl/util/select_most_precise.hpp>
+#include <ggl/strategies/strategies.hpp>
+
+
+namespace ggl
+{
+
+/*!
+ \brief Meta-function defining return type of area function
+ \ingroup area
+ \note The strategy defines the return-type (so this situation is different
+ from length, where distance is sqr/sqrt, but length always squared)
+
+ */
+template <typename Geometry>
+struct area_result
+{
+ typedef typename point_type<Geometry>::type point_type;
+ typedef typename strategy_area
+ <
+ typename cs_tag<point_type>::type,
+ point_type
+ >::type strategy_type;
+
+ typedef typename strategy_type::return_type type;
+};
+
+
+} // namespace ggl
+
+
+#endif // GGL_AREA_RESULT_HPP

Modified: sandbox/ggl/formal_review_request/boost/ggl/strategies/distance_result.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/distance_result.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/distance_result.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -6,8 +6,8 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef GGL_GEOMETRY_STRATEGIES_DISTANCE_RESULT_HPP
-#define GGL_GEOMETRY_STRATEGIES_DISTANCE_RESULT_HPP
+#ifndef GGL_STRATEGIES_DISTANCE_RESULT_HPP
+#define GGL_STRATEGIES_DISTANCE_RESULT_HPP
 
 #include <utility>
 #include <cmath>
@@ -15,8 +15,12 @@
 #include <iostream>
 
 #include <boost/mpl/if.hpp>
+#include <boost/numeric/conversion/cast.hpp>
 #include <boost/type_traits.hpp>
 
+#include <ggl/util/select_most_precise.hpp>
+
+
 namespace ggl {
 
 /*!
@@ -63,7 +67,15 @@
 #if defined(NUMERIC_ADAPTOR_INCLUDED)
             return boost::sqrt(m_squared_distance);
 #else
- return std::sqrt((long double)m_squared_distance);
+ return boost::numeric_cast<cast_type>
+ (
+ std::sqrt(
+ boost::numeric_cast
+ <
+ typename select_most_precise<cast_type, double>::type
+ >(m_squared_distance)
+ )
+ );
 #endif
         }
 
@@ -262,4 +274,4 @@
 } // namespace ggl
 
 
-#endif // GGL_GEOMETRY_STRATEGIES_DISTANCE_RESULT_HPP
+#endif // GGL_STRATEGIES_DISTANCE_RESULT_HPP

Added: sandbox/ggl/formal_review_request/boost/ggl/strategies/length_result.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/length_result.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -0,0 +1,40 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_LENGTH_RESULT_HPP
+#define GGL_LENGTH_RESULT_HPP
+
+
+#include <ggl/core/coordinate_type.hpp>
+#include <ggl/util/select_most_precise.hpp>
+
+
+namespace ggl
+{
+
+/*!
+ \brief Meta-function defining return type of length function
+ \ingroup length
+ \note Length of a line of integer coordinates can be double.
+ So we take at least a double. If Big Number types are used,
+ we take that type.
+
+ */
+template <typename Geometry>
+struct length_result
+{
+ typedef typename select_most_precise
+ <
+ typename coordinate_type<Geometry>::type,
+ long double
+ >::type type;
+};
+
+} // namespace ggl
+
+
+#endif // GGL_LENGTH_RESULT_HPP

Modified: sandbox/ggl/formal_review_request/boost/ggl/util/write_dsv.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/util/write_dsv.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/util/write_dsv.hpp 2009-10-22 11:25:18 EDT (Thu, 22 Oct 2009)
@@ -1,7 +1,6 @@
 // Generic Geometry Library
 //
 // Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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)
@@ -61,47 +60,69 @@
     {}
 };
 
-template <typename P, int Dimension, int Count>
+/*!
+\brief Stream coordinate of a point as \ref DSV
+*/
+template <typename Point, std::size_t Dimension, std::size_t Count>
 struct stream_coordinate
 {
     template <typename Char, typename Traits>
- static inline void apply(std::basic_ostream<Char, Traits>& os, P const& p,
+ static inline void apply(std::basic_ostream<Char, Traits>& os,
+ Point const& point,
             dsv_settings const& settings)
     {
- os << (Dimension > 0 ? settings.coordinate_separator : "")
- << get<Dimension>(p);
- stream_coordinate<P, Dimension + 1, Count>::apply(os, p, settings);
+ os << (Dimension > 0 ? settings.coordinate_separator : "")
+ << get<Dimension>(point);
+
+ stream_coordinate
+ <
+ Point, Dimension + 1, Count
+ >::apply(os, point, settings);
     }
 };
 
-template <typename P, int Count>
-struct stream_coordinate<P, Count, Count>
+template <typename Point, std::size_t Count>
+struct stream_coordinate<Point, Count, Count>
 {
     template <typename Char, typename Traits>
- static inline void apply(std::basic_ostream<Char, Traits>&, P const&,
+ static inline void apply(std::basic_ostream<Char, Traits>&,
+ Point const&,
             dsv_settings const& settings)
     {}
 };
 
 
-template <typename P, int Index, int Dimension, int Count>
-struct stream_box_corner
+/*!
+\brief Stream indexed coordinate of a box/segment as \ref DSV
+*/
+template
+<
+ typename Geometry,
+ std::size_t Index,
+ std::size_t Dimension,
+ std::size_t Count
+>
+struct stream_indexed
 {
     template <typename Char, typename Traits>
- static inline void apply(std::basic_ostream<Char, Traits>& os, P const& p,
+ static inline void apply(std::basic_ostream<Char, Traits>& os,
+ Geometry const& geometry,
             dsv_settings const& settings)
     {
- os << (Dimension > 0 ? settings.coordinate_separator : "")
- << get<Index, Dimension>(p);
- stream_box_corner<P, Index, Dimension + 1, Count>::apply(os, p, settings);
+ os << (Dimension > 0 ? settings.coordinate_separator : "")
+ << get<Index, Dimension>(geometry);
+ stream_indexed
+ <
+ Geometry, Index, Dimension + 1, Count
+ >::apply(os, geometry, settings);
     }
 };
 
-template <typename P, int Index, int Count>
-struct stream_box_corner<P, Index, Count, Count>
+template <typename Geometry, std::size_t Index, std::size_t Count>
+struct stream_indexed<Geometry, Index, Count, Count>
 {
     template <typename Char, typename Traits>
- static inline void apply(std::basic_ostream<Char, Traits>&, P const&,
+ static inline void apply(std::basic_ostream<Char, Traits>&, Geometry const&,
             dsv_settings const& settings)
     {}
 };
@@ -117,7 +138,8 @@
 struct dsv_point
 {
     template <typename Char, typename Traits>
- static inline void apply(std::basic_ostream<Char, Traits>& os, Point const& p,
+ static inline void apply(std::basic_ostream<Char, Traits>& os,
+ Point const& p,
             dsv_settings const& settings)
     {
         os << settings.point_open;
@@ -138,8 +160,8 @@
 {
     template <typename Char, typename Traits>
     static inline void apply(std::basic_ostream<Char, Traits>& os,
- Range const& range,
- dsv_settings const& settings)
+ Range const& range,
+ dsv_settings const& settings)
     {
         typedef typename boost::range_const_iterator<Range>::type iterator_type;
 
@@ -191,13 +213,15 @@
                 dsv_settings const& settings)
     {
         typedef typename ring_type<Polygon>::type ring;
- typedef typename boost::range_const_iterator<
- typename interior_type<Polygon>::type>::type iterator;
+ typedef typename boost::range_const_iterator
+ <
+ typename interior_type<Polygon>::type
+ >::type iterator_type;
 
         os << settings.list_open;
 
         dsv_range<ring>::apply(os, exterior_ring(poly), settings);
- for (iterator it = boost::begin(interior_rings(poly));
+ for (iterator_type it = boost::begin(interior_rings(poly));
             it != boost::end(interior_rings(poly));
             ++it)
         {
@@ -211,40 +235,40 @@
         BOOST_CONCEPT_ASSERT( (concept::ConstPoint<typename point_type<Polygon>::type>) );
 };
 
-template <typename Box, std::size_t Index>
-struct dsv_box_corner
+template <typename Geometry, std::size_t Index>
+struct dsv_per_index
 {
- typedef typename point_type<Box>::type point_type;
+ typedef typename point_type<Geometry>::type point_type;
 
     template <typename Char, typename Traits>
     static inline void apply(std::basic_ostream<Char, Traits>& os,
- Box const& box,
+ Geometry const& geometry,
             dsv_settings const& settings)
     {
         os << settings.point_open;
- stream_box_corner
+ stream_indexed
             <
- Box, Index, 0, dimension<Box>::type::value
- >::apply(os, box, settings);
+ Geometry, Index, 0, dimension<Geometry>::type::value
+ >::apply(os, geometry, settings);
         os << settings.point_close;
     }
 };
 
 
-template <typename Box>
-struct dsv_box
+template <typename Geometry>
+struct dsv_indexed
 {
- typedef typename point_type<Box>::type point_type;
+ typedef typename point_type<Geometry>::type point_type;
 
     template <typename Char, typename Traits>
     static inline void apply(std::basic_ostream<Char, Traits>& os,
- Box const& box,
+ Geometry const& geometry,
             dsv_settings const& settings)
     {
         os << settings.list_open;
- dsv_box_corner<Box, 0>::apply(os, box, settings);
+ dsv_per_index<Geometry, 0>::apply(os, geometry, settings);
         os << settings.point_separator;
- dsv_box_corner<Box, 1>::apply(os, box, settings);
+ dsv_per_index<Geometry, 1>::apply(os, geometry, settings);
         os << settings.list_close;
     }
 };
@@ -272,27 +296,23 @@
 {};
 
 
-/*!
-\brief Specialization to stream a box as DSV
-*/
 template <typename Box>
 struct dsv<box_tag, false, Box>
- : detail::dsv::dsv_box<Box>
+ : detail::dsv::dsv_indexed<Box>
+{};
+
+template <typename Segment>
+struct dsv<segment_tag, false, Segment>
+ : detail::dsv::dsv_indexed<Segment>
 {};
 
 
-/*!
-\brief Specialization to stream a ring as DSV
-*/
 template <typename Ring>
 struct dsv<ring_tag, false, Ring>
     : detail::dsv::dsv_range<Ring>
 {};
 
 
-/*!
-\brief Specialization to stream polygon as DSV
-*/
 template <typename Polygon>
 struct dsv<polygon_tag, false, Polygon>
     : detail::dsv::dsv_poly<Polygon>


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