Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59678 - in sandbox/geometry/boost/geometry: algorithms algorithms/detail algorithms/detail/overlay algorithms/overlay core extensions/gis/io/wkt multi multi/algorithms multi/algorithms/overlay multi/core strategies strategies/cartesian strategies/transform
From: barend.gehrels_at_[hidden]
Date: 2010-02-14 09:50:07


Author: barendgehrels
Date: 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
New Revision: 59678
URL: http://svn.boost.org/trac/boost/changeset/59678

Log:
Additions and some fixes
Added:
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/stream_info.hpp (contents, props changed)
   sandbox/geometry/boost/geometry/multi/algorithms/overlay/self_turn_points.hpp (contents, props changed)
   sandbox/geometry/boost/geometry/multi/algorithms/unique.hpp (contents, props changed)
   sandbox/geometry/boost/geometry/multi/core/interior_rings.hpp (contents, props changed)
Text files modified:
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp | 17 +++
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/traversal_info.hpp | 2
   sandbox/geometry/boost/geometry/algorithms/detail/overlay/turn_info.hpp | 3
   sandbox/geometry/boost/geometry/algorithms/detail/point_on_border.hpp | 4
   sandbox/geometry/boost/geometry/algorithms/detail/ring_identifier.hpp | 12 ++
   sandbox/geometry/boost/geometry/algorithms/distance.hpp | 132 ++++++++++++++++++++++++++++--
   sandbox/geometry/boost/geometry/algorithms/intersection.hpp | 56 ++++++++++++
   sandbox/geometry/boost/geometry/algorithms/overlay/enrich_intersection_points.hpp | 168 ++++++++++++++++++++++++++-------------
   sandbox/geometry/boost/geometry/algorithms/overlay/get_turns.hpp | 4
   sandbox/geometry/boost/geometry/algorithms/overlay/traverse.hpp | 2
   sandbox/geometry/boost/geometry/algorithms/sectionalize.hpp | 3
   sandbox/geometry/boost/geometry/core/interior_rings.hpp | 8 +
   sandbox/geometry/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp | 8 +
   sandbox/geometry/boost/geometry/multi/algorithms/overlay/copy_segments.hpp | 6 -
   sandbox/geometry/boost/geometry/multi/multi.hpp | 5 +
   sandbox/geometry/boost/geometry/strategies/cartesian/cart_intersect.hpp | 99 +++++++++++++----------
   sandbox/geometry/boost/geometry/strategies/cartesian/distance_projected_point.hpp | 3
   sandbox/geometry/boost/geometry/strategies/cartesian/side_by_triangle.hpp | 3
   sandbox/geometry/boost/geometry/strategies/distance_result.hpp | 2
   sandbox/geometry/boost/geometry/strategies/transform/map_transformer.hpp | 17 ++-
   sandbox/geometry/boost/geometry/strategies/transform/matrix_transformers.hpp | 8 +
   21 files changed, 415 insertions(+), 147 deletions(-)

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -191,13 +191,13 @@
         return side1 == side2 && ! opposite(side1, turn);
     }
 
- static inline void block_second(bool block, TurnInfo& ti)
+ /*static inline void block_second(bool block, TurnInfo& ti)
     {
         if (block)
         {
             ti.operations[1].operation = operation_blocked;
         }
- }
+ }*/
 
 
     template
@@ -269,7 +269,11 @@
                 if (between(side_pk_q1, side_pk_q2, side_qk_q))
                 {
                     ui_else_iu(q_turns_left, ti);
- block_second(block_q, ti);
+ if (block_q)
+ {
+ ti.operations[1].operation = operation_blocked;
+ }
+ //block_second(block_q, ti);
                     return;
                 }
 
@@ -286,7 +290,12 @@
                 if (side_pk_q1 == -side_qk_q)
                 {
                     uu_else_ii(! q_turns_left, ti);
- block_second(block_q, ti);
+ if (block_q)
+ {
+ ti.ignore = false;
+ ti.operations[1].operation = operation_blocked;
+ }
+ //block_second(block_q, ti);
                     return;
                 }
             }

Added: sandbox/geometry/boost/geometry/algorithms/detail/overlay/stream_info.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/stream_info.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -0,0 +1,71 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP
+
+#include <boost/array.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace overlay {
+
+
+
+ static inline std::string dir(int d)
+ {
+ return d == 0 ? "-" : (d == 1 ? "L" : d == -1 ? "R" : "#");
+ }
+ static inline std::string how_str(int h)
+ {
+ return h == 0 ? "-" : (h == 1 ? "A" : "D");
+ }
+
+ template <typename P>
+ std::ostream& operator<<(std::ostream &os, turn_info<P> const& info)
+ {
+ typename geometry::coordinate_type<P>::type d = info.distance;
+ os << "\t"
+ << " src " << info.seg_id.source_index
+ << " seg " << info.seg_id.segment_index
+ << " (// " << info.other_id.source_index
+ << "." << info.other_id.segment_index << ")"
+ << " how " << info.how
+ << "[" << how_str(info.arrival)
+ << " " << dir(info.direction)
+ << (info.opposite ? " o" : "")
+ << "]"
+ << " sd "
+ << dir(info.sides.get<0,0>())
+ << dir(info.sides.get<0,1>())
+ << dir(info.sides.get<1,0>())
+ << dir(info.sides.get<1,1>())
+ << " nxt seg " << info.travels_to_vertex_index
+ << " , ip " << info.travels_to_ip_index
+ << " , or " << info.next_ip_index
+ << " dst " << double(d)
+ << info.visit_state;
+ if (info.flagged)
+ {
+ os << " FLAGGED";
+ }
+ return os;
+ }
+
+
+
+}} // namespace detail::overlay
+#endif //DOXYGEN_NO_DETAIL
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_TURN_INFO_HPP

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/traversal_info.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/traversal_info.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/traversal_info.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -25,8 +25,6 @@
 template <typename P>
 struct traversal_turn_operation : public turn_operation
 {
- segment_identifier seg_id;
- segment_identifier other_id;
     enrichment_info<P> enriched;
     visit_info visited;
 };

