Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r74858 - in branches/release: boost/geometry boost/geometry/algorithms boost/geometry/algorithms/detail boost/geometry/algorithms/detail/overlay boost/geometry/algorithms/detail/sections boost/geometry/arithmetic boost/geometry/core boost/geometry/domains boost/geometry/geometries boost/geometry/geometries/adapted boost/geometry/geometries/concepts boost/geometry/iterators boost/geometry/multi boost/geometry/multi/algorithms boost/geometry/multi/algorithms/detail/overlay boost/geometry/multi/core boost/geometry/policies boost/geometry/policies/relate boost/geometry/strategies boost/geometry/strategies/agnostic boost/geometry/strategies/cartesian boost/geometry/strategies/concepts boost/geometry/util boost/geometry/views libs/geometry/doc libs/geometry/doc/concept libs/geometry/doc/doxy libs/geometry/doc/generated libs/geometry/doc/html libs/geometry/doc/reference libs/geometry/doc/reference/algorithms libs/geometry/doc/src libs/geometry/doc/src/examples/algorithms libs/geometry/doc/src/examples/geometries/adapted libs/geometry/example libs/geometry/test libs/geometry/test/algorithms libs/geometry/test/algorithms/overlay libs/geometry/test/algorithms/overlay/robustness libs/geometry/test/multi libs/geometry/test/multi/algorithms libs/geometry/test/strategies libs/geometry/test/util
From: barend.gehrels_at_[hidden]
Date: 2011-10-09 14:30:11


Author: barendgehrels
Date: 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
New Revision: 74858
URL: http://svn.boost.org/trac/boost/changeset/74858

Log:
Merged up to and including change 74761
Added:
   branches/release/boost/geometry/algorithms/covered_by.hpp
      - copied, changed from r73201, /trunk/boost/geometry/algorithms/covered_by.hpp
   branches/release/boost/geometry/algorithms/detail/assign_box_corners.hpp
      - copied unchanged from r73399, /trunk/boost/geometry/algorithms/detail/assign_box_corners.hpp
   branches/release/boost/geometry/algorithms/detail/assign_indexed_point.hpp
      - copied unchanged from r73399, /trunk/boost/geometry/algorithms/detail/assign_indexed_point.hpp
   branches/release/boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp
      - copied unchanged from r73399, /trunk/boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp
   branches/release/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp
      - copied unchanged from r73582, /trunk/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp
   branches/release/boost/geometry/multi/algorithms/convert.hpp
      - copied unchanged from r73399, /trunk/boost/geometry/multi/algorithms/convert.hpp
   branches/release/boost/geometry/multi/algorithms/covered_by.hpp
      - copied unchanged from r73201, /trunk/boost/geometry/multi/algorithms/covered_by.hpp
   branches/release/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp
      - copied, changed from r73201, /trunk/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp
   branches/release/boost/geometry/strategies/cartesian/box_in_box.hpp
      - copied, changed from r73201, /trunk/boost/geometry/strategies/cartesian/box_in_box.hpp
   branches/release/boost/geometry/strategies/cartesian/point_in_box.hpp
      - copied, changed from r73201, /trunk/boost/geometry/strategies/cartesian/point_in_box.hpp
   branches/release/boost/geometry/strategies/covered_by.hpp
      - copied unchanged from r73201, /trunk/boost/geometry/strategies/covered_by.hpp
   branches/release/boost/geometry/util/parameter_type_of.hpp
      - copied unchanged from r73201, /trunk/boost/geometry/util/parameter_type_of.hpp
   branches/release/boost/geometry/util/rational.hpp
      - copied, changed from r74156, /trunk/boost/geometry/util/rational.hpp
   branches/release/libs/geometry/example/ml01_multipolygon_simplify.cpp
      - copied unchanged from r74854, /trunk/libs/geometry/example/ml01_multipolygon_simplify.cpp
   branches/release/libs/geometry/example/ml01_multipolygon_simplify.vcproj
      - copied unchanged from r74854, /trunk/libs/geometry/example/ml01_multipolygon_simplify.vcproj
   branches/release/libs/geometry/example/ml02_distance_strategy.cpp
      - copied unchanged from r74854, /trunk/libs/geometry/example/ml02_distance_strategy.cpp
   branches/release/libs/geometry/example/ml02_distance_strategy.vcproj
      - copied unchanged from r74854, /trunk/libs/geometry/example/ml02_distance_strategy.vcproj
   branches/release/libs/geometry/test/algorithms/covered_by.cpp
      - copied unchanged from r73201, /trunk/libs/geometry/test/algorithms/covered_by.cpp
   branches/release/libs/geometry/test/algorithms/covered_by.vcproj
      - copied unchanged from r73201, /trunk/libs/geometry/test/algorithms/covered_by.vcproj
   branches/release/libs/geometry/test/algorithms/overlay/robustness/intersects.cpp
      - copied unchanged from r73629, /trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.cpp
   branches/release/libs/geometry/test/algorithms/overlay/robustness/intersects.vcproj
      - copied unchanged from r73629, /trunk/libs/geometry/test/algorithms/overlay/robustness/intersects.vcproj
   branches/release/libs/geometry/test/algorithms/test_convert.hpp
      - copied unchanged from r73399, /trunk/libs/geometry/test/algorithms/test_convert.hpp
   branches/release/libs/geometry/test/algorithms/test_covered_by.hpp
      - copied unchanged from r73201, /trunk/libs/geometry/test/algorithms/test_covered_by.hpp
   branches/release/libs/geometry/test/multi/algorithms/multi_convert.cpp
      - copied unchanged from r73399, /trunk/libs/geometry/test/multi/algorithms/multi_convert.cpp
   branches/release/libs/geometry/test/multi/algorithms/multi_convert.vcproj
      - copied unchanged from r73399, /trunk/libs/geometry/test/multi/algorithms/multi_convert.vcproj
   branches/release/libs/geometry/test/multi/algorithms/multi_covered_by.cpp
      - copied unchanged from r73201, /trunk/libs/geometry/test/multi/algorithms/multi_covered_by.cpp
   branches/release/libs/geometry/test/multi/algorithms/multi_covered_by.vcproj
      - copied unchanged from r73201, /trunk/libs/geometry/test/multi/algorithms/multi_covered_by.vcproj
   branches/release/libs/geometry/test/util/rational.cpp
      - copied unchanged from r74465, /trunk/libs/geometry/test/util/rational.cpp
   branches/release/libs/geometry/test/util/rational.vcproj
      - copied unchanged from r74465, /trunk/libs/geometry/test/util/rational.vcproj
Removed:
   branches/release/boost/geometry/algorithms/detail/overlay/within_util.hpp
Properties modified:
   branches/release/boost/geometry/algorithms/ (props changed)
   branches/release/boost/geometry/arithmetic/ (props changed)
   branches/release/boost/geometry/core/ (props changed)
   branches/release/boost/geometry/domains/ (props changed)
   branches/release/boost/geometry/geometries/ (props changed)
   branches/release/boost/geometry/geometry.hpp (props changed)
   branches/release/boost/geometry/iterators/ (props changed)
   branches/release/boost/geometry/multi/ (props changed)
   branches/release/boost/geometry/policies/ (props changed)
   branches/release/boost/geometry/strategies/ (props changed)
   branches/release/boost/geometry/util/ (props changed)
   branches/release/boost/geometry/views/ (props changed)
   branches/release/libs/geometry/doc/ (props changed)
   branches/release/libs/geometry/doc/Jamfile.v2 (contents, props changed)
   branches/release/libs/geometry/doc/about_documentation.qbk (props changed)
   branches/release/libs/geometry/doc/acknowledgments.qbk (props changed)
   branches/release/libs/geometry/doc/compiling.qbk (props changed)
   branches/release/libs/geometry/doc/concept/ (props changed)
   branches/release/libs/geometry/doc/copyright_note_policy.txt (props changed)
   branches/release/libs/geometry/doc/design_rationale.qbk (props changed)
   branches/release/libs/geometry/doc/doxy/ (props changed)
   branches/release/libs/geometry/doc/generated/ (props changed)
   branches/release/libs/geometry/doc/geometry.qbk (props changed)
   branches/release/libs/geometry/doc/html/ (props changed)
   branches/release/libs/geometry/doc/imports.qbk (props changed)
   branches/release/libs/geometry/doc/introduction.qbk (contents, props changed)
   branches/release/libs/geometry/doc/make_qbk.py (props changed)
   branches/release/libs/geometry/doc/matrix.qbk (props changed)
   branches/release/libs/geometry/doc/quickref.xml (props changed)
   branches/release/libs/geometry/doc/quickstart.qbk (props changed)
   branches/release/libs/geometry/doc/readme.txt (props changed)
   branches/release/libs/geometry/doc/reference/ (props changed)
   branches/release/libs/geometry/doc/reference.qbk (props changed)
   branches/release/libs/geometry/doc/src/ (props changed)
   branches/release/libs/geometry/example/ (props changed)
   branches/release/libs/geometry/test/ (props changed)
Text files modified:
   branches/release/boost/geometry/algorithms/assign.hpp | 137 ++------------
   branches/release/boost/geometry/algorithms/convert.hpp | 241 +++++++++++++++++++-----
   branches/release/boost/geometry/algorithms/covered_by.hpp | 2
   branches/release/boost/geometry/algorithms/detail/assign_values.hpp | 11
   branches/release/boost/geometry/algorithms/detail/has_self_intersections.hpp | 3
   branches/release/boost/geometry/algorithms/detail/overlay/assign_parents.hpp | 13
   branches/release/boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp | 6
   branches/release/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp | 7
   branches/release/boost/geometry/algorithms/detail/overlay/copy_segments.hpp | 11
   branches/release/boost/geometry/algorithms/detail/overlay/enrichment_info.hpp | 22 +
   branches/release/boost/geometry/algorithms/detail/overlay/get_turns.hpp | 44 +++-
   branches/release/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp | 43 ++++
   branches/release/boost/geometry/algorithms/detail/overlay/overlay.hpp | 25 +-
   branches/release/boost/geometry/algorithms/detail/overlay/ring_properties.hpp | 6
   branches/release/boost/geometry/algorithms/detail/overlay/select_rings.hpp | 57 +++--
   branches/release/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp | 112 ++++++++---
   branches/release/boost/geometry/algorithms/detail/overlay/traverse.hpp | 374 +++++++++++++++------------------------
   branches/release/boost/geometry/algorithms/detail/sections/sectionalize.hpp | 11
   branches/release/boost/geometry/algorithms/within.hpp | 246 +++++++------------------
   branches/release/boost/geometry/core/tags.hpp | 16 +
   branches/release/boost/geometry/geometries/adapted/boost_fusion.hpp | 2
   branches/release/boost/geometry/geometries/concepts/check.hpp | 2
   branches/release/boost/geometry/multi/algorithms/detail/overlay/select_rings.hpp | 5
   branches/release/boost/geometry/multi/algorithms/within.hpp | 43 ++-
   branches/release/boost/geometry/multi/core/tags.hpp | 2
   branches/release/boost/geometry/policies/relate/intersection_points.hpp | 11 +
   branches/release/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp | 2
   branches/release/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp | 41 +++-
   branches/release/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp | 9
   branches/release/boost/geometry/strategies/cartesian/area_surveyor.hpp | 2
   branches/release/boost/geometry/strategies/cartesian/box_in_box.hpp | 2
   branches/release/boost/geometry/strategies/cartesian/cart_intersect.hpp | 51 ++++-
   branches/release/boost/geometry/strategies/cartesian/point_in_box.hpp | 6
   branches/release/boost/geometry/strategies/cartesian/side_by_triangle.hpp | 2
   branches/release/boost/geometry/strategies/concepts/distance_concept.hpp | 75 -------
   branches/release/boost/geometry/strategies/concepts/within_concept.hpp | 255 ++++++++++++++++++++++++--
   branches/release/boost/geometry/strategies/strategies.hpp | 3
   branches/release/boost/geometry/strategies/strategy_transform.hpp | 27 ++
   branches/release/boost/geometry/strategies/within.hpp | 23 +-
   branches/release/boost/geometry/util/rational.hpp | 50 ++++
   branches/release/libs/geometry/doc/Jamfile.v2 | 27 +-
   branches/release/libs/geometry/doc/introduction.qbk | 15 +
   branches/release/libs/geometry/doc/reference/algorithms/convex_hull.qbk | 2
   branches/release/libs/geometry/doc/src/examples/algorithms/create_svg_overlay.hpp | 2
   branches/release/libs/geometry/doc/src/examples/geometries/adapted/boost_fusion.cpp | 2
   branches/release/libs/geometry/test/algorithms/Jamfile.v2 | 1
   branches/release/libs/geometry/test/algorithms/algorithms_tests.sln | 6
   branches/release/libs/geometry/test/algorithms/assign.cpp | 8
   branches/release/libs/geometry/test/algorithms/convert.cpp | 296 +++++++++++++++++++++++--------
   branches/release/libs/geometry/test/algorithms/difference.cpp | 60 +++++-
   branches/release/libs/geometry/test/algorithms/intersection.cpp | 87 +++++++-
   branches/release/libs/geometry/test/algorithms/intersects.cpp | 51 +++++
   branches/release/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp | 6
   branches/release/libs/geometry/test/algorithms/overlay/get_turns.cpp | 5
   branches/release/libs/geometry/test/algorithms/overlay/overlay_cases.hpp | 27 ++
   branches/release/libs/geometry/test/algorithms/overlay/robustness/robustness.sln | 6
   branches/release/libs/geometry/test/algorithms/overlay/select_rings.cpp | 2
   branches/release/libs/geometry/test/algorithms/overlay/self_intersection_points.vcproj | 1
   branches/release/libs/geometry/test/algorithms/overlay/traverse.cpp | 6
   branches/release/libs/geometry/test/algorithms/test_difference.hpp | 4
   branches/release/libs/geometry/test/algorithms/test_intersection.hpp | 44 ++--
   branches/release/libs/geometry/test/algorithms/test_overlay.hpp | 2
   branches/release/libs/geometry/test/algorithms/test_union.hpp | 5
   branches/release/libs/geometry/test/algorithms/test_within.hpp | 5
   branches/release/libs/geometry/test/algorithms/union.cpp | 61 ++---
   branches/release/libs/geometry/test/algorithms/within.cpp | 129 ++++++++++++
   branches/release/libs/geometry/test/geometry_test_common.hpp | 43 ++++
   branches/release/libs/geometry/test/multi/algorithms/Jamfile.v2 | 2
   branches/release/libs/geometry/test/multi/algorithms/multi_difference.cpp | 2
   branches/release/libs/geometry/test/multi/algorithms/multi_intersection.cpp | 14 +
   branches/release/libs/geometry/test/multi/algorithms/multi_simplify.cpp | 9
   branches/release/libs/geometry/test/multi/algorithms/multi_within.cpp | 12
   branches/release/libs/geometry/test/multi/multi_tests.sln | 12 +
   branches/release/libs/geometry/test/strategies/within.cpp | 59 ++++++
   branches/release/libs/geometry/test/util/Jamfile.v2 | 1
   branches/release/libs/geometry/test/util/util_tests.sln | 6
   76 files changed, 1945 insertions(+), 1075 deletions(-)

Modified: branches/release/boost/geometry/algorithms/assign.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/assign.hpp (original)
+++ branches/release/boost/geometry/algorithms/assign.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -25,6 +25,8 @@
 #include <boost/numeric/conversion/cast.hpp>
 #include <boost/type_traits.hpp>
 
+#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
+#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
 #include <boost/geometry/algorithms/detail/assign_values.hpp>
 #include <boost/geometry/algorithms/convert.hpp>
 
@@ -122,124 +124,6 @@
>::apply(geometry);
 }
 
