Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69314 - in trunk/boost/geometry: . algorithms
From: barend.gehrels_at_[hidden]
Date: 2011-02-26 17:33:15


Author: barendgehrels
Date: 2011-02-26 17:33:13 EST (Sat, 26 Feb 2011)
New Revision: 69314
URL: http://svn.boost.org/trac/boost/changeset/69314

Log:
Added _inserter versions for (symmetric)difference
Replaced double by coordinate type in correct
Added multi in generic geometry include file
Text files modified:
   trunk/boost/geometry/algorithms/correct.hpp | 6 +
   trunk/boost/geometry/algorithms/difference.hpp | 100 ++++++++++++++++++++++++++++++++++----
   trunk/boost/geometry/algorithms/envelope.hpp | 11 ++++
   trunk/boost/geometry/algorithms/intersection.hpp | 2
   trunk/boost/geometry/algorithms/intersection_inserter.hpp | 7 +-
   trunk/boost/geometry/algorithms/sym_difference.hpp | 102 +++++++++++++++++++++++++++++++++------
   trunk/boost/geometry/algorithms/union.hpp | 53 ++++++++++---------
   trunk/boost/geometry/geometry.hpp | 5 +
   8 files changed, 227 insertions(+), 59 deletions(-)

Modified: trunk/boost/geometry/algorithms/correct.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/correct.hpp (original)
+++ trunk/boost/geometry/algorithms/correct.hpp 2011-02-26 17:33:13 EST (Sat, 26 Feb 2011)
@@ -219,7 +219,11 @@
 
 template <typename Ring>
 struct correct<ring_tag, Ring>
- : detail::correct::correct_ring<Ring, std::less<double> >
+ : detail::correct::correct_ring
+ <
+ Ring,
+ std::less<typename coordinate_type<Ring>::type>
+ >
 {};
 
 template <typename Polygon>

Modified: trunk/boost/geometry/algorithms/difference.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/difference.hpp (original)
+++ trunk/boost/geometry/algorithms/difference.hpp 2011-02-26 17:33:13 EST (Sat, 26 Feb 2011)
@@ -17,8 +17,91 @@
 
 
 /*!
+\brief_calc2{difference} \brief_strategy
+\ingroup difference
+\details \details_calc2{difference_inserter, spatial set theoretic difference}
+ \brief_strategy. details_inserter{difference}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam OutputIterator output iterator
+\tparam Strategy \tparam_strategy_overlay
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{difference}
+\param strategy \param_strategy{difference}
+\return \return_out
+
+\qbk{distinguish,with strategy}
+*/
+template
+<
+ typename GeometryOut,
+ typename Geometry1,
+ typename Geometry2,
+ typename OutputIterator,
+ typename Strategy
+>
+inline OutputIterator difference_inserter(Geometry1 const& geometry1,
+ Geometry2 const& geometry2, OutputIterator out,
+ Strategy const& strategy)
+{
+ concept::check<Geometry1 const>();
+ concept::check<Geometry2 const>();
+ concept::check<GeometryOut>();
+
+ return detail::intersection::inserter<GeometryOut, false, true, false, overlay_difference>(
+ geometry1, geometry2,
+ out,
+ strategy);
+}
+
+/*!
+\brief_calc2{difference}
+\ingroup difference
+\details \details_calc2{difference_inserter, spatial set theoretic difference}.
+ details_inserter{difference}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam OutputIterator output iterator
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{difference}
+\return \return_out
+
+*/
+template
+<
+ typename GeometryOut,
+ typename Geometry1,
+ typename Geometry2,
+ typename OutputIterator
+>
+inline OutputIterator difference_inserter(Geometry1 const& geometry1,
+ Geometry2 const& geometry2, OutputIterator out)
+{
+ concept::check<Geometry1 const>();
+ concept::check<Geometry2 const>();
+ concept::check<GeometryOut>();
+
+ typedef strategy_intersection
+ <
+ typename cs_tag<GeometryOut>::type,
+ Geometry1,
+ Geometry2,
+ typename geometry::point_type<GeometryOut>::type
+ > strategy;
+
+ return difference_inserter<GeometryOut>(geometry1, geometry2,
+ out, strategy());
+}
+
+
+/*!
 \brief_calc2{difference}
 \ingroup difference
+\details \details_calc2{difference, spatial set theoretic difference}.
 \tparam Geometry1 \tparam_geometry
 \tparam Geometry2 \tparam_geometry
 \tparam Collection output collection, either a multi-geometry,
@@ -44,21 +127,14 @@
     typedef typename boost::range_value<Collection>::type geometry_out;
     concept::check<geometry_out>();
 
- typedef strategy_intersection
- <
- typename cs_tag<geometry_out>::type,
- Geometry1,
- Geometry2,
- typename geometry::point_type<geometry_out>::type
- > strategy;
-
- detail::intersection::inserter<geometry_out, false, true, false, overlay_difference>(
- geometry1, geometry2,
- std::back_inserter(output_collection),
- strategy());
+ difference_inserter<geometry_out>(
+ geometry1, geometry2,
+ std::back_inserter(output_collection));
 }
 
 
+
+
 }} // namespace boost::geometry
 
 

Modified: trunk/boost/geometry/algorithms/envelope.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/envelope.hpp (original)
+++ trunk/boost/geometry/algorithms/envelope.hpp 2011-02-26 17:33:13 EST (Sat, 26 Feb 2011)
@@ -217,6 +217,12 @@
 \skip example_envelope_polygon
 \line {
 \until }
+
+
+\qbk{
+[heading Example]
+[envelope] [envelope_output]
+}
 */
 template<typename Geometry, typename Box>
 inline void envelope(Geometry const& geometry, Box& mbr)