Modified: sandbox/geometry/boost/geometry/algorithms/detail/overlay/turn_info.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/overlay/turn_info.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/overlay/turn_info.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -10,6 +10,7 @@
 
 #include <boost/array.hpp>
 
+#include <boost/geometry/algorithms/overlay/segment_identifier.hpp>
 
 namespace boost { namespace geometry
 {
@@ -52,6 +53,8 @@
 struct turn_operation
 {
     operation_type operation;
+ segment_identifier seg_id;
+ segment_identifier other_id;
 
     turn_operation()
         : operation(operation_none)

Modified: sandbox/geometry/boost/geometry/algorithms/detail/point_on_border.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/point_on_border.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/point_on_border.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -77,8 +77,8 @@
 
             iterator it = boost::begin(range);
             iterator prev = it++;
- while (detail::equals::equals_point_point(*it, *prev)
- && it != boost::end(range))
+ while (it != boost::end(range)
+ && detail::equals::equals_point_point(*it, *prev))
             {
                 prev = it++;
             }

Modified: sandbox/geometry/boost/geometry/algorithms/detail/ring_identifier.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/ring_identifier.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/ring_identifier.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -46,6 +46,18 @@
             ;
     }
 
+#if defined(BOOST_GEOMETRY_DEBUG_IDENTIFIER)
+ friend std::ostream& operator<<(std::ostream &os, ring_identifier const& seg_id)
+ {
+ os << "(s:" << seg_id.source_index;
+ if (seg_id.ring_index >= 0) os << ", r:" << seg_id.ring_index;
+ if (seg_id.multi_index >= 0) os << ", m:" << seg_id.multi_index;
+ os << ")";
+ return os;
+ }
+#endif
+
+
     int source_index;
     int multi_index;
     int ring_index;

Modified: sandbox/geometry/boost/geometry/algorithms/distance.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/distance.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/distance.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -23,6 +23,7 @@
 
 #include <boost/geometry/strategies/distance.hpp>
 #include <boost/geometry/strategies/distance_result.hpp>
+#include <boost/geometry/algorithms/within.hpp>
 
 /*!
 \defgroup distance distance: calculate distance between two geometries
@@ -93,28 +94,28 @@
 };
 
 
-template<typename P, typename L, typename PPStrategy, typename PSStrategy>
-struct point_to_linestring
+template<typename Point, typename Range, typename PPStrategy, typename PSStrategy>
+struct point_to_range
 {
     typedef typename PPStrategy::return_type return_type;
 
- static inline return_type apply(P const& point, L const& linestring,
+ static inline return_type apply(Point const& point, Range const& range,
             PPStrategy const& pp_strategy, PSStrategy const& ps_strategy)
     {
- typedef segment<const typename point_type<L>::type> segment_type;
+ typedef segment<const typename point_type<Range>::type> segment_type;
 
- if (boost::begin(linestring) == boost::end(linestring))
+ if (boost::size(range) == 0)
         {
             return return_type(0);
         }
 
         // line of one point: return point square_distance
- typedef typename boost::range_const_iterator<L>::type iterator_type;
- iterator_type it = boost::begin(linestring);
+ typedef typename boost::range_const_iterator<Range>::type iterator_type;
+ iterator_type it = boost::begin(range);
         iterator_type prev = it++;
- if (it == boost::end(linestring))
+ if (it == boost::end(range))
         {
- return pp_strategy.apply(point, *boost::begin(linestring));
+ return pp_strategy.apply(point, *boost::begin(range));
         }
 
 
@@ -123,7 +124,7 @@
 
         // check if other segments are closer
         prev = it++;
- while(it != boost::end(linestring))
+ while(it != boost::end(range))
         {
             return_type ds = ps_strategy.apply(point, *prev, *it);
             if (geometry::close_to_zero(ds))
@@ -142,6 +143,77 @@
 };
 
 
+template<typename Point, typename Ring, typename PPStrategy, typename PSStrategy>
+struct point_to_ring
+{
+ typedef std::pair<typename PPStrategy::return_type, bool> distance_containment;
+
+ static inline distance_containment apply(Point const& point,
+ Ring const& ring,
+ PPStrategy const& pp_strategy, PSStrategy const& ps_strategy)
+ {
+ return distance_containment
+ (
+ point_to_range
+ <
+ Point,
+ Ring,
+ PPStrategy,
+ PSStrategy
+ >::apply(point, ring, pp_strategy, ps_strategy),
+ geometry::within(point, ring)
+ );
+ }
+};
+
+
+
+template<typename Point, typename Polygon, typename PPStrategy, typename PSStrategy>
+struct point_to_polygon
+{
+ typedef typename PPStrategy::return_type return_type;
+ typedef std::pair<typename PPStrategy::return_type, bool> distance_containment;
+
+ static inline distance_containment apply(Point const& point,
+ Polygon const& polygon,
+ PPStrategy const& pp_strategy, PSStrategy const& ps_strategy)
+ {
+ // Check distance to all rings
+ typedef point_to_ring
+ <
+ Point,
+ typename ring_type<Polygon>::type,
+ PPStrategy,
+ PSStrategy
+ > per_ring;
+
+ distance_containment dc = per_ring::apply(point,
+ exterior_ring(polygon), pp_strategy, ps_strategy);
+
+ for (typename boost::range_const_iterator
+ <
+ typename interior_type<Polygon>::type
+ >::type it = boost::begin(interior_rings(polygon));
+ it != boost::end(interior_rings(polygon));
+ ++it)
+ {
+ distance_containment dcr = per_ring::apply(point,
+ *it, pp_strategy, ps_strategy);
+ if (dcr.first < dc.first)
+ {
+ dc.first = dcr.first;
+ }
+ // If it was inside, and also inside inner ring,
+ // turn off the inside-flag, it is outside the polygon
+ if (dc.second && dcr.second)
+ {
+ dc.second = false;
+ }
+ }
+ return dc;
+ }
+};
+
 
 }} // namespace detail::distance
 #endif // DOXYGEN_NO_DETAIL
@@ -196,7 +268,7 @@
                             typename point_type<Linestring>::type
>::type ps_strategy_type;
 
- return detail::distance::point_to_linestring
+ return detail::distance::point_to_range
             <
                 Point, Linestring, Strategy, ps_strategy_type
>::apply(point, linestring, strategy, ps_strategy_type());
@@ -219,13 +291,49 @@
             Strategy const& strategy)
     {
         typedef typename Strategy::point_strategy_type pp_strategy_type;
- return detail::distance::point_to_linestring
+ return detail::distance::point_to_range
             <
                 Point, Linestring, pp_strategy_type, Strategy
>::apply(point, linestring, pp_strategy_type(), strategy);
     }
 };
 
+/// Point-polygon , where point-segment strategy is specified
+template <typename Point, typename Polygon, typename Strategy>
+struct distance
+<
+ point_tag, polygon_tag,
+ Point, Polygon,
+ strategy_tag_distance_point_point, Strategy,
+ false, false
+>
+{
+ typedef typename Strategy::return_type return_type;
+
+ static inline return_type apply(Point const& point,
+ Polygon const& polygon,
+ Strategy const& strategy)
+ {
+ typedef typename geometry::strategy_distance_segment
+ <
+ typename cs_tag<Point>::type,
+ typename cs_tag<Polygon>::type,
+ Point,
+ typename point_type<Polygon>::type
+ >::type ps_strategy_type;
+
+ std::pair<return_type, bool>
+ dc = detail::distance::point_to_polygon
+ <
+ Point, Polygon, Strategy, ps_strategy_type
+ >::apply(point, polygon, strategy, ps_strategy_type());
+
+ return dc.second ? return_type(0) : dc.first;
+ }
+};
+
+
+
 // Point-segment version 1, with point-point strategy
 template <typename Point, typename Segment, typename Strategy>
 struct distance

Modified: sandbox/geometry/boost/geometry/algorithms/intersection.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/intersection.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/intersection.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -222,8 +222,8 @@
             OutputIterator out,
             Strategy const& strategy)
 {
- concept::check<const Geometry1>();
- concept::check<const Geometry2>();
+ concept::check<Geometry1 const>();
+ concept::check<Geometry2 const>();
 
     return boost::mpl::if_c
         <
@@ -278,8 +278,8 @@
             Geometry2 const& geometry2,
             OutputIterator out)
 {
- concept::check<const Geometry1>();
- concept::check<const Geometry2>();
+ concept::check<Geometry1 const>();
+ concept::check<Geometry2 const>();
 
     typedef typename geometry::point_type<GeometryOut>::type point_type;
     typedef detail::intersection::intersection_point<point_type> ip_type;
@@ -297,6 +297,54 @@
 }
 
 
+/*!
+ \brief Intersects two geometries
+ \ingroup intersection
+ \details The two input geometries are intersected and the resulting
+ linestring(s), ring(s) or polygon(s) are added
+ to the specified collection.
+ \tparam Geometry1 first geometry type
+ \tparam Geometry2 second geometry type
+ \tparam Collection collection of rings, polygons (e.g. a vector<polygon> or a multi_polygon)
+ \param geometry1 first geometry
+ \param geometry2 second geometry
+ \param output_collection the collection
+ \return true if successful
+*/
+template
+<
+ typename Geometry1,
+ typename Geometry2,
+ typename Collection
+>
+inline void intersection(Geometry1 const& geometry1,
+ Geometry2 const& geometry2,
+ Collection& output_collection)
+{
+ concept::check<Geometry1 const>();
+ concept::check<Geometry2 const>();
+
+ typedef typename boost::range_value<Collection>::type geometry_out;
+ concept::check<geometry_out>();
+
+ typedef typename geometry::point_type<geometry_out>::type point_type;
+ typedef detail::intersection::intersection_point<point_type> ip_type;
+
+ typedef strategy_intersection
+ <
+ typename cs_tag<point_type>::type,
+ Geometry1,
+ Geometry2,
+ ip_type
+ > strategy;
+
+
+ intersection_inserter<geometry_out>(geometry1, geometry2,
+ std::back_inserter(output_collection),
+ strategy());
+}
+
+
 }} // namespace boost::geometry
 
 