-
-#ifndef DOXYGEN_NO_DETAIL
-namespace detail
-{
-// Note: this is moved to namespace detail because the names and parameter orders
-// are not yet 100% clear.
-
-/*!
-\brief Assign the four points of a 2D box
-\ingroup assign
-\note The order is crucial. Most logical is LOWER, UPPER and sub-order LEFT, RIGHT
- so this is how it is implemented.
-\tparam Box \tparam_box
-\tparam Point \tparam_point
-\param box \param_box
-\param lower_left point being assigned to lower left coordinates of the box
-\param lower_right point being assigned to lower right coordinates of the box
-\param upper_left point being assigned to upper left coordinates of the box
-\param upper_right point being assigned to upper right coordinates of the box
-
-\qbk{
-[heading Example]
-[assign_box_corners] [assign_box_corners_output]
-}
-*/
-template <typename Box, typename Point>
-inline void assign_box_corners(Box const& box,
- Point& lower_left, Point& lower_right,
- Point& upper_left, Point& upper_right)
-{
- concept::check<Box const>();
- concept::check<Point>();
-
- detail::assign::assign_box_2d_corner
- <min_corner, min_corner>(box, lower_left);
- detail::assign::assign_box_2d_corner
- <max_corner, min_corner>(box, lower_right);
- detail::assign::assign_box_2d_corner
- <min_corner, max_corner>(box, upper_left);
- detail::assign::assign_box_2d_corner
- <max_corner, max_corner>(box, upper_right);
-}
-
-template <bool Reverse, typename Box, typename Range>
-inline void assign_box_corners_oriented(Box const& box, Range& corners)
-{
- if (Reverse)
- {
- // make counterclockwise ll,lr,ur,ul
- assign_box_corners(box, corners[0], corners[1], corners[3], corners[2]);
- }
- else
- {
- // make clockwise ll,ul,ur,lr
- assign_box_corners(box, corners[0], corners[3], corners[1], corners[2]);
- }
-}
-
-
-/*!
-\brief Assign a box or segment with the value of a point
-\ingroup assign
-\tparam Index indicates which box-corner, min_corner (0) or max_corner (1)
- or which point of segment (0/1)
-\tparam Point \tparam_point
-\tparam Geometry \tparam_box_or_segment
-\param point \param_point
-\param geometry \param_box_or_segment
-
-\qbk{
-[heading Example]
-[assign_point_to_index] [assign_point_to_index_output]
-}
-*/
-template <std::size_t Index, typename Geometry, typename Point>
-inline void assign_point_to_index(Point const& point, Geometry& geometry)
-{
- concept::check<Point const>();
- concept::check<Geometry>();
-
- detail::assign::assign_point_to_index
- <
- Geometry, Point, Index, 0, dimension<Geometry>::type::value
- >::apply(point, geometry);
-}
-
-
-/*!
-\brief Assign a point with a point of a box or segment
-\ingroup assign
-\tparam Index indicates which box-corner, min_corner (0) or max_corner (1)
- or which point of segment (0/1)
-\tparam Geometry \tparam_box_or_segment
-\tparam Point \tparam_point
-\param geometry \param_box_or_segment
-\param point \param_point
-
-\qbk{
-[heading Example]
-[assign_point_from_index] [assign_point_from_index_output]
-}
-*/
-template <std::size_t Index, typename Point, typename Geometry>
-inline void assign_point_from_index(Geometry const& geometry, Point& point)
-{
- concept::check<Geometry const>();
- concept::check<Point>();
-
- detail::assign::assign_point_from_index
- <
- Geometry, Point, Index, 0, dimension<Geometry>::type::value
- >::apply(geometry, point);
-}
-
-} // namespace detail
-#endif // DOXYGEN_NO_DETAIL
-
-
 /*!
 \brief Assigns one geometry to another geometry
 \details The assign algorithm assigns one geometry, e.g. a BOX, to another geometry, e.g. a RING. This only
@@ -263,8 +147,25 @@
 {
     concept::check_concepts_and_equal_dimensions<Geometry1, Geometry2 const>();
 
+ bool const same_point_order =
+ point_order<Geometry1>::value == point_order<Geometry2>::value;
+ bool const same_closure =
+ closure<Geometry1>::value == closure<Geometry2>::value;
+
+ BOOST_MPL_ASSERT_MSG
+ (
+ same_point_order, ASSIGN_IS_NOT_SUPPORTED_FOR_DIFFERENT_POINT_ORDER
+ , (types<Geometry1, Geometry2>)
+ );
+ BOOST_MPL_ASSERT_MSG
+ (
+ same_closure, ASSIGN_IS_NOT_SUPPORTED_FOR_DIFFERENT_CLOSURE
+ , (types<Geometry1, Geometry2>)
+ );
+
     dispatch::convert
         <
+ false,
             typename tag<Geometry2>::type,
             typename tag<Geometry1>::type,
             dimension<Geometry1>::type::value,

Modified: branches/release/boost/geometry/algorithms/convert.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/convert.hpp (original)
+++ branches/release/boost/geometry/algorithms/convert.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -11,23 +11,31 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_HPP
-#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_HPP
+#ifndef BOOST_GEOMETRY_ALGORITHMS_CONVERT_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_CONVERT_HPP
 
 
 #include <cstddef>
 
 #include <boost/numeric/conversion/cast.hpp>
 #include <boost/range.hpp>
+#include <boost/type_traits/is_array.hpp>
 
 #include <boost/geometry/arithmetic/arithmetic.hpp>
 #include <boost/geometry/algorithms/append.hpp>
 #include <boost/geometry/algorithms/clear.hpp>
 #include <boost/geometry/algorithms/for_each.hpp>
 #include <boost/geometry/algorithms/detail/assign_values.hpp>
+#include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
+#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
 #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
 
+#include <boost/geometry/views/closeable_view.hpp>
+#include <boost/geometry/views/reversible_view.hpp>
+
 #include <boost/geometry/core/cs.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/point_order.hpp>
 #include <boost/geometry/geometries/concepts/check.hpp>
 
 
@@ -76,6 +84,123 @@
     {}
 };
 
+template <typename Box, typename Range, bool Close, bool Reverse>
+struct box_to_range
+{
+ static inline void apply(Box const& box, Range& range)
+ {
+ traits::resize<Range>::apply(range, Close ? 5 : 4);
+ assign_box_corners_oriented<Reverse>(box, range);
+ if (Close)
+ {
+ range[4] = range[0];
+ }
+ }
+};
+
+template <typename Segment, typename Range>
+struct segment_to_range
+{
+ static inline void apply(Segment const& segment, Range& range)
+ {
+ traits::resize<Range>::apply(range, 2);
+
+ typename boost::range_iterator<Range>::type it = boost::begin(range);
+
+ assign_point_from_index<0>(segment, *it);
+ ++it;
+ assign_point_from_index<1>(segment, *it);
+ }
+};
+
+template
+<
+ typename Range1,
+ typename Range2,
+ bool Reverse = false
+>
+struct range_to_range
+{
+ typedef typename reversible_view
+ <
+ Range1 const,
+ Reverse ? iterate_reverse : iterate_forward
+ >::type rview_type;
+ typedef typename closeable_view
+ <
+ rview_type const,
+ geometry::closure<Range1>::value
+ >::type view_type;
+
+ static inline void apply(Range1 const& source, Range2& destination)
+ {
+ geometry::clear(destination);
+
+ rview_type rview(source);
+
+ // We consider input always as closed, and skip last
+ // point for open output.
+ view_type view(rview);
+
+ int n = boost::size(view);
+ if (geometry::closure<Range2>::value == geometry::open)
+ {
+ n--;
+ }
+
+ int i = 0;
+ for (typename boost::range_iterator<view_type const>::type it
+ = boost::begin(view);
+ it != boost::end(view) && i < n;
+ ++it, ++i)
+ {
+ geometry::append(destination, *it);
+ }
+ }
+};
+
+template <typename Polygon1, typename Polygon2>
+struct polygon_to_polygon
+{
+ typedef range_to_range
+ <
+ typename geometry::ring_type<Polygon1>::type,
+ typename geometry::ring_type<Polygon2>::type,
+ geometry::point_order<Polygon1>::value
+ != geometry::point_order<Polygon2>::value
+ > per_ring;
+
+ static inline void apply(Polygon1 const& source, Polygon2& destination)
+ {
+ // Clearing managed per ring, and in the resizing of interior rings
+
+ per_ring::apply(geometry::exterior_ring(source),
+ geometry::exterior_ring(destination));
+
+ // Container should be resizeable
+ traits::resize
+ <
+ typename boost::remove_reference
+ <
+ typename traits::interior_mutable_type<Polygon2>::type
+ >::type
+ >::apply(interior_rings(destination), num_interior_rings(source));
+
+ typename interior_return_type<Polygon1 const>::type rings_source
+ = interior_rings(source);
+ typename interior_return_type<Polygon2>::type rings_dest
+ = interior_rings(destination);
+
+ BOOST_AUTO_TPL(it_source, boost::begin(rings_source));
+ BOOST_AUTO_TPL(it_dest, boost::begin(rings_dest));
+
+ for ( ; it_source != boost::end(rings_source); ++it_source, ++it_dest)
+ {
+ per_ring::apply(*it_source, *it_dest);
+ }
+ }
+};
+
 
 }} // namespace detail::conversion
 #endif // DOXYGEN_NO_DETAIL
@@ -87,12 +212,18 @@
 
 template
 <
+ bool UseAssignment,
     typename Tag1, typename Tag2,
     std::size_t DimensionCount,
     typename Geometry1, typename Geometry2
>
 struct convert
 {
+ BOOST_MPL_ASSERT_MSG
+ (
+ false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPES
+ , (types<Geometry1, Geometry2>)
+ );
 };
 
 
@@ -102,10 +233,9 @@
     std::size_t DimensionCount,
     typename Geometry1, typename Geometry2
>
-struct convert<Tag, Tag, DimensionCount, Geometry1, Geometry2>
+struct convert<true, Tag, Tag, DimensionCount, Geometry1, Geometry2>
 {
- // Same geometry type -> copy coordinates from G1 to G2
- // Actually: we try now to just copy it
+ // Same geometry type -> copy whole geometry
     static inline void apply(Geometry1 const& source, Geometry2& destination)
     {
         destination = source;
@@ -118,57 +248,51 @@
     std::size_t DimensionCount,
     typename Geometry1, typename Geometry2
>
-struct convert<point_tag, point_tag, DimensionCount, Geometry1, Geometry2>
+struct convert<false, point_tag, point_tag, DimensionCount, Geometry1, Geometry2>
     : detail::conversion::point_to_point<Geometry1, Geometry2, 0, DimensionCount>
 {};
 
+template <std::size_t DimensionCount, typename Segment, typename LineString>
+struct convert<false, segment_tag, linestring_tag, DimensionCount, Segment, LineString>
+ : detail::conversion::segment_to_range<Segment, LineString>
+{};
 
-template <std::size_t DimensionCount, typename Ring1, typename Ring2>
-struct convert<ring_tag, ring_tag, DimensionCount, Ring1, Ring2>
-{
- static inline void apply(Ring1 const& source, Ring2& destination)
- {
- geometry::clear(destination);
- for (typename boost::range_iterator<Ring1 const>::type it
- = boost::begin(source);
- it != boost::end(source);
- ++it)
- {
- geometry::append(destination, *it);
- }
- }
-};
-
-
-template <typename Box, typename Ring>
-struct convert<box_tag, ring_tag, 2, Box, Ring>
-{
- static inline void apply(Box const& box, Ring& ring)
- {
- // go from box to ring -> add coordinates in correct order
- geometry::clear(ring);
- typename point_type<Box>::type point;
-
- geometry::assign_values(point, get<min_corner, 0>(box), get<min_corner, 1>(box));
- geometry::append(ring, point);
 
- geometry::assign_values(point, get<min_corner, 0>(box), get<max_corner, 1>(box));
- geometry::append(ring, point);
+template <std::size_t DimensionCount, typename Ring1, typename Ring2>
+struct convert<false, ring_tag, ring_tag, DimensionCount, Ring1, Ring2>
+ : detail::conversion::range_to_range
+ <
+ Ring1,
+ Ring2,
+ geometry::point_order<Ring1>::value
+ != geometry::point_order<Ring2>::value
+ >
+{};
 
- geometry::assign_values(point, get<max_corner, 0>(box), get<max_corner, 1>(box));
- geometry::append(ring, point);
+template <std::size_t DimensionCount, typename LineString1, typename LineString2>
+struct convert<false, linestring_tag, linestring_tag, DimensionCount, LineString1, LineString2>
+ : detail::conversion::range_to_range<LineString1, LineString2>
+{};
 
- geometry::assign_values(point, get<max_corner, 0>(box), get<min_corner, 1>(box));
- geometry::append(ring, point);
+template <std::size_t DimensionCount, typename Polygon1, typename Polygon2>
+struct convert<false, polygon_tag, polygon_tag, DimensionCount, Polygon1, Polygon2>
+ : detail::conversion::polygon_to_polygon<Polygon1, Polygon2>
+{};
 
- geometry::assign_values(point, get<min_corner, 0>(box), get<min_corner, 1>(box));
- geometry::append(ring, point);
- }
-};
+template <typename Box, typename Ring>
+struct convert<false, box_tag, ring_tag, 2, Box, Ring>
+ : detail::conversion::box_to_range
+ <
+ Box,
+ Ring,
+ geometry::closure<Ring>::value == closed,
+ geometry::point_order<Ring>::value == counterclockwise
+ >
+{};
 
 
 template <typename Box, typename Polygon>
-struct convert<box_tag, polygon_tag, 2, Box, Polygon>
+struct convert<false, box_tag, polygon_tag, 2, Box, Polygon>
 {
     static inline void apply(Box const& box, Polygon& polygon)
     {
@@ -176,7 +300,7 @@
 
         convert
             <
- box_tag, ring_tag,
+ false, box_tag, ring_tag,
                 2, Box, ring_type
>::apply(box, exterior_ring(polygon));
     }
@@ -184,7 +308,7 @@
 
 
 template <typename Point, std::size_t DimensionCount, typename Box>
-struct convert<point_tag, box_tag, DimensionCount, Point, Box>
+struct convert<false, point_tag, box_tag, DimensionCount, Point, Box>
 {
     static inline void apply(Point const& point, Box& box)
     {
@@ -201,14 +325,14 @@
 
 
 template <typename Ring, std::size_t DimensionCount, typename Polygon>
-struct convert<ring_tag, polygon_tag, DimensionCount, Ring, Polygon>
+struct convert<false, ring_tag, polygon_tag, DimensionCount, Ring, Polygon>
 {
     static inline void apply(Ring const& ring, Polygon& polygon)
     {
         typedef typename ring_type<Polygon>::type ring_type;
         convert
             <
- ring_tag, ring_tag, DimensionCount,
+ false, ring_tag, ring_tag, DimensionCount,
                 Ring, ring_type
>::apply(ring, exterior_ring(polygon));
     }
@@ -216,7 +340,7 @@
 
 
 template <typename Polygon, std::size_t DimensionCount, typename Ring>
-struct convert<polygon_tag, ring_tag, DimensionCount, Polygon, Ring>
+struct convert<false, polygon_tag, ring_tag, DimensionCount, Polygon, Ring>
 {
     static inline void apply(Polygon const& polygon, Ring& ring)
     {
@@ -224,6 +348,7 @@
 
         convert
             <
+ false,
                 ring_tag, ring_tag, DimensionCount,
                 ring_type, Ring
>::apply(exterior_ring(polygon), ring);
@@ -237,8 +362,11 @@
 
 /*!
 \brief Converts one geometry to another geometry
-\details The convert algorithm converts one geometry, e.g. a BOX, to another geometry, e.g. a RING. This only
-if it is possible and applicable.
+\details The convert algorithm converts one geometry, e.g. a BOX, to another
+geometry, e.g. a RING. This only if it is possible and applicable.
+If the point-order is different, or the closure is different between two
+geometry types, it will be converted correctly by explicitly reversing the
+points or closing or opening the polygon rings.
 \ingroup convert
 \tparam Geometry1 \tparam_geometry
 \tparam Geometry2 \tparam_geometry
@@ -254,8 +382,11 @@
 
     dispatch::convert
         <
- typename tag<Geometry1>::type,
- typename tag<Geometry2>::type,
+ boost::is_same<Geometry1, Geometry2>::value
+ // && boost::has_assign<Geometry2>::value, -- type traits extensions
+ && ! boost::is_array<Geometry1>::value,
+ typename tag_cast<typename tag<Geometry1>::type, multi_tag>::type,
+ typename tag_cast<typename tag<Geometry2>::type, multi_tag>::type,
             dimension<Geometry1>::type::value,
             Geometry1,
             Geometry2
@@ -266,4 +397,4 @@
 }} // namespace boost::geometry
 
 
-#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_CONVERT_HPP
+#endif // BOOST_GEOMETRY_ALGORITHMS_CONVERT_HPP

Copied: branches/release/boost/geometry/algorithms/covered_by.hpp (from r73201, /trunk/boost/geometry/algorithms/covered_by.hpp)
==============================================================================
--- /trunk/boost/geometry/algorithms/covered_by.hpp (original)
+++ branches/release/boost/geometry/algorithms/covered_by.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -180,7 +180,7 @@
 inline bool covered_by(Geometry1 const& geometry1, Geometry2 const& geometry2,
         Strategy const& strategy)
 {
- concept::within::check
+ concept::within::check
         <
             typename tag<Geometry1>::type,
             typename tag<Geometry2>::type,

Modified: branches/release/boost/geometry/algorithms/detail/assign_values.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/assign_values.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/assign_values.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -90,14 +90,7 @@
 
     static inline void apply(BoxOrSegment& geometry)
     {
- typedef typename coordinate_type<point_type>::type coordinate_type;
-
- typedef typename boost::mpl::if_
- <
- typename boost::is_arithmetic<coordinate_type>::type,
- coordinate_type,
- double
- >::type bound_type;
+ typedef typename coordinate_type<point_type>::type bound_type;
 
         initialize
             <
@@ -207,7 +200,7 @@
     {
         geometry::set<Dimension>( point, boost::numeric_cast
             <
- typename coordinate_type<Geometry>::type
+ typename coordinate_type<Point>::type
>(geometry::get<Index, Dimension>(geometry)));
 
         assign_point_from_index

Modified: branches/release/boost/geometry/algorithms/detail/has_self_intersections.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/has_self_intersections.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/has_self_intersections.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -59,11 +59,10 @@
 template <typename Geometry>
 inline bool has_self_intersections(Geometry const& geometry)
 {
- using namespace boost::geometry;
     typedef typename point_type<Geometry>::type point_type;
     typedef detail::overlay::turn_info<point_type> turn_info;
     std::deque<turn_info> turns;
- detail::get_turns::no_interrupt_policy policy;
+ detail::disjoint::disjoint_interrupt_policy policy;
     geometry::self_turns<detail::overlay::assign_null_policy>(geometry, turns, policy);
     
 #ifdef BOOST_GEOMETRY_DEBUG_HAS_SELF_INTERSECTIONS

Modified: branches/release/boost/geometry/algorithms/detail/overlay/assign_parents.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/assign_parents.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/assign_parents.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -14,7 +14,7 @@
 #include <boost/geometry/algorithms/expand.hpp>
 #include <boost/geometry/algorithms/detail/partition.hpp>
 #include <boost/geometry/algorithms/detail/overlay/get_ring.hpp>
-#include <boost/geometry/algorithms/detail/overlay/within_util.hpp>
+#include <boost/geometry/algorithms/within.hpp>
 
 #include <boost/geometry/geometries/box.hpp>
 
@@ -42,23 +42,22 @@
     typedef typename geometry::tag<Geometry1>::type tag1;
     typedef typename geometry::tag<Geometry2>::type tag2;
 
- int code = -1;
     switch (ring_id.source_index)
     {
         case 0 :
- code = point_in_ring(item2.point,
+ return geometry::within(item2.point,
                 get_ring<tag1>::apply(ring_id, geometry1));
             break;
         case 1 :
- code = point_in_ring(item2.point,
+ return geometry::within(item2.point,
                 get_ring<tag2>::apply(ring_id, geometry2));
             break;
         case 2 :
- code = point_in_ring(item2.point,
+ return geometry::within(item2.point,
                 get_ring<void>::apply(ring_id, collection));
             break;
     }
- return code == 1;
+ return false;
 }
 
 
@@ -77,7 +76,7 @@
     {}
 
     inline ring_info_helper(ring_identifier i, area_type a)
- : id(i), real_area(a), abs_area(abs(a))
+ : id(i), real_area(a), abs_area(geometry::math::abs(a))
     {}
 };
 

Modified: branches/release/boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/calculate_distance_policy.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -10,7 +10,7 @@
 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CALCULATE_DISTANCE_POLICY_HPP
 
 
-#include <boost/geometry/algorithms/distance.hpp>
+#include <boost/geometry/algorithms/comparable_distance.hpp>
 
 
 namespace boost { namespace geometry
@@ -34,9 +34,9 @@
     static inline void apply(Info& info, Point1 const& p1, Point2 const& p2)
     {
         info.operations[0].enriched.distance
- = geometry::distance(info.point, p1);
+ = geometry::comparable_distance(info.point, p1);
         info.operations[1].enriched.distance
- = geometry::distance(info.point, p2);
+ = geometry::comparable_distance(info.point, p2);
     }
 
 };

Modified: branches/release/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/clip_linestring.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -11,10 +11,11 @@
 
 #include <boost/range.hpp>
 
-#include <boost/geometry/algorithms/append.hpp>
 #include <boost/geometry/algorithms/clear.hpp>
 #include <boost/geometry/algorithms/convert.hpp>
 
+#include <boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp>
+
 #include <boost/geometry/util/select_coordinate_type.hpp>
 #include <boost/geometry/geometries/segment.hpp>
 
@@ -215,9 +216,9 @@
             // b. Add p1 only if it is the first point, then add p2
             if (boost::empty(line_out))
             {
- geometry::append(line_out, p1);
+ detail::overlay::append_no_duplicates(line_out, p1, true);
             }
- geometry::append(line_out, p2);
+ detail::overlay::append_no_duplicates(line_out, p2);
 
             // c. If c2 is clipped, finish the line
             if (c2)

Modified: branches/release/boost/geometry/algorithms/detail/overlay/copy_segments.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/copy_segments.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/copy_segments.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -27,6 +27,7 @@
 #include <boost/geometry/views/closeable_view.hpp>
 #include <boost/geometry/views/reversible_view.hpp>
 
+#include <boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp>
 
 namespace boost { namespace geometry
 {
@@ -92,12 +93,7 @@
 
         for (size_type i = 0; i < count; ++i, ++it)
         {
-#ifdef BOOST_GEOMETRY_DEBUG_INTERSECTION
- std::cout << " add: ("
- << geometry::get<0>(*it) << ", " << geometry::get<1>(*it) << ")"
- << std::endl;
-#endif
- geometry::append(current_output, *it);
+ detail::overlay::append_no_duplicates(current_output, *it);
         }
     }
 };
@@ -164,7 +160,8 @@
         // (see comments in ring-version)
         for (int i = 0; i < count; i++, index++)
         {
- geometry::append(current_output, bp[index % 5]);
+ detail::overlay::append_no_duplicates(current_output, bp[index % 5]);
+
         }
     }
 };

Modified: branches/release/boost/geometry/algorithms/detail/overlay/enrichment_info.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/enrichment_info.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/enrichment_info.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -10,7 +10,7 @@
 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_ENRICHMENT_INFO_HPP
 
 
-#include <boost/geometry/strategies/default_distance_result.hpp>
+#include <boost/geometry/strategies/distance.hpp>
 
 
 namespace boost { namespace geometry
@@ -23,15 +23,25 @@
 
 
 /*!
- \brief Keeps info to enrich intersection info (per source)
- \details Class to keep information necessary for traversal phase (a phase
- of the overlay process). The information is gathered during the
- enrichment phase
+\brief Keeps info to enrich intersection info (per source)
+\details Class to keep information necessary for traversal phase (a phase
+ of the overlay process). The information is gathered during the
+ enrichment phase
  */
 template<typename P>
 struct enrichment_info
 {
- typedef typename default_distance_result<P, P>::type distance_type;
+ typedef typename strategy::distance::services::return_type
+ <
+ typename strategy::distance::services::comparable_type
+ <
+ typename strategy::distance::services::default_strategy
+ <
+ point_tag,
+ P
+ >::type
+ >::type
+ >::type distance_type;
 
     inline enrichment_info()
         : travels_to_vertex_index(-1)

Modified: branches/release/boost/geometry/algorithms/detail/overlay/get_turns.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/get_turns.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/get_turns.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -127,6 +127,31 @@
>::type range2_iterator;
 
 
+ template <typename Geometry, typename Section>
+ static inline bool neighbouring(Section const& section,
+ int index1, int index2)
+ {
+ // About n-2:
+ // (square: range_count=5, indices 0,1,2,3
+ // -> 0-3 are adjacent, don't check on intersections)
+ // Also tested for open polygons, and/or duplicates
+ // About first condition: will be optimized by compiler (static)
+ // It checks if it is areal (box,ring,(multi)polygon
+ int const n = int(section.range_count);
+ return boost::is_same
+ <
+ typename tag_cast
+ <
+ typename geometry::point_type<Geometry1>::type,
+ areal_tag
+ >::type,
+ areal_tag
+ >::value
+ && index1 == 0
+ && index2 >= n - 2
+ ;
+ }
+
 
 public :
     // Returns true if terminated, false if interrupted
@@ -196,7 +221,7 @@
                 if (skip)
                 {
                     // If sources are the same (possibly self-intersecting):
- // skip if it is a neighbouring sement.
+ // skip if it is a neighbouring segment.
                     // (including first-last segment
                     // and two segments with one or more degenerate/duplicate
                     // (zero-length) segments in between)
@@ -204,12 +229,9 @@
                     // Also skip if index1 < index2 to avoid getting all
                     // intersections twice (only do this on same source!)
 
- // About n-2:
- // (square: range_count=5, indices 0,1,2,3
- // -> 0-3 are adjacent)
- skip = index2 >= index1
- || ndi1 == ndi2 + 1
- || (index2 == 0 && index1 >= int(sec1.range_count) - 2)
+ skip = index1 >= index2
+ || ndi2 == ndi1 + 1
+ || neighbouring<Geometry1>(sec1, index1, index2)
                         ;
                 }
 
@@ -492,9 +514,9 @@
         next++;
         next++;
 
- bool first = true;
+ //bool first = true;
 
- char previous_side[2] = {0, 0};
+ //char previous_side[2] = {0, 0};
 
         int index = 0;
 
@@ -505,7 +527,7 @@
             segment_identifier seg_id(source_id1,
                         multi_index, ring_index, index);
 
- if (first)
+ /*if (first)
             {
                 previous_side[0] = get_side<0>(box, *prev);
                 previous_side[1] = get_side<1>(box, *prev);
@@ -519,7 +541,7 @@
             // 1) EITHER the two points are lying on one side of the box (! 0 && the same)
             // 2) OR same in Y-direction
             // 3) OR all points are inside the box (0)
- /*if (! (
+ if (! (
                 (current_side[0] != 0 && current_side[0] == previous_side[0])
                 || (current_side[1] != 0 && current_side[1] == previous_side[1])
                 || (current_side[0] == 0

Modified: branches/release/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -295,6 +295,49 @@
     }
 };
 
+template
+<
+ typename Tag1, typename Tag2,
+ bool Areal1, bool Areal2,
+ typename Geometry1, typename Geometry2,
+ bool Reverse1, bool Reverse2, bool ReverseOut,
+ typename OutputIterator, typename PointOut,
+ overlay_type OverlayType,
+ typename Strategy
+>
+struct intersection_insert
+ <
+ Tag1, Tag2, point_tag,
+ Areal1, Areal2, false,
+ Geometry1, Geometry2,
+ Reverse1, Reverse2, ReverseOut,
+ OutputIterator, PointOut,
+ OverlayType,
+ Strategy
+ >
+{
+ static inline OutputIterator apply(Geometry1 const& geometry1,
+ Geometry2 const& geometry2, OutputIterator out, Strategy const& strategy)
+ {
+
+ typedef detail::overlay::turn_info<PointOut> turn_info;
+ std::vector<turn_info> turns;
+
+ detail::get_turns::no_interrupt_policy policy;
+ geometry::get_turns
+ <
+ false, false, detail::overlay::assign_null_policy
+ >(geometry1, geometry2, turns, policy);
+ for (typename std::vector<turn_info>::const_iterator it
+ = turns.begin(); it != turns.end(); ++it)
+ {
+ *out++ = it->point;
+ }
+
+ return out;
+ }
+};
+
 
 template
 <

Modified: branches/release/boost/geometry/algorithms/detail/overlay/overlay.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/overlay.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/overlay.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -9,6 +9,7 @@
 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_OVERLAY_HPP
 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_OVERLAY_HPP
 
+
 #include <deque>
 #include <map>
 
@@ -25,8 +26,6 @@
 #include <boost/geometry/algorithms/detail/overlay/traversal_info.hpp>
 #include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
 
-#include <boost/geometry/algorithms/detail/has_self_intersections.hpp>
-
 
 #include <boost/geometry/algorithms/num_points.hpp>
 #include <boost/geometry/algorithms/reverse.hpp>
@@ -124,7 +123,7 @@
     std::map<ring_identifier, int> empty;
     std::map<ring_identifier, properties> all_of_one_of_them;
 
- select_rings<Direction>(geometry1, geometry2, empty, all_of_one_of_them);
+ select_rings<Direction>(geometry1, geometry2, empty, all_of_one_of_them, false);
     ring_container_type rings;
     assign_parents(geometry1, geometry2, rings, all_of_one_of_them);
     return add_rings<GeometryOut>(all_of_one_of_them, geometry1, geometry2, rings, out);
@@ -169,9 +168,6 @@
>(geometry1, geometry2, out);
         }
         
- has_self_intersections(geometry1);
- has_self_intersections(geometry2);
-
         container_type turn_points;
 
 #ifdef BOOST_GEOMETRY_TIME_OVERLAY
@@ -215,11 +211,14 @@
         // Note that these rings are always in clockwise order, even in CCW polygons,
         // and are marked as "to be reversed" below
         ring_container_type rings;
- geometry::traverse<Reverse1, Reverse2>(geometry1, geometry2,
- Direction == overlay_union
- ? geometry::detail::overlay::operation_union
- : geometry::detail::overlay::operation_intersection,
- turn_points, rings);
+ traverse<Reverse1, Reverse2, Geometry1, Geometry2>::apply
+ (
+ geometry1, geometry2,
+ Direction == overlay_union
+ ? geometry::detail::overlay::operation_union
+ : geometry::detail::overlay::operation_intersection,
+ turn_points, rings
+ );
 
 #ifdef BOOST_GEOMETRY_TIME_OVERLAY
         std::cout << "traverse: " << timer.elapsed() << std::endl;
@@ -236,7 +235,7 @@
         typedef ring_properties<typename geometry::point_type<Geometry1>::type> properties;
 
         std::map<ring_identifier, properties> selected;
- select_rings<Direction>(geometry1, geometry2, map, selected);
+ select_rings<Direction>(geometry1, geometry2, map, selected, ! turn_points.empty());
 
 #ifdef BOOST_GEOMETRY_TIME_OVERLAY
         std::cout << "select_rings: " << timer.elapsed() << std::endl;
@@ -251,7 +250,7 @@
                     it != boost::end(rings);
                     ++it)
             {
- selected[id] = properties(*it);
+ selected[id] = properties(*it, true);
                 selected[id].reversed = ReverseOut;
                 id.multi_index++;
             }

Modified: branches/release/boost/geometry/algorithms/detail/overlay/ring_properties.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/ring_properties.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/ring_properties.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -52,17 +52,17 @@
     {}
 
     template <typename RingOrBox>
- inline ring_properties(RingOrBox const& ring_or_box)
+ inline ring_properties(RingOrBox const& ring_or_box, bool midpoint)
         : within_code(-1)
         , reversed(false)
         , discarded(false)
         , parent_area(-1)
     {
         this->area = geometry::area(ring_or_box);
- geometry::point_on_border(this->point, ring_or_box, true);
+ geometry::point_on_border(this->point, ring_or_box, midpoint);
     }
 
- area_type get_area() const
+ inline area_type get_area() const
     {
         return reversed ? -area : area;
     }

Modified: branches/release/boost/geometry/algorithms/detail/overlay/select_rings.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/select_rings.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/select_rings.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -40,15 +40,17 @@
     struct select_rings<box_tag, Box>
     {
         template <typename Geometry, typename Map>
- static inline void apply(Box const& box, Geometry const& geometry, ring_identifier const& id, Map& map)
+ static inline void apply(Box const& box, Geometry const& geometry,
+ ring_identifier const& id, Map& map, bool midpoint)
         {
- map[id] = typename Map::mapped_type(box);
+ map[id] = typename Map::mapped_type(box, midpoint);
         }
 
         template <typename Map>
- static inline void apply(Box const& box, ring_identifier const& id, Map& map)
+ static inline void apply(Box const& box,
+ ring_identifier const& id, Map& map, bool midpoint)
         {
- map[id] = typename Map::mapped_type(box);
+ map[id] = typename Map::mapped_type(box, midpoint);
         }
     };
 
@@ -56,20 +58,22 @@
     struct select_rings<ring_tag, Ring>
     {
         template <typename Geometry, typename Map>
- static inline void apply(Ring const& ring, Geometry const& geometry, ring_identifier const& id, Map& map)
+ static inline void apply(Ring const& ring, Geometry const& geometry,
+ ring_identifier const& id, Map& map, bool midpoint)
         {
             if (boost::size(ring) > 0)
             {
- map[id] = typename Map::mapped_type(ring);
+ map[id] = typename Map::mapped_type(ring, midpoint);
             }
         }
 
         template <typename Map>
- static inline void apply(Ring const& ring, ring_identifier const& id, Map& map)
+ static inline void apply(Ring const& ring,
+ ring_identifier const& id, Map& map, bool midpoint)
         {
             if (boost::size(ring) > 0)
             {
- map[id] = typename Map::mapped_type(ring);
+ map[id] = typename Map::mapped_type(ring, midpoint);
             }
         }
     };
@@ -79,36 +83,38 @@
     struct select_rings<polygon_tag, Polygon>
     {
         template <typename Geometry, typename Map>
- static inline void apply(Polygon const& polygon, Geometry const& geometry, ring_identifier id, Map& map)
+ static inline void apply(Polygon const& polygon, Geometry const& geometry,
+ ring_identifier id, Map& map, bool midpoint)
         {
             typedef typename geometry::ring_type<Polygon>::type ring_type;
             typedef select_rings<ring_tag, ring_type> per_ring;
 
- per_ring::apply(exterior_ring(polygon), geometry, id, map);
+ per_ring::apply(exterior_ring(polygon), geometry, id, map, midpoint);
 
             typename interior_return_type<Polygon const>::type rings
                         = interior_rings(polygon);
             for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
             {
                 id.ring_index++;
- per_ring::apply(*it, geometry, id, map);
+ per_ring::apply(*it, geometry, id, map, midpoint);
             }
         }
 
         template <typename Map>
- static inline void apply(Polygon const& polygon, ring_identifier id, Map& map)
+ static inline void apply(Polygon const& polygon,
+ ring_identifier id, Map& map, bool midpoint)
         {
             typedef typename geometry::ring_type<Polygon>::type ring_type;
             typedef select_rings<ring_tag, ring_type> per_ring;
 
- per_ring::apply(exterior_ring(polygon), id, map);
+ per_ring::apply(exterior_ring(polygon), id, map, midpoint);
 
             typename interior_return_type<Polygon const>::type rings
                         = interior_rings(polygon);
             for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
             {
                 id.ring_index++;
- per_ring::apply(*it, id, map);
+ per_ring::apply(*it, id, map, midpoint);
             }
         }
     };
@@ -203,7 +209,7 @@
         bool found = intersection_map.find(it->first) != intersection_map.end();
         if (! found)
         {
- ring_identifier id = it->first;
+ ring_identifier const id = it->first;
             typename SelectionMap::mapped_type properties = it->second; // Copy by value
 
             // Calculate the "within code" (previously this was done earlier but is
@@ -242,16 +248,20 @@
     typename IntersectionMap, typename SelectionMap
>
 inline void select_rings(Geometry1 const& geometry1, Geometry2 const& geometry2,
- IntersectionMap const& intersection_map, SelectionMap& selection_map)
+ IntersectionMap const& intersection_map,
+ SelectionMap& selection_map, bool midpoint)
 {
     typedef typename geometry::tag<Geometry1>::type tag1;
     typedef typename geometry::tag<Geometry2>::type tag2;
 
     SelectionMap map_with_all;
- dispatch::select_rings<tag1, Geometry1>::apply(geometry1, geometry2, ring_identifier(0, -1, -1), map_with_all);
- dispatch::select_rings<tag2, Geometry2>::apply(geometry2, geometry1, ring_identifier(1, -1, -1), map_with_all);
+ dispatch::select_rings<tag1, Geometry1>::apply(geometry1, geometry2,
+ ring_identifier(0, -1, -1), map_with_all, midpoint);
+ dispatch::select_rings<tag2, Geometry2>::apply(geometry2, geometry1,
+ ring_identifier(1, -1, -1), map_with_all, midpoint);
 
- update_selection_map<OverlayType>(geometry1, geometry2, intersection_map, map_with_all, selection_map);
+ update_selection_map<OverlayType>(geometry1, geometry2, intersection_map,
+ map_with_all, selection_map);
 }
 
 template
@@ -261,14 +271,17 @@
     typename IntersectionMap, typename SelectionMap
>
 inline void select_rings(Geometry const& geometry,
- IntersectionMap const& intersection_map, SelectionMap& selection_map)
+ IntersectionMap const& intersection_map,
+ SelectionMap& selection_map, bool midpoint)
 {
     typedef typename geometry::tag<Geometry>::type tag;
 
     SelectionMap map_with_all;
- dispatch::select_rings<tag, Geometry>::apply(geometry, ring_identifier(0, -1, -1), map_with_all);
+ dispatch::select_rings<tag, Geometry>::apply(geometry,
+ ring_identifier(0, -1, -1), map_with_all, midpoint);
 
- update_selection_map<OverlayType>(intersection_map, map_with_all, selection_map);
+ update_selection_map<OverlayType>(geometry, geometry, intersection_map,
+ map_with_all, selection_map);
 }
 
 

Modified: branches/release/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -19,6 +19,7 @@
 #include <boost/geometry/geometries/concepts/check.hpp>
 
 #include <boost/geometry/algorithms/detail/disjoint.hpp>
+#include <boost/geometry/algorithms/detail/partition.hpp>
 #include <boost/geometry/algorithms/detail/overlay/get_turns.hpp>
 
 #include <boost/geometry/geometries/box.hpp>
@@ -31,6 +32,60 @@
 namespace detail { namespace self_get_turn_points
 {
 
+class self_ip_exception : public geometry::exception {};
+
+template
+<
+ typename Geometry,
+ typename Turns,
+ typename TurnPolicy,
+ typename InterruptPolicy
+>
+struct self_section_visitor
+{
+ Geometry const& m_geometry;
+ Turns& m_turns;
+ InterruptPolicy& m_interrupt_policy;
+
+ inline self_section_visitor(Geometry const& g,
+ Turns& turns, InterruptPolicy& ip)
+ : m_geometry(g)
+ , m_turns(turns)
+ , m_interrupt_policy(ip)
+ {}
+
+ template <typename Section>
+ inline bool apply(Section const& sec1, Section const& sec2)
+ {
+ if (! detail::disjoint::disjoint_box_box(sec1.bounding_box, sec2.bounding_box)
+ && ! sec1.duplicate
+ && ! sec2.duplicate)
+ {
+ detail::get_turns::get_turns_in_sections
+ <
+ Geometry, Geometry,
+ false, false,
+ Section, Section,
+ Turns, TurnPolicy,
+ InterruptPolicy
+ >::apply(
+ 0, m_geometry, sec1,
+ 0, m_geometry, sec2,
+ m_turns, m_interrupt_policy);
+ }
+ if (m_interrupt_policy.has_intersections)
+ {
+ // TODO: we should give partition an interrupt policy.
+ // Now we throw, and catch below, to stop the partition loop.
+ throw self_ip_exception();
+ }
+ return true;
+ }
+
+};
+
+
+
 template
 <
     typename Geometry,
@@ -45,49 +100,38 @@
             Turns& turns,
             InterruptPolicy& interrupt_policy)
     {
+ typedef model::box
+ <
+ typename geometry::point_type<Geometry>::type
+ > box_type;
         typedef typename geometry::sections
             <
- model::box <typename geometry::point_type<Geometry>::type>,
- 1
+ box_type, 1
> sections_type;
 
         sections_type sec;
         geometry::sectionalize<false>(geometry, sec);
 
- for (typename boost::range_iterator<sections_type const>::type
- it1 = sec.begin();
- it1 != sec.end();
- ++it1)
+ self_section_visitor
+ <
+ Geometry,
+ Turns, TurnPolicy, InterruptPolicy
+ > visitor(geometry, turns, interrupt_policy);
+
+ try
         {
- for (typename boost::range_iterator<sections_type const>::type
- it2 = sec.begin();
- it2 != sec.end();
- ++it2)
- {
- if (! geometry::detail::disjoint::disjoint_box_box(
- it1->bounding_box, it2->bounding_box)
- && ! it1->duplicate
- && ! it2->duplicate
- )
- {
- if (! geometry::detail::get_turns::get_turns_in_sections
- <
- Geometry, Geometry,
- false, false,
- typename boost::range_value<sections_type>::type,
- typename boost::range_value<sections_type>::type,
- Turns, TurnPolicy,
- InterruptPolicy
- >::apply(
- 0, geometry, *it1,
- 0, geometry, *it2,
- turns, interrupt_policy))
- {
- return false;
- }
- }
- }
+ geometry::partition
+ <
+ box_type,
+ detail::get_turns::get_section_box,
+ detail::get_turns::ovelaps_section_box
+ >::apply(sec, visitor);
         }
+ catch(self_ip_exception const& )
+ {
+ return false;
+ }
+
         return true;
     }
 };

Modified: branches/release/boost/geometry/algorithms/detail/overlay/traverse.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/traverse.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/overlay/traverse.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -14,8 +14,10 @@
 
 #include <boost/range.hpp>
 
-#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
+#include <boost/geometry/algorithms/detail/overlay/append_no_duplicates.hpp>
+#include <boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp>
 #include <boost/geometry/algorithms/detail/overlay/copy_segments.hpp>
+#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
 #include <boost/geometry/core/access.hpp>
 #include <boost/geometry/core/coordinate_dimension.hpp>
 #include <boost/geometry/geometries/concepts/check.hpp>
@@ -38,7 +40,8 @@
 {
 
 template <typename Turn, typename Operation>
-inline void debug_traverse(Turn const& turn, Operation op, std::string const& header)
+inline void debug_traverse(Turn const& turn, Operation op,
+ std::string const& header)
 {
 #ifdef BOOST_GEOMETRY_DEBUG_TRAVERSE
     std::cout << header
@@ -57,30 +60,6 @@
 }
 
 
-template <typename Turns>
-inline void clear_visit_info(Turns& turns)
-{
- typedef typename boost::range_value<Turns>::type tp_type;
-
- for (typename boost::range_iterator<Turns>::type
- it = boost::begin(turns);
- it != boost::end(turns);
- ++it)
- {
- for (typename boost::range_iterator
- <
- typename tp_type::container_type
- >::type op_it = boost::begin(it->operations);
- op_it != boost::end(it->operations);
- ++op_it)
- {
- op_it->visited.clear();
- }
- it->discarded = false;
- }
-}
-
-
 template <typename Info, typename Turn>
 inline void set_visited_for_continue(Info& info, Turn const& turn)
 {
@@ -125,7 +104,11 @@
     // If there is no next IP on this segment
     if (info.enriched.next_ip_index < 0)
     {
- if (info.enriched.travels_to_vertex_index < 0 || info.enriched.travels_to_ip_index < 0) return false;
+ if (info.enriched.travels_to_vertex_index < 0
+ || info.enriched.travels_to_ip_index < 0)
+ {
+ return false;
+ }
 
         BOOST_ASSERT(info.enriched.travels_to_vertex_index >= 0);
         BOOST_ASSERT(info.enriched.travels_to_ip_index >= 0);
@@ -151,7 +134,7 @@
         seg_id = info.seg_id;
     }
 
- geometry::append(current_output, ip->point);
+ detail::overlay::append_no_duplicates(current_output, ip->point);
     return true;
 }
 
@@ -227,76 +210,6 @@
 
 
 
-template
-<
- typename Rings,
- typename Turns,
- typename Operation,
- typename Geometry1,
- typename Geometry2
->
-inline void backtrack(std::size_t size_at_start, bool& fail,
- Rings& rings, typename boost::range_value<Rings>::type& ring,
- Turns& turns, Operation& operation,
-
-#ifdef BOOST_GEOMETRY_OVERLAY_REPORT_WKT
- std::string const& reason,
- Geometry1 const& geometry1,
- Geometry2 const& geometry2
-#else
- std::string const& reason,
- Geometry1 const& ,
- Geometry2 const&
-#endif
- )
-{
-#ifdef BOOST_GEOMETRY_DEBUG_ENRICH
- std::cout << " REJECT " << reason << std::endl;
-#endif
- fail = true;
-
- // Make bad output clean
- rings.resize(size_at_start);
- ring.clear();
-
- // Reject this as a starting point
- operation.visited.set_rejected();
-
- // And clear all visit info
- clear_visit_info(turns);
-
- /***
- int c = 0;
- for (int i = 0; i < turns.size(); i++)
- {
- for (int j = 0; j < 2; j++)
- {
- if (turns[i].operations[j].visited.rejected())
- {
- c++;
- }
- }
- }
- std::cout << "BACKTRACK (" << reason << " )"
- << " " << c << " of " << turns.size() << " rejected"
- << std::endl;
- ***/
-
-
-
-#ifdef BOOST_GEOMETRY_OVERLAY_REPORT_WKT
- std::cout << " BT (" << reason << " )";
- std::cout
- << geometry::wkt(geometry1) << std::endl
- << geometry::wkt(geometry2) << std::endl;
-#endif
-
-}
-
-}} // namespace detail::overlay
-#endif // DOXYGEN_NO_DETAIL
-
-
 /*!
     \brief Traverses through intersection points / geometries
     \ingroup overlay
@@ -306,164 +219,173 @@
     bool Reverse1, bool Reverse2,
     typename Geometry1,
     typename Geometry2,
- typename Turns,
- typename Rings
+ typename Backtrack = backtrack_check_self_intersections<Geometry1, Geometry2>
>
-inline void traverse(Geometry1 const& geometry1,
- Geometry2 const& geometry2,
- detail::overlay::operation_type operation,
- Turns& turns, Rings& rings)
+class traverse
 {
- typedef typename boost::range_iterator<Turns>::type turn_iterator;
- typedef typename boost::range_value<Turns>::type turn_type;
- typedef typename boost::range_iterator
- <
- typename turn_type::container_type
- >::type turn_operation_iterator_type;
+public :
+ template <typename Turns, typename Rings>
+ static inline void apply(Geometry1 const& geometry1,
+ Geometry2 const& geometry2,
+ detail::overlay::operation_type operation,
+ Turns& turns, Rings& rings)
+ {
+ typedef typename boost::range_iterator<Turns>::type turn_iterator;
+ typedef typename boost::range_value<Turns>::type turn_type;
+ typedef typename boost::range_iterator
+ <
+ typename turn_type::container_type
+ >::type turn_operation_iterator_type;
 
- std::size_t size_at_start = boost::size(rings);
+ std::size_t size_at_start = boost::size(rings);
 
- bool fail = false;
- do
- {
- fail = false;
- // Iterate through all unvisited points
- for (turn_iterator it = boost::begin(turns);
- ! fail && it != boost::end(turns);
- ++it)
+ typename Backtrack::state_type state;
+ do
         {
- // Skip discarded ones
- if (! (it->is_discarded() || it->blocked()))
+ state.reset();
+
+ // Iterate through all unvisited points
+ for (turn_iterator it = boost::begin(turns);
+ state.good() && it != boost::end(turns);
+ ++it)
             {
- for (turn_operation_iterator_type iit = boost::begin(it->operations);
- ! fail && iit != boost::end(it->operations);
- ++iit)
+ // Skip discarded ones
+ if (! (it->is_discarded() || it->blocked()))
                 {
- if (iit->visited.none()
- && ! iit->visited.rejected()
- && (iit->operation == operation
- || iit->operation == detail::overlay::operation_continue)
- )
+ for (turn_operation_iterator_type iit = boost::begin(it->operations);
+ state.good() && iit != boost::end(it->operations);
+ ++iit)
                     {
- set_visited_for_continue(*it, *iit);
-
- typename boost::range_value<Rings>::type current_output;
- geometry::append(current_output, it->point);
-
- turn_iterator current = it;
- turn_operation_iterator_type current_iit = iit;
- segment_identifier current_seg_id;
-
- if (! detail::overlay::assign_next_ip<Reverse1, Reverse2>(
- geometry1, geometry2,
- turns,
- current, current_output,
- *iit, current_seg_id))
- {
- detail::overlay::backtrack(
- size_at_start, fail,
- rings, current_output, turns, *current_iit,
- "No next IP",
- geometry1, geometry2);
- }
-
- if (! detail::overlay::select_next_ip(
- operation,
- *current,
- current_seg_id,
- current_iit))
- {
- detail::overlay::backtrack(
- size_at_start, fail,
- rings, current_output, turns, *iit,
- "Dead end at start",
- geometry1, geometry2);
- }
- else
+ if (iit->visited.none()
+ && ! iit->visited.rejected()
+ && (iit->operation == operation
+ || iit->operation == detail::overlay::operation_continue)
+ )
                         {
+ set_visited_for_continue(*it, *iit);
 
- iit->visited.set_started();
- detail::overlay::debug_traverse(*it, *iit, "-> Started");
- detail::overlay::debug_traverse(*current, *current_iit, "Selected ");
+ typename boost::range_value<Rings>::type current_output;
+ detail::overlay::append_no_duplicates(current_output,
+ it->point, true);
 
+ turn_iterator current = it;
+ turn_operation_iterator_type current_iit = iit;
+ segment_identifier current_seg_id;
 
- unsigned int i = 0;
+ if (! detail::overlay::assign_next_ip<Reverse1, Reverse2>(
+ geometry1, geometry2,
+ turns,
+ current, current_output,
+ *iit, current_seg_id))
+ {
+ Backtrack::apply(
+ size_at_start,
+ rings, current_output, turns, *current_iit,
+ "No next IP",
+ geometry1, geometry2, state);
+ }
 
- while (current_iit != iit && ! fail)
+ if (! detail::overlay::select_next_ip(
+ operation,
+ *current,
+ current_seg_id,
+ current_iit))
+ {
+ Backtrack::apply(
+ size_at_start,
+ rings, current_output, turns, *iit,
+ "Dead end at start",
+ geometry1, geometry2, state);
+ }
+ else
                             {
- if (current_iit->visited.visited())
- {
- // It visits a visited node again, without passing the start node.
- // This makes it suspicious for endless loops
- detail::overlay::backtrack(
- size_at_start, fail,
- rings, current_output, turns, *iit,
- "Visit again",
- geometry1, geometry2);
- }
- else
- {
 
+ iit->visited.set_started();
+ detail::overlay::debug_traverse(*it, *iit, "-> Started");
+ detail::overlay::debug_traverse(*current, *current_iit, "Selected ");
 
- // We assume clockwise polygons only, non self-intersecting, closed.
- // However, the input might be different, and checking validity
- // is up to the library user.
-
- // Therefore we make here some sanity checks. If the input
- // violates the assumptions, the output polygon will not be correct
- // but the routine will stop and output the current polygon, and
- // will continue with the next one.
 
- // Below three reasons to stop.
- detail::overlay::assign_next_ip<Reverse1, Reverse2>(
- geometry1, geometry2,
- turns, current, current_output,
- *current_iit, current_seg_id);
+ unsigned int i = 0;
 
- if (! detail::overlay::select_next_ip(
- operation,
- *current,
- current_seg_id,
- current_iit))
+ while (current_iit != iit && state.good())
+ {
+ if (current_iit->visited.visited())
                                     {
- // Should not occur in valid (non-self-intersecting) polygons
- // Should not occur in self-intersecting polygons without spikes
- // Might occur in polygons with spikes
- detail::overlay::backtrack(
- size_at_start, fail,
+ // It visits a visited node again, without passing the start node.
+ // This makes it suspicious for endless loops
+ Backtrack::apply(
+ size_at_start,
                                             rings, current_output, turns, *iit,
- "Dead end",
- geometry1, geometry2);
+ "Visit again",
+ geometry1, geometry2, state);
                                     }
- detail::overlay::debug_traverse(*current, *current_iit, "Selected ");
-
- if (i++ > 2 + 2 * turns.size())
+ else
                                     {
- // Sanity check: there may be never more loops
- // than turn points.
- // Turn points marked as "ii" can be visited twice.
- detail::overlay::backtrack(
- size_at_start, fail,
- rings, current_output, turns, *iit,
- "Endless loop",
- geometry1, geometry2);
+
+
+ // We assume clockwise polygons only, non self-intersecting, closed.
+ // However, the input might be different, and checking validity
+ // is up to the library user.
+
+ // Therefore we make here some sanity checks. If the input
+ // violates the assumptions, the output polygon will not be correct
+ // but the routine will stop and output the current polygon, and
+ // will continue with the next one.
+
+ // Below three reasons to stop.
+ detail::overlay::assign_next_ip<Reverse1, Reverse2>(
+ geometry1, geometry2,
+ turns, current, current_output,
+ *current_iit, current_seg_id);
+
+ if (! detail::overlay::select_next_ip(
+ operation,
+ *current,
+ current_seg_id,
+ current_iit))
+ {
+ // Should not occur in valid (non-self-intersecting) polygons
+ // Should not occur in self-intersecting polygons without spikes
+ // Might occur in polygons with spikes
+ Backtrack::apply(
+ size_at_start,
+ rings, current_output, turns, *iit,
+ "Dead end",
+ geometry1, geometry2, state);
+ }
+ detail::overlay::debug_traverse(*current, *current_iit, "Selected ");
+
+ if (i++ > 2 + 2 * turns.size())
+ {
+ // Sanity check: there may be never more loops
+ // than turn points.
+ // Turn points marked as "ii" can be visited twice.
+ Backtrack::apply(
+ size_at_start,
+ rings, current_output, turns, *iit,
+ "Endless loop",
+ geometry1, geometry2, state);
+ }
                                     }
                                 }
- }
 
- if (! fail)
- {
- iit->visited.set_finished();
- detail::overlay::debug_traverse(*current, *iit, "->Finished");
- rings.push_back(current_output);
+ if (state.good())
+ {
+ iit->visited.set_finished();
+ detail::overlay::debug_traverse(*current, *iit, "->Finished");
+ rings.push_back(current_output);
+ }
                             }
                         }
                     }
                 }
             }
- }
- } while (fail);
-}
+ } while (! state.good());
+ }
+};
+
+}} // namespace detail::overlay
+#endif // DOXYGEN_NO_DETAIL
 
 
 }} // namespace boost::geometry

Deleted: branches/release/boost/geometry/algorithms/detail/overlay/within_util.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/overlay/within_util.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
+++ (empty file)
@@ -1,98 +0,0 @@
-// Boost.Geometry (aka GGL, Generic Geometry Library)
-
-// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands.
-
-// Use, modification and distribution is subject to the Boost Software License,
-// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-
-#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_WITHIN_UTIL_HPP
-#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_WITHIN_UTIL_HPP
-
-
-
-#include <boost/geometry/algorithms/within.hpp>
-#include <boost/geometry/strategies/agnostic/point_in_poly_winding.hpp>
-
-
-namespace boost { namespace geometry
-{
-
-
-#ifndef DOXYGEN_NO_DETAIL
-namespace detail { namespace overlay
-{
-
-
-template<typename Tag, typename Point, typename Geometry>
-struct within_code
-{};
-
-template<typename Point, typename Box>
-struct within_code<box_tag, Point, Box>
-{
- static inline int apply(Point const& point, Box const& box)
- {
- // 1. Check outside
- if (get<0>(point) < get<min_corner, 0>(box)
- || get<0>(point) > get<max_corner, 0>(box)
- || get<1>(point) < get<min_corner, 1>(box)
- || get<1>(point) > get<max_corner, 1>(box))
- {
- return -1;
- }
- // 2. Check border
- if (geometry::math::equals(get<0>(point), get<min_corner, 0>(box))
- || geometry::math::equals(get<0>(point), get<max_corner, 0>(box))
- || geometry::math::equals(get<1>(point), get<min_corner, 1>(box))
- || geometry::math::equals(get<1>(point), get<max_corner, 1>(box)))
- {
- return 0;
- }
- return 1;
- }
-};
-template<typename Point, typename Ring>
-struct within_code<ring_tag, Point, Ring>
-{
- static inline int apply(Point const& point, Ring const& ring)
- {
- // Same as point_in_ring but here ALWAYS with winding.
- typedef strategy::within::winding<Point> strategy_type;
-
- return detail::within::point_in_ring
- <
- Point,
- Ring,
- order_as_direction<geometry::point_order<Ring>::value>::value,
- geometry::closure<Ring>::value,
- strategy_type
- >::apply(point, ring, strategy_type());
- }
-};
-
-
-template<typename Point, typename Geometry>
-inline int point_in_ring(Point const& point, Geometry const& geometry)
-{
- return within_code<typename geometry::tag<Geometry>::type, Point, Geometry>
- ::apply(point, geometry);
-}
-
-template<typename Point, typename Geometry>
-inline bool within_or_touch(Point const& point, Geometry const& geometry)
-{
- return within_code<typename geometry::tag<Geometry>::type, Point, Geometry>
- ::apply(point, geometry) >= 0;
-}
-
-
-
-}} // namespace detail::overlay
-#endif // DOXYGEN_NO_DETAIL
-
-
-}} // namespace boost::geometry
-
-
-#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_WITHIN_UTIL_HPP

Modified: branches/release/boost/geometry/algorithms/detail/sections/sectionalize.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/detail/sections/sectionalize.hpp (original)
+++ branches/release/boost/geometry/algorithms/detail/sections/sectionalize.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -189,11 +189,12 @@
 
     static inline bool apply(Segment const& seg)
     {
- coordinate_type const diff =
- geometry::get<1, Dimension>(seg) - geometry::get<0, Dimension>(seg);
-
- coordinate_type const zero = 0;
- if (! geometry::math::equals(diff, zero))
+ if (! geometry::math::equals
+ (
+ geometry::get<0, Dimension>(seg),
+ geometry::get<1, Dimension>(seg)
+ )
+ )
         {
             return false;
         }

Modified: branches/release/boost/geometry/algorithms/within.hpp
==============================================================================
--- branches/release/boost/geometry/algorithms/within.hpp (original)
+++ branches/release/boost/geometry/algorithms/within.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -31,10 +31,12 @@
 #include <boost/geometry/core/point_order.hpp>
 #include <boost/geometry/core/ring_type.hpp>
 #include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/tags.hpp>
 
 #include <boost/geometry/geometries/concepts/check.hpp>
 #include <boost/geometry/strategies/within.hpp>
 #include <boost/geometry/strategies/concepts/within_concept.hpp>
+#include <boost/geometry/util/math.hpp>
 #include <boost/geometry/util/order_as_direction.hpp>
 #include <boost/geometry/views/closeable_view.hpp>
 #include <boost/geometry/views/reversible_view.hpp>
@@ -48,105 +50,6 @@
 {
 
 
-/*!
- \brief Implementation for boxes
- \ingroup boolean_relations
- \note Should have strategy for e.g. Wrangel
- */
-template
-<
- typename Point,
- typename Box,
- typename Strategy,
- std::size_t Dimension,
- std::size_t DimensionCount
->
-struct point_in_box
-{
- static inline int apply(Point const& p, Box const& b, Strategy const& s)
- {
- assert_dimension_equal<Point, Box>();
-
- if (get<Dimension>(p) <= get<min_corner, Dimension>(b)
- || get<Dimension>(p) >= get<max_corner, Dimension>(b))
- {
- return -1;
- }
-
- return point_in_box
- <
- Point,
- Box,
- Strategy,
- Dimension + 1,
- DimensionCount
- >::apply(p, b, s);
- }
-};
-
-template
-<
- typename Point,
- typename Box,
- typename Strategy,
- std::size_t DimensionCount
->
-struct point_in_box<Point, Box, Strategy, DimensionCount, DimensionCount>
-{
- static inline int apply(Point const& , Box const& , Strategy const& )
- {
- return 1;
- }
-};
-
-
-template
-<
- typename Box1,
- typename Box2,
- typename Strategy,
- std::size_t Dimension,
- std::size_t DimensionCount
->
-struct box_in_box
-{
- static inline int apply(Box1 const& b1, Box2 const& b2, Strategy const& s)
- {
- assert_dimension_equal<Box1, Box2>();
-
- if (get<min_corner, Dimension>(b1) <= get<min_corner, Dimension>(b2)
- || get<max_corner, Dimension>(b1) >= get<max_corner, Dimension>(b2))
- {
- return -1;
- }
-
- return box_in_box
- <
- Box1,
- Box2,
- Strategy,
- Dimension + 1,
- DimensionCount
- >::apply(b1, b2, s);
- }
-};
-
-template
-<
- typename Box1,
- typename Box2,
- typename Strategy,
- std::size_t DimensionCount
->
-struct box_in_box<Box1, Box2, Strategy, DimensionCount, DimensionCount>
-{
- static inline int apply(Box1 const& , Box2 const& , Strategy const&)
- {
- return 1;
- }
-};
-
-
 template
 <
     typename Point,