@@ -241,6 +247,11 @@
 \tparam Geometry \tparam_geometry
 \param geometry \param_geometry
 \return \return_calc{envelope}
+
+\qbk{
+[heading Example]
+[make_envelope] [make_envelope_output]
+}
 */
 template<typename Box, typename Geometry>
 inline Box make_envelope(Geometry const& geometry)

Modified: trunk/boost/geometry/algorithms/intersection.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/intersection.hpp (original)
+++ trunk/boost/geometry/algorithms/intersection.hpp 2011-02-26 17:33:13 EST (Sat, 26 Feb 2011)
@@ -210,7 +210,7 @@
> strategy;
 
 
- return boost::mpl::if_c
+ return boost::mpl::if_c
         <
             geometry::reverse_dispatch<Geometry1, Geometry2>::type::value,
             dispatch::intersection_reversed

Modified: trunk/boost/geometry/algorithms/intersection_inserter.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/intersection_inserter.hpp (original)
+++ trunk/boost/geometry/algorithms/intersection_inserter.hpp 2011-02-26 17:33:13 EST (Sat, 26 Feb 2011)
@@ -401,11 +401,11 @@
 \tparam Geometry1 \tparam_geometry
 \tparam Geometry2 \tparam_geometry
 \tparam OutputIterator \tparam_out{\p_l_or_c}
-\tparam Strategy Compound strategy for intersection
+\tparam Strategy \tparam_strategy_overlay
 \param geometry1 \param_geometry
 \param geometry2 \param_geometry
 \param out \param_out{intersection}
-\param strategy The strategy
+\param strategy \param_strategy{intersection}
 \return \return_out
 
 \qbk{distinguish,with strategy}