Modified: sandbox/geometry/boost/geometry/algorithms/overlay/enrich_intersection_points.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/overlay/enrich_intersection_points.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/overlay/enrich_intersection_points.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -14,9 +14,10 @@
 #include <map>
 #include <vector>
 
-#ifdef BOOST_GEOMETRY_DEBUG_OVERLAY
+//#ifdef BOOST_GEOMETRY_DEBUG_OVERLAY
 #include <iostream>
-#endif
+#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
+//#endif
 
 #include <boost/assert.hpp>
 #include <boost/range/functions.hpp>
@@ -170,14 +171,15 @@
     typename Geometry2,
     typename Strategy
>
-struct sort_on_operation
+struct sort_on_segment_and_distance
         : public sort_on_distance
             <
                 Indexed,
                 Geometry1, Geometry2, Strategy
>
 {
- sort_on_operation(Geometry1 const& geometry1, Geometry2 const& geometry2,
+ sort_on_segment_and_distance(Geometry1 const& geometry1,
+ Geometry2 const& geometry2,
                 Strategy const& strategy)
         : sort_on_distance
             <
@@ -198,6 +200,49 @@
 };
 
 
+template <typename Point, typename Operation, typename Geometry1, typename Geometry2>
+inline bool swap_operations(Operation const& left, Operation const& right,
+ Geometry1 const& geometry1, Geometry2 const& geometry2)
+{
+ Point pi, pj, ri, rj, si, sj;
+ if (left.seg_id == right.seg_id)
+ {
+ geometry::copy_segment_points(geometry1, geometry2,
+ left.seg_id,
+ pi, pj);
+ geometry::copy_segment_points(geometry1, geometry2,
+ left.other_id,
+ ri, rj);
+ geometry::copy_segment_points(geometry1, geometry2,
+ right.other_id,
+ si, sj);
+ std::cout << "Considering seg" << std::endl;
+ }
+ else if (left.other_id == right.other_id)
+ {
+ geometry::copy_segment_points(geometry1, geometry2,
+ left.other_id,
+ pi, pj);
+ geometry::copy_segment_points(geometry1, geometry2,
+ left.seg_id,
+ ri, rj);
+ geometry::copy_segment_points(geometry1, geometry2,
+ right.seg_id,
+ si, sj);
+ std::cout << "Considering other" << std::endl;
+ }
+ else
+ {
+ return false;
+ }
+
+ int const order = get_relative_order<Point>::apply(pi, pj,
+ ri, rj, si, sj);
+ std::cout << "Order: " << order << std::endl;
+ return order == 1;
+}
+
+
 // Sorts IP-s of this ring on segment-identifier, and if on same segment,
 // on distance.
 // Then assigns for each IP which is the next IP on this segment,
@@ -212,14 +257,14 @@
     typename Geometry2,
     typename Strategy
>
-static inline bool assign_order(Container& operation_container,
+static inline bool enrich(Container& operations,
             TurnPoints& turn_points,
             Geometry1 const& geometry1, Geometry2 const& geometry2,
             Strategy const& strategy)
 {
- std::sort(boost::begin(operation_container),
- boost::end(operation_container),
- sort_on_operation
+ std::sort(boost::begin(operations),
+ boost::end(operations),
+ sort_on_segment_and_distance
                     <
                         IndexType,
                         Geometry1, Geometry2,
@@ -227,48 +272,61 @@
>(geometry1, geometry2, strategy));
 
 
+ typedef typename IndexType::type operation_type;
+ typedef typename boost::range_iterator<Container const>::type iterator_type;
 
-#ifdef BOOST_GEOMETRY_DEBUG_OVERLAY
+//#ifdef BOOST_GEOMETRY_DEBUG_OVERLAY
+ /***
     // Check if it is really sorted.
- if (copy.size() > 1)
+ if (operations.size() > 1)
     {
- indexed_iterator_type it = boost::begin(copy);
- for (indexed_iterator_type prev = it++;
- it != boost::end(copy);
+ typedef typename boost::range_iterator<Container>::type nc_iterator;
+ nc_iterator it = boost::begin(operations);
+ for (nc_iterator prev = it++;
+ it != boost::end(operations);
             prev = it++)
         {
- if (geometry::math::equals(
- prev->operations_of_subject.front().enriched.distance,
- it->operations_of_subject.front().enriched.distance))
+ operation_type& prev_op = turn_points[prev->index]
+ .operations[prev->operation_index];
+ operation_type& op = turn_points[it->index]
+ .operations[it->operation_index];
+ if ((prev_op.seg_id == op.seg_id || prev_op.other_id == op.other_id)
+ && geometry::math::equals(prev_op.enriched.distance,
+ op.enriched.distance))
            {
- typedef typename turn_point_type::operation_type op;
- op const& first = prev->operations_of_subject.front();
- op const& second = it->operations_of_subject.front();
-
- std::cout << "Equal Distance on " << seg_id
- << " : " << first.seg_id << " / " << first.other_id
- << " and " << second.seg_id << " / " << second.other_id
+ std::cout << "Equal Distance on "
+ << " : " << prev_op.seg_id << " / " << prev_op.other_id
+ << " and " << op.seg_id << " / " << op.other_id
                     << std::endl;
                 std::cout << "\tType of intersections: "
- << prev->subject.method
- << " , " << it->subject.method
+ << operation_char(prev_op.operation)
+ << " , " << operation_char(op.operation)
                     << std::endl;
+
+ if (swap_operations
+ <
+ typename point_type<Geometry1>::type
+ >(prev_op, op, geometry1, geometry2))
+ {
+ std::cout << "Should be swapped" << std::endl;
+
+ std::swap(*prev, *it);
+ }
            }
         }
     }
-#endif
+ ***/
+//#endif
 
- typedef typename IndexType::type operation_type;
- typedef typename boost::range_iterator<Container const>::type iterator_type;
 
     // Assign travel-to-vertex/ip index for each turning point.
     // Because IP's are circular, PREV starts at the very last one,
     // being assigned from the first one.
     // For "next ip on same segment" it should not be considered circular.
     bool first = true;
- iterator_type it = boost::begin(operation_container);
- for (iterator_type prev = it + (boost::size(operation_container) - 1);
- it != boost::end(operation_container);
+ iterator_type it = boost::begin(operations);
+ for (iterator_type prev = it + (boost::size(operations) - 1);
+ it != boost::end(operations);
          prev = it++)
     {
         operation_type& prev_op = turn_points[prev->index]
@@ -288,12 +346,6 @@
         first = false;
     }
 
-#ifdef BOOST_GEOMETRY_DEBUG_OVERLAY
- std::cout << "Enrichment - ordered on segment (src: "
- << source_index << "): " << std::endl;
- report_tp(turn_points);
-#endif
-
     return true;
 }
 
@@ -340,36 +392,36 @@
          it != boost::end(turn_points);
          ++it, ++index)
     {
- int op_index = 0;
- for (typename boost::range_iterator<container_type const>::type
- op_it = boost::begin(it->operations);
- op_it != boost::end(it->operations);
- ++op_it, ++op_index)
+ if (! it->ignore)
         {
- ring_identifier ring_id
- (
- op_it->seg_id.source_index,
- op_it->seg_id.multi_index,
- op_it->seg_id.ring_index
- );
- mapped_vector[ring_id].push_back
- (
- indexed_type(index, op_index, *op_it)
- );
+ int op_index = 0;
+ for (typename boost::range_iterator<container_type const>::type
+ op_it = boost::begin(it->operations);
+ op_it != boost::end(it->operations);
+ ++op_it, ++op_index)
+ {
+ ring_identifier ring_id
+ (
+ op_it->seg_id.source_index,
+ op_it->seg_id.multi_index,
+ op_it->seg_id.ring_index
+ );
+ mapped_vector[ring_id].push_back
+ (
+ indexed_type(index, op_index, *op_it)
+ );
+ }
         }
     }
 
-#ifdef BOOST_GEOMETRY_DEBUG_OVERLAY
- detail::overlay::report_map(map);
-#endif
-
- // No const-operator because contents of mapped copy is changed)
+ // Note: no const-operator because contents of mapped copy is temporary,
+ // and changed by enrich)
     for (typename mapped_vector_type::iterator mit
         = mapped_vector.begin();
         mit != mapped_vector.end();
         ++mit)
     {
- detail::overlay::assign_order<indexed_type>(mit->second, turn_points,
+ detail::overlay::enrich<indexed_type>(mit->second, turn_points,
                     geometry1, geometry2, strategy);
     }
 }

Modified: sandbox/geometry/boost/geometry/algorithms/overlay/get_turns.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/overlay/get_turns.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/overlay/get_turns.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -43,8 +43,10 @@
 #include <boost/geometry/algorithms/detail/disjoint.hpp>
 #include <boost/geometry/algorithms/detail/overlay/get_turn_info.hpp>
 
-#include <boost/geometry/algorithms/detail/sections/get_full_section.hpp>
+#include <boost/geometry/algorithms/overlay/segment_identifier.hpp>
+
 
+#include <boost/geometry/algorithms/detail/sections/get_full_section.hpp>
 
 #include <boost/geometry/algorithms/combine.hpp>
 #include <boost/geometry/algorithms/distance.hpp>

Modified: sandbox/geometry/boost/geometry/algorithms/overlay/traverse.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/overlay/traverse.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/overlay/traverse.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -182,8 +182,6 @@
 }
 
 
-// This backtracking approach is necessary for invalid (== self-interescting)
-// geometries and the approach will be enhanced. TODO
 template
 <
     typename Rings,

Modified: sandbox/geometry/boost/geometry/algorithms/sectionalize.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/sectionalize.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/sectionalize.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -123,7 +123,8 @@
         coordinate_type const diff =
             geometry::get<1, Dimension>(seg) - geometry::get<0, Dimension>(seg);
 
- directions[Dimension] = diff > 0 ? 1 : (diff < 0 ? -1 : 0);
+ coordinate_type zero = coordinate_type();
+ directions[Dimension] = diff > zero ? 1 : diff < zero ? -1 : 0;
 
         get_direction_loop
             <

Modified: sandbox/geometry/boost/geometry/core/interior_rings.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/core/interior_rings.hpp (original)
+++ sandbox/geometry/boost/geometry/core/interior_rings.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -118,12 +118,16 @@
 
 template <typename Tag, typename Geometry>
 struct num_interior_rings
+{};
+
+
+template <typename Ring>
+struct num_interior_rings<ring_tag, Ring>
 {
- static inline std::size_t apply(Geometry const&)
+ static inline std::size_t apply(Ring const& ring)
     {
         return 0;
     }
-
 };
 
 

Modified: sandbox/geometry/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/gis/io/wkt/read_wkt.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -116,7 +116,13 @@
             // Note that it is much slower than atof. However, it is more standard
             // and in parsing the change in performance falls probably away against
             // the tokenizing
- set<Dimension>(point, (finished ? type() : boost::lexical_cast<type>(it->c_str())));
+ set<Dimension>(point, finished ? type()
+#if defined(BOOST_GEOMETRY_NO_LEXICAL_CAST)
+ : atof(it->c_str())
+#else
+ : boost::lexical_cast<type>(it->c_str())
+#endif
+ );
         }
         catch(boost::bad_lexical_cast const& blc)
         {

Modified: sandbox/geometry/boost/geometry/multi/algorithms/overlay/copy_segments.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/algorithms/overlay/copy_segments.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/algorithms/overlay/copy_segments.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -58,13 +58,10 @@
 #endif // DOXYGEN_NO_DETAIL
 
 
-
-
 #ifndef DOXYGEN_NO_DISPATCH
 namespace dispatch {
 
 
-
 template
 <
     typename MultiPolygon,
@@ -93,12 +90,11 @@
 {};
 
 
-
 } // namespace dispatch
 #endif // DOXYGEN_NO_DISPATCH
 
 
-
 }} // namespace boost::geometry
 