@@ -157,7 +60,7 @@
>
 struct point_in_ring
 {
- BOOST_CONCEPT_ASSERT( (geometry::concept::WithinStrategy<Strategy>) );
+ BOOST_CONCEPT_ASSERT( (geometry::concept::WithinStrategyPolygonal<Strategy>) );
 
     static inline int apply(Point const& point, Ring const& ring,
             Strategy const& strategy)
@@ -181,13 +84,14 @@
         iterator_type it = boost::begin(view);
         iterator_type end = boost::end(view);
 
+ bool stop = false;
         for (iterator_type previous = it++;
- it != end;
+ it != end && ! stop;
             ++previous, ++it)
         {
             if (! strategy.apply(point, *previous, *it, state))
             {
- return false;
+ stop = true;
             }
         }
 
@@ -196,7 +100,6 @@
 };
 
 
-
 // Polygon: in exterior ring, and if so, not within interior ring(s)
 template
 <
@@ -208,7 +111,7 @@
>
 struct point_in_polygon
 {
- BOOST_CONCEPT_ASSERT( (geometry::concept::WithinStrategy<Strategy>) );
+ BOOST_CONCEPT_ASSERT( (geometry::concept::WithinStrategyPolygonal<Strategy>) );
 
     static inline int apply(Point const& point, Polygon const& poly,
             Strategy const& strategy)
@@ -280,84 +183,60 @@
 
 template <typename Point, typename Box, typename Strategy>
 struct within<point_tag, box_tag, Point, Box, Strategy>
- : detail::within::point_in_box
- <
- Point,
- Box,
- Strategy,
- 0,
- dimension<Point>::type::value
- >
-{};
+{
+ static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
+ {
+ return strategy.apply(point, box);
+ }
+};
 
 template <typename Box1, typename Box2, typename Strategy>
 struct within<box_tag, box_tag, Box1, Box2, Strategy>
- : detail::within::box_in_box
- <
- Box1,
- Box2,
- Strategy,
- 0,
- dimension<Box1>::type::value
- >
-{};
+{
+ static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
+ {
+ assert_dimension_equal<Box1, Box2>();
+ return strategy.apply(box1, box2);
+ }
+};
 
 
 
 template <typename Point, typename Ring, typename Strategy>
 struct within<point_tag, ring_tag, Point, Ring, Strategy>
- : detail::within::point_in_ring
- <
- Point,
- Ring,
- order_as_direction<geometry::point_order<Ring>::value>::value,
- geometry::closure<Ring>::value,
- Strategy
- >
-{};
+{
+ static inline bool apply(Point const& point, Ring const& ring, Strategy const& strategy)
+ {
+ return detail::within::point_in_ring
+ <
+ Point,
+ Ring,
+ order_as_direction<geometry::point_order<Ring>::value>::value,
+ geometry::closure<Ring>::value,
+ Strategy
+ >::apply(point, ring, strategy) == 1;
+ }
+};
 
 template <typename Point, typename Polygon, typename Strategy>
 struct within<point_tag, polygon_tag, Point, Polygon, Strategy>
- : detail::within::point_in_polygon
- <
- Point,
- Polygon,
- order_as_direction<geometry::point_order<Polygon>::value>::value,
- geometry::closure<Polygon>::value,
- Strategy
- >
-{};
-
-} // namespace dispatch
-#endif // DOXYGEN_NO_DISPATCH
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-namespace strategy { namespace within
 {
-
-/// Strategy for box-in-box (not used but has to be present for default strategy)
-struct unused_strategy {};
-
-namespace services
-{
-
-// Specialize for box-in-areal (box-in-box). This is meant to do box-in-box
-// but will be catched by box-in-any-areal, which has to change later
-// (we might introduce another tag which is not "areal", derived by poly/ring/
-// multi_poly, but NOT by box, and use that here. E.g. "polygonal")
-// Using cartesian prevents spherical yet from compiling, which is good.
-template <typename Box1, typename Box2>
-struct default_strategy<box_tag, areal_tag, cartesian_tag, cartesian_tag, Box1, Box2>
-{
- typedef unused_strategy type;
+ static inline bool apply(Point const& point, Polygon const& polygon, Strategy const& strategy)
+ {
+ return detail::within::point_in_polygon
+ <
+ Point,
+ Polygon,
+ order_as_direction<geometry::point_order<Polygon>::value>::value,
+ geometry::closure<Polygon>::value,
+ Strategy
+ >::apply(point, polygon, strategy) == 1;
+ }
 };
 
-} // namespace services
-
-}} // namespace strategy::within
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
 