@@ -435,7 +435,8 @@
 /*!
 \brief \brief_calc2{intersection}
 \ingroup intersection
-\details \details_calc2{intersection_inserter, spatial set theoretic intersection}. \details_inserter{intersection}
+\details \details_calc2{intersection_inserter, spatial set theoretic intersection}.
+ \details_inserter{intersection}
 \tparam GeometryOut \tparam_geometry{\p_l_or_c}
 \tparam Geometry1 \tparam_geometry
 \tparam Geometry2 \tparam_geometry

Modified: trunk/boost/geometry/algorithms/sym_difference.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/sym_difference.hpp (original)
+++ trunk/boost/geometry/algorithms/sym_difference.hpp 2011-02-26 17:33:13 EST (Sat, 26 Feb 2011)
@@ -19,8 +19,90 @@
 
 
 /*!
+\brief \brief_calc2{symmetric difference} \brief_strategy
+\ingroup sym_difference
+\details \details_calc2{symmetric difference, spatial set theoretic symmetric difference (XOR)}
+ \brief_strategy. details_inserter{sym_difference}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam Strategy \tparam_strategy_overlay
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{difference}
+\param strategy \param_strategy{difference}
+\return \return_out
+
+\qbk{distinguish,with strategy}
+*/
+template
+<
+ typename GeometryOut,
+ typename Geometry1,
+ typename Geometry2,
+ typename OutputIterator,
+ typename Strategy
+>
+inline OutputIterator sym_difference_inserter(Geometry1 const& geometry1,
+ Geometry2 const& geometry2, OutputIterator out,
+ Strategy const& strategy)
+{
+ concept::check<Geometry1 const>();
+ concept::check<Geometry2 const>();
+ concept::check<GeometryOut>();
+
+ out = detail::intersection::inserter<GeometryOut, false, true, false, overlay_difference>(
+ geometry1, geometry2, out, strategy);
+ out = detail::intersection::inserter<GeometryOut, false, true, false, overlay_difference>(
+ geometry2, geometry1, out, strategy);
+ return out;
+}
+
+
+/*!
+\brief \brief_calc2{symmetric difference}
+\ingroup sym_difference
+\details \details_calc2{symmetric difference, spatial set theoretic symmetric difference (XOR)}
+ \details_inserter{sym_difference}
+\tparam GeometryOut output geometry type, must be specified
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param out \param_out{difference}
+\return \return_out
+
+*/
+template
+<
+ typename GeometryOut,
+ typename Geometry1,
+ typename Geometry2,
+ typename OutputIterator
+>
+inline OutputIterator sym_difference_inserter(Geometry1 const& geometry1,
+ Geometry2 const& geometry2, OutputIterator out)
+{
+ concept::check<Geometry1 const>();
+ concept::check<Geometry2 const>();
+ concept::check<GeometryOut>();
+
+ typedef strategy_intersection
+ <
+ typename cs_tag<GeometryOut>::type,
+ Geometry1,
+ Geometry2,
+ typename geometry::point_type<GeometryOut>::type
+ > strategy_type;
+
+ return sym_difference_inserter<GeometryOut>(geometry1, geometry2, out, strategy_type());
+}
+
+
+/*!
 \brief \brief_calc2{symmetric difference}
 \ingroup sym_difference
+\details \details_calc2{symmetric difference, spatial set theoretic symmetric difference (XOR)}.
 \tparam Geometry1 \tparam_geometry
 \tparam Geometry2 \tparam_geometry
 \tparam Collection output collection, either a multi-geometry,
@@ -46,23 +128,9 @@
     typedef typename boost::range_value<Collection>::type geometry_out;
     concept::check<geometry_out>();
 
- typedef strategy_intersection
- <
- typename cs_tag<geometry_out>::type,
- Geometry1,
- Geometry2,
- typename geometry::point_type<geometry_out>::type
- > strategy;
-
-
- detail::intersection::inserter<geometry_out, false, true, false, overlay_difference>(
- geometry1, geometry2,
- std::back_inserter(output_collection),
- strategy());
- detail::intersection::inserter<geometry_out, false, true, false, overlay_difference>(
- geometry2, geometry1,
- std::back_inserter(output_collection),
- strategy());
+ sym_difference_inserter<geometry_out>(
+ geometry1, geometry2,
+ std::back_inserter(output_collection));
 }
 
 

Modified: trunk/boost/geometry/algorithms/union.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/union.hpp (original)
+++ trunk/boost/geometry/algorithms/union.hpp 2011-02-26 17:33:13 EST (Sat, 26 Feb 2011)
@@ -33,7 +33,7 @@
     // tag dispatching:
     typename TagIn1, typename TagIn2, typename TagOut,
     // metafunction finetuning helpers:
- bool Areal1, bool Areal2, bool ArealOut,
+ bool Areal1, bool Areal2, bool ArealOut,
     // real types
     typename Geometry1, typename Geometry2,
     bool Reverse1, bool Reverse2, bool ReverseOut,
@@ -77,7 +77,7 @@
 template
 <
     typename GeometryTag1, typename GeometryTag2, typename GeometryTag3,
- bool Areal1, bool Areal2, bool ArealOut,
+ bool Areal1, bool Areal2, bool ArealOut,
     typename Geometry1, typename Geometry2,
     bool Reverse1, bool Reverse2, bool ReverseOut,
     typename OutputIterator, typename GeometryOut,
@@ -92,7 +92,7 @@
         return union_inserter
             <
                 GeometryTag2, GeometryTag1, GeometryTag3,
- Areal2, Areal1, ArealOut,
+ Areal2, Areal1, ArealOut,
                 Geometry2, Geometry1,
                 Reverse2, Reverse1, ReverseOut,
                 OutputIterator, GeometryOut,
@@ -134,8 +134,8 @@
                 geometry::is_areal<Geometry2>::value,
                 geometry::is_areal<GeometryOut>::value,
                 Geometry1, Geometry2,
- overlay::do_reverse<geometry::point_order<Geometry1>::value, Reverse1>::value,
- overlay::do_reverse<geometry::point_order<Geometry2>::value, Reverse2>::value,
+ overlay::do_reverse<geometry::point_order<Geometry1>::value, Reverse1>::value,
+ overlay::do_reverse<geometry::point_order<Geometry2>::value, Reverse2>::value,
                 ReverseOut,
                 OutputIterator, GeometryOut,
                 Strategy
@@ -149,8 +149,8 @@
                 geometry::is_areal<Geometry2>::value,
                 geometry::is_areal<GeometryOut>::value,
                 Geometry1, Geometry2,
- overlay::do_reverse<geometry::point_order<Geometry1>::value, Reverse1>::value,
- overlay::do_reverse<geometry::point_order<Geometry2>::value, Reverse2>::value,
+ overlay::do_reverse<geometry::point_order<Geometry1>::value, Reverse1>::value,
+ overlay::do_reverse<geometry::point_order<Geometry2>::value, Reverse2>::value,
                 ReverseOut,
                 OutputIterator, GeometryOut,
                 Strategy
@@ -163,18 +163,22 @@
 
 
 /*!
-\brief Combines two geometries which each other
+\brief_calc2{union} \brief_strategy
 \ingroup union
+\details \details_calc2{union_inserter, spatial set theoretic union}
+ \brief_strategy. details_inserter{union}
 \tparam GeometryOut output geometry type, must be specified
 \tparam Geometry1 \tparam_geometry
 \tparam Geometry2 \tparam_geometry
 \tparam OutputIterator output iterator
-\tparam Strategy compound strategy for intersection
+\tparam Strategy \tparam_strategy_overlay
 \param geometry1 \param_geometry
 \param geometry2 \param_geometry
-\param out the output iterator, outputting polygons
-\param strategy the strategy
-\return the output iterator
+\param out \param_out{union}
+\param strategy \param_strategy{union}
+\return \return_out
+
+\qbk{distinguish,with strategy}
 */
 template
 <