+
 #endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_OVERLAY_COPY_SEGMENTS_HPP

Added: sandbox/geometry/boost/geometry/multi/algorithms/overlay/self_turn_points.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/multi/algorithms/overlay/self_turn_points.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -0,0 +1,56 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_OVERLAY_SELF_TURN_POINTS_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_OVERLAY_SELF_TURN_POINTS_HPP
+
+
+#include <boost/geometry/multi/core/tags.hpp>
+#include <boost/geometry/algorithms/overlay/self_turn_points.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+ typename MultiPolygon,
+ typename IntersectionPoints,
+ typename IntersectionStrategy,
+ typename AssignPolicy
+>
+struct self_get_turn_points
+ <
+ multi_polygon_tag, true, MultiPolygon,
+ IntersectionPoints, IntersectionStrategy,
+ AssignPolicy
+ >
+ : detail::self_get_turn_points::get_turns
+ <
+ MultiPolygon,
+ IntersectionPoints,
+ IntersectionStrategy,
+ AssignPolicy
+ >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_OVERLAY_SELF_TURN_POINTS_HPP

Added: sandbox/geometry/boost/geometry/multi/algorithms/unique.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/multi/algorithms/unique.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -0,0 +1,97 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP
+#define BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP
+
+
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/algorithms/unique.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace unique
+{
+
+
+template <typename MultiGeometry, typename ComparePolicy, typename Policy>
+struct multi_unique
+{
+ static inline void apply(MultiGeometry& multi, ComparePolicy const& compare)
+ {
+ for (typename boost::range_iterator<MultiGeometry>::type
+ it = boost::begin(multi);
+ it != boost::end(multi);
+ ++it)
+ {
+ Policy::apply(*it, compare);
+ }
+ }
+};
+
+
+}} // namespace detail::unique
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+// For points, unique is not applicable and does nothing
+// (Note that it is not "spatially unique" but that it removes duplicate coordinates,
+// like std::unique does). Spatially unique is "dissolve" which can (or will be)
+// possible for multi-points as well, removing points at the same location.
+
+
+template <typename MultiLineString, typename ComparePolicy>
+struct unique<multi_linestring_tag, MultiLineString, ComparePolicy>
+ : detail::unique::multi_unique
+ <
+ MultiLineString,
+ ComparePolicy,
+ detail::unique::range_unique
+ <
+ typename boost::range_value<MultiLineString>::type,
+ ComparePolicy
+ >
+ >
+{};
+
+
+template <typename MultiPolygon, typename ComparePolicy>
+struct unique<multi_polygon_tag, MultiPolygon, ComparePolicy>
+ : detail::unique::multi_unique
+ <
+ MultiPolygon,
+ ComparePolicy,
+ detail::unique::polygon_unique
+ <
+ typename boost::range_value<MultiPolygon>::type,
+ ComparePolicy
+ >
+ >
+{};
+
+
+} // namespace dispatch
+#endif
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP

Added: sandbox/geometry/boost/geometry/multi/core/interior_rings.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/multi/core/interior_rings.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -0,0 +1,70 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+//
+// Copyright Barend Gehrels 2010, Geodan, Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_MULTI_CORE_INTERIOR_RINGS_HPP
+#define BOOST_GEOMETRY_MULTI_CORE_INTERIOR_RINGS_HPP
+
+
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
+
+#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/multi/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+
+template <typename MultiPolygon>
+struct interior_type<multi_polygon_tag, MultiPolygon>
+{
+ typedef typename core_dispatch::interior_type
+ <
+ polygon_tag,
+ typename boost::range_value<MultiPolygon>::type
+ >::type type;
+};
+
+
+
+template <typename MultiPolygon>
+struct num_interior_rings<multi_polygon_tag, MultiPolygon>
+{
+ static inline std::size_t apply(MultiPolygon const& multi_polygon)
+ {
+ std::size_t n = 0;
+ for (typename boost::range_iterator<MultiPolygon const>::type
+ it = boost::begin(multi_polygon);
+ it != boost::end(multi_polygon);
+ ++it)
+ {
+ n += geometry::num_interior_rings(*it);
+ }
+ return n;
+ }
+
+};
+
+
+} // namespace core_dispatch
+#endif
+
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_MULTI_CORE_INTERIOR_RINGS_HPP