-#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
 
 /*!
 \brief \brief_check12{is completely inside}
@@ -387,6 +266,7 @@
 {
     concept::check<Geometry1 const>();
     concept::check<Geometry2 const>();
+ assert_dimension_equal<Geometry1, Geometry2>();
 
     typedef typename point_type<Geometry1>::type point_type1;
     typedef typename point_type<Geometry2>::type point_type2;
@@ -394,11 +274,19 @@
     typedef typename strategy::within::services::default_strategy
         <
             typename tag<Geometry1>::type,
+ typename tag<Geometry2>::type,
+ typename tag<Geometry1>::type,
             typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
- typename cs_tag<point_type1>::type,
- typename cs_tag<point_type2>::type,
- point_type1,
- point_type2
+ typename tag_cast
+ <
+ typename cs_tag<point_type1>::type, spherical_tag
+ >::type,
+ typename tag_cast
+ <
+ typename cs_tag<point_type2>::type, spherical_tag
+ >::type,
+ Geometry1,
+ Geometry2
>::type strategy_type;
 
     return dispatch::within
@@ -408,7 +296,7 @@
             Geometry1,
             Geometry2,
             strategy_type
- >::apply(geometry1, geometry2, strategy_type()) == 1;
+ >::apply(geometry1, geometry2, strategy_type());
 }
 
 /*!
@@ -443,12 +331,16 @@
 inline bool within(Geometry1 const& geometry1, Geometry2 const& geometry2,
         Strategy const& strategy)
 {
- // Always assume a point-in-polygon strategy here.
- // Because for point-in-box, it makes no sense to specify one.
- BOOST_CONCEPT_ASSERT( (geometry::concept::WithinStrategy<Strategy>) );
-
+ concept::within::check
+ <
+ typename tag<Geometry1>::type,
+ typename tag<Geometry2>::type,
+ typename tag_cast<typename tag<Geometry2>::type, areal_tag>::type,
+ Strategy
+ >();
     concept::check<Geometry1 const>();
     concept::check<Geometry2 const>();
+ assert_dimension_equal<Geometry1, Geometry2>();
 
     return dispatch::within
         <
@@ -457,7 +349,7 @@
             Geometry1,
             Geometry2,
             Strategy
- >::apply(geometry1, geometry2, strategy) == 1;
+ >::apply(geometry1, geometry2, strategy);
 }
 
 }} // namespace boost::geometry

Modified: branches/release/boost/geometry/core/tags.hpp
==============================================================================
--- branches/release/boost/geometry/core/tags.hpp (original)
+++ branches/release/boost/geometry/core/tags.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -20,18 +20,21 @@
 
 // Tags defining strategies linked to coordinate systems
 
+/// Tag used for casting spherical/geographic coordinate systems
+struct spherical_tag {};
+
 
 /// Tag indicating Cartesian coordinate system family (cartesian,epsg)
 struct cartesian_tag {};
 
 /// Tag indicating Spherical polar coordinate system family
-struct spherical_polar_tag {};
+struct spherical_polar_tag : spherical_tag {};
 
 /// Tag indicating Spherical equatorial coordinate system family
-struct spherical_equatorial_tag {};
+struct spherical_equatorial_tag : spherical_tag {};
 
 /// Tag indicating Geographic coordinate system family (geographic)
-struct geographic_tag {};
+struct geographic_tag : spherical_tag {};
 
 
 
@@ -53,6 +56,9 @@
 /// For areal types (polygon, multi_polygon, box, ring)
 struct areal_tag {};
 
+// Subset of areal types (polygon, multi_polygon, ring)
+struct polygonal_tag : areal_tag {};
+
 /// For volume types (also box (?), polyhedron)
 struct volumetric_tag {};
 
@@ -70,10 +76,10 @@
 struct linestring_tag : single_tag, linear_tag {};
 
 /// OGC Polygon identifying tag
-struct polygon_tag : single_tag, areal_tag {};
+struct polygon_tag : single_tag, polygonal_tag {};
 
 /// Convenience (linear) ring identifying tag
-struct ring_tag : single_tag, areal_tag {};
+struct ring_tag : single_tag, polygonal_tag {};
 
 /// Convenience 2D or 3D box (mbr / aabb) identifying tag
 struct box_tag : single_tag, areal_tag {};

Modified: branches/release/boost/geometry/geometries/adapted/boost_fusion.hpp
==============================================================================
--- branches/release/boost/geometry/geometries/adapted/boost_fusion.hpp (original)
+++ branches/release/boost/geometry/geometries/adapted/boost_fusion.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -165,7 +165,7 @@
                            fusion_adapt_detail::is_fusion_sequence<Sequence> \
>::type \
> \
- { typedef cs::cartesian type; }; \
+ { typedef CoordinateSystem type; }; \
     }}}
 
 

Modified: branches/release/boost/geometry/geometries/concepts/check.hpp
==============================================================================
--- branches/release/boost/geometry/geometries/concepts/check.hpp (original)
+++ branches/release/boost/geometry/geometries/concepts/check.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -44,7 +44,7 @@
     BOOST_CONCEPT_ASSERT((Concept ));
 };
 
-}} // namespace detail::check
+}} // namespace detail::concept_check
 #endif // DOXYGEN_NO_DETAIL
 
 

Modified: branches/release/boost/geometry/multi/algorithms/detail/overlay/select_rings.hpp
==============================================================================
--- branches/release/boost/geometry/multi/algorithms/detail/overlay/select_rings.hpp (original)
+++ branches/release/boost/geometry/multi/algorithms/detail/overlay/select_rings.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -30,7 +30,8 @@
     struct select_rings<multi_polygon_tag, Multi>
     {
         template <typename Geometry, typename Map>
- static inline void apply(Multi const& multi, Geometry const& geometry, ring_identifier id, Map& map)
+ static inline void apply(Multi const& multi, Geometry const& geometry,
+ ring_identifier id, Map& map, bool midpoint)
         {
             typedef typename boost::range_iterator
                 <
@@ -43,7 +44,7 @@
             for (iterator_type it = boost::begin(multi); it != boost::end(multi); ++it)
             {
                 id.ring_index = -1;
- per_polygon::apply(*it, geometry, id, map);
+ per_polygon::apply(*it, geometry, id, map, midpoint);
                 id.multi_index++;
             }
         }

Modified: branches/release/boost/geometry/multi/algorithms/within.hpp
==============================================================================
--- branches/release/boost/geometry/multi/algorithms/within.hpp (original)
+++ branches/release/boost/geometry/multi/algorithms/within.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -37,7 +37,7 @@
     typename Strategy,
     typename Policy
>
-struct geometry_in_multi
+struct geometry_multi_within_code
 {
     static inline int apply(Geometry const& geometry,
             MultiGeometry const& multi,
@@ -48,7 +48,8 @@
             it != boost::end(multi);
             ++it)
         {
- // Geometry within a multi: true if within one of them
+ // Geometry coding on multi: 1 (within) if within one of them;
+ // 0 (touch) if on border of one of them
             int const code = Policy::apply(geometry, *it, strategy);
             if (code != -1)
             {
@@ -70,21 +71,29 @@
 
 template <typename Point, typename MultiPolygon, typename Strategy>
 struct within<point_tag, multi_polygon_tag, Point, MultiPolygon, Strategy>
- : detail::within::geometry_in_multi
- <
- Point,
- MultiPolygon,
- Strategy,
- detail::within::point_in_polygon
- <
- Point,
- typename boost::range_value<MultiPolygon>::type,
- order_as_direction<geometry::point_order<MultiPolygon>::value>::value,
- geometry::closure<MultiPolygon>::value,
- Strategy
- >
- >
-{};
+{
+ static inline bool apply(Point const& point,
+ MultiPolygon const& multi_polygon, Strategy const& strategy)
+ {
+ return detail::within::geometry_multi_within_code
+ <
+ Point,
+ MultiPolygon,
+ Strategy,
+ detail::within::point_in_polygon
+ <
+ Point,
+ typename boost::range_value<MultiPolygon>::type,
+ order_as_direction
+ <
+ geometry::point_order<MultiPolygon>::value
+ >::value,
+ geometry::closure<MultiPolygon>::value,
+ Strategy
+ >
+ >::apply(point, multi_polygon, strategy) == 1;
+ }
+};
 
 } // namespace dispatch
 #endif // DOXYGEN_NO_DISPATCH

Modified: branches/release/boost/geometry/multi/core/tags.hpp
==============================================================================
--- branches/release/boost/geometry/multi/core/tags.hpp (original)
+++ branches/release/boost/geometry/multi/core/tags.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -27,7 +27,7 @@
 struct multi_linestring_tag : multi_tag, linear_tag {};
 
 /// OGC Multi polygon identifying tag
-struct multi_polygon_tag : multi_tag, areal_tag {};
+struct multi_polygon_tag : multi_tag, polygonal_tag {};
 
 /// OGC Geometry Collection identifying tag
 struct geometry_collection_tag : multi_tag {};

Modified: branches/release/boost/geometry/policies/relate/intersection_points.hpp
==============================================================================
--- branches/release/boost/geometry/policies/relate/intersection_points.hpp (original)
+++ branches/release/boost/geometry/policies/relate/intersection_points.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -70,7 +70,16 @@
         promoted_type const da = (promoted_type(dx2) * wy) - (promoted_type(dy2) * wx);
 
         // r: ratio 0-1 where intersection divides A/B
- promoted_type const r = da / d;
+ promoted_type r = da / d;
+ // Handle robustness issues
+ if (r < 0)
+ {
+ r = 0;
+ }
+ else if (r > 1)
+ {
+ r = 1;
+ }
 
         result.count = 1;
         set<0>(result.intersections[0],

Copied: branches/release/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp (from r73201, /trunk/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp)
==============================================================================
--- /trunk/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp (original)
+++ branches/release/boost/geometry/strategies/agnostic/point_in_box_by_side.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -110,7 +110,7 @@
 {
     typedef within::point_in_box_by_side
                 <
- Point, Box, within::decide_within
+ Point, Box, within::decide_within
> type;
 };
 

Modified: branches/release/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp (original)
+++ branches/release/boost/geometry/strategies/agnostic/point_in_poly_winding.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -17,6 +17,7 @@
 #include <boost/geometry/util/select_calculation_type.hpp>
 
 #include <boost/geometry/strategies/side.hpp>
+#include <boost/geometry/strategies/covered_by.hpp>
 #include <boost/geometry/strategies/within.hpp>
 
 
@@ -181,23 +182,18 @@
 {
 
 // Register using "areal_tag" for ring, polygon, multi-polygon
-template <typename Point, typename PointOfSegment>
-struct default_strategy<point_tag, areal_tag, cartesian_tag, cartesian_tag, Point, PointOfSegment>
+template <typename AnyTag, typename Point, typename Geometry>
+struct default_strategy<point_tag, AnyTag, point_tag, areal_tag, cartesian_tag, cartesian_tag, Point, Geometry>
 {
- typedef winding<Point, PointOfSegment> type;
+ typedef winding<Point, typename geometry::point_type<Geometry>::type> type;
 };
 
-template <typename Point, typename PointOfSegment>
-struct default_strategy<point_tag, areal_tag, spherical_polar_tag, spherical_polar_tag, Point, PointOfSegment>
+template <typename AnyTag, typename Point, typename Geometry>
+struct default_strategy<point_tag, AnyTag, point_tag, areal_tag, spherical_tag, spherical_tag, Point, Geometry>
 {
- typedef winding<Point, PointOfSegment> type;
+ typedef winding<Point, typename geometry::point_type<Geometry>::type> type;
 };
 
-template <typename Point, typename PointOfSegment>
-struct default_strategy<point_tag, areal_tag, spherical_equatorial_tag, spherical_equatorial_tag, Point, PointOfSegment>
-{
- typedef winding<Point, PointOfSegment> type;
-};
 
 } // namespace services
 
@@ -207,6 +203,29 @@
 }} // namespace strategy::within
 
 
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+namespace strategy { namespace covered_by { namespace services
+{
+
+// Register using "areal_tag" for ring, polygon, multi-polygon
+template <typename AnyTag, typename Point, typename Geometry>
+struct default_strategy<point_tag, AnyTag, point_tag, areal_tag, cartesian_tag, cartesian_tag, Point, Geometry>
+{
+ typedef strategy::within::winding<Point, typename geometry::point_type<Geometry>::type> type;
+};
+
+template <typename AnyTag, typename Point, typename Geometry>
+struct default_strategy<point_tag, AnyTag, point_tag, areal_tag, spherical_tag, spherical_tag, Point, Geometry>
+{
+ typedef strategy::within::winding<Point, typename geometry::point_type<Geometry>::type> type;
+};
+
+
+}}} // namespace strategy::covered_by::services
+#endif
+
+
 }} // namespace boost::geometry
 
 

Modified: branches/release/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp (original)
+++ branches/release/boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -94,7 +94,12 @@
 {
 public :
 
- typedef typename strategy::distance::services::comparable_type<PointDistanceStrategy>::type distance_strategy_type;
+ // See also ticket 5954 https://svn.boost.org/trac/boost/ticket/5954
+ // Comparable is currently not possible here because it has to be compared to the squared of max_distance, and more.
+ // For now we have to take the real distance.
+ typedef PointDistanceStrategy distance_strategy_type;
+ // typedef typename strategy::distance::services::comparable_type<PointDistanceStrategy>::type distance_strategy_type;
+
     typedef typename strategy::distance::services::return_type<distance_strategy_type>::type return_type;
 
 private :
@@ -145,7 +150,7 @@
 #ifdef GL_DEBUG_DOUGLAS_PEUCKER
             std::cout << "consider " << dsv(it->p)
                 << " at " << double(dist)
- << ((dist > max_dist) ? " maybe" : " no")
+ << ((dist > max_dist) ? " maybe" : " no")
                 << std::endl;
 
 #endif

Modified: branches/release/boost/geometry/strategies/cartesian/area_surveyor.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/cartesian/area_surveyor.hpp (original)
+++ branches/release/boost/geometry/strategies/cartesian/area_surveyor.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -82,7 +82,7 @@
         inline return_type area() const
         {
             return_type result = sum;
- result *= 0.5;
+ result /= 2;
             return result;
         }
     };

Copied: branches/release/boost/geometry/strategies/cartesian/box_in_box.hpp (from r73201, /trunk/boost/geometry/strategies/cartesian/box_in_box.hpp)
==============================================================================
--- /trunk/boost/geometry/strategies/cartesian/box_in_box.hpp (original)
+++ branches/release/boost/geometry/strategies/cartesian/box_in_box.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -160,7 +160,7 @@
 {
     typedef within::box_in_box
                 <
- BoxContained, BoxContaining,
+ BoxContained, BoxContaining,
                     within::box_covered_by_range
> type;
 };

Modified: branches/release/boost/geometry/strategies/cartesian/cart_intersect.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/cartesian/cart_intersect.hpp (original)
+++ branches/release/boost/geometry/strategies/cartesian/cart_intersect.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -16,6 +16,8 @@
 #include <boost/geometry/geometries/concepts/point_concept.hpp>
 #include <boost/geometry/geometries/concepts/segment_concept.hpp>
 
+#include <boost/geometry/algorithms/detail/assign_values.hpp>
+
 #include <boost/geometry/util/math.hpp>
 #include <boost/geometry/util/select_calculation_type.hpp>
 
@@ -54,6 +56,19 @@
     }
 };
 
+template <std::size_t Index, typename Segment>
+inline typename geometry::point_type<Segment>::type get_from_index(
+ Segment const& segment)
+{
+ typedef typename geometry::point_type<Segment>::type point_type;
+ point_type point;
+ geometry::detail::assign::assign_point_from_index
+ <
+ Segment, point_type, Index, 0, dimension<Segment>::type::value
+ >::apply(segment, point);
+ return point;
+}
+
 }
 #endif
 
@@ -91,10 +106,10 @@
     /// Relate segments a and b
     static inline return_type apply(segment_type1 const& a, segment_type2 const& b)
     {
- coordinate_type dx_a = get<1, 0>(a) - get<0, 0>(a); // distance in x-dir
- coordinate_type dx_b = get<1, 0>(b) - get<0, 0>(b);
- coordinate_type dy_a = get<1, 1>(a) - get<0, 1>(a); // distance in y-dir
- coordinate_type dy_b = get<1, 1>(b) - get<0, 1>(b);
+ coordinate_type const dx_a = get<1, 0>(a) - get<0, 0>(a); // distance in x-dir
+ coordinate_type const dx_b = get<1, 0>(b) - get<0, 0>(b);
+ coordinate_type const dy_a = get<1, 1>(a) - get<0, 1>(a); // distance in y-dir
+ coordinate_type const dy_b = get<1, 1>(b) - get<0, 1>(b);
         return apply(a, b, dx_a, dy_a, dx_b, dy_b);
     }
 
@@ -133,8 +148,15 @@
         // Note: Do NOT yet calculate the determinant here, but use the SIDE strategy.
         // Determinant calculation is not robust; side (orient) can be made robust
         // (and is much robuster even without measures)
- sides.set<1>(side::apply(a.first, a.second, b.first),
- side::apply(a.first, a.second, b.second));
+ sides.set<1>
+ (
+ side::apply(detail::get_from_index<0>(a)
+ , detail::get_from_index<1>(a)
+ , detail::get_from_index<0>(b)),
+ side::apply(detail::get_from_index<0>(a)
+ , detail::get_from_index<1>(a)
+ , detail::get_from_index<1>(b))
+ );
 
         if (sides.same<1>())
         {
@@ -143,8 +165,15 @@
         }
 
         // 2b) For other segment
- sides.set<0>(side::apply(b.first, b.second, a.first),
- side::apply(b.first, b.second, a.second));
+ sides.set<0>
+ (
+ side::apply(detail::get_from_index<0>(b)
+ , detail::get_from_index<1>(b)
+ , detail::get_from_index<0>(a)),
+ side::apply(detail::get_from_index<0>(b)
+ , detail::get_from_index<1>(b)
+ , detail::get_from_index<1>(a))
+ );
 
         if (sides.same<0>())
         {
@@ -164,7 +193,7 @@
 
         bool collinear = sides.collinear();
 
- // Get the same type, but at least a double (also used for divisions
+ // Get the same type, but at least a double (also used for divisions)
         typedef typename select_most_precise
             <
                 coordinate_type, double
@@ -347,8 +376,8 @@
                 // In robustness it can occur that a point of A is inside B AND a point of B is inside A,
                 // still while has_common_points is true (so one point equals the other).
                 // If that is the case we select on length.
- coordinate_type const length_a = abs(a_1 - a_2);
- coordinate_type const length_b = abs(b_1 - b_2);
+ coordinate_type const length_a = geometry::math::abs(a_1 - a_2);
+ coordinate_type const length_b = geometry::math::abs(b_1 - b_2);
                 if (length_a > length_b)
                 {
                     a_in_b = false;

Copied: branches/release/boost/geometry/strategies/cartesian/point_in_box.hpp (from r73201, /trunk/boost/geometry/strategies/cartesian/point_in_box.hpp)
==============================================================================
--- /trunk/boost/geometry/strategies/cartesian/point_in_box.hpp (original)
+++ branches/release/boost/geometry/strategies/cartesian/point_in_box.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -61,7 +61,7 @@
     static inline bool apply(Point const& point, Box const& box)
     {
         if (! SubStrategy::apply(get<Dimension>(point),
- get<min_corner, Dimension>(box),
+ get<min_corner, Dimension>(box),
                     get<max_corner, Dimension>(box))
             )
         {
@@ -102,7 +102,7 @@
>
 struct point_in_box
 {
- static inline bool apply(Point const& point, Box const& box)
+ static inline bool apply(Point const& point, Box const& box)
     {
         return relate_point_box_loop
             <
@@ -154,7 +154,7 @@
 {
     typedef within::point_in_box
                 <
- Point, Box,
+ Point, Box,
                     within::covered_by_range
> type;
 };

Modified: branches/release/boost/geometry/strategies/cartesian/side_by_triangle.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/cartesian/side_by_triangle.hpp (original)
+++ branches/release/boost/geometry/strategies/cartesian/side_by_triangle.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -89,7 +89,7 @@
 
         promoted_type const s = dx * dpy - dy * dpx;
 
- promoted_type zero = promoted_type();
+ promoted_type const zero = promoted_type();
         return math::equals(s, zero) ? 0
             : s > zero ? 1
             : -1;

Modified: branches/release/boost/geometry/strategies/concepts/distance_concept.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/concepts/distance_concept.hpp (original)
+++ branches/release/boost/geometry/strategies/concepts/distance_concept.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -19,13 +19,7 @@
 
 #include <boost/concept_check.hpp>
 
-#include <boost/function_types/function_arity.hpp>
-#include <boost/function_types/is_member_function_pointer.hpp>
-#include <boost/function_types/parameter_types.hpp>
-#include <boost/mpl/at.hpp>
-#include <boost/mpl/int.hpp>
-#include <boost/mpl/plus.hpp>
-#include <boost/type_traits.hpp>
+#include <boost/geometry/util/parameter_type_of.hpp>
 
 #include <boost/geometry/geometries/concepts/point_concept.hpp>
 #include <boost/geometry/geometries/segment.hpp>
@@ -50,40 +44,15 @@
         template <typename ApplyMethod>
         static void apply(ApplyMethod const&)
         {
- namespace ft = boost::function_types;
- typedef typename ft::parameter_types
- <
- ApplyMethod
- >::type parameter_types;
-
- typedef typename boost::mpl::if_
- <
- ft::is_member_function_pointer<ApplyMethod>,
- boost::mpl::int_<1>,
- boost::mpl::int_<0>
- >::type base_index;
-
             // 1: inspect and define both arguments of apply
- typedef typename boost::remove_reference
+ typedef typename parameter_type_of
                 <
- typename boost::mpl::at
- <
- parameter_types,
- base_index
- >::type
+ ApplyMethod, 0
>::type ptype1;
 
- typedef typename boost::remove_reference
+ typedef typename parameter_type_of
                 <
- typename boost::mpl::at
- <
- parameter_types,
- typename boost::mpl::plus
- <
- base_index,
- boost::mpl::int_<1>
- >::type
- >::type
+ ApplyMethod, 1
>::type ptype2;
 
             // 2) check if apply-arguments fulfill point concept
@@ -177,40 +146,14 @@
         template <typename ApplyMethod>
         static void apply(ApplyMethod const&)
         {
- namespace ft = boost::function_types;
- typedef typename ft::parameter_types
- <
- ApplyMethod
- >::type parameter_types;
-
- typedef typename boost::mpl::if_
- <
- ft::is_member_function_pointer<ApplyMethod>,
- boost::mpl::int_<1>,
- boost::mpl::int_<0>
- >::type base_index;
-
- // 1: inspect and define both arguments of apply
- typedef typename boost::remove_reference
+ typedef typename parameter_type_of
                 <
- typename boost::mpl::at
- <
- parameter_types,
- base_index
- >::type
+ ApplyMethod, 0
>::type ptype;
 
- typedef typename boost::remove_reference
+ typedef typename parameter_type_of
                 <
- typename boost::mpl::at
- <
- parameter_types,
- typename boost::mpl::plus
- <
- base_index,
- boost::mpl::int_<1>
- >::type
- >::type
+ ApplyMethod, 1
>::type sptype;
 
             // 2) check if apply-arguments fulfill point concept

Modified: branches/release/boost/geometry/strategies/concepts/within_concept.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/concepts/within_concept.hpp (original)
+++ branches/release/boost/geometry/strategies/concepts/within_concept.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -17,6 +17,9 @@
 
 
 #include <boost/concept_check.hpp>
+#include <boost/function_types/result_type.hpp>
+
+#include <boost/geometry/util/parameter_type_of.hpp>
 
 
 namespace boost { namespace geometry { namespace concept
@@ -24,57 +27,265 @@
 
 
 /*!
- \brief Checks strategy for within (point-in-polygon)
- \ingroup within
+\brief Checks strategy for within (point-in-polygon)
+\ingroup within
 */
 template <typename Strategy>