@@ -189,20 +193,26 @@
             OutputIterator out,
             Strategy const& strategy)
 {
+ concept::check<Geometry1 const>();
+ concept::check<Geometry2 const>();
+ concept::check<GeometryOut>();
+
     return detail::union_::inserter<GeometryOut, false, false, true>(geometry1, geometry2, out, strategy);
 }
 
 /*!
-\brief Combines two geometries which each other
+\brief_calc2{union}
 \ingroup union
+\details \details_calc2{union_inserter, spatial set theoretic union}.
+ \details_inserter{union}
 \tparam GeometryOut output geometry type, must be specified
 \tparam Geometry1 \tparam_geometry
 \tparam Geometry2 \tparam_geometry
 \tparam OutputIterator output iterator
 \param geometry1 \param_geometry
 \param geometry2 \param_geometry
-\param out the output iterator, outputting polygons
-\return the output iterator
+\param out \param_out{union}
+\return \return_out
 */
 template
 <
@@ -217,6 +227,7 @@
 {
     concept::check<Geometry1 const>();
     concept::check<Geometry2 const>();
+ concept::check<GeometryOut>();
 
     typedef strategy_intersection
         <
@@ -233,6 +244,7 @@
 /*!
 \brief Combines two geometries which each other
 \ingroup union
+\details \details_calc2{union, spatial set theoretic union}.
 \tparam Geometry1 \tparam_geometry
 \tparam Geometry2 \tparam_geometry
 \tparam Collection output collection, either a multi-geometry,
@@ -260,17 +272,8 @@
     typedef typename boost::range_value<Collection>::type geometry_out;
     concept::check<geometry_out>();
 
- typedef strategy_intersection
- <
- typename cs_tag<geometry_out>::type,
- Geometry1,
- Geometry2,
- typename geometry::point_type<geometry_out>::type
- > strategy;
-
     union_inserter<geometry_out>(geometry1, geometry2,
- std::back_inserter(output_collection),
- strategy());
+ std::back_inserter(output_collection));
 }
 
 

Modified: trunk/boost/geometry/geometry.hpp
==============================================================================
--- trunk/boost/geometry/geometry.hpp (original)
+++ trunk/boost/geometry/geometry.hpp 2011-02-26 17:33:13 EST (Sat, 26 Feb 2011)
@@ -60,6 +60,11 @@
 #include <boost/geometry/algorithms/unique.hpp>
 #include <boost/geometry/algorithms/within.hpp>
 
+// Include multi a.o. because it can give weird effects
+// if you don't (e.g. area=0 of a filled multipolygon)
+#include <boost/geometry/multi/multi.hpp>
+
+
 // check includes all concepts
 #include <boost/geometry/geometries/concepts/check.hpp>
 


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