Modified: sandbox/geometry/boost/geometry/multi/multi.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/multi.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/multi.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -13,6 +13,7 @@
 
 #include <boost/geometry/multi/core/geometry_id.hpp>
 #include <boost/geometry/multi/core/is_multi.hpp>
+#include <boost/geometry/multi/core/interior_rings.hpp>
 #include <boost/geometry/multi/core/point_type.hpp>
 #include <boost/geometry/multi/core/ring_type.hpp>
 #include <boost/geometry/multi/core/tags.hpp>
@@ -23,6 +24,7 @@
 #include <boost/geometry/multi/algorithms/centroid.hpp>
 #include <boost/geometry/multi/algorithms/convex_hull.hpp>
 #include <boost/geometry/multi/algorithms/correct.hpp>
+#include <boost/geometry/multi/algorithms/dissolve.hpp>
 #include <boost/geometry/multi/algorithms/distance.hpp>
 #include <boost/geometry/multi/algorithms/envelope.hpp>
 #include <boost/geometry/multi/algorithms/equals.hpp>
@@ -36,10 +38,13 @@
 #include <boost/geometry/multi/algorithms/simplify.hpp>
 #include <boost/geometry/multi/algorithms/transform.hpp>
 #include <boost/geometry/multi/algorithms/union.hpp>
+#include <boost/geometry/multi/algorithms/unique.hpp>
 #include <boost/geometry/multi/algorithms/within.hpp>
+
 #include <boost/geometry/multi/algorithms/detail/modify_with_predicate.hpp>
 #include <boost/geometry/multi/algorithms/detail/multi_sum.hpp>
 #include <boost/geometry/multi/algorithms/overlay/copy_segments.hpp>
+#include <boost/geometry/multi/algorithms/overlay/self_turn_points.hpp>
 #include <boost/geometry/multi/algorithms/overlay/get_intersection_points.hpp>
 
 