-class WithinStrategy
+class WithinStrategyPolygonal
 {
 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
 
- // 1) must define state_type,
+ // 1) must define state_type
     typedef typename Strategy::state_type state_type;
 
- // 2) must define point_type (of "point" in poly)
- typedef typename Strategy::point_type point_type;
+ struct checker
+ {
+ template <typename ApplyMethod, typename ResultMethod>
+ static void apply(ApplyMethod const&, ResultMethod const& )
+ {
+ typedef typename parameter_type_of
+ <
+ ApplyMethod, 0
+ >::type point_type;
+ typedef typename parameter_type_of
+ <
+ ApplyMethod, 1
+ >::type segment_point_type;
+
+ // CHECK: apply-arguments should both fulfill point concept
+ BOOST_CONCEPT_ASSERT
+ (
+ (concept::ConstPoint<point_type>)
+ );
+
+ BOOST_CONCEPT_ASSERT
+ (
+ (concept::ConstPoint<segment_point_type>)
+ );
+
+ // CHECK: return types (result: int, apply: bool)
+ BOOST_MPL_ASSERT_MSG
+ (
+ (boost::is_same
+ <
+ bool, typename boost::function_types::result_type<ApplyMethod>::type
+ >::type::value),
+ WRONG_RETURN_TYPE_OF_APPLY
+ , (bool)
+ );
+ BOOST_MPL_ASSERT_MSG
+ (
+ (boost::is_same
+ <
+ int, typename boost::function_types::result_type<ResultMethod>::type
+ >::type::value),
+ WRONG_RETURN_TYPE_OF_RESULT
+ , (int)
+ );
+
+
+ // CHECK: calling method apply and result
+ Strategy const* str;
+ state_type* st;
+ point_type const* p;
+ segment_point_type const* sp;
+
+ bool b = str->apply(*p, *sp, *sp, *st);
+ int r = str->result(*st);
 
- // 3) must define point_type, of polygon (segments)
- typedef typename Strategy::segment_point_type spoint_type;
+ boost::ignore_unused_variable_warning(r);
+ boost::ignore_unused_variable_warning(b);
+ boost::ignore_unused_variable_warning(str);
+ }
+ };
+
+
+public :
+ BOOST_CONCEPT_USAGE(WithinStrategyPolygonal)
+ {
+ checker::apply(&Strategy::apply, &Strategy::result);
+ }
+#endif
+};
 
+template <typename Strategy>
+class WithinStrategyPointBox
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
 
- struct check_methods
+ struct checker
     {
- static void apply()
+ template <typename ApplyMethod>
+ static void apply(ApplyMethod const&)
         {
- Strategy const* str;
+ typedef typename parameter_type_of
+ <
+ ApplyMethod, 0
+ >::type point_type;
+ typedef typename parameter_type_of
+ <
+ ApplyMethod, 1
+ >::type box_type;
+
+ // CHECK: apply-arguments should fulfill point/box concept
+ BOOST_CONCEPT_ASSERT
+ (
+ (concept::ConstPoint<point_type>)
+ );
+
+ BOOST_CONCEPT_ASSERT
+ (
+ (concept::ConstBox<box_type>)
+ );
+
+ // CHECK: return types (apply: bool)
+ BOOST_MPL_ASSERT_MSG
+ (
+ (boost::is_same
+ <
+ bool,
+ typename boost::function_types::result_type<ApplyMethod>::type
+ >::type::value),
+ WRONG_RETURN_TYPE
+ , (bool)
+ );
 
- state_type* st;
+
+ // CHECK: calling method apply
+ Strategy const* str;
             point_type const* p;
- spoint_type const* sp;
+ box_type const* bx;
 
- // 4) must implement a method apply
- // having a point, two segment-points, and state
- str->apply(*p, *sp, *sp, *st);
+ bool b = str->apply(*p, *bx);
 
- // 5) must implement a method result returning int
- int r = str->result(*st);
+ boost::ignore_unused_variable_warning(b);
+ boost::ignore_unused_variable_warning(str);
+ }
+ };
 
- boost::ignore_unused_variable_warning(r);
+
+public :
+ BOOST_CONCEPT_USAGE(WithinStrategyPointBox)
+ {
+ checker::apply(&Strategy::apply);
+ }
+#endif
+};
+
+template <typename Strategy>
+class WithinStrategyBoxBox
+{
+#ifndef DOXYGEN_NO_CONCEPT_MEMBERS
+
+ struct checker
+ {
+ template <typename ApplyMethod>
+ static void apply(ApplyMethod const&)
+ {
+ typedef typename parameter_type_of
+ <
+ ApplyMethod, 0
+ >::type box_type1;
+ typedef typename parameter_type_of
+ <
+ ApplyMethod, 1
+ >::type box_type2;
+
+ // CHECK: apply-arguments should both fulfill box concept
+ BOOST_CONCEPT_ASSERT
+ (
+ (concept::ConstBox<box_type1>)
+ );
+
+ BOOST_CONCEPT_ASSERT
+ (
+ (concept::ConstBox<box_type2>)
+ );
+
+ // CHECK: return types (apply: bool)
+ BOOST_MPL_ASSERT_MSG
+ (
+ (boost::is_same
+ <
+ bool,
+ typename boost::function_types::result_type<ApplyMethod>::type
+ >::type::value),
+ WRONG_RETURN_TYPE
+ , (bool)
+ );
+
+
+ // CHECK: calling method apply
+ Strategy const* str;
+ box_type1 const* b1;
+ box_type2 const* b2;
+
+ bool b = str->apply(*b1, *b2);
+
+ boost::ignore_unused_variable_warning(b);
             boost::ignore_unused_variable_warning(str);
         }
     };
 
 
 public :
- BOOST_CONCEPT_USAGE(WithinStrategy)
+ BOOST_CONCEPT_USAGE(WithinStrategyBoxBox)
     {
- check_methods::apply();
+ checker::apply(&Strategy::apply);
     }
 #endif
 };
 
+// So now: boost::geometry::concept::within
+namespace within
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename FirstTag, typename SecondTag, typename CastedTag, typename Strategy>
+struct check_within
+{};
+
+
+template <typename AnyTag, typename Strategy>
+struct check_within<point_tag, AnyTag, areal_tag, Strategy>
+{
+ BOOST_CONCEPT_ASSERT( (WithinStrategyPolygonal<Strategy>) );
+};
+
+
+template <typename Strategy>
+struct check_within<point_tag, box_tag, areal_tag, Strategy>
+{
+ BOOST_CONCEPT_ASSERT( (WithinStrategyPointBox<Strategy>) );
+};
+
+template <typename Strategy>
+struct check_within<box_tag, box_tag, areal_tag, Strategy>
+{
+ BOOST_CONCEPT_ASSERT( (WithinStrategyBoxBox<Strategy>) );
+};
+
+
+} // namespace dispatch
+#endif
+
+
+/*!
+\brief Checks, in compile-time, the concept of any within-strategy
+\ingroup concepts
+*/
+template <typename FirstTag, typename SecondTag, typename CastedTag, typename Strategy>
+inline void check()
+{
+ dispatch::check_within<FirstTag, SecondTag, CastedTag, Strategy> c;
+ boost::ignore_unused_variable_warning(c);
+}
+
 
+}}}} // namespace boost::geometry::concept::within
 
-}}} // namespace boost::geometry::concept
 
 #endif // BOOST_GEOMETRY_STRATEGIES_CONCEPTS_WITHIN_CONCEPT_HPP

Modified: branches/release/boost/geometry/strategies/strategies.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/strategies.hpp (original)
+++ branches/release/boost/geometry/strategies/strategies.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -28,10 +28,12 @@
 #include <boost/geometry/strategies/within.hpp>
 
 #include <boost/geometry/strategies/cartesian/area_surveyor.hpp>
+#include <boost/geometry/strategies/cartesian/box_in_box.hpp>
 #include <boost/geometry/strategies/cartesian/centroid_bashein_detmer.hpp>
 #include <boost/geometry/strategies/cartesian/centroid_weighted_length.hpp>
 #include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
 #include <boost/geometry/strategies/cartesian/distance_projected_point.hpp>
+#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
 #include <boost/geometry/strategies/cartesian/point_in_poly_franklin.hpp>
 #include <boost/geometry/strategies/cartesian/point_in_poly_crossings_multiply.hpp>
 #include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
@@ -43,6 +45,7 @@
 #include <boost/geometry/strategies/spherical/ssf.hpp>
 
 #include <boost/geometry/strategies/agnostic/hull_graham_andrew.hpp>
+#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>
 #include <boost/geometry/strategies/agnostic/point_in_poly_winding.hpp>
 #include <boost/geometry/strategies/agnostic/simplify_douglas_peucker.hpp>
 

Modified: branches/release/boost/geometry/strategies/strategy_transform.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/strategy_transform.hpp (original)
+++ branches/release/boost/geometry/strategies/strategy_transform.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -222,6 +222,17 @@
         set_from_radian<1>(p, acos(z));
         return true;
     }
+
+ template <typename P, typename T>
+ inline bool cartesian_to_spherical_equatorial2(T x, T y, T z, P& p)
+ {
+ assert_dimension<P, 2>();
+
+ set_from_radian<0>(p, atan2(y, x));
+ set_from_radian<1>(p, asin(z));
+ return true;
+ }
+
 
     template <typename P, typename T>
     inline bool cartesian_to_spherical3(T x, T y, T z, P& p)
@@ -323,6 +334,16 @@
     }
 };
 
+template <typename P1, typename P2>
+struct from_cartesian_3_to_spherical_equatorial_2
+{
+ inline bool apply(P1 const& p1, P2& p2) const
+ {
+ assert_dimension<P1, 3>();
+ return detail::cartesian_to_spherical_equatorial2(get<0>(p1), get<1>(p1), get<2>(p1), p2);
+ }
+};
+
 
 /*!
     \brief Transformation strategy for 3D cartesian (x,y,z) to 3D spherical (phi,theta,r)
@@ -421,6 +442,12 @@
     typedef from_cartesian_3_to_spherical_polar_2<P1, P2> type;
 };
 
+template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
+struct default_strategy<cartesian_tag, spherical_equatorial_tag, CoordSys1, CoordSys2, 3, 2, P1, P2>
+{
+ typedef from_cartesian_3_to_spherical_equatorial_2<P1, P2> type;
+};
+
 /// Specialization to transform from XYZ to sphere(phi,theta,r)
 template <typename CoordSys1, typename CoordSys2, typename P1, typename P2>
 struct default_strategy<cartesian_tag, spherical_polar_tag, CoordSys1, CoordSys2, 3, 3, P1, P2>

Modified: branches/release/boost/geometry/strategies/within.hpp
==============================================================================
--- branches/release/boost/geometry/strategies/within.hpp (original)
+++ branches/release/boost/geometry/strategies/within.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -16,7 +16,6 @@
 
 #include <boost/mpl/assert.hpp>
 
-#include <boost/geometry/strategies/tags.hpp>
 
 namespace boost { namespace geometry
 {
@@ -29,28 +28,32 @@
 {
 
 /*!
- \brief Traits class binding a within determination strategy to a coordinate system
- \ingroup within
- \tparam CsTagContained tag of coordinate system of point-type
- \tparam CsTagContained tag of coordinate system of segment-type
- \tparam Point point-type of input points
- \tparam PointContaining point-type of input segment-points
+\brief Traits class binding a within determination strategy to a coordinate system
+\ingroup within
+\tparam TagContained tag (possibly casted) of point-type
+\tparam TagContained tag (possibly casted) of (possibly) containing type
+\tparam CsTagContained tag of coordinate system of point-type
+\tparam CsTagContaining tag of coordinate system of (possibly) containing type
+\tparam Geometry geometry-type of input (often point, or box)
+\tparam GeometryContaining geometry-type of input (possibly) containing type
 */
 template
 <
     typename TagContained,
     typename TagContaining,
+ typename CastedTagContained,
+ typename CastedTagContaining,
     typename CsTagContained,
     typename CsTagContaining,
- typename Point,
- typename PointContaining
+ typename GeometryContained,
+ typename GeometryContaining
>
 struct default_strategy
 {
     BOOST_MPL_ASSERT_MSG
         (
             false, NOT_IMPLEMENTED_FOR_THIS_TYPES
- , (types<Point, PointContaining>)
+ , (types<GeometryContained, GeometryContaining>)
         );
 };
 

Copied: branches/release/boost/geometry/util/rational.hpp (from r74156, /trunk/boost/geometry/util/rational.hpp)
==============================================================================
--- /trunk/boost/geometry/util/rational.hpp (original)
+++ branches/release/boost/geometry/util/rational.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -33,28 +33,62 @@
 template <typename T>
 struct coordinate_cast<rational<T> >
 {
+ static inline void split_parts(std::string const& source, std::string::size_type p,
+ T& before, T& after, bool& negate, std::string::size_type& len)
+ {
+ std::string before_part = source.substr(0, p);
+ std::string const after_part = source.substr(p + 1);
+
+ negate = false;
+
+ if (before_part.size() > 0 && before_part[0] == '-')
+ {
+ negate = true;
+ before_part.erase(0, 1);
+ }
+ before = atol(before_part.c_str());
+ after = atol(after_part.c_str());
+ len = after_part.length();
+ }
+
+
     static inline rational<T> apply(std::string const& source)
     {
+ T before, after;
+ bool negate;
+ std::string::size_type len;
+
         // Note: decimal comma is not (yet) supported, it does (and should) not
         // occur in a WKT, where points are comma separated.
- std::string::size_type const p = source.find(".");
+ std::string::size_type p = source.find(".");
         if (p == std::string::npos)
         {
- return rational<T>(atol(source.c_str()));
+ p = source.find("/");
+ if (p == std::string::npos)
+ {
+ return rational<T>(atol(source.c_str()));
+ }
+ split_parts(source, p, before, after, negate, len);
+
+ return negate
+ ? -rational<T>(before, after)
+ : rational<T>(before, after)
+ ;
+
         }
 
- std::string const natural_part = source.substr(0, p);
- std::string const fraction = source.substr(p + 1);
+ split_parts(source, p, before, after, negate, len);
 
- T const nat = atol(natural_part.c_str());
- T const nom = atol(fraction.c_str());
         T den = 1;
- for (std::string::size_type i = 0; i < fraction.length(); i++)
+ for (std::string::size_type i = 0; i < len; i++)
         {
             den *= 10;
         }
 
- return rational<T>(nat) + rational<T>(nom, den);
+ return negate
+ ? -rational<T>(before) - rational<T>(after, den)
+ : rational<T>(before) + rational<T>(after, den)
+ ;
     }
 };
 

Modified: branches/release/libs/geometry/doc/Jamfile.v2
==============================================================================
--- branches/release/libs/geometry/doc/Jamfile.v2 (original)
+++ branches/release/libs/geometry/doc/Jamfile.v2 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -14,8 +14,10 @@
 # Auto-index, experimental. Commented otherwise does not build without.
 #using auto-index ;
 
-import boostbook ;
-import quickbook ;
+using quickbook ;
+
+path-constant here : . ;
+path-constant images_location : html ;
 
 
 boostbook geometry
@@ -23,18 +25,19 @@
     : <dependency>Jamfile.v2
         <dependency>quickref.xml
         <dependency>generated/point.qbk
- : <xsl:param>chunk.section.depth=4
+ <xsl:param>chunk.section.depth=4
 # <auto-index>off
 # <auto-index-internal>on
 # <auto-index-verbose>off
 # <xsl:param>index.on.type=1
- <format>html
- <xsl:param>chunk.first.sections=1
- <xsl:param>toc.section.depth=3
- <xsl:param>toc.max.depth=2
- <xsl:param>generate.section.toc.level=4
- <xsl:param>boost.root=../../../..
- <quickbook-define>enable_index
- ;
-
+# <format>html
+ <xsl:param>chunk.first.sections=1
+ <xsl:param>toc.section.depth=3
+ <xsl:param>toc.max.depth=2
+ <xsl:param>generate.section.toc.level=4
+ <xsl:param>boost.root=../../../..
+ <quickbook-define>enable_index
+ <include>$(here)
+ <format>pdf:<xsl:param>img.src.path=$(images_location)/
+;
 

Modified: branches/release/libs/geometry/doc/introduction.qbk
==============================================================================
--- branches/release/libs/geometry/doc/introduction.qbk (original)
+++ branches/release/libs/geometry/doc/introduction.qbk 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -39,10 +39,17 @@
 * conventions from the std library
 * conventions and names from one of the __ogc__ standards on geometry
 