Modified: sandbox/geometry/boost/geometry/strategies/cartesian/cart_intersect.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/cartesian/cart_intersect.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/cartesian/cart_intersect.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -305,29 +305,29 @@
         // a_1-----a_2/b_1-------b_2 or reverse (B left of A)
         if (has_common_points && (math::equals(a_2, b_1) || math::equals(b_2, a_1)))
         {
- if (a2_eq_b1) return Policy::collinear_touch(get<1, 0>(a), get<1, 1>(a), 0, -1);
- if (a1_eq_b2) return Policy::collinear_touch(get<0, 0>(a), get<0, 1>(a), -1, 0);
- if (a2_eq_b2) return Policy::collinear_touch(get<1, 0>(a), get<1, 1>(a), 0, 0);
- if (a1_eq_b1) return Policy::collinear_touch(get<0, 0>(a), get<0, 1>(a), -1, -1);
+ if (a2_eq_b1) return Policy::collinear_touch(get<1, 0>(a), get<1, 1>(a), 0, -1);
+ if (a1_eq_b2) return Policy::collinear_touch(get<0, 0>(a), get<0, 1>(a), -1, 0);
+ if (a2_eq_b2) return Policy::collinear_touch(get<1, 0>(a), get<1, 1>(a), 0, 0);
+ if (a1_eq_b1) return Policy::collinear_touch(get<0, 0>(a), get<0, 1>(a), -1, -1);
         }
 
 
         // "Touch/within" -> there are common points and also an intersection of interiors:
         // Corresponds to many cases:
- // #1a: a1------->a2 #1b: a1-->a2
- // b1--->b2 b1------->b2
- // #2a: a2<-------a1 #2b: a2<--a1
- // b1--->b2 b1------->b2
+ // #1a: a1------->a2 #1b: a1-->a2
+ // b1--->b2 b1------->b2
+ // #2a: a2<-------a1 #2b: a2<--a1
+ // b1--->b2 b1------->b2
         // #3a: a1------->a2 #3b: a1-->a2
- // b2<---b1 b2<-------b1
- // #4a: a2<-------a1 #4b: a2<--a1
- // b2<---b1 b2<-------b1
+ // b2<---b1 b2<-------b1
+ // #4a: a2<-------a1 #4b: a2<--a1
+ // b2<---b1 b2<-------b1
 
         // Note: next cases are similar and handled by the code
         // #4c: a1--->a2
- // b1-------->b2
+ // b1-------->b2
         // #4d: a1-------->a2
- // b1-->b2
+ // b1-->b2
 
         // For case 1-4: a_1 < (b_1 or b_2) < a_2, two intersections are equal to segment B
         // For case 5-8: b_1 < (a_1 or a_2) < b_2, two intersections are equal to segment A
@@ -365,54 +365,65 @@
 
 
         /*
+
         Now that all cases with equal,touch,inside,disjoint,
         degenerate are handled the only thing left is an overlap
 
+ Either a1 is between b1,b2
+ or a2 is between b1,b2 (a2 arrives)
+
         Next table gives an overview.
         The IP's are ordered following the line A1->A2
 
- # Layout swapped arrival info IP info
- #1: a1--------->a2 a arrives in b (b1,a2)
- b1----->b2 -
- #2: a2<---------a1 a - (a1,b1)
- b1----->b2 -
- #3: a1--------->a2 a arrives in b (b2,a2)
- b2<-----b1 b b arrives in a
- #4: a2<---------a1 a - (a1,b2)
- b2<-----b1 b b arrives in a
-
- #5: a1--------->a2 - (a1,b2)
- b1----->b2 b arrives in a
- #6: a2<---------a1 a a arrives in b (b2,a2)
- b1----->b2 b arrives in a
- #7: a1--------->a2 - (a1,b1)
- b2<-----b1 b -
- #8: a2<---------a1 a a arrives in b (b1,a2)
- b2<-----b1 b -
+ | |
+ | a_2 in between | a_1 in between
+ | |
+ -----+---------------------------------+--------------------------
+ | a1--------->a2 | a1--------->a2
+ | b1----->b2 | b1----->b2
+ | (b1,a2), a arrives | (a1,b2), b arrives
+ | |
+ -----+---------------------------------+--------------------------
+ a sw.| a2<---------a1* | a2<---------a1*
+ | b1----->b2 | b1----->b2
+ | (a1,b1), no arrival | (b2,a2), a and b arrive
+ | |
+ -----+---------------------------------+--------------------------
+ | a1--------->a2 | a1--------->a2
+ b sw.| b2<-----b1 | b2<-----b1
+ | (b2,a2), a and b arrive | (a1,b1), no arrival
+ | |
+ -----+---------------------------------+--------------------------
+ a sw.| a2<---------a1* | a2<---------a1*
+ b sw.| b2<-----b1 | b2<-----b1
+ | (a1,b2), b arrives | (b1,a2), a arrives
+ | |
+ -----+---------------------------------+--------------------------
+ * Note that a_1 < a_2, and a1 <> a_1; if a is swapped,
+ the picture might seem wrong but it (supposed to be) is right.
         */
 