-The library can be downloaded from [@http://svn.boost.org/svn/boost/trunk Boost.Trunk],
-from [@http://svn.boost.org/svn/boost/branches/release Boost.Release], or will come
-to you by the normal Boost distribution process. Note that [*extensions] are
-only distributed in Boost.Trunk, and that they are subject to change.
+The library was released with Boost 1.47.0 and from that point on it is oficially part of the Boost C++ Libraries.
+
+Latest stable version of the source code is included in the [@http://www.boost.org/users/download/ Boost packaged releases].
+It can also be downloaded from the current [@http://svn.boost.org/svn/boost/branches/release Boost release branch]
+in the Boost Subversion repository.
+
+The library development upstream is available from the [@http://svn.boost.org/svn/boost/trunk Boost trunk] in the Boost Subversion repository.
+
+Note that the library [*extensions] are not distributed in the official Boost releases, but only available
+in the [@http://svn.boost.org/svn/boost/trunk/boost/geometry/extensions/ Boost trunk]
+and that they are subject to change.
 
 __boost_geometry__ was accepted by Boost at November 28, 2009
 ([@http://permalink.gmane.org/gmane.comp.lib.boost.announce/246 review report]).

Modified: branches/release/libs/geometry/doc/reference/algorithms/convex_hull.qbk
==============================================================================
--- branches/release/libs/geometry/doc/reference/algorithms/convex_hull.qbk (original)
+++ branches/release/libs/geometry/doc/reference/algorithms/convex_hull.qbk 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -11,7 +11,7 @@
 =============================================================================/]
 
 [heading Complexity]
-Linear
+Logarithmic
 
 [heading Example]
 [convex_hull]

Modified: branches/release/libs/geometry/doc/src/examples/algorithms/create_svg_overlay.hpp
==============================================================================
--- branches/release/libs/geometry/doc/src/examples/algorithms/create_svg_overlay.hpp (original)
+++ branches/release/libs/geometry/doc/src/examples/algorithms/create_svg_overlay.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -12,6 +12,8 @@
 #define CREATE_SVG_OVERLAY_HPP
 
 #include <fstream>
+
+#include <boost/foreach.hpp>
 #include <boost/algorithm/string.hpp>
 
 #if defined(HAVE_SVG)

Modified: branches/release/libs/geometry/doc/src/examples/geometries/adapted/boost_fusion.cpp
==============================================================================
--- branches/release/libs/geometry/doc/src/examples/geometries/adapted/boost_fusion.cpp (original)
+++ branches/release/libs/geometry/doc/src/examples/geometries/adapted/boost_fusion.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -24,7 +24,7 @@
 };
 
 BOOST_FUSION_ADAPT_STRUCT(sample_point, (double, x) (double, y) (double, z))
-BOOST_GEOMETRY_REGISTER_BOOST_FUSION_CS(sample_point)
+BOOST_GEOMETRY_REGISTER_BOOST_FUSION_CS(cs::cartesian)
 
 int main()
 {

Modified: branches/release/libs/geometry/test/algorithms/Jamfile.v2
==============================================================================
--- branches/release/libs/geometry/test/algorithms/Jamfile.v2 (original)
+++ branches/release/libs/geometry/test/algorithms/Jamfile.v2 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -19,6 +19,7 @@
     [ run convex_hull.cpp ]
     [ run correct.cpp ]
     [ run convert.cpp ]
+ [ run covered_by.cpp ]
     [ run difference.cpp ]
     [ run disjoint.cpp ]
     [ run distance.cpp ]

Modified: branches/release/libs/geometry/test/algorithms/algorithms_tests.sln
==============================================================================
--- branches/release/libs/geometry/test/algorithms/algorithms_tests.sln (original)
+++ branches/release/libs/geometry/test/algorithms/algorithms_tests.sln 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -56,6 +56,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "convert", "convert.vcproj", "{FABF1AA7-F695-49F8-92F6-AB6C4B0C088A}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "covered_by", "covered_by.vcproj", "{5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -174,6 +176,10 @@
                 {FABF1AA7-F695-49F8-92F6-AB6C4B0C088A}.Debug|Win32.Build.0 = Debug|Win32
                 {FABF1AA7-F695-49F8-92F6-AB6C4B0C088A}.Release|Win32.ActiveCfg = Release|Win32
                 {FABF1AA7-F695-49F8-92F6-AB6C4B0C088A}.Release|Win32.Build.0 = Release|Win32
+ {5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}.Debug|Win32.Build.0 = Debug|Win32
+ {5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}.Release|Win32.ActiveCfg = Release|Win32
+ {5ABF0B56-F9F1-4D93-B15A-E3972F45D97B}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

Modified: branches/release/libs/geometry/test/algorithms/assign.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/assign.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/assign.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -162,6 +162,14 @@
     ring_type ring;
     bg::assign(ring, b);
 
+ {
+ typedef bg::model::ring<P, false, false> ring_type_ccw;
+ ring_type_ccw ring_ccw;
+ // Should NOT compile (currently): bg::assign(ring_ccw, ring);
+
+ }
+
+
     //std::cout << bg::wkt(b) << std::endl;
     //std::cout << bg::wkt(ring) << std::endl;
 

Modified: branches/release/libs/geometry/test/algorithms/convert.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/convert.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/convert.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -12,97 +12,237 @@
 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
 
-#include <geometry_test_common.hpp>
 
+#include <algorithms/test_convert.hpp>
 
-#include <boost/geometry/algorithms/assign.hpp>
-#include <boost/geometry/algorithms/convert.hpp>
-#include <boost/geometry/algorithms/make.hpp>
-#include <boost/geometry/algorithms/num_points.hpp>
 
-#include <boost/geometry/geometries/geometries.hpp>
-#include <boost/geometry/geometries/adapted/c_array.hpp>
-#include <boost/geometry/geometries/adapted/boost_tuple.hpp>
-#include <test_common/test_point.hpp>
 
-BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(cs::cartesian)
-BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(cs::cartesian)
-
-
-template <typename P>
-void test_all()
+template <typename Point1, typename Point2>
+void test_mixed_point_types()
 {
- typedef bg::model::box<P> box_type;
-
- P p;
- bg::assign_values(p, 1, 2);
+ // Point
+ test_mixed_identical_result<Point1, Point2>("POINT(1 2)");
 
- box_type b;
- bg::convert(p, b);
-
- BOOST_CHECK_CLOSE((bg::get<0, 0>(b)), 1.0, 0.001);
- BOOST_CHECK_CLOSE((bg::get<0, 1>(b)), 2.0, 0.001);
- BOOST_CHECK_CLOSE((bg::get<1, 0>(b)), 1.0, 0.001);
- BOOST_CHECK_CLOSE((bg::get<1, 1>(b)), 2.0, 0.001);
+ // Linestring
+ test_mixed_identical_result
+ <
+ bg::model::linestring<Point1>,
+ bg::model::linestring<Point2>
+ >
+ ("LINESTRING(1 1,2 2)");
+
+ // Ring
+ test_mixed_identical_result
+ <
+ bg::model::ring<Point1>,
+ bg::model::ring<Point2>
+ >
+ ("POLYGON((1 1,2 2,3 0,1 1))");
+ test_mixed_reversible_result
+ <
+ bg::model::ring<Point1, true>,
+ bg::model::ring<Point2, false>
+ >
+ (
+ "POLYGON((1 1,2 2,3 0,1 1))",
+ "POLYGON((1 1,3 0,2 2,1 1))"
+ );
+ test_mixed
+ <
+ bg::model::ring<Point1, true, true>,
+ bg::model::ring<Point2, true, false>
+ >
+ (
+ "POLYGON((1 1,2 2,3 0,1 1))",
+ "POLYGON((1 1,2 2,3 0))"
+ );
+ test_mixed
+ <
+ bg::model::ring<Point1, true, false>,
+ bg::model::ring<Point2, true, true>
+ >
+ (
+ "POLYGON((1 1,2 2,3 0))",
+ "POLYGON((1 1,2 2,3 0,1 1))"
+ );
+
+ // Polygon
+ test_mixed_reversible_result
+ <
+ bg::model::polygon<Point1, true>,
+ bg::model::polygon<Point2, false>
+ >
+ (
+ "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))",
+ "POLYGON((0 0,5 0,5 5,0 5,0 0),(1 1,2 4,3 2,1 1))"
+ );
+ test_mixed
+ <
+ bg::model::polygon<Point1>,
+ bg::model::polygon<Point2, false, false>
+ >
+ (
+ "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))",
+ "POLYGON((0 0,5 0,5 5,0 5),(1 1,2 4,3 2))"
+ );
+ // (polygon uses ring, so other tests omitted here)
+
+ // Combinations:
+ // ring <-> polygon
+ test_mixed_identical_result
+ <
+ bg::model::polygon<Point1>,
+ bg::model::ring<Point2>
+ >
+ ("POLYGON((1 1,2 2,3 0,1 1))");
+ test_mixed_reversible_result
+ <
+ bg::model::polygon<Point1, true>,
+ bg::model::ring<Point2, false>
+ >
+ (
+ "POLYGON((1 1,2 2,3 0,1 1))",
+ "POLYGON((1 1,3 0,2 2,1 1))"
+ );
+ // Any hole will be omitted going from polygon to ring
+ test_mixed
+ <
+ bg::model::polygon<Point1>,
+ bg::model::ring<Point2>
+ >
+ (
+ "POLYGON((0 0,0 5,5 5,5 0,0 0),(1 1,3 2,2 4,1 1))",
+ "POLYGON((0 0,0 5,5 5,5 0,0 0))"
+ );
+
+ // point -> box
+ test_mixed
+ <
+ Point1,
+ bg::model::box<Point2>
+ >
+ (
+ "POINT(0 0)",
+ "POLYGON((0 0,0 0,0 0,0 0,0 0))"
+ );
+
+ // segment -> line
+ test_mixed
+ <
+ bg::model::segment<Point1>,
+ bg::model::linestring<Point2>
+ >
+ (
+ "LINESTRING(0 0,1 1)",
+ "LINESTRING(0 0,1 1)"
+ );
+
+ // box -> ring ( <- is NYI)
+ test_mixed
+ <
+ bg::model::box<Point1>,
+ bg::model::ring<Point2>
+ >
+ (
+ "BOX(0 0,2 2)",
+ "POLYGON((0 0,0 2,2 2,2 0,0 0))"
+ );
+ test_mixed
+ <
+ bg::model::box<Point1>,
+ bg::model::ring<Point2, false>
+ >
+ (
+ "BOX(0 0,2 2)",
+ "POLYGON((0 0,2 0,2 2,0 2,0 0))"
+ );
+ test_mixed
+ <
+ bg::model::box<Point1>,
+ bg::model::ring<Point2, true, false>
+ >
+ (
+ "BOX(0 0,2 2)",
+ "POLYGON((0 0,0 2,2 2,2 0))"
+ );
+ test_mixed
+ <
+ bg::model::box<Point1>,
+ bg::model::ring<Point2, false, false>
+ >
+ (
+ "BOX(0 0,2 2)",
+ "POLYGON((0 0,2 0,2 2,0 2))"
+ );
+
+ // box -> polygon ( <- is NYI)
+ test_mixed
+ <
+ bg::model::box<Point1>,
+ bg::model::polygon<Point2>
+ >
+ (
+ "BOX(0 0,2 2)",
+ "POLYGON((0 0,0 2,2 2,2 0,0 0))"
+ );
+ test_mixed
+ <
+ bg::model::box<Point1>,
+ bg::model::polygon<Point2, false>
+ >
+ (
+ "BOX(0 0,2 2)",
+ "POLYGON((0 0,2 0,2 2,0 2,0 0))"
+ );
+ test_mixed
+ <
+ bg::model::box<Point1>,
+ bg::model::polygon<Point2, true, false>
+ >
+ (
+ "BOX(0 0,2 2)",
+ "POLYGON((0 0,0 2,2 2,2 0))"
+ );
+ test_mixed
+ <
+ bg::model::box<Point1>,
+ bg::model::polygon<Point2, false, false>
+ >
+ (
+ "BOX(0 0,2 2)",
+ "POLYGON((0 0,2 0,2 2,0 2))"
+ );
 }
 
-template <typename P>
-void test_std()
+template <typename Point1, typename Point2>
+void test_mixed_types()
 {
- test_all<P>();
-
- typedef bg::model::box<P> box_type;
- typedef bg::model::ring<P> ring_type;
- typedef bg::model::polygon<P> polygon_type;
-
- box_type b;
- bg::set<bg::min_corner, 0>(b, 1);
- bg::set<bg::min_corner, 1>(b, 2);
- bg::set<bg::max_corner, 0>(b, 3);
- bg::set<bg::max_corner, 1>(b, 4);
-
- ring_type ring;
- bg::convert(b, ring);
-
- //std::cout << bg::wkt(b) << std::endl;
- //std::cout << bg::wkt(ring) << std::endl;
-
- typename boost::range_const_iterator<ring_type>::type it = ring.begin();
- BOOST_CHECK_CLOSE(bg::get<0>(*it), 1.0, 0.001);
- BOOST_CHECK_CLOSE(bg::get<1>(*it), 2.0, 0.001);
- it++;
- BOOST_CHECK_CLOSE(bg::get<0>(*it), 1.0, 0.001);
- BOOST_CHECK_CLOSE(bg::get<1>(*it), 4.0, 0.001);
- it++;
- BOOST_CHECK_CLOSE(bg::get<0>(*it), 3.0, 0.001);
- BOOST_CHECK_CLOSE(bg::get<1>(*it), 4.0, 0.001);
- it++;
- BOOST_CHECK_CLOSE(bg::get<0>(*it), 3.0, 0.001);
- BOOST_CHECK_CLOSE(bg::get<1>(*it), 2.0, 0.001);
- it++;
- BOOST_CHECK_CLOSE(bg::get<0>(*it), 1.0, 0.001);
- BOOST_CHECK_CLOSE(bg::get<1>(*it), 2.0, 0.001);
-
- BOOST_CHECK_EQUAL(ring.size(), 5u);
-
-
- polygon_type polygon;
-
- bg::convert(ring, polygon);
- BOOST_CHECK_EQUAL(bg::num_points(polygon), 5u);
+ test_mixed_point_types<Point1, Point2>();
+ test_mixed_point_types<Point2, Point1>();
+}
 
- bg::convert(polygon, ring);
- BOOST_CHECK_EQUAL(bg::num_points(ring), 5u);
+void test_array()
+{
+ int a[2] = {1, 2};
+ int b[2];
+ bg::convert(a, b);
+ BOOST_CHECK_EQUAL(b[0], 1);
+ BOOST_CHECK_EQUAL(b[1], 2);
 }
 
 int test_main(int, char* [])
 {
- test_std<bg::model::point<int, 2, bg::cs::cartesian> >();
- test_std<bg::model::point<float, 2, bg::cs::cartesian> >();
- test_std<bg::model::point<double, 2, bg::cs::cartesian> >();
-
-#ifdef HAVE_TTMATH
- test_std<bg::model::point<ttmath_big, 2, bg::cs::cartesian> >();
-#endif
+ test_mixed_types
+ <
+ bg::model::point<int, 2, bg::cs::cartesian>,
+ bg::model::point<double, 2, bg::cs::cartesian>
+ >();
+ test_mixed_types
+ <
+ boost::tuple<float, float>,
+ bg::model::point<float, 2, bg::cs::cartesian>
+ >();
+
+ test_array();
     return 0;
 }

Modified: branches/release/libs/geometry/test/algorithms/difference.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/difference.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/difference.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -46,8 +46,7 @@
     typedef bg::model::polygon<P> polygon;
     typedef bg::model::ring<P> ring;
 
- bool const is_float =
- boost::is_same<typename bg::coordinate_type<P>::type, float>::value;
+ typedef typename bg::coordinate_type<P>::type ct;
 
     test_one<polygon, polygon, polygon>("simplex_normal",
         simplex_normal[0], simplex_normal[1],
@@ -93,7 +92,7 @@
     test_one<polygon, polygon, polygon>("distance_zero",
         distance_zero[0], distance_zero[1],
         2, 0, 8.7048386,
- is_float ? 1 : 2, // The too small one is discarded for floating point
+ if_typed<ct, float>(1, 2), // The too small one is discarded for floating point
         0, 0.0098387);
 
 
@@ -200,18 +199,55 @@
     ***/
 
 #ifdef _MSC_VER
- {
- // Isovist (submitted by Brandon during Formal Review)
- std::string tn = string_from_type<typename bg::coordinate_type<polygon>::type>::name();
- test_one<polygon, polygon, polygon>("isovist",
- isovist1[0], isovist1[1],
- 4, 0, 0.279121891701124,
- 4, 0, 224.889211358929,
- 0.01);
- }
+ // Isovist (submitted by Brandon during Formal Review)
+ test_one<polygon, polygon, polygon>("isovist",
+ isovist1[0], isovist1[1],
+ 4, 0, 0.279121891701124,
+ 4, 0, 224.889211358929,
+ 0.01);
+
+ test_one<polygon, polygon, polygon>("ggl_list_20110306_javier",
+ ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
+ 1, 0, 71495.3331,
+ 2, 0, 8960.49049);
 #endif
+
+ test_one<polygon, polygon, polygon>("ggl_list_20110307_javier",
+ ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
+ 1, 0, 16815.6,
+ 1, 0, 3200.4,
+ 0.01);
+
+ test_one<polygon, polygon, polygon>("ggl_list_20110716_enrico",
+ ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
+ 3, 0, 35723.8506317139,
+ 1, 0, 58456.4964294434
+ );
+
+ test_one<polygon, polygon, polygon>("ggl_list_20110820_christophe",
+ ggl_list_20110820_christophe[0], ggl_list_20110820_christophe[1],
+ 1, 0, 2.8570121719168924,
+ 1, 0, 64.498061986388564);
+
 
 
+#ifdef _MSC_VER
+ // 2011-07-02
+ // Interesting FP-precision case.
+ // sql server gives: 6.62295817619452E-05
+ // PostGIS gives: 0.0 (no output)
+ // Boost.Geometry gives results depending on FP-type, and compiler, and operating system.
+ // For double, it is zero (skipped). On gcc/Linux, for float either.
+ // Because we cannot predict this, we only test for MSVC
+ test_one<polygon, polygon, polygon>("ggl_list_20110627_phillip",
+ ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
+ if_typed<ct, double>(0, 1), 0,
+ if_typed_tt<ct>(0.0000000000001105367, 0.0),
+ 1, 0, 3577.40960816756,
+ 0.01
+ );
+#endif
+
     // Other combi's
     {
         test_one<polygon, polygon, ring>(

Modified: branches/release/libs/geometry/test/algorithms/intersection.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/intersection.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/intersection.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -20,11 +20,15 @@
 //#define BOOST_GEOMETRY_DEBUG_IDENTIFIER
 
 
+#include <boost/geometry/geometries/point_xy.hpp>
+#include <boost/geometry/geometries/register/linestring.hpp>
+
+#include <boost/geometry/util/rational.hpp>
+
 #include <algorithms/test_intersection.hpp>
 #include <algorithms/test_overlay.hpp>
 
-#include <boost/geometry/geometries/point_xy.hpp>
-#include <boost/geometry/geometries/register/linestring.hpp>
+#include <algorithms/overlay/overlay_cases.hpp>
 
 #include <test_common/test_point.hpp>
 #include <test_common/with_pointer.hpp>
@@ -155,17 +159,40 @@
         crossed[0], crossed[1],
         3, 0, 1.5);
 
+ typedef typename bg::coordinate_type<Polygon>::type ct;
+
 #ifdef _MSC_VER
- {
- // Isovist (submitted by Brandon during Formal Review)
- std::string tn = string_from_type<typename bg::coordinate_type<Polygon>::type>::name();
- test_one<Polygon, Polygon, Polygon>("isovist",
- isovist1[0], isovist1[1],
- 1,
- tn == std::string("f") ? 19 : tn == std::string("d") ? 22 : 20,
- 88.19203,
- tn == std::string("f") ? 0.5 : tn == std::string("d") ? 0.1 : 0.01);
- }
+ // Isovist (submitted by Brandon during Formal Review)
+ test_one<Polygon, Polygon, Polygon>("isovist",
+ isovist1[0], isovist1[1],
+ 1,
+ if_typed<ct, float>(19, if_typed<ct, double>(20, 20)),
+ 88.19203,
+ if_typed<ct, float>(0.5, if_typed<ct, double>(0.1, 0.01)));
+#endif
+
+ //std::cout << typeid(ct).name() << std::endl;
+
+ test_one<Polygon, Polygon, Polygon>("ggl_list_20110306_javier",
+ ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
+ 1, if_typed_tt<ct>(5, 4),
+ 0.6649875,
+ if_typed<ct, float>(1.0, 0.01));
+
+ test_one<Polygon, Polygon, Polygon>("ggl_list_20110307_javier",
+ ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
+ 1, 4, 0.4, 0.01);
+
+ test_one<Polygon, Polygon, Polygon>("ggl_list_20110627_phillip",
+ ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
+ 1, if_typed_tt<ct>(6, 5), 11151.6618);
+
+#ifdef _MSC_VER // gcc/linux behaves differently
+ test_one<Polygon, Polygon, Polygon>("ggl_list_20110716_enrico",
+ ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
+ 3,
+ if_typed<ct, float>(19, if_typed<ct, double>(22, 21)),
+ 35723.8506317139);
 #endif
 
     return;
@@ -238,6 +265,23 @@
 
 
 template <typename P>
+void test_point_output()
+{
+ typedef bg::model::linestring<P> linestring;
+ typedef bg::model::polygon<P> polygon;
+ typedef bg::model::box<P> box;
+ typedef bg::model::segment<P> segment;
+
+ test_point_output<polygon, polygon>(simplex_normal[0], simplex_normal[1], 6);
+ test_point_output<box, polygon>("box(1 1,6 4)", simplex_normal[0], 4);
+ test_point_output<linestring, polygon>("linestring(0 2,6 2)", simplex_normal[0], 2);
+ // NYI because of sectionize:
+ // test_point_output<segment, polygon>("linestring(0 2,6 2)", simplex_normal[0], 2);
+ // NYI because needs special treatment:
+ // test_point_output<box, box>("box(0 0,4 4)", "box(2 2,6 6)", 2);
+}
+
+template <typename P>
 void test_all()
 {
     typedef bg::model::linestring<P> linestring;
@@ -311,6 +355,8 @@
     test_boxes<box>("box(2 2,8 7)", "box(14 4,20 10)", 0, false);
     test_boxes<box>("box(2 2,4 4)", "box(4 4,8 8)", 0, true);
 
+ test_point_output<P>();
+
 
     /*
     test_one<polygon, box, polygon>(99, "box(115041.10 471900.10, 118334.60 474523.40)",
@@ -375,10 +421,18 @@
     BOOST_CHECK_MESSAGE(false, "No exception thrown");
 }
 
-int test_main(int, char* [])
+template <typename Point>
+void test_rational()
 {
- test_exception<bg::model::d2::point_xy<double> >();
+ typedef bg::model::polygon<Point> polygon;
+ test_one<polygon, polygon, polygon>("simplex_normal",
+ simplex_normal[0], simplex_normal[1],
+ 1, 7, 5.47363293);
+}
+
 
+int test_main(int, char* [])
+{
     test_all<bg::model::d2::point_xy<double> >();
 
 #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE)
@@ -388,9 +442,12 @@
     test_all<bg::model::d2::point_xy<ttmath_big> >();
 #endif
 
- //test_pointer_version();
 #endif
 
+ test_exception<bg::model::d2::point_xy<double> >();
+ test_pointer_version();
+ test_rational<bg::model::d2::point_xy<boost::rational<int> > >();
+
     return 0;
 }
 

Modified: branches/release/libs/geometry/test/algorithms/intersects.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/intersects.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/intersects.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -58,6 +58,57 @@
     // Hole: two intersecting holes
     test_self_intersects<polygon>(
         "POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,1 3,3 3,3 1,1 1),(2 2,2 3.5,3.5 3.5,3.5 2,2 2))", true);
+
+ // Mail Akira T on [Boost-users] at 27-7-2011 3:17
+ test_self_intersects<bg::model::linestring<P> >(
+ "LINESTRING(0 0,0 4,4 4,2 2,2 5)", true);
+
+ test_self_intersects<bg::model::linestring<P> >(
+ "LINESTRING(0 4,4 4,2 2,2 5)", true);
+
+ // Test self-intersections at last segment in close/open rings:
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,3 3,4 1,0 0))", false);
+
+ test_self_intersects<bg::model::ring<P, true, false> >(
+ "POLYGON((0 0,3 3,4 1))", false);
+
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,3 3,4 1,0 1,0 0))", true);
+
+ test_self_intersects<bg::model::ring<P, true, false> >(
+ "POLYGON((0 0,3 3,4 1,0 1))", true);
+
+ // Duplicates in first or last
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,3 3,4 1,0 1,0 1,0 0))", true);
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,3 3,4 1,0 1,0 0,0 0))", true);
+ test_self_intersects<bg::model::ring<P, true, false> >(
+ "POLYGON((0 0,3 3,4 1,0 1,0 1))", true);
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1,0 0))", true);
+ test_self_intersects<bg::model::ring<P, true, false> >(
+ "POLYGON((0 0,0 0,3 3,4 1,0 1,0 1))", true);
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1,0 0))", true);
+ test_self_intersects<bg::model::ring<P, true, false> >(
+ "POLYGON((0 0,3 3,3 3,4 1,0 1,0 1))", true);
+
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,3 3,4 1,0 0,0 0))", false);
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,3 3,4 1,4 1,0 0))", false);
+ test_self_intersects<bg::model::ring<P, true, false> >(
+ "POLYGON((0 0,3 3,4 1,4 1))", false);
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,0 0,3 3,4 1,0 0))", false);
+ test_self_intersects<bg::model::ring<P, true, false> >(
+ "POLYGON((0 0,0 0,3 3,4 1))", false);
+ test_self_intersects<bg::model::ring<P> >(
+ "POLYGON((0 0,3 3,3 3,4 1,0 0))", false);
+ test_self_intersects<bg::model::ring<P, true, false> >(
+ "POLYGON((0 0,3 3,3 3,4 1))", false);
 }
 
 

Modified: branches/release/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/overlay/ccw_traverse.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -62,7 +62,11 @@
     typedef std::deque<ring_type> out_vector;
     out_vector v;
 
- bg::traverse<rev<Geometry1>::value, rev<Geometry2>::value>(g1, g2, op, turns, v);
+ bg::detail::overlay::traverse
+ <
+ rev<Geometry1>::value, rev<Geometry2>::value,
+ Geometry1, Geometry2
+ >::apply(g1, g2, op, turns, v);
 
     typename bg::coordinate_type<Geometry1>::type result = 0.0;
     BOOST_FOREACH(ring_type& ring, v)

Modified: branches/release/libs/geometry/test/algorithms/overlay/get_turns.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/overlay/get_turns.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/overlay/get_turns.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -303,6 +303,11 @@
             4,
             ggl_list_20110306_javier[0], ggl_list_20110306_javier[1]);
 
+#ifdef _MSC_VER // gcc returns 14 for float
+ test_get_turns<polygon, polygon>::apply("ggl_list_20110716_enrico",
+ 13,
+ ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1]);
+#endif
 
     // pies
     test_get_turns<polygon, polygon>::apply("pie_23_16_16", 3, pie_23_16_16[0], pie_23_16_16[1]);

Modified: branches/release/libs/geometry/test/algorithms/overlay/overlay_cases.hpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/overlay/overlay_cases.hpp (original)
+++ branches/release/libs/geometry/test/algorithms/overlay/overlay_cases.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -490,6 +490,33 @@
     "POLYGON((-2 2,2002 2,2002 -2002,-2 -2002,-2 2),(0 -147.00000000000003,0 -2000,2000 -2000,2000 0,104 0,440 -240,400 -280,0 -147.00000000000003))",
     "POLYGON((359.99000000000001 -280,0 -182,0 -147,400.00999999999999 -280,359.99000000000001 -280))"
     };
+
+static std::string ggl_list_20110307_javier[2] =
+ {
+ "POLYGON((-2 2, 1842 2, 1842 -2362, -2 -2362, -2 2), (0 0, 0 -2360, 1840 -2360, 1840 0, 0 0))",
+ // "POLYGON((-0.01 -1960, 0 -1960, 0 -1880, 0.01 -1960, -0.01 -1960))"
+ "POLYGON ((-0.01 -1960, 80.01 -1960, 0 -1880, -0.01 -1960))"
+ };
+
+
+static std::string ggl_list_20110627_phillip[2] =
+ {
+ "POLYGON((537.99678544791459 124.30517362077681,437.36539413622404 142.02728895075373,456.33031803043468 249.50296671450121,556.96217263181723 231.78347688272990,537.99678544791459 124.30517362077681))",
+ "POLYGON((437.35 142.03,461.94 281.32,564.5 263.26,539.9 123.97,437.35 142.03))"
+ };
+
+static std::string ggl_list_20110716_enrico[2] =
+ {
+ "POLYGON((1.83691e-014 -300,-259.808 -150,-259.808 150,-5.51073e-014 300,259.808 150,259.808 -150,9.18455e-014 -300,1.83691e-014 -300),(7.65379e-014 -250,216.506 -125,216.506 125,-4.59227e-014 250,-216.506 125,-216.506 -125,1.53076e-014 -250,7.65379e-014 -250))",
+ "POLYGON((1.83691e-014 -300,-259.808 -150,-216.506 -125,-216.506 125,-259.808 150,-5.51073e-014 300,-4.59227e-014 250,216.506 125,259.808 150,259.808 -150,216.506 -125,7.65379e-014 -250,9.18455e-014 -300,1.83691e-014 -300),(6.12303e-014 -200,173.205 -100,173.205 100,-3.67382e-014 200,-173.205 100,-173.205 -100,1.22461e-014 -200,6.12303e-014 -200))"
+ };
+
+
+static std::string ggl_list_20110820_christophe[2] =
+{
+ "POLYGON((17.763942722600319 32.23605727739968,19.192448808558737 30.807551191441263,16.000000000000000 30.000000000000000,17.763942722600319 32.236057277399681))",
+ "POLYGON((0.24806946917841693 26.015444246572663,31.751930530821582 33.984555753427337,32.248069469178418 30.015444246572663,0.24806946917841693 26.015444246572663))"
+};
 
 
 // GEOS "TestOverlay" test.

Modified: branches/release/libs/geometry/test/algorithms/overlay/robustness/robustness.sln
==============================================================================
--- branches/release/libs/geometry/test/algorithms/overlay/robustness/robustness.sln (original)
+++ branches/release/libs/geometry/test/algorithms/overlay/robustness/robustness.sln 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -12,6 +12,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "interior_triangles", "interior_triangles.vcproj", "{7583C2E3-AD74-4C34-8E94-9162F641B215}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "intersects", "intersects.vcproj", "{1AC9B120-3ED0-4444-86E5-1916108943C7}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -42,6 +44,10 @@
                 {7583C2E3-AD74-4C34-8E94-9162F641B215}.Debug|Win32.Build.0 = Debug|Win32
                 {7583C2E3-AD74-4C34-8E94-9162F641B215}.Release|Win32.ActiveCfg = Release|Win32
                 {7583C2E3-AD74-4C34-8E94-9162F641B215}.Release|Win32.Build.0 = Release|Win32
+ {1AC9B120-3ED0-4444-86E5-1916108943C7}.Debug|Win32.ActiveCfg = Debug|Win32
+ {1AC9B120-3ED0-4444-86E5-1916108943C7}.Debug|Win32.Build.0 = Debug|Win32
+ {1AC9B120-3ED0-4444-86E5-1916108943C7}.Release|Win32.ActiveCfg = Release|Win32
+ {1AC9B120-3ED0-4444-86E5-1916108943C7}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

Modified: branches/release/libs/geometry/test/algorithms/overlay/select_rings.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/overlay/select_rings.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/overlay/select_rings.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -50,7 +50,7 @@
     map_type selected;
     std::map<bg::ring_identifier, int> empty;
 
- bg::detail::overlay::select_rings<OverlayType>(geometry1, geometry2, empty, selected);
+ bg::detail::overlay::select_rings<OverlayType>(geometry1, geometry2, empty, selected, true);
 
     BOOST_CHECK_EQUAL(selected.size(), expected_ids.size());
     BOOST_CHECK_EQUAL(selected.size(), expected_withins.size());

Modified: branches/release/libs/geometry/test/algorithms/overlay/self_intersection_points.vcproj
==============================================================================
--- branches/release/libs/geometry/test/algorithms/overlay/self_intersection_points.vcproj (original)
+++ branches/release/libs/geometry/test/algorithms/overlay/self_intersection_points.vcproj 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -46,6 +46,7 @@
                                 ExceptionHandling="2"
                                 RuntimeLibrary="1"
                                 UsePrecompiledHeader="0"
+ DebugInformationFormat="1"
                         />
                         <Tool
                                 Name="VCManagedResourceCompilerTool"

Modified: branches/release/libs/geometry/test/algorithms/overlay/traverse.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/overlay/traverse.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/overlay/traverse.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -158,7 +158,11 @@
         out_vector v;
 
 
- bg::traverse<Reverse1, Reverse2>(g1, g2, Direction, turns, v);
+ bg::detail::overlay::traverse
+ <
+ Reverse1, Reverse2,
+ G1, G2
+ >::apply(g1, g2, Direction, turns, v);
 
         // Check number of resulting rings
         BOOST_CHECK_MESSAGE(expected_count == boost::size(v),

Modified: branches/release/libs/geometry/test/algorithms/test_difference.hpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/test_difference.hpp (original)
+++ branches/release/libs/geometry/test/algorithms/test_difference.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -23,7 +23,6 @@
 
 #include <boost/geometry/algorithms/area.hpp>
 #include <boost/geometry/algorithms/num_points.hpp>
-#include <boost/geometry/algorithms/unique.hpp>
 
 #include <boost/geometry/geometries/geometries.hpp>
 
@@ -73,9 +72,6 @@
     {
         if (expected_point_count > 0)
         {
- // Get a correct point-count without duplicate points
- // (note that overlay might be adapted to avoid duplicates)
- bg::unique(*it);
             n += bg::num_points(*it);
         }
 

Modified: branches/release/libs/geometry/test/algorithms/test_intersection.hpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/test_intersection.hpp (original)
+++ branches/release/libs/geometry/test/algorithms/test_intersection.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -13,14 +13,12 @@
 #include <iomanip>
 
 #include <boost/foreach.hpp>
-#include <geometry_test_common.hpp>
 
 #include <boost/geometry/algorithms/intersection.hpp>
 #include <boost/geometry/algorithms/area.hpp>
 #include <boost/geometry/algorithms/correct.hpp>
 #include <boost/geometry/algorithms/length.hpp>
 #include <boost/geometry/algorithms/num_points.hpp>
-#include <boost/geometry/algorithms/unique.hpp>
 
 #include <boost/geometry/geometries/geometries.hpp>
 
@@ -33,7 +31,7 @@
 # include <boost/geometry/extensions/io/svg/svg_mapper.hpp>
 #endif
 
-
+#include <geometry_test_common.hpp>
 
 
 template <typename OutputType, typename CalculationType, typename G1, typename G2>
@@ -41,8 +39,7 @@
         G1 const& g1, G2 const& g2,
         std::size_t expected_count = 0, std::size_t expected_point_count = 0,
         double expected_length_or_area = 0,
- double percentage = 0.0001,
- bool make_unique = true)
+ double percentage = 0.0001)
 {
     static const bool is_line = bg::geometry_id<OutputType>::type::value == 2;
 
@@ -78,21 +75,11 @@
     {
         if (expected_point_count > 0)
         {
- if (make_unique)
- {
- // Get a correct point-count without duplicate points
- // (note that overlay might be adapted to avoid duplicates)
- bg::unique(*it);
- n += bg::num_points(*it, true);
- }
- else
- {
- n += bg::num_points(*it, true);
- }
+ n += bg::num_points(*it, true);
         }
 
         // instead of specialization we check it run-time here
- length_or_area += is_line
+ length_or_area += is_line
             ? bg::length(*it)
             : bg::area(*it);
 
@@ -126,7 +113,8 @@
                 );
     }
 
- BOOST_CHECK_CLOSE(length_or_area, expected_length_or_area, percentage);
+ double const detected_length_or_area = boost::numeric_cast<double>(length_or_area);
+ BOOST_CHECK_CLOSE(detected_length_or_area, expected_length_or_area, percentage);
 #endif
 
 
@@ -179,8 +167,7 @@
         std::string const& wkt1, std::string const& wkt2,
         std::size_t expected_count = 0, std::size_t expected_point_count = 0,
         double expected_length_or_area = 0,
- double percentage = 0.0001,
- bool make_unique = true)
+ double percentage = 0.0001)
 {
     G1 g1;
     bg::read_wkt(wkt1, g1);
@@ -194,9 +181,24 @@
 
     return test_intersection<OutputType, void>(caseid, g1, g2,
         expected_count, expected_point_count,
- expected_length_or_area, percentage, make_unique);
+ expected_length_or_area, percentage);
 }
 
+template <typename Geometry1, typename Geometry2>
+void test_point_output(std::string const& wkt1, std::string const& wkt2, int expected_count)
+{
+ Geometry1 g1;
+ bg::read_wkt(wkt1, g1);
+ bg::correct(g1);
+
+ Geometry2 g2;
+ bg::read_wkt(wkt2, g2);
+ bg::correct(g2);
+
+ std::vector<typename bg::point_type<Geometry1>::type> points;
+ bg::intersection(g1, g2, points);
+ BOOST_CHECK_EQUAL(points.size(), expected_count);
+}
 
 
 #endif

Modified: branches/release/libs/geometry/test/algorithms/test_overlay.hpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/test_overlay.hpp (original)
+++ branches/release/libs/geometry/test/algorithms/test_overlay.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -144,7 +144,7 @@
 
 // within each other, having no intersections but many holes within each other
 static std::string winded[2] =
- {"POLYGON((0 0,0 11,11 11,11 0,0 0),(3 3,4 3,4 4,3 4,3 3),(5 3,6 3,6 4,5 4,5 3),(2 6,7 6,7 6,7 9,2 9,2 6),(9 2,10 2,10 5,9 5,9 2))",
+ {"POLYGON((0 0,0 11,11 11,11 0,0 0),(3 3,4 3,4 4,3 4,3 3),(5 3,6 3,6 4,5 4,5 3),(2 6,7 6,7 9,2 9,2 6),(9 2,10 2,10 5,9 5,9 2))",
     "POLYGON((1 1,1 10,10 10,10 6,8 6,8 1,1 1),(2 2,7 2,7 5,2 5,2 2),(3 7,4 7,4 8,3 8,3 7),(5 7,6 7,6 8,5 8,5 7),(8 7,9 7,9 8,8 8,8 7))"};
 
 static std::string within_holes_disjoint[2] =

Modified: branches/release/libs/geometry/test/algorithms/test_union.hpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/test_union.hpp (original)
+++ branches/release/libs/geometry/test/algorithms/test_union.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -21,7 +21,6 @@
 #include <boost/geometry/algorithms/correct.hpp>
 #include <boost/geometry/algorithms/length.hpp>
 #include <boost/geometry/algorithms/num_points.hpp>
-#include <boost/geometry/algorithms/unique.hpp>
 
 #include <boost/geometry/geometries/geometries.hpp>
 
@@ -55,10 +54,6 @@
         area += bg::area(*it);
         holes += bg::num_interior_rings(*it);
 
- // Get a correct point-count without duplicate points
- // (note that overlay might be adapted to avoid duplicates)
- OutputType simplified;
- bg::unique(*it);
         n += bg::num_points(*it, true);
     }
 

Modified: branches/release/libs/geometry/test/algorithms/test_within.hpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/test_within.hpp (original)
+++ branches/release/libs/geometry/test/algorithms/test_within.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -21,6 +21,10 @@
 
 #include <boost/geometry/domains/gis/io/wkt/read_wkt.hpp>
 
+#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
+#include <boost/geometry/strategies/cartesian/box_in_box.hpp>
+#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>
+
 
 template <typename Geometry1, typename Geometry2>
 void test_geometry(std::string const& wkt1,
@@ -42,6 +46,7 @@
 }
 
 
+
 template <typename Point, bool Clockwise, bool Closed>
 void test_ordered_ring(std::string const& wkt_point,
         std::string const& wkt_geometry, bool expected, bool on_border)

Modified: branches/release/libs/geometry/test/algorithms/union.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/union.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/union.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -25,26 +25,12 @@
 #include <algorithms/overlay/overlay_cases.hpp>
 #include <boost/geometry/geometries/point_xy.hpp>
 
-static std::string javier4[2] =
- {
- "POLYGON((-2 2, 1842 2, 1842 -2362, -2 -2362, -2 2), (0 0, 0 -2360, 1840 -2360, 1840 0, 0 0))",
- // "POLYGON((-0.01 -1960, 0 -1960, 0 -1880, 0.01 -1960, -0.01 -1960))"
- "POLYGON ((-0.01 -1960, 80.01 -1960, 0 -1880, -0.01 -1960))"
- };
-
-
-
-
-
-
 
 
 template <typename Ring, typename Polygon>
 void test_areal()
 {
- test_one<Polygon, Polygon, Polygon>("javier4",
- javier4[0], javier4[1],
- 1, 1, 13, 20016.4);
+ typedef typename bg::coordinate_type<Polygon>::type ct;
 
     test_one<Polygon, Polygon, Polygon>("simplex_normal",
         simplex_normal[0], simplex_normal[1],
@@ -63,12 +49,7 @@
     // This sample was selected because of the border case, and ttmath generates one point more.
     test_one<Polygon, Polygon, Polygon>("star_poly", example_star, example_polygon,
         1, 1,
-#if defined(HAVE_TTMATH)
- boost::is_same<typename bg::coordinate_type<Ring>::type, ttmath_big>::value ? 28 : 27,
-#else
- 27,
-#endif
- 5.647949);
+ if_typed_tt<ct>(28, 27), 5.647949);
 
     // Pseudo-box as Polygon
     // (note, internally, the intersection points is different, so yes,
@@ -237,20 +218,34 @@
     test_one<Polygon, Polygon, Polygon>("ggl_list_20110306_javier",
         ggl_list_20110306_javier[0], ggl_list_20110306_javier[1],
         1, 1, 16, 80456.4904910401);
+
+ test_one<Polygon, Polygon, Polygon>("ggl_list_20110307_javier",
+ ggl_list_20110307_javier[0], ggl_list_20110307_javier[1],
+ 1, 1, 13, 20016.4);
+
+ test_one<Polygon, Polygon, Polygon>("ggl_list_20110627_phillip",
+ ggl_list_20110627_phillip[0], ggl_list_20110627_phillip[1],
+ 1, 0,
+ if_typed<ct, double>(5, if_typed_tt<ct>(8, 7)),
+ 14729.07145);
+
+#ifdef TEST_ENRICO
+ test_one<Polygon, Polygon, Polygon>("ggl_list_20110716_enrico",
+ ggl_list_20110716_enrico[0], ggl_list_20110716_enrico[1],
+ 1, 1,
+ if_typed<ct, double>(18, 17),
+ 129904.197692871);
+#endif
 
 #ifdef _MSC_VER
- {
- // Isovist (submitted by Brandon during Formal Review)
- std::string tn = string_from_type<typename bg::coordinate_type<Polygon>::type>::name();
- test_one<Polygon, Polygon, Polygon>("isovist",
- isovist1[0], isovist1[1],
- 1,
- 0,
- tn == std::string("f") ? 71
- : tn == std::string("d") ? 72
- : 73,
- 313.36036462);
- }
+ // Isovist (submitted by Brandon during Formal Review)
+ test_one<Polygon, Polygon, Polygon>("isovist",
+ isovist1[0], isovist1[1],
+ 1,
+ 0,
+ if_typed<ct, float>(71,
+ if_typed<ct, double>(70, 73)),
+ 313.36036462);
 #endif
 }
 

Modified: branches/release/libs/geometry/test/algorithms/within.cpp
==============================================================================
--- branches/release/libs/geometry/test/algorithms/within.cpp (original)
+++ branches/release/libs/geometry/test/algorithms/within.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -37,18 +37,28 @@
     typedef bg::model::box<P> box_type;
 
     test_geometry<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", true);
+ test_geometry<P, box_type>("POINT(0 0)", "BOX(0 0,2 2)", false);
+ test_geometry<P, box_type>("POINT(2 2)", "BOX(0 0,2 2)", false);
+ test_geometry<P, box_type>("POINT(0 1)", "BOX(0 0,2 2)", false);
+ test_geometry<P, box_type>("POINT(1 0)", "BOX(0 0,2 2)", false);
 
     test_geometry<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", true);
     test_geometry<box_type, box_type>("BOX(0 0,3 3)", "BOX(1 1,2 2)", false);
 
-
- // Mixed point types
- test_geometry
- <
- bg::model::d2::point_xy<float>,
- bg::model::polygon<P>
- >("POINT(1 1)", "POLYGON((0 0,0 2,2 2,2 0,0 0))", true);
-
+ /*
+ test_within_code<P, box_type>("POINT(1 1)", "BOX(0 0,2 2)", 1);
+ test_within_code<P, box_type>("POINT(1 0)", "BOX(0 0,2 2)", 0);
+ test_within_code<P, box_type>("POINT(0 1)", "BOX(0 0,2 2)", 0);
+ test_within_code<P, box_type>("POINT(0 3)", "BOX(0 0,2 2)", -1);
+ test_within_code<P, box_type>("POINT(3 3)", "BOX(0 0,2 2)", -1);
+
+ test_within_code<box_type, box_type>("BOX(1 1,2 2)", "BOX(0 0,3 3)", 1);
+ test_within_code<box_type, box_type>("BOX(0 1,2 2)", "BOX(0 0,3 3)", 0);
+ test_within_code<box_type, box_type>("BOX(1 0,2 2)", "BOX(0 0,3 3)", 0);
+ test_within_code<box_type, box_type>("BOX(1 1,2 3)", "BOX(0 0,3 3)", 0);
+ test_within_code<box_type, box_type>("BOX(1 1,3 2)", "BOX(0 0,3 3)", 0);
+ test_within_code<box_type, box_type>("BOX(1 1,3 4)", "BOX(0 0,3 3)", -1);
+ */
 
     // Real-life problem (solved now), point is in the middle, 409623 is also a coordinate
     // on the border, has been wrong in the past (2009)
@@ -106,6 +116,105 @@
     BOOST_CHECK_EQUAL(bg::within(Point(7, 52.5), triangle), true);
     BOOST_CHECK_EQUAL(bg::within(Point(8.0, 51.5), triangle), false);
     BOOST_CHECK_EQUAL(bg::within(Point(6.0, 51.0), triangle), false);
+
+ // Test spherical boxes
+ // See also http://www.gcmap.com/mapui?P=1E45N-19E45N-19E55N-1E55N-1E45N,10E55.1N,10E45.1N
+ bg::model::box<Point> box;
+ bg::read_wkt("POLYGON((1 45,19 55))", box);
+ BOOST_CHECK_EQUAL(bg::within(Point(10, 55.1), box), true);
+ BOOST_CHECK_EQUAL(bg::within(Point(10, 55.2), box), true);
+ BOOST_CHECK_EQUAL(bg::within(Point(10, 55.3), box), true);
+ BOOST_CHECK_EQUAL(bg::within(Point(10, 55.4), box), false);
+
+ BOOST_CHECK_EQUAL(bg::within(Point(10, 45.1), box), false);
+ BOOST_CHECK_EQUAL(bg::within(Point(10, 45.2), box), false);
+ BOOST_CHECK_EQUAL(bg::within(Point(10, 45.3), box), false);
+ BOOST_CHECK_EQUAL(bg::within(Point(10, 45.4), box), true);
+
+ // Crossing the dateline (Near Tuvalu)
+ // http://www.gcmap.com/mapui?P=178E10S-178W10S-178W6S-178E6S-178E10S,180W5.999S,180E9.999S
+ // http://en.wikipedia.org/wiki/Tuvalu
+
+ bg::model::box<Point> tuvalu(Point(178, -10), Point(-178, -6));
+ BOOST_CHECK_EQUAL(bg::within(Point(180, -8), tuvalu), true);
+ BOOST_CHECK_EQUAL(bg::within(Point(-180, -8), tuvalu), true);
+ BOOST_CHECK_EQUAL(bg::within(Point(180, -5.999), tuvalu), false);
+ BOOST_CHECK_EQUAL(bg::within(Point(180, -10.001), tuvalu), true);
+}
+
+void test_3d()
+{
+ typedef boost::geometry::model::point<double, 3, boost::geometry::cs::cartesian> point_type;
+ typedef boost::geometry::model::box<point_type> box_type;
+ box_type box(point_type(0, 0, 0), point_type(4, 4, 4));
+ BOOST_CHECK_EQUAL(bg::within(point_type(2, 2, 2), box), true);
+ BOOST_CHECK_EQUAL(bg::within(point_type(2, 4, 2), box), false);
+ BOOST_CHECK_EQUAL(bg::within(point_type(2, 2, 4), box), false);
+ BOOST_CHECK_EQUAL(bg::within(point_type(2, 2, 5), box), false);
+}
+
+template <typename P1, typename P2>
+void test_mixed_of()
+{
+ typedef boost::geometry::model::polygon<P1> polygon_type1;
+ typedef boost::geometry::model::polygon<P2> polygon_type2;
+ typedef boost::geometry::model::box<P1> box_type1;
+ typedef boost::geometry::model::box<P2> box_type2;
+
+ polygon_type1 poly1, poly2;
+ boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly1);
+ boost::geometry::read_wkt("POLYGON((0 0,0 5,5 5,5 0,0 0))", poly2);
+
+ box_type1 box1(P1(1, 1), P1(4, 4));
+ box_type2 box2(P2(0, 0), P2(5, 5));
+ P1 p1(3, 3);
+ P2 p2(3, 3);
+
+ BOOST_CHECK_EQUAL(bg::within(p1, poly2), true);
+ BOOST_CHECK_EQUAL(bg::within(p2, poly1), true);
+ BOOST_CHECK_EQUAL(bg::within(p2, box1), true);
+ BOOST_CHECK_EQUAL(bg::within(p1, box2), true);
+ BOOST_CHECK_EQUAL(bg::within(box1, box2), true);
+ BOOST_CHECK_EQUAL(bg::within(box2, box1), false);
+}
+
+
+void test_mixed()
+{
+ // Mixing point types and coordinate types
+ test_mixed_of
+ <
+ boost::geometry::model::d2::point_xy<double>,
+ boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
+ >();
+ test_mixed_of
+ <
+ boost::geometry::model::d2::point_xy<float>,
+ boost::geometry::model::point<double, 2, boost::geometry::cs::cartesian>
+ >();
+ test_mixed_of
+ <
+ boost::geometry::model::d2::point_xy<int>,
+ boost::geometry::model::d2::point_xy<double>
+ >();
+}
+
+void test_strategy()
+{
+ // Test by explicitly specifying a strategy
+ typedef bg::model::d2::point_xy<double> point_type;
+ typedef bg::model::box<point_type> box_type;
+ point_type p(3, 3);
+ box_type b(point_type(0, 0), point_type(5, 5));
+
+ bool r = bg::within(p, b,
+ bg::strategy::within::point_in_box<point_type, box_type>());
+
+ r = bg::within(b, b,
+ bg::strategy::within::box_in_box<box_type, box_type>());
+
+ r = bg::within(p, b,
+ bg::strategy::within::point_in_box_by_side<point_type, box_type>());
 }
 
 
@@ -116,6 +225,10 @@
 
     test_spherical<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
 
+ test_mixed();
+ test_3d();
+ test_strategy();
+
 
 #if defined(HAVE_TTMATH)
     test_all<bg::model::d2::point_xy<ttmath_big> >();

Modified: branches/release/libs/geometry/test/geometry_test_common.hpp
==============================================================================
--- branches/release/libs/geometry/test/geometry_test_common.hpp (original)
+++ branches/release/libs/geometry/test/geometry_test_common.hpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -32,16 +32,28 @@
 #endif
 
 
-
 #include <boost/foreach.hpp>
 
 
 // Include some always-included-for-testing files
 #if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
-# include <boost/test/floating_point_comparison.hpp>
-# include <boost/test/included/test_exec_monitor.hpp>
+
+// Until Boost fixes it, silence warning issued by clang:
+// warning: unused variable 'check_is_close' [-Wunused-variable]
+#ifdef __clang__
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wunused-variable"
+#endif
+
+# include <boost/test/floating_point_comparison.hpp>
+# include <boost/test/included/test_exec_monitor.hpp>
 //# include <boost/test/included/prg_exec_monitor.hpp>
-# include <boost/test/impl/execution_monitor.ipp>
+# include <boost/test/impl/execution_monitor.ipp>
+
+#ifdef __clang__
+# pragma clang diagnostic pop
+#endif
+
 #endif
 
 
@@ -82,6 +94,11 @@
     { static std::string name() { return "t"; } };
 #endif
 
+#if defined(BOOST_RATIONAL_HPP)
+template <typename T> struct string_from_type<boost::rational<T> >
+{ static std::string name() { return "r"; } };
+#endif
+
 
 #if defined(HAVE_GMP)
     template <> struct string_from_type<boost::numeric_adaptor::gmp_value_type>
@@ -94,6 +111,24 @@
 #endif
 
 
+template <typename CoordinateType, typename T>
+inline T if_typed_tt(T value_tt, T value)
+{
+#if defined(HAVE_TTMATH)
+ return boost::is_same<CoordinateType, ttmath_big>::value ? value_tt : value;
+#else
+ return value;
+#endif
+}
+
+template <typename CoordinateType, typename Specified, typename T>
+inline T if_typed(T value_typed, T value)
+{
+ return boost::is_same<CoordinateType, Specified>::value ? value_typed : value;
+}
+
+
+
 
 struct geographic_policy
 {

Modified: branches/release/libs/geometry/test/multi/algorithms/Jamfile.v2
==============================================================================
--- branches/release/libs/geometry/test/multi/algorithms/Jamfile.v2 (original)
+++ branches/release/libs/geometry/test/multi/algorithms/Jamfile.v2 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -12,8 +12,10 @@
     :
     [ run multi_area.cpp ]
     [ run multi_centroid.cpp ]
+ [ run multi_convert.cpp ]
     [ run multi_convex_hull.cpp ]
     [ run multi_correct.cpp ]
+ [ run multi_covered_by.cpp ]
     [ run multi_difference.cpp ]
     [ run multi_envelope.cpp ]
     [ run multi_equals.cpp ]

Modified: branches/release/libs/geometry/test/multi/algorithms/multi_difference.cpp
==============================================================================
--- branches/release/libs/geometry/test/multi/algorithms/multi_difference.cpp (original)
+++ branches/release/libs/geometry/test/multi/algorithms/multi_difference.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -11,7 +11,7 @@
 #include <string>
 
 // #define BOOST_GEOMETRY_DEBUG_ASSEMBLE
-#define BOOST_GEOMETRY_CHECK_WITH_SQLSERVER
+//#define BOOST_GEOMETRY_CHECK_WITH_SQLSERVER
 
 #include <algorithms/test_difference.hpp>
 #include <algorithms/test_overlay.hpp>

Modified: branches/release/libs/geometry/test/multi/algorithms/multi_intersection.cpp
==============================================================================
--- branches/release/libs/geometry/test/multi/algorithms/multi_intersection.cpp (original)
+++ branches/release/libs/geometry/test/multi/algorithms/multi_intersection.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -138,6 +138,19 @@
         2, 4, 2 * std::sqrt(2.0));
 }
 
+template <typename P>
+void test_point_output()
+{
+ typedef bg::model::box<P> box;
+ typedef bg::model::linestring<P> linestring;
+ typedef bg::model::polygon<P> polygon;
+ typedef bg::model::multi_polygon<polygon> multi_polygon;
+
+ test_point_output<multi_polygon, multi_polygon>(case_multi_simplex[0], case_multi_simplex[1], 10);
+ test_point_output<linestring, multi_polygon>("linestring(4 0,0 4)", case_multi_simplex[0], 4);
+ test_point_output<box, multi_polygon>("box(3 0,4 6)", case_multi_simplex[0], 8);
+}
+
 
 template <typename P>
 void test_all()
@@ -174,6 +187,7 @@
     test_linear<linestring, multi_linestring, box>();
 #endif
 
+ test_point_output<P>();
     // linear
 
 }

Modified: branches/release/libs/geometry/test/multi/algorithms/multi_simplify.cpp
==============================================================================
--- branches/release/libs/geometry/test/multi/algorithms/multi_simplify.cpp (original)
+++ branches/release/libs/geometry/test/multi/algorithms/multi_simplify.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -44,6 +44,15 @@
     test_geometry<mp>(
         "MULTIPOLYGON(((4 0,8 2,8 7,4 9,0 7,0 2,2 1,4 0),(7 3,7 6,1 6,1 3,4 3,7 3)))",
         "MULTIPOLYGON(((4 0,8 2,8 7,4 9,0 7,0 2,4 0),(7 3,7 6,1 6,1 3,7 3)))", 1.0);
+
+ // Ticket 5954 https://svn.boost.org/trac/boost/ticket/5954
+ test_geometry<mp>(
+ "MULTIPOLYGON(((0.561648 1,1 1,1 0,0.468083 0,0.52758 0.00800554,0.599683 0.0280924,0.601611 0.265374,0.622693 0.316765,0.69507 0.357497,0.695623 0.429711,0.655111 0.502298,0.696467 0.543147,0.840712 0.593546,0.882583 0.66546,0.852357 0.748213,0.84264 0.789567,0.832667 0.841202,0.832667 0.841202,0.740538 0.873004,0.617349 0.905045,0.566576 0.977697,0.561648 1)),((0 0.801979,0.0308575 0.786234,0.0705513 0.631135,0.141616 0.527248,0.233985 0.505872,0.264777 0.526263,0.336631 0.505009,0.356603 0.422321,0.355803 0.350038,0.375252 0.205364,0.415206 0.0709182,0.45479 0,0 0,0 0,0 0.801979)))",
+ "MULTIPOLYGON(((0.561648 1,1 1,1 0,0.468083 0,0.52758 0.00800554,0.599683 0.0280924,0.601611 0.265374,0.622693 0.316765,0.69507 0.357497,0.695623 0.429711,0.655111 0.502298,0.696467 0.543147,0.840712 0.593546,0.882583 0.66546,0.852357 0.748213,0.84264 0.789567,0.832667 0.841202,0.740538 0.873004,0.617349 0.905045,0.566576 0.977697,0.561648 1)),((0 0.801979,0.0308575 0.786234,0.0705513 0.631135,0.141616 0.527248,0.233985 0.505872,0.264777 0.526263,0.336631 0.505009,0.356603 0.422321,0.355803 0.350038,0.375252 0.205364,0.415206 0.0709182,0.45479 0,0 0,0 0.801979)))", 1.0 / 2048.0);
+ test_geometry<mp>(
+ "MULTIPOLYGON(((1149.69 2047,2047 2047,2047 0,958.166 0,1079.96 16.3873,1227.55 57.5051,1231.5 543.221,1274.65 648.418,1422.81 731.796,1423.94 879.618,1341.01 1028.2,1425.67 1111.82,1720.94 1214.99,1806.65 1362.2,1744.77 1531.59,1724.88 1616.24,1704.47 1721.94,1704.47 1721.94,1515.88 1787.04,1263.71 1852.63,1159.78 2001.35,1149.69 2047)),((0 1641.65,63.1653 1609.42,144.419 1291.93,289.888 1079.28,478.967 1035.52,541.999 1077.26,689.084 1033.75,729.966 864.491,728.329 716.528,768.141 420.38,849.927 145.17,930.955 0,0 0,0 0,0 1641.65)))",
+ "MULTIPOLYGON(((1149.69 2047,2047 2047,2047 0,958.166 0,1079.96 16.3873,1227.55 57.5051,1231.5 543.221,1274.65 648.418,1422.81 731.796,1423.94 879.618,1341.01 1028.2,1425.67 1111.82,1720.94 1214.99,1806.65 1362.2,1744.77 1531.59,1724.88 1616.24,1704.47 1721.94,1515.88 1787.04,1263.71 1852.63,1159.78 2001.35,1149.69 2047)),((0 1641.65,63.1653 1609.42,144.419 1291.93,289.888 1079.28,478.967 1035.52,541.999 1077.26,689.084 1033.75,729.966 864.491,728.329 716.528,768.141 420.38,849.927 145.17,930.955 0,0 0,0 1641.65)))", 1.0);
+ // End ticket 5954
 }
 
 int test_main( int , char* [] )

Modified: branches/release/libs/geometry/test/multi/algorithms/multi_within.cpp
==============================================================================
--- branches/release/libs/geometry/test/multi/algorithms/multi_within.cpp (original)
+++ branches/release/libs/geometry/test/multi/algorithms/multi_within.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -29,16 +29,20 @@
 {
     typedef bg::model::multi_polygon<bg::model::polygon<P> > mp;
 
- // trivial cases
+ // test multi-with-one-polygon (trivial case)
     test_geometry<P, mp>("POINT(1 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", true);
     test_geometry<P, mp>("POINT(3 3)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
+ test_geometry<P, mp>("POINT(0 1)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
+ test_geometry<P, mp>("POINT(4 4)", "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)))", false);
 
     // test if it is in one of them
- test_geometry<P, mp>("POINT(4 4)", "MULTIPOLYGON("
+ std::string multi("MULTIPOLYGON("
         "((0 0,0 2,2 2,2 0,0 0))"
         "((3 3,3 6,6 6,6 3,3 3))"
- ")",
- true);
+ ")");
+ test_geometry<P, mp>("POINT(4 4)", multi, true);
+ test_geometry<P, mp>("POINT(1 1)", multi, true);
+ test_geometry<P, mp>("POINT(0 1)", multi, false);
 }
 
 int test_main( int , char* [] )

Modified: branches/release/libs/geometry/test/multi/multi_tests.sln
==============================================================================
--- branches/release/libs/geometry/test/multi/multi_tests.sln (original)
+++ branches/release/libs/geometry/test/multi/multi_tests.sln 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -42,6 +42,10 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_transform", "algorithms\multi_transform.vcproj", "{64985954-0A74-46F5-908F-865E905C3414}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_covered_by", "algorithms\multi_covered_by.vcproj", "{680E56F0-229C-4377-BDC0-80EB9B59314B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "multi_convert", "algorithms\multi_convert.vcproj", "{21B7EF55-23C3-4FD2-9F2F-FD8F0F3FE167}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -132,6 +136,14 @@
                 {64985954-0A74-46F5-908F-865E905C3414}.Debug|Win32.Build.0 = Debug|Win32
                 {64985954-0A74-46F5-908F-865E905C3414}.Release|Win32.ActiveCfg = Release|Win32
                 {64985954-0A74-46F5-908F-865E905C3414}.Release|Win32.Build.0 = Release|Win32
+ {680E56F0-229C-4377-BDC0-80EB9B59314B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {680E56F0-229C-4377-BDC0-80EB9B59314B}.Debug|Win32.Build.0 = Debug|Win32
+ {680E56F0-229C-4377-BDC0-80EB9B59314B}.Release|Win32.ActiveCfg = Release|Win32
+ {680E56F0-229C-4377-BDC0-80EB9B59314B}.Release|Win32.Build.0 = Release|Win32
+ {21B7EF55-23C3-4FD2-9F2F-FD8F0F3FE167}.Debug|Win32.ActiveCfg = Debug|Win32
+ {21B7EF55-23C3-4FD2-9F2F-FD8F0F3FE167}.Debug|Win32.Build.0 = Debug|Win32
+ {21B7EF55-23C3-4FD2-9F2F-FD8F0F3FE167}.Release|Win32.ActiveCfg = Release|Win32
+ {21B7EF55-23C3-4FD2-9F2F-FD8F0F3FE167}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE

Modified: branches/release/libs/geometry/test/strategies/within.cpp
==============================================================================
--- branches/release/libs/geometry/test/strategies/within.cpp (original)
+++ branches/release/libs/geometry/test/strategies/within.cpp 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -11,16 +11,21 @@
 
 #include <geometry_test_common.hpp>
 
+#include <boost/geometry/algorithms/covered_by.hpp>
 #include <boost/geometry/algorithms/within.hpp>
 
 #include <boost/geometry/strategies/cartesian/point_in_poly_franklin.hpp>
 #include <boost/geometry/strategies/cartesian/point_in_poly_crossings_multiply.hpp>
 #include <boost/geometry/strategies/agnostic/point_in_poly_winding.hpp>
+#include <boost/geometry/strategies/cartesian/point_in_box.hpp>
+#include <boost/geometry/strategies/cartesian/box_in_box.hpp>
+#include <boost/geometry/strategies/agnostic/point_in_box_by_side.hpp>
 
 #include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
 
 
 #include <boost/geometry/geometries/point.hpp>
+#include <boost/geometry/geometries/box.hpp>
 #include <boost/geometry/geometries/polygon.hpp>
 
 #include <boost/geometry/domains/gis/io/wkt/wkt.hpp>
@@ -36,7 +41,7 @@
             Strategy const& strategy, std::string const& strategy_id,
             bool expected)
 {
- BOOST_CONCEPT_ASSERT( (bg::concept::WithinStrategy<Strategy>) );
+ BOOST_CONCEPT_ASSERT( (bg::concept::WithinStrategyPolygonal<Strategy>) );
     bool detected = bg::within(point, polygon, strategy);
 
     BOOST_CHECK_MESSAGE(detected == expected,
@@ -68,11 +73,63 @@
         "cross.mult", boost::contains(deviations, "c") ? !expected : expected);
 }
 
+template <typename Point>
+void test_box_of(std::string const& wkt_point, std::string const& wkt_box,
+ bool expected_within, bool expected_covered_by)
+{
+ typedef bg::model::box<Point> box_type;
+
+ Point point;
+ box_type box;
+ bg::read_wkt(wkt_point, point);
+ bg::read_wkt(wkt_box, box);
+
+ bool detected_within = bg::within(point, box);
+ bool detected_covered_by = bg::covered_by(point, box);
+ BOOST_CHECK_EQUAL(detected_within, expected_within);
+ BOOST_CHECK_EQUAL(detected_covered_by, expected_covered_by);
+
+ // Also test with the non-default agnostic side version
+ namespace wi = bg::strategy::within;
+ wi::point_in_box_by_side<Point, box_type> within_strategy;
+ wi::point_in_box_by_side<Point, box_type, wi::decide_covered_by> covered_by_strategy;
+
+ detected_within = bg::within(point, box, within_strategy);
+ detected_covered_by = bg::covered_by(point, box, covered_by_strategy);
+ BOOST_CHECK_EQUAL(detected_within, expected_within);
+ BOOST_CHECK_EQUAL(detected_covered_by, expected_covered_by);
+
+ // We might exchange strategies between within/covered by.
+ // So the lines below might seem confusing, but are as intended
+ detected_within = bg::covered_by(point, box, within_strategy);
+ detected_covered_by = bg::within(point, box, covered_by_strategy);
+ BOOST_CHECK_EQUAL(detected_within, expected_within);
+ BOOST_CHECK_EQUAL(detected_covered_by, expected_covered_by);
+
+ // Finally we call the strategies directly
+ detected_within = within_strategy.apply(point, box);
+ detected_covered_by = covered_by_strategy.apply(point, box);
+ BOOST_CHECK_EQUAL(detected_within, expected_within);
+ BOOST_CHECK_EQUAL(detected_covered_by, expected_covered_by);
+}
+
+template <typename Point>
+void test_box()
+{
+ test_box_of<Point>("POINT(1 1)", "BOX(0 0,2 2)", true, true);
+ test_box_of<Point>("POINT(0 0)", "BOX(0 0,2 2)", false, true);
+ test_box_of<Point>("POINT(2 2)", "BOX(0 0,2 2)", false, true);
+ test_box_of<Point>("POINT(0 1)", "BOX(0 0,2 2)", false, true);
+ test_box_of<Point>("POINT(1 0)", "BOX(0 0,2 2)", false, true);
+ test_box_of<Point>("POINT(3 3)", "BOX(0 0,2 2)", false, false);
+}
 
 
 template <typename Point>
 void test_all()
 {
+ test_box<Point>();
+
     typedef bg::model::polygon<Point> polygon;
 
     std::string const box = "POLYGON((0 0,0 2,2 2,2 0,0 0))";

Modified: branches/release/libs/geometry/test/util/Jamfile.v2
==============================================================================
--- branches/release/libs/geometry/test/util/Jamfile.v2 (original)
+++ branches/release/libs/geometry/test/util/Jamfile.v2 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -11,6 +11,7 @@
 test-suite boost-geometry-util
     :
     [ run for_each_coordinate.cpp ]
+ [ run rational.cpp ]
     [ run select_most_precise.cpp ]
     [ run write_dsv.cpp ]
     ;

Modified: branches/release/libs/geometry/test/util/util_tests.sln
==============================================================================
--- branches/release/libs/geometry/test/util/util_tests.sln (original)
+++ branches/release/libs/geometry/test/util/util_tests.sln 2011-10-09 14:30:04 EDT (Sun, 09 Oct 2011)
@@ -8,6 +8,8 @@
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "as_range", "as_range.vcproj", "{A36D8426-67EB-405C-B6E8-3FBB3374A59B}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "rational", "rational.vcproj", "{6ABF6324-C1DC-4687-9895-B4CE2B27446F}"
+EndProject
 Global
         GlobalSection(SolutionConfigurationPlatforms) = preSolution
                 Debug|Win32 = Debug|Win32
@@ -30,6 +32,10 @@
                 {A36D8426-67EB-405C-B6E8-3FBB3374A59B}.Debug|Win32.Build.0 = Debug|Win32
                 {A36D8426-67EB-405C-B6E8-3FBB3374A59B}.Release|Win32.ActiveCfg = Release|Win32
                 {A36D8426-67EB-405C-B6E8-3FBB3374A59B}.Release|Win32.Build.0 = Release|Win32
+ {6ABF6324-C1DC-4687-9895-B4CE2B27446F}.Debug|Win32.ActiveCfg = Debug|Win32
+ {6ABF6324-C1DC-4687-9895-B4CE2B27446F}.Debug|Win32.Build.0 = Debug|Win32
+ {6ABF6324-C1DC-4687-9895-B4CE2B27446F}.Release|Win32.ActiveCfg = Release|Win32
+ {6ABF6324-C1DC-4687-9895-B4CE2B27446F}.Release|Win32.Build.0 = Release|Win32
         EndGlobalSection
         GlobalSection(SolutionProperties) = preSolution
                 HideSolutionNode = FALSE


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