- bool no_swap = !a_swapped && !b_swapped;
- if (a_1 < b_1 && b_1 < a_2)
+ bool const both_swapped = a_swapped && b_swapped;
+ if (b_1 < a_2 && a_2 < b_2)
         {
- // # 1,2,3,4
+ // Left column, from bottom to top
             return
- no_swap ? Policy::collinear_overlaps(get<0, 0>(b), get<0, 1>(b), get<1, 0>(a), get<1, 1>(a), 1, -1, opposite)
- : a_swapped ? Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<0, 0>(b), get<0, 1>(b), -1, -1, opposite)
- : b_swapped ? Policy::collinear_overlaps(get<1, 0>(b), get<1, 1>(b), get<1, 0>(a), get<1, 1>(a), 1, 1, opposite)
- : Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<1, 0>(b), get<1, 1>(b), -1, 1, opposite)
+ both_swapped ? Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<1, 0>(b), get<1, 1>(b), -1, 1, opposite)
+ : b_swapped ? Policy::collinear_overlaps(get<1, 0>(b), get<1, 1>(b), get<1, 0>(a), get<1, 1>(a), 1, 1, opposite)
+ : a_swapped ? Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<0, 0>(b), get<0, 1>(b), -1, -1, opposite)
+ : Policy::collinear_overlaps(get<0, 0>(b), get<0, 1>(b), get<1, 0>(a), get<1, 1>(a), 1, -1, opposite)
                 ;
         }
         if (b_1 < a_1 && a_1 < b_2)
         {
- // # 5, 6, 7, 8
+ // Right column, from bottom to top
             return
- no_swap ? Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<1, 0>(b), get<1, 1>(b), -1, 1, opposite)
- : a_swapped ? Policy::collinear_overlaps(get<1, 0>(b), get<1, 1>(b), get<1, 0>(a), get<1, 1>(a), 1, 1, opposite)
- : b_swapped ? Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<0, 0>(b), get<0, 1>(b), -1, -1, opposite)
- : Policy::collinear_overlaps(get<0, 0>(b), get<0, 1>(b), get<1, 0>(a), get<1, 1>(a), 1, -1, opposite)
+ both_swapped ? Policy::collinear_overlaps(get<0, 0>(b), get<0, 1>(b), get<1, 0>(a), get<1, 1>(a), 1, -1, opposite)
+ : b_swapped ? Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<0, 0>(b), get<0, 1>(b), -1, -1, opposite)
+ : a_swapped ? Policy::collinear_overlaps(get<1, 0>(b), get<1, 1>(b), get<1, 0>(a), get<1, 1>(a), 1, 1, opposite)
+ : Policy::collinear_overlaps(get<0, 0>(a), get<0, 1>(a), get<1, 0>(b), get<1, 1>(b), -1, 1, opposite)
                 ;
         }
-
         // Nothing should goes through. If any we have made an error
         // Robustness: it can occur here...
         return Policy::error("Robustness issue, non-logical behaviour");

Modified: sandbox/geometry/boost/geometry/strategies/cartesian/distance_projected_point.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/cartesian/distance_projected_point.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/cartesian/distance_projected_point.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -99,8 +99,9 @@
 
         Strategy strategy;
 
+ coordinate_type zero = coordinate_type();
         coordinate_type c1 = dot_product(w, v);
- if (c1 <= 0)
+ if (c1 <= zero)
         {
             return strategy.apply(p, p1);
         }

Modified: sandbox/geometry/boost/geometry/strategies/cartesian/side_by_triangle.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/cartesian/side_by_triangle.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/cartesian/side_by_triangle.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -80,7 +80,8 @@
 
                 promoted_type const s = dx * dpy - dy * dpx;
 
- return math::equals(s, 0) ? 0 : s > 0 ? 1 : -1;
+ promoted_type zero = promoted_type();
+ return math::equals(s, zero) ? 0 : s > zero ? 1 : -1;
                 //return s > 0 ? 1 : s < 0 ? -1 : 0;
             }
         };

Modified: sandbox/geometry/boost/geometry/strategies/distance_result.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/distance_result.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/distance_result.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -139,7 +139,7 @@
 #if defined(NUMERIC_ADAPTOR_INCLUDED)
                 boost::sqrt(sq);
 #else
- std::sqrt(sq);
+ sqrt(sq);
 #endif
             return os;
         }

Modified: sandbox/geometry/boost/geometry/strategies/transform/map_transformer.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/transform/map_transformer.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/transform/map_transformer.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -99,8 +99,10 @@
 
             // Calculate appropriate scale, take min because whole box must fit
             // Scale is in PIXELS/MAPUNITS (meters)
- type sx = type(px2 - px1) / type(wx2 - wx1);
- type sy = type(py2 - py1) / type(wy2 - wy1);
+ W wdx = wx2 - wx1;
+ W wdy = wy2 - wy1;
+ type sx = (px2 - px1) / boost::numeric_cast<type>(wdx);
+ type sy = (py2 - py1) / boost::numeric_cast<type>(wdy);
 
             if (SameScale)
             {
@@ -110,10 +112,13 @@
             }
 
             // Calculate centerpoints
- type wmx = type(wx1 + wx2) / 2.0;
- type wmy = type(wy1 + wy2) / 2.0;
- type pmx = type(px1 + px2) / 2.0;
- type pmy = type(py1 + py2) / 2.0;
+ W wtx = wx1 + wx2;
+ W wty = wy1 + wy2;
+ W two = 2;
+ W wmx = wtx / two;
+ W wmy = wty / two;
+ type pmx = (px1 + px2) / 2.0;
+ type pmy = (py1 + py2) / 2.0;
 
             set_transformation_point(wmx, wmy, pmx, pmy, sx, sy);
 

Modified: sandbox/geometry/boost/geometry/strategies/transform/matrix_transformers.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/strategies/transform/matrix_transformers.hpp (original)
+++ sandbox/geometry/boost/geometry/strategies/transform/matrix_transformers.hpp 2010-02-14 09:50:03 EST (Sun, 14 Feb 2010)
@@ -90,10 +90,18 @@
 
         typedef typename geometry::coordinate_type<P2>::type ct2;
 
+ /*
         set<0>(p2, boost::numeric_cast<ct2>(
             c1 * m_matrix(0,0) + c2 * m_matrix(0,1) + m_matrix(0,2)));
         set<1>(p2, boost::numeric_cast<ct2>(
             c1 * m_matrix(1,0) + c2 * m_matrix(1,1) + m_matrix(1,2)));
+ */
+
+ coordinate_type p2x = c1 * m_matrix(0,0) + c2 * m_matrix(0,1) + m_matrix(0,2);
+ coordinate_type p2y = c1 * m_matrix(1,0) + c2 * m_matrix(1,1) + m_matrix(1,2);
+
+ set<0>(p2, p2x);
+ set<1>(p2, p2y);
 
         return true;
     }


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