diff --git a/doc/doxy/Doxyfile b/doc/doxy/Doxyfile
index cbb016757..fd23c3815 100644
--- a/doc/doxy/Doxyfile
+++ b/doc/doxy/Doxyfile
@@ -177,10 +177,12 @@ WARN_LOGFILE =
INPUT = . .. ../../../../boost/geometry/core \
../../../../boost/geometry/algorithms \
../../../../boost/geometry/algorithms/detail \
+ ../../../../boost/geometry/algorithms/detail/buffer \
../../../../boost/geometry/algorithms/detail/comparable_distance \
../../../../boost/geometry/algorithms/detail/disjoint \
../../../../boost/geometry/algorithms/detail/distance \
../../../../boost/geometry/algorithms/detail/equals \
+ ../../../../boost/geometry/algorithms/detail/intersection \
../../../../boost/geometry/algorithms/detail/is_simple \
../../../../boost/geometry/algorithms/detail/is_valid \
../../../../boost/geometry/algorithms/detail/overlay \
diff --git a/doc/doxy/doxygen_input/groups/groups.hpp b/doc/doxy/doxygen_input/groups/groups.hpp
index 01b5333b2..56d10bfd1 100644
--- a/doc/doxy/doxygen_input/groups/groups.hpp
+++ b/doc/doxy/doxygen_input/groups/groups.hpp
@@ -48,6 +48,7 @@
\defgroup num_geometries number of geometries: calculate the number of geometries in a multi-geometry
\defgroup num_interior_rings number of interior rings: calculate the number of interior rings
\defgroup num_points number of points: calculate number of points of a geometry
+\defgroup num_segments number of segments: calculate number of segments of a geometry
\defgroup overlaps overlaps: detect overlap between two geometries
\defgroup perimeter perimeter: calculate perimeter of a geometry
\defgroup projection projection: Projection struct's, classes
diff --git a/doc/imports.qbk b/doc/imports.qbk
index 7acbe5124..072e0bcd8 100644
--- a/doc/imports.qbk
+++ b/doc/imports.qbk
@@ -50,6 +50,7 @@
[import src/examples/algorithms/num_geometries.cpp]
[import src/examples/algorithms/num_interior_rings.cpp]
[import src/examples/algorithms/num_points.cpp]
+[import src/examples/algorithms/num_segments.cpp]
[import src/examples/algorithms/reverse.cpp]
[import src/examples/algorithms/return_envelope.cpp]
[import src/examples/algorithms/simplify.cpp]
diff --git a/doc/make_qbk.py b/doc/make_qbk.py
index 93e4d04ad..7031f0e5c 100755
--- a/doc/make_qbk.py
+++ b/doc/make_qbk.py
@@ -85,9 +85,9 @@ algorithms = ["append", "assign", "make", "clear"
, "convex_hull", "crosses", "difference", "disjoint", "distance"
, "envelope", "equals", "expand", "for_each", "is_simple", "is_valid"
, "intersection", "intersects", "length", "num_geometries"
- , "num_interior_rings", "num_points", "overlaps", "perimeter"
- , "reverse", "simplify", "sym_difference", "touches", "transform"
- , "union", "unique", "within"]
+ , "num_interior_rings", "num_points", "num_segments", "overlaps"
+ , "perimeter", "reverse", "simplify", "sym_difference", "touches"
+ , "transform", "union", "unique", "within"]
access_functions = ["get", "set", "exterior_ring", "interior_rings"
, "num_points", "num_interior_rings", "num_geometries"]
diff --git a/doc/quickref.xml b/doc/quickref.xml
index aed650baa..232451723 100644
--- a/doc/quickref.xml
+++ b/doc/quickref.xml
@@ -424,6 +424,7 @@
num_interior_rings
num_geometries
num_points
+ num_segments
diff --git a/doc/reference.qbk b/doc/reference.qbk
index 40c51b5db..bfc3711bd 100644
--- a/doc/reference.qbk
+++ b/doc/reference.qbk
@@ -136,6 +136,7 @@
[include generated/num_geometries.qbk]
[include generated/num_interior_rings.qbk]
[include generated/num_points.qbk]
+[include generated/num_segments.qbk]
[include generated/overlaps.qbk]
diff --git a/doc/reference/algorithms/num_segments.qbk b/doc/reference/algorithms/num_segments.qbk
new file mode 100644
index 000000000..9e9ea7cec
--- /dev/null
+++ b/doc/reference/algorithms/num_segments.qbk
@@ -0,0 +1,35 @@
+[/============================================================================
+ Boost.Geometry (aka GGL, Generic Geometry Library)
+
+ Copyright (c) 2014, Oracle and/or its affiliates.
+
+ Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+
+ Licensed under the Boost Software License version 1.0.
+ http://www.boost.org/users/license.html
+=============================================================================/]
+
+[def __this_function__ num_segments]
+
+[heading_conformance_no_ogc __this_function__]
+
+[heading Behavior]
+[table
+[[Case] [Behavior] ]
+[[__point__][[qbk_ret 0]]]
+[[__segment__][[qbk_ret 1]]]
+[[__box__][[qbk_ret 4]]]
+[[__range__][[qbk_ret boost::size(geometry) - 1]]]
+[[__other__][[qbk_ret the sum of the number of segments of its elements]]]
+[[Open geometries][[qbk_ret the sum of the number of segments of its elements, it adds one for open (per ring) if specified]]]
+[[Closed geometries][[qbk_ret the sum of the number of segments of its elements]]]
+]
+
+
+[heading Complexity]
+Constant or Linear
+
+[heading Examples]
+[num_segments]
+[num_segments_output]
+
diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk
index 6ae4c9c53..bdee4d07e 100644
--- a/doc/release_notes.qbk
+++ b/doc/release_notes.qbk
@@ -39,14 +39,18 @@
[*Solved tickets]
* [@https://svn.boost.org/trac/boost/ticket/8310 8310] Wrong results with overlapping polygons (fixed using point_on_surface for disjoint)
+* [@https://svn.boost.org/trac/boost/ticket/8375 8375] sym_difference of non-closed polygons returns closed polygon
+* [@https://svn.boost.org/trac/boost/ticket/8376 8376] difference of non-closed polygons returns closed polygon
* [@https://svn.boost.org/trac/boost/ticket/9081 9081] Booleans create self-intersecting polygons from non-self-intersecting polygons
* [@https://svn.boost.org/trac/boost/ticket/9245 9245] Check for process errors in make_qbk.py
* [@https://svn.boost.org/trac/boost/ticket/9563 9563] (Sym)difference not successful, fixed by rescaling to robust type
* [@https://svn.boost.org/trac/boost/ticket/9628 9628] Wrong result of within() due to the winding strategy not working correctly for nearly-horizontal segments
+* [@https://svn.boost.org/trac/boost/ticket/9828 9828] boost::geometry::union_(...) creates redundant closing point
* [@https://svn.boost.org/trac/boost/ticket/9871 9871] Remove spike in polygon with only a spike
* [@https://svn.boost.org/trac/boost/ticket/9947 9947] Missing info about WKT in documentation
* [@https://svn.boost.org/trac/boost/ticket/10019 10019] Difference of Linestring and Box returns their intersection
* [@https://svn.boost.org/trac/boost/ticket/10077 10077] Wrong types in concept checks in boost/geometry/arithmetic/arithmetic.hpp
+* [@https://svn.boost.org/trac/boost/ticket/10234 10234] Wrong results of covered_by() for nearly-horizontal segments
[*Bugfixes]
diff --git a/doc/src/docutils/tools/support_status/support_status.cpp b/doc/src/docutils/tools/support_status/support_status.cpp
index 4cf636d74..9372a1967 100644
--- a/doc/src/docutils/tools/support_status/support_status.cpp
+++ b/doc/src/docutils/tools/support_status/support_status.cpp
@@ -40,6 +40,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -129,6 +130,7 @@ DECLARE_UNARY_ALGORITHM(length)
DECLARE_UNARY_ALGORITHM(num_geometries)
DECLARE_UNARY_ALGORITHM(num_interior_rings)
DECLARE_UNARY_ALGORITHM(num_points)
+DECLARE_UNARY_ALGORITHM(num_segments)
DECLARE_BINARY_ALGORITHM(overlaps)
DECLARE_UNARY_ALGORITHM(perimeter)
DECLARE_UNARY_ALGORITHM(reverse)
diff --git a/doc/src/examples/algorithms/Jamfile.v2 b/doc/src/examples/algorithms/Jamfile.v2
index d8e25d9fb..946e66f39 100644
--- a/doc/src/examples/algorithms/Jamfile.v2
+++ b/doc/src/examples/algorithms/Jamfile.v2
@@ -66,6 +66,7 @@ exe make_inverse : make_inverse.cpp ;
exe num_geometries : num_geometries.cpp ;
exe num_interior_rings : num_interior_rings.cpp ;
exe num_points : num_points.cpp ;
+exe num_segments : num_segments.cpp ;
exe return_envelope : return_envelope.cpp ;
diff --git a/doc/src/examples/algorithms/num_segments.cpp b/doc/src/examples/algorithms/num_segments.cpp
new file mode 100644
index 000000000..40a244cfe
--- /dev/null
+++ b/doc/src/examples/algorithms/num_segments.cpp
@@ -0,0 +1,46 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+// QuickBook Example
+
+// Copyright (c) 2014, Oracle and/or its affiliates
+
+// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+
+// Licensed under the Boost Software License version 1.0.
+// http://www.boost.org/users/license.html
+
+//[num_segments
+//` Get the number of segments in a geometry
+
+#include
+
+#include
+#include
+
+
+int main()
+{
+ boost::geometry::model::multi_polygon
+ <
+ boost::geometry::model::polygon
+ <
+ boost::geometry::model::d2::point_xy, true, false // cw, open polygon
+ >
+ > mp;
+ boost::geometry::read_wkt("MULTIPOLYGON(((0 0,0 10,10 0),(1 1,8 1,1 8)),((10 10,10 20,20 10)))", mp);
+ std::cout << "Number of segments: " << boost::geometry::num_segments(mp) << std::endl;
+ std::cout << "Number of segments (add_to_open <- true): " << boost::geometry::num_segments(mp, true) << std::endl;
+ return 0;
+}
+
+//]
+
+
+//[num_segments_output
+/*`
+Output:
+[pre
+ Number of segments: 6
+Number of segments (add_to_open <- true): 9
+]
+*/
+//]
diff --git a/include/boost/geometry/algorithms/append.hpp b/include/boost/geometry/algorithms/append.hpp
index 1dafac04b..1a8828ba4 100644
--- a/include/boost/geometry/algorithms/append.hpp
+++ b/include/boost/geometry/algorithms/append.hpp
@@ -8,6 +8,7 @@
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -20,6 +21,10 @@
#define BOOST_GEOMETRY_ALGORITHMS_APPEND_HPP
+#include
+#include
+#include
+
#include
#include
#include
@@ -28,9 +33,7 @@
#include
#include
#include
-#include
-#include
-#include
+#include
namespace boost { namespace geometry
@@ -98,7 +101,7 @@ struct point_to_polygon
else if (ring_index < int(num_interior_rings(polygon)))
{
append_point::apply(
- interior_rings(polygon)[ring_index], point);
+ range::at(interior_rings(polygon), ring_index), point);
}
}
};
@@ -120,7 +123,7 @@ struct range_to_polygon
else if (ring_index < int(num_interior_rings(polygon)))
{
append_range::apply(
- interior_rings(polygon)[ring_index], range);
+ range::at(interior_rings(polygon), ring_index), range);
}
}
};
@@ -202,6 +205,71 @@ struct append
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace append
+{
+
+template
+struct append_to_multigeometry
+{
+ static inline void apply(MultiGeometry& multigeometry,
+ RangeOrPoint const& range_or_point,
+ int ring_index, int multi_index)
+ {
+
+ dispatch::append
+ <
+ typename boost::range_value::type,
+ RangeOrPoint
+ >::apply(range::at(multigeometry, multi_index), range_or_point, ring_index);
+ }
+};
+
+}} // namespace detail::append
+#endif // DOXYGEN_NO_DETAIL
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+namespace splitted_dispatch
+{
+
+template
+struct append_point
+ : detail::append::append_point
+{};
+
+template
+struct append_range
+ : detail::append::append_range
+{};
+
+template
+struct append_point
+ : detail::append::append_to_multigeometry
+{};
+
+template
+struct append_range
+ : detail::append::append_to_multigeometry
+{};
+
+template
+struct append_point
+ : detail::append::append_to_multigeometry
+{};
+
+template
+struct append_range
+ : detail::append::append_to_multigeometry
+{};
+
+} // namespace splitted_dispatch
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
namespace resolve_variant {
diff --git a/include/boost/geometry/algorithms/convert.hpp b/include/boost/geometry/algorithms/convert.hpp
index f8685af2d..914ef8f42 100644
--- a/include/boost/geometry/algorithms/convert.hpp
+++ b/include/boost/geometry/algorithms/convert.hpp
@@ -41,6 +41,8 @@
#include
#include
+#include
+
#include
#include
#include
@@ -111,7 +113,7 @@ struct box_to_range
assign_box_corners_oriented(box, range);
if (Close)
{
- range[4] = range[0];
+ range::at(range, 4) = range::at(range, 0);
}
}
};
@@ -160,13 +162,17 @@ struct range_to_range
// point for open output.
view_type view(rview);
- int n = boost::size(view);
+ typedef typename boost::range_size::type size_type;
+ size_type n = boost::size(view);
if (geometry::closure::value == geometry::open)
{
n--;
}
- int i = 0;
+ // If size == 0 && geometry::open <=> n = numeric_limits::max()
+ // but ok, sice below it == end()
+
+ size_type i = 0;
for (typename boost::range_iterator::type it
= boost::begin(view);
it != boost::end(view) && i < n;
diff --git a/include/boost/geometry/algorithms/detail/assign_box_corners.hpp b/include/boost/geometry/algorithms/detail/assign_box_corners.hpp
index f1bc59613..669d6d365 100644
--- a/include/boost/geometry/algorithms/detail/assign_box_corners.hpp
+++ b/include/boost/geometry/algorithms/detail/assign_box_corners.hpp
@@ -19,7 +19,7 @@
#include
#include
-
+#include
namespace boost { namespace geometry
@@ -80,12 +80,16 @@ 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]);
+ assign_box_corners(box,
+ range::at(corners, 0), range::at(corners, 1),
+ range::at(corners, 3), range::at(corners, 2));
}
else
{
// make clockwise ll,ul,ur,lr
- assign_box_corners(box, corners[0], corners[3], corners[1], corners[2]);
+ assign_box_corners(box,
+ range::at(corners, 0), range::at(corners, 3),
+ range::at(corners, 1), range::at(corners, 2));
}
}
#if defined(_MSC_VER)
diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp
index 0ace72f63..182f5af6a 100644
--- a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp
+++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp
@@ -14,7 +14,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -42,7 +42,11 @@ struct turn_ovelaps_box
template
static inline bool apply(Box const& box, Turn const& turn)
{
- return ! geometry::disjoint(box, turn.robust_point);
+ return ! dispatch::disjoint
+ <
+ typename Turn::robust_point_type,
+ Box
+ >::apply(turn.robust_point, box);
}
};
diff --git a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp
index 695f3a2be..b085da513 100644
--- a/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp
+++ b/include/boost/geometry/algorithms/detail/distance/segment_to_box.hpp
@@ -14,9 +14,10 @@
#include
#include
+#include
+#include
#include
#include
-#include
#include
#include
@@ -103,7 +104,7 @@ public:
<
Strategy
>::apply(strategy);
- boost::ignore_unused_variable_warning(cstrategy);
+ boost::ignore_unused(cstrategy);
// get segment points
segment_point p[2];
@@ -181,7 +182,7 @@ public:
<
Strategy
>::apply(strategy);
- boost::ignore_unused_variable_warning(cstrategy);
+ boost::ignore_unused(cstrategy);
// get segment points
segment_point p[2];
@@ -199,7 +200,7 @@ public:
}
point_box_comparable_strategy pb_cstrategy;
- boost::ignore_unused_variable_warning(pb_cstrategy);
+ boost::ignore_unused(pb_cstrategy);
cd[4] = pb_cstrategy.apply(p[0], box);
cd[5] = pb_cstrategy.apply(p[1], box);
@@ -281,6 +282,8 @@ private:
PPStrategy const& pp_strategy,
PSStrategy const& ps_strategy)
{
+ boost::ignore_unused(pp_strategy, ps_strategy);
+
// the implementation below is written for non-negative slope
// segments
//
@@ -325,6 +328,8 @@ private:
BoxPoint const& top_left,
PSStrategy const& ps_strategy)
{
+ boost::ignore_unused(ps_strategy);
+
// the segment lies above the box
typedef cast_to_result cast;
diff --git a/include/boost/geometry/algorithms/detail/extreme_points.hpp b/include/boost/geometry/algorithms/detail/extreme_points.hpp
index c6a47bb8f..055bc1acb 100644
--- a/include/boost/geometry/algorithms/detail/extreme_points.hpp
+++ b/include/boost/geometry/algorithms/detail/extreme_points.hpp
@@ -280,7 +280,8 @@ struct extreme_points_on_ring
template
static inline bool right_turn(Ring const& ring, Iterator it)
{
- int const index = std::distance(boost::begin(ring), it);
+ typename std::iterator_traits::difference_type const index
+ = std::distance(boost::begin(ring), it);
geometry::ever_circling_range_iterator left(ring);
geometry::ever_circling_range_iterator right(ring);
left += index;
@@ -328,7 +329,8 @@ struct extreme_points_on_ring
return false;
}
- int const index = std::distance(boost::begin(ring), max_it);
+ typename std::iterator_traits::difference_type const
+ index = std::distance(boost::begin(ring), max_it);
//std::cout << "Extreme point lies at " << index << " having " << geometry::wkt(*max_it) << std::endl;
geometry::ever_circling_range_iterator left(ring);
diff --git a/include/boost/geometry/algorithms/detail/intersection/box_box.hpp b/include/boost/geometry/algorithms/detail/intersection/box_box.hpp
new file mode 100644
index 000000000..30c31ff1e
--- /dev/null
+++ b/include/boost/geometry/algorithms/detail/intersection/box_box.hpp
@@ -0,0 +1,54 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// 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_INTERSECTION_BOX_BOX_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_BOX_BOX_HPP
+
+
+#include
+#include
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+template
+<
+ typename Box1, typename Box2, bool Reverse
+>
+struct intersection
+ <
+ Box1, Box2,
+ box_tag, box_tag,
+ Reverse
+ > : public detail::intersection::intersection_box_box
+ <
+ 0, geometry::dimension::value
+ >
+{};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_BOX_BOX_HPP
diff --git a/include/boost/geometry/algorithms/detail/intersection/implementation.hpp b/include/boost/geometry/algorithms/detail/intersection/implementation.hpp
new file mode 100644
index 000000000..d8fb2ec38
--- /dev/null
+++ b/include/boost/geometry/algorithms/detail/intersection/implementation.hpp
@@ -0,0 +1,22 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// 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_INTERSECTION_IMPLEMENTATION_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_IMPLEMENTATION_HPP
+
+
+#include
+#include
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_IMPLEMENTATION_HPP
diff --git a/include/boost/geometry/algorithms/detail/intersection/interface.hpp b/include/boost/geometry/algorithms/detail/intersection/interface.hpp
new file mode 100644
index 000000000..323ab7c85
--- /dev/null
+++ b/include/boost/geometry/algorithms/detail/intersection/interface.hpp
@@ -0,0 +1,309 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// 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_INTERSECTION_INTERFACE_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_INTERFACE_HPP
+
+
+// TODO: those headers probably may be removed
+#include
+#include
+
+#include
+#include
+
+
+namespace boost { namespace geometry
+{
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+// By default, all is forwarded to the intersection_insert-dispatcher
+template
+<
+ typename Geometry1, typename Geometry2,
+ typename Tag1 = typename geometry::tag::type,
+ typename Tag2 = typename geometry::tag::type,
+ bool Reverse = reverse_dispatch::type::value
+>
+struct intersection
+{
+ template
+ static inline bool apply(Geometry1 const& geometry1,
+ Geometry2 const& geometry2,
+ RobustPolicy const& robust_policy,
+ GeometryOut& geometry_out,
+ Strategy const& strategy)
+ {
+ typedef typename boost::range_value::type OneOut;
+
+ intersection_insert
+ <
+ Geometry1, Geometry2, OneOut,
+ overlay_intersection
+ >::apply(geometry1, geometry2, robust_policy, std::back_inserter(geometry_out), strategy);
+
+ return true;
+ }
+
+};
+
+
+// If reversal is needed, perform it
+template
+<
+ typename Geometry1, typename Geometry2,
+ typename Tag1, typename Tag2
+>
+struct intersection
+<
+ Geometry1, Geometry2,
+ Tag1, Tag2,
+ true
+>
+ : intersection
+{
+ template
+ static inline bool apply(
+ Geometry1 const& g1,
+ Geometry2 const& g2,
+ RobustPolicy const& robust_policy,
+ GeometryOut& out,
+ Strategy const& strategy)
+ {
+ return intersection<
+ Geometry2, Geometry1,
+ Tag2, Tag1,
+ false
+ >::apply(g2, g1, robust_policy, out, strategy);
+ }
+};
+
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+namespace resolve_variant
+{
+
+template
+struct intersection
+{
+ template
+ static inline bool
+ apply(
+ const Geometry1& geometry1,
+ const Geometry2& geometry2,
+ GeometryOut& geometry_out)
+ {
+ concept::check();
+ concept::check();
+
+ typedef typename geometry::rescale_overlay_policy_type
+ <
+ Geometry1,
+ Geometry2
+ >::type rescale_policy_type;
+
+ rescale_policy_type robust_policy
+ = geometry::get_rescale_policy(geometry1, geometry2);
+
+ typedef strategy_intersection
+ <
+ typename cs_tag::type,
+ Geometry1,
+ Geometry2,
+ typename geometry::point_type::type,
+ rescale_policy_type
+ > strategy;
+
+ return dispatch::intersection
+ <
+ Geometry1,
+ Geometry2
+ >::apply(geometry1, geometry2, robust_policy, geometry_out, strategy());
+ }
+};
+
+
+template
+struct intersection, Geometry2>
+{
+ template
+ struct visitor: static_visitor
+ {
+ Geometry2 const& m_geometry2;
+ GeometryOut& m_geometry_out;
+
+ visitor(Geometry2 const& geometry2,
+ GeometryOut& geometry_out)
+ : m_geometry2(geometry2),
+ m_geometry_out(geometry_out)
+ {}
+
+ template
+ result_type operator()(Geometry1 const& geometry1) const
+ {
+ return intersection
+ <
+ Geometry1,
+ Geometry2
+ >::template apply
+ <
+ GeometryOut
+ >
+ (geometry1, m_geometry2, m_geometry_out);
+ }
+ };
+
+ template
+ static inline bool
+ apply(variant const& geometry1,
+ Geometry2 const& geometry2,
+ GeometryOut& geometry_out)
+ {
+ return apply_visitor(visitor(geometry2, geometry_out), geometry1);
+ }
+};
+
+
+template
+struct intersection >
+{
+ template
+ struct visitor: static_visitor
+ {
+ Geometry1 const& m_geometry1;
+ GeometryOut& m_geometry_out;
+
+ visitor(Geometry1 const& geometry1,
+ GeometryOut& geometry_out)
+ : m_geometry1(geometry1),
+ m_geometry_out(geometry_out)
+ {}
+
+ template
+ result_type operator()(Geometry2 const& geometry2) const
+ {
+ return intersection
+ <
+ Geometry1,
+ Geometry2
+ >::template apply
+ <
+ GeometryOut
+ >
+ (m_geometry1, geometry2, m_geometry_out);
+ }
+ };
+
+ template
+ static inline bool
+ apply(
+ Geometry1 const& geometry1,
+ const variant& geometry2,
+ GeometryOut& geometry_out)
+ {
+ return apply_visitor(visitor(geometry1, geometry_out), geometry2);
+ }
+};
+
+
+template
+struct intersection, variant >
+{
+ template
+ struct visitor: static_visitor
+ {
+ GeometryOut& m_geometry_out;
+
+ visitor(GeometryOut& geometry_out)
+ : m_geometry_out(geometry_out)
+ {}
+
+ template
+ result_type operator()(
+ Geometry1 const& geometry1,
+ Geometry2 const& geometry2) const
+ {
+ return intersection
+ <
+ Geometry1,
+ Geometry2
+ >::template apply
+ <
+ GeometryOut
+ >
+ (geometry1, geometry2, m_geometry_out);
+ }
+ };
+
+ template
+ static inline bool
+ apply(
+ const variant& geometry1,
+ const variant& geometry2,
+ GeometryOut& geometry_out)
+ {
+ return apply_visitor(visitor(geometry_out), geometry1, geometry2);
+ }
+};
+
+} // namespace resolve_variant
+
+
+/*!
+\brief \brief_calc2{intersection}
+\ingroup intersection
+\details \details_calc2{intersection, spatial set theoretic intersection}.
+\tparam Geometry1 \tparam_geometry
+\tparam Geometry2 \tparam_geometry
+\tparam GeometryOut Collection of geometries (e.g. std::vector, std::deque, boost::geometry::multi*) of which
+ the value_type fulfills a \p_l_or_c concept, or it is the output geometry (e.g. for a box)
+\param geometry1 \param_geometry
+\param geometry2 \param_geometry
+\param geometry_out The output geometry, either a multi_point, multi_polygon,
+ multi_linestring, or a box (for intersection of two boxes)
+
+\qbk{[include reference/algorithms/intersection.qbk]}
+*/
+template
+<
+ typename Geometry1,
+ typename Geometry2,
+ typename GeometryOut
+>
+inline bool intersection(Geometry1 const& geometry1,
+ Geometry2 const& geometry2,
+ GeometryOut& geometry_out)
+{
+ return resolve_variant::intersection
+ <
+ Geometry1,
+ Geometry2
+ >::template apply
+ <
+ GeometryOut
+ >
+ (geometry1, geometry2, geometry_out);
+}
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_INTERFACE_HPP
diff --git a/include/boost/geometry/algorithms/detail/intersection/multi.hpp b/include/boost/geometry/algorithms/detail/intersection/multi.hpp
new file mode 100644
index 000000000..b1f13862f
--- /dev/null
+++ b/include/boost/geometry/algorithms/detail/intersection/multi.hpp
@@ -0,0 +1,423 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// 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_INTERSECTION_MULTI_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_MULTI_HPP
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+// TODO: those headers probably may be removed
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+
+#include
+#include
+#include
+
+// TODO: remove this after moving num_point from multi directory
+#include
+
+namespace boost { namespace geometry
+{
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace intersection
+{
+
+
+template
+struct intersection_multi_linestring_multi_linestring_point
+{
+ template
+ <
+ typename MultiLinestring1, typename MultiLinestring2,
+ typename RobustPolicy,
+ typename OutputIterator, typename Strategy
+ >
+ static inline OutputIterator apply(MultiLinestring1 const& ml1,
+ MultiLinestring2 const& ml2,
+ RobustPolicy const& robust_policy,
+ OutputIterator out,
+ Strategy const& strategy)
+ {
+ // Note, this loop is quadratic w.r.t. number of linestrings per input.
+ // Future Enhancement: first do the sections of each, then intersect.
+ for (typename boost::range_iterator
+ <
+ MultiLinestring1 const
+ >::type it1 = boost::begin(ml1);
+ it1 != boost::end(ml1);
+ ++it1)
+ {
+ for (typename boost::range_iterator
+ <
+ MultiLinestring2 const
+ >::type it2 = boost::begin(ml2);
+ it2 != boost::end(ml2);
+ ++it2)
+ {
+ out = intersection_linestring_linestring_point
+ ::apply(*it1, *it2, robust_policy, out, strategy);
+ }
+ }
+
+ return out;
+ }
+};
+
+
+template
+struct intersection_linestring_multi_linestring_point
+{
+ template
+ <
+ typename Linestring, typename MultiLinestring,
+ typename RobustPolicy,
+ typename OutputIterator, typename Strategy
+ >
+ static inline OutputIterator apply(Linestring const& linestring,
+ MultiLinestring const& ml,
+ RobustPolicy const& robust_policy,
+ OutputIterator out,
+ Strategy const& strategy)
+ {
+ for (typename boost::range_iterator
+ <
+ MultiLinestring const
+ >::type it = boost::begin(ml);
+ it != boost::end(ml);
+ ++it)
+ {
+ out = intersection_linestring_linestring_point
+ ::apply(linestring, *it, robust_policy, out, strategy);
+ }
+
+ return out;
+ }
+};
+
+
+// This loop is quite similar to the loop above, but beacuse the iterator
+// is second (above) or first (below) argument, it is not trivial to merge them.
+template
+<
+ bool ReverseAreal,
+ typename LineStringOut,
+ overlay_type OverlayType
+>
+struct intersection_of_multi_linestring_with_areal
+{
+ template
+ <
+ typename MultiLinestring, typename Areal,
+ typename RobustPolicy,
+ typename OutputIterator, typename Strategy
+ >
+ static inline OutputIterator apply(MultiLinestring const& ml, Areal const& areal,
+ RobustPolicy const& robust_policy,
+ OutputIterator out,
+ Strategy const& strategy)
+ {
+ for (typename boost::range_iterator
+ <
+ MultiLinestring const
+ >::type it = boost::begin(ml);
+ it != boost::end(ml);
+ ++it)
+ {
+ out = intersection_of_linestring_with_areal
+ <
+ ReverseAreal, LineStringOut, OverlayType
+ >::apply(*it, areal, robust_policy, out, strategy);
+ }
+
+ return out;
+
+ }
+};
+
+// This one calls the one above with reversed arguments
+template
+<
+ bool ReverseAreal,
+ typename LineStringOut,
+ overlay_type OverlayType
+>
+struct intersection_of_areal_with_multi_linestring
+{
+ template
+ <
+ typename Areal, typename MultiLinestring,
+ typename RobustPolicy,
+ typename OutputIterator, typename Strategy
+ >
+ static inline OutputIterator apply(Areal const& areal, MultiLinestring const& ml,
+ RobustPolicy const& robust_policy,
+ OutputIterator out,
+ Strategy const& strategy)
+ {
+ return intersection_of_multi_linestring_with_areal
+ <
+ ReverseAreal, LineStringOut, OverlayType
+ >::apply(ml, areal, robust_policy, out, strategy);
+ }
+};
+
+
+
+template
+struct clip_multi_linestring
+{
+ template
+ <
+ typename MultiLinestring, typename Box,
+ typename RobustPolicy,
+ typename OutputIterator, typename Strategy
+ >
+ static inline OutputIterator apply(MultiLinestring const& multi_linestring,
+ Box const& box,
+ RobustPolicy const& robust_policy,
+ OutputIterator out, Strategy const& )
+ {
+ typedef typename point_type::type point_type;
+ strategy::intersection::liang_barsky lb_strategy;
+ for (typename boost::range_iterator::type it
+ = boost::begin(multi_linestring);
+ it != boost::end(multi_linestring); ++it)
+ {
+ out = detail::intersection::clip_range_with_box
+ (box, *it, robust_policy, out, lb_strategy);
+ }
+ return out;
+ }
+};
+
+
+}} // namespace detail::intersection
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+
+// Linear
+template
+<
+ typename MultiLinestring1, typename MultiLinestring2,
+ typename GeometryOut,
+ overlay_type OverlayType,
+ bool Reverse1, bool Reverse2, bool ReverseOut
+>
+struct intersection_insert
+ <
+ MultiLinestring1, MultiLinestring2,
+ GeometryOut,
+ OverlayType,
+ Reverse1, Reverse2, ReverseOut,
+ multi_linestring_tag, multi_linestring_tag, point_tag,
+ false, false, false
+ > : detail::intersection::intersection_multi_linestring_multi_linestring_point
+ <
+ GeometryOut
+ >
+{};
+
+
+template
+<
+ typename Linestring, typename MultiLinestring,
+ typename GeometryOut,
+ overlay_type OverlayType,
+ bool Reverse1, bool Reverse2, bool ReverseOut
+>
+struct intersection_insert
+ <
+ Linestring, MultiLinestring,
+ GeometryOut,
+ OverlayType,
+ Reverse1, Reverse2, ReverseOut,
+ linestring_tag, multi_linestring_tag, point_tag,
+ false, false, false
+ > : detail::intersection::intersection_linestring_multi_linestring_point
+ <
+ GeometryOut
+ >
+{};
+
+
+template
+<
+ typename MultiLinestring, typename Box,
+ typename GeometryOut,
+ overlay_type OverlayType,
+ bool Reverse1, bool Reverse2, bool ReverseOut
+>
+struct intersection_insert
+ <
+ MultiLinestring, Box,
+ GeometryOut,
+ OverlayType,
+ Reverse1, Reverse2, ReverseOut,
+ multi_linestring_tag, box_tag, linestring_tag,
+ false, true, false
+ > : detail::intersection::clip_multi_linestring
+ <
+ GeometryOut
+ >
+{};
+
+
+template
+<
+ typename Linestring, typename MultiPolygon,
+ typename GeometryOut,
+ overlay_type OverlayType,
+ bool ReverseLinestring, bool ReverseMultiPolygon, bool ReverseOut
+>
+struct intersection_insert
+ <
+ Linestring, MultiPolygon,
+ GeometryOut,
+ OverlayType,
+ ReverseLinestring, ReverseMultiPolygon, ReverseOut,
+ linestring_tag, multi_polygon_tag, linestring_tag,
+ false, true, false
+ > : detail::intersection::intersection_of_linestring_with_areal
+ <
+ ReverseMultiPolygon,
+ GeometryOut,
+ OverlayType
+ >
+{};
+
+
+// Derives from areal/mls because runtime arguments are in that order.
+// areal/mls reverses it itself to mls/areal
+template
+<
+ typename Polygon, typename MultiLinestring,
+ typename GeometryOut,
+ overlay_type OverlayType,
+ bool ReversePolygon, bool ReverseMultiLinestring, bool ReverseOut
+>
+struct intersection_insert
+ <
+ Polygon, MultiLinestring,
+ GeometryOut,
+ OverlayType,
+ ReversePolygon, ReverseMultiLinestring, ReverseOut,
+ polygon_tag, multi_linestring_tag, linestring_tag,
+ true, false, false
+ > : detail::intersection::intersection_of_areal_with_multi_linestring
+ <
+ ReversePolygon,
+ GeometryOut,
+ OverlayType
+ >
+{};
+
+
+template
+<
+ typename MultiLinestring, typename Ring,
+ typename GeometryOut,
+ overlay_type OverlayType,
+ bool ReverseMultiLinestring, bool ReverseRing, bool ReverseOut
+>
+struct intersection_insert
+ <
+ MultiLinestring, Ring,
+ GeometryOut,
+ OverlayType,
+ ReverseMultiLinestring, ReverseRing, ReverseOut,
+ multi_linestring_tag, ring_tag, linestring_tag,
+ false, true, false
+ > : detail::intersection::intersection_of_multi_linestring_with_areal
+ <
+ ReverseRing,
+ GeometryOut,
+ OverlayType
+ >
+{};
+
+template
+<
+ typename MultiLinestring, typename Polygon,
+ typename GeometryOut,
+ overlay_type OverlayType,
+ bool ReverseMultiLinestring, bool ReverseRing, bool ReverseOut
+>
+struct intersection_insert
+ <
+ MultiLinestring, Polygon,
+ GeometryOut,
+ OverlayType,
+ ReverseMultiLinestring, ReverseRing, ReverseOut,
+ multi_linestring_tag, polygon_tag, linestring_tag,
+ false, true, false
+ > : detail::intersection::intersection_of_multi_linestring_with_areal
+ <
+ ReverseRing,
+ GeometryOut,
+ OverlayType
+ >
+{};
+
+
+
+template
+<
+ typename MultiLinestring, typename MultiPolygon,
+ typename GeometryOut,
+ overlay_type OverlayType,
+ bool ReverseMultiLinestring, bool ReverseMultiPolygon, bool ReverseOut
+>
+struct intersection_insert
+ <
+ MultiLinestring, MultiPolygon,
+ GeometryOut,
+ OverlayType,
+ ReverseMultiLinestring, ReverseMultiPolygon, ReverseOut,
+ multi_linestring_tag, multi_polygon_tag, linestring_tag,
+ false, true, false
+ > : detail::intersection::intersection_of_multi_linestring_with_areal
+ <
+ ReverseMultiPolygon,
+ GeometryOut,
+ OverlayType
+ >
+{};
+
+
+} // namespace dispatch
+#endif
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_MULTI_HPP
+
diff --git a/include/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp b/include/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp
index 4040fbe6b..5ee9b031e 100644
--- a/include/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp
+++ b/include/boost/geometry/algorithms/detail/overlay/copy_segment_point.hpp
@@ -20,6 +20,7 @@
#include
#include
#include
+#include
#include
#include
@@ -95,8 +96,8 @@ struct copy_segment_point_polygon
>::apply
(
seg_id.ring_index < 0
- ? geometry::exterior_ring(polygon)
- : geometry::interior_rings(polygon)[seg_id.ring_index],
+ ? geometry::exterior_ring(polygon)
+ : range::at(geometry::interior_rings(polygon), seg_id.ring_index),
seg_id, second,
point
);
@@ -146,7 +147,7 @@ struct copy_segment_point_multi
);
// Call the single-version
- return Policy::apply(multi[seg_id.multi_index], seg_id, second, point);
+ return Policy::apply(range::at(multi, seg_id.multi_index), seg_id, second, point);
}
};
diff --git a/include/boost/geometry/algorithms/detail/overlay/copy_segments.hpp b/include/boost/geometry/algorithms/detail/overlay/copy_segments.hpp
index d4bf0a90f..5aae862ce 100644
--- a/include/boost/geometry/algorithms/detail/overlay/copy_segments.hpp
+++ b/include/boost/geometry/algorithms/detail/overlay/copy_segments.hpp
@@ -6,6 +6,7 @@
// Modifications copyright (c) 2014 Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -39,6 +40,8 @@
#include
#include
+#include
+
namespace boost { namespace geometry
{
@@ -155,18 +158,18 @@ public:
// Sanity check
if ( from_index > to_index
|| from_index < 0
- || to_index >= int(boost::size(ls)) )
+ || to_index >= static_cast(boost::size(ls)) )
{
return;
}
- typedef typename boost::range_difference::type size_type;
- size_type const count = to_index - from_index + 1;
+ typedef typename boost::range_difference::type diff_t;
+ diff_t const count = to_index - from_index + 1;
typename boost::range_iterator::type
it = boost::begin(ls) + from_index;
- for (size_type i = 0; i < count; ++i, ++it)
+ for (diff_t i = 0; i < count; ++i, ++it)
{
append_to_output(current_output, *it, robust_policy,
boost::integral_constant());
@@ -193,8 +196,8 @@ struct copy_segments_polygon
copy_segments_ring::apply
(
seg_id.ring_index < 0
- ? geometry::exterior_ring(polygon)
- : geometry::interior_rings(polygon)[seg_id.ring_index],
+ ? geometry::exterior_ring(polygon)
+ : range::at(geometry::interior_rings(polygon), seg_id.ring_index),
seg_id, to_index,
robust_policy,
current_output
@@ -265,10 +268,10 @@ struct copy_segments_multi
);
// Call the single-version
- Policy::apply(multi_geometry[seg_id.multi_index],
- seg_id, to_index,
- robust_policy,
- current_output);
+ Policy::apply(range::at(multi_geometry, seg_id.multi_index),
+ seg_id, to_index,
+ robust_policy,
+ current_output);
}
};
diff --git a/include/boost/geometry/algorithms/detail/overlay/follow.hpp b/include/boost/geometry/algorithms/detail/overlay/follow.hpp
index 632f79f40..83aa4ce6e 100644
--- a/include/boost/geometry/algorithms/detail/overlay/follow.hpp
+++ b/include/boost/geometry/algorithms/detail/overlay/follow.hpp
@@ -494,8 +494,10 @@ public :
detail::copy_segments::copy_segments_linestring
<
false, RemoveSpikes
- >::apply(linestring, current_segment_id,
- boost::size(linestring) - 1, robust_policy,
+ >::apply(linestring,
+ current_segment_id,
+ static_cast(boost::size(linestring) - 1),
+ robust_policy,
current_piece);
}
diff --git a/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp
index 851162bda..2954921a0 100644
--- a/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp
+++ b/include/boost/geometry/algorithms/detail/overlay/follow_linear_linear.hpp
@@ -263,8 +263,10 @@ protected:
detail::copy_segments::copy_segments_linestring
<
false, false // do not reverse; do not remove spikes
- >::apply(linestring, current_segment_id,
- boost::size(linestring) - 1, robust_policy,
+ >::apply(linestring,
+ current_segment_id,
+ static_cast(boost::size(linestring) - 1),
+ robust_policy,
current_piece);
}
diff --git a/include/boost/geometry/algorithms/detail/overlay/get_ring.hpp b/include/boost/geometry/algorithms/detail/overlay/get_ring.hpp
index ab9219a3d..131d58d58 100644
--- a/include/boost/geometry/algorithms/detail/overlay/get_ring.hpp
+++ b/include/boost/geometry/algorithms/detail/overlay/get_ring.hpp
@@ -19,6 +19,7 @@
#include
#include
#include
+#include
namespace boost { namespace geometry
@@ -34,16 +35,16 @@ template
struct get_ring
{};
-// A container of rings (multi-ring but that does not exist)
+// A range of rings (multi-ring but that does not exist)
// gets the "void" tag and is dispatched here.
template<>
struct get_ring
{
- template
- static inline typename boost::range_value::type const&
- apply(ring_identifier const& id, Container const& container)
+ template
+ static inline typename boost::range_value::type const&
+ apply(ring_identifier const& id, Range const& container)
{
- return container[id.multi_index];
+ return range::at(container, id.multi_index);
}
};
@@ -88,7 +89,7 @@ struct get_ring
);
return id.ring_index < 0
? exterior_ring(polygon)
- : interior_rings(polygon)[id.ring_index];
+ : range::at(interior_rings(polygon), id.ring_index);
}
};
@@ -107,7 +108,7 @@ struct get_ring
&& id.multi_index < int(boost::size(multi_polygon))
);
return get_ring::apply(id,
- multi_polygon[id.multi_index]);
+ range::at(multi_polygon, id.multi_index));
}
};
diff --git a/include/boost/geometry/algorithms/detail/sections/range_by_section.hpp b/include/boost/geometry/algorithms/detail/sections/range_by_section.hpp
index 4ef11175f..63feb12a7 100644
--- a/include/boost/geometry/algorithms/detail/sections/range_by_section.hpp
+++ b/include/boost/geometry/algorithms/detail/sections/range_by_section.hpp
@@ -7,8 +7,8 @@
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
-// This file was modified by Oracle on 2013.
-// Modifications copyright (c) 2013, Oracle and/or its affiliates.
+// This file was modified by Oracle on 2013, 2014.
+// Modifications copyright (c) 2013, 2014, Oracle and/or its affiliates.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
@@ -30,6 +30,7 @@
#include
#include
#include
+#include
namespace boost { namespace geometry
@@ -57,7 +58,7 @@ struct full_section_polygon
{
return section.ring_id.ring_index < 0
? geometry::exterior_ring(polygon)
- : geometry::interior_rings(polygon)[section.ring_id.ring_index];
+ : range::at(geometry::interior_rings(polygon), section.ring_id.ring_index);
}
};
@@ -79,7 +80,7 @@ struct full_section_multi
&& section.ring_id.multi_index < int(boost::size(multi))
);
- return Policy::apply(multi[section.ring_id.multi_index], section);
+ return Policy::apply(range::at(multi, section.ring_id.multi_index), section);
}
};
diff --git a/include/boost/geometry/algorithms/intersection.hpp b/include/boost/geometry/algorithms/intersection.hpp
index b066e8150..0169f12db 100644
--- a/include/boost/geometry/algorithms/intersection.hpp
+++ b/include/boost/geometry/algorithms/intersection.hpp
@@ -2,6 +2,11 @@
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
// 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)
@@ -10,310 +15,8 @@
#define BOOST_GEOMETRY_ALGORITHMS_INTERSECTION_HPP
-#include
-#include
-#include
-#include
-#include
-
-
-namespace boost { namespace geometry
-{
-
-
-#ifndef DOXYGEN_NO_DISPATCH
-namespace dispatch
-{
-
-// By default, all is forwarded to the intersection_insert-dispatcher
-template
-<
- typename Geometry1, typename Geometry2,
- typename Tag1 = typename geometry::tag::type,
- typename Tag2 = typename geometry::tag::type,
- bool Reverse = reverse_dispatch::type::value
->
-struct intersection
-{
- template
- static inline bool apply(Geometry1 const& geometry1,
- Geometry2 const& geometry2,
- RobustPolicy const& robust_policy,
- GeometryOut& geometry_out,
- Strategy const& strategy)
- {
- typedef typename boost::range_value::type OneOut;
-
- intersection_insert
- <
- Geometry1, Geometry2, OneOut,
- overlay_intersection
- >::apply(geometry1, geometry2, robust_policy, std::back_inserter(geometry_out), strategy);
-
- return true;
- }
-
-};
-
-
-// If reversal is needed, perform it
-template
-<
- typename Geometry1, typename Geometry2,
- typename Tag1, typename Tag2
->
-struct intersection
-<
- Geometry1, Geometry2,
- Tag1, Tag2,
- true
->
- : intersection
-{
- template
- static inline bool apply(
- Geometry1 const& g1,
- Geometry2 const& g2,
- RobustPolicy const& robust_policy,
- GeometryOut& out,
- Strategy const& strategy)
- {
- return intersection<
- Geometry2, Geometry1,
- Tag2, Tag1,
- false
- >::apply(g2, g1, robust_policy, out, strategy);
- }
-};
-
-
-template
-<
- typename Box1, typename Box2, bool Reverse
->
-struct intersection
- <
- Box1, Box2,
- box_tag, box_tag,
- Reverse
- > : public detail::intersection::intersection_box_box
- <
- 0, geometry::dimension::value
- >
-{};
-
-
-} // namespace dispatch
-#endif // DOXYGEN_NO_DISPATCH
-
-
-namespace resolve_variant
-{
-
-template
-struct intersection
-{
- template
- static inline bool
- apply(
- const Geometry1& geometry1,
- const Geometry2& geometry2,
- GeometryOut& geometry_out)
- {
- concept::check();
- concept::check();
-
- typedef typename geometry::rescale_overlay_policy_type
- <
- Geometry1,
- Geometry2
- >::type rescale_policy_type;
-
- rescale_policy_type robust_policy
- = geometry::get_rescale_policy(geometry1, geometry2);
-
- typedef strategy_intersection
- <
- typename cs_tag::type,
- Geometry1,
- Geometry2,
- typename geometry::point_type::type,
- rescale_policy_type
- > strategy;
-
- return dispatch::intersection
- <
- Geometry1,
- Geometry2
- >::apply(geometry1, geometry2, robust_policy, geometry_out, strategy());
- }
-};
-
-
-template
-struct intersection, Geometry2>
-{
- template
- struct visitor: static_visitor
- {
- Geometry2 const& m_geometry2;
- GeometryOut& m_geometry_out;
-
- visitor(Geometry2 const& geometry2,
- GeometryOut& geometry_out)
- : m_geometry2(geometry2),
- m_geometry_out(geometry_out)
- {}
-
- template
- result_type operator()(Geometry1 const& geometry1) const
- {
- return intersection
- <
- Geometry1,
- Geometry2
- >::template apply
- <
- GeometryOut
- >
- (geometry1, m_geometry2, m_geometry_out);
- }
- };
-
- template
- static inline bool
- apply(variant const& geometry1,
- Geometry2 const& geometry2,
- GeometryOut& geometry_out)
- {
- return apply_visitor(visitor(geometry2, geometry_out), geometry1);
- }
-};
-
-
-template
-struct intersection >
-{
- template
- struct visitor: static_visitor
- {
- Geometry1 const& m_geometry1;
- GeometryOut& m_geometry_out;
-
- visitor(Geometry1 const& geometry1,
- GeometryOut& geometry_out)
- : m_geometry1(geometry1),
- m_geometry_out(geometry_out)
- {}
-
- template
- result_type operator()(Geometry2 const& geometry2) const
- {
- return intersection
- <
- Geometry1,
- Geometry2
- >::template apply
- <
- GeometryOut
- >
- (m_geometry1, geometry2, m_geometry_out);
- }
- };
-
- template
- static inline bool
- apply(
- Geometry1 const& geometry1,
- const variant& geometry2,
- GeometryOut& geometry_out)
- {
- return apply_visitor(visitor(geometry1, geometry_out), geometry2);
- }
-};
-
-
-template
-struct intersection, variant >
-{
- template
- struct visitor: static_visitor
- {
- GeometryOut& m_geometry_out;
-
- visitor(GeometryOut& geometry_out)
- : m_geometry_out(geometry_out)
- {}
-
- template
- result_type operator()(
- Geometry1 const& geometry1,
- Geometry2 const& geometry2) const
- {
- return intersection
- <
- Geometry1,
- Geometry2
- >::template apply
- <
- GeometryOut
- >
- (geometry1, geometry2, m_geometry_out);
- }
- };
-
- template
- static inline bool
- apply(
- const variant& geometry1,
- const variant& geometry2,
- GeometryOut& geometry_out)
- {
- return apply_visitor(visitor(geometry_out), geometry1, geometry2);
- }
-};
-
-} // namespace resolve_variant
-
-
-/*!
-\brief \brief_calc2{intersection}
-\ingroup intersection
-\details \details_calc2{intersection, spatial set theoretic intersection}.
-\tparam Geometry1 \tparam_geometry
-\tparam Geometry2 \tparam_geometry
-\tparam GeometryOut Collection of geometries (e.g. std::vector, std::deque, boost::geometry::multi*) of which
- the value_type fulfills a \p_l_or_c concept, or it is the output geometry (e.g. for a box)
-\param geometry1 \param_geometry
-\param geometry2 \param_geometry
-\param geometry_out The output geometry, either a multi_point, multi_polygon,
- multi_linestring, or a box (for intersection of two boxes)
-
-\qbk{[include reference/algorithms/intersection.qbk]}
-*/
-template
-<
- typename Geometry1,
- typename Geometry2,
- typename GeometryOut
->
-inline bool intersection(Geometry1 const& geometry1,
- Geometry2 const& geometry2,
- GeometryOut& geometry_out)
-{
- return resolve_variant::intersection
- <
- Geometry1,
- Geometry2
- >::template apply
- <
- GeometryOut
- >
- (geometry1, geometry2, geometry_out);
-}
-
-
-}} // namespace boost::geometry
+#include
+#include
#endif // BOOST_GEOMETRY_ALGORITHMS_INTERSECTION_HPP
diff --git a/include/boost/geometry/algorithms/num_interior_rings.hpp b/include/boost/geometry/algorithms/num_interior_rings.hpp
index e815f5981..034b918cb 100644
--- a/include/boost/geometry/algorithms/num_interior_rings.hpp
+++ b/include/boost/geometry/algorithms/num_interior_rings.hpp
@@ -4,6 +4,11 @@
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -54,6 +59,28 @@ struct num_interior_rings
};
+template
+struct num_interior_rings
+{
+ static inline std::size_t apply(MultiPolygon const& multi_polygon)
+ {
+ std::size_t n = 0;
+ for (typename boost::range_iterator::type
+ it = boost::begin(multi_polygon);
+ it != boost::end(multi_polygon);
+ ++it)
+ {
+ n += num_interior_rings
+ <
+ typename boost::range_value::type
+ >::apply(*it);
+ }
+ return n;
+ }
+
+};
+
+
} // namespace dispatch
#endif
diff --git a/include/boost/geometry/algorithms/num_segments.hpp b/include/boost/geometry/algorithms/num_segments.hpp
new file mode 100644
index 000000000..4f9d1257a
--- /dev/null
+++ b/include/boost/geometry/algorithms/num_segments.hpp
@@ -0,0 +1,262 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2014, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
+
+// Licensed under the Boost Software License version 1.0.
+// http://www.boost.org/users/license.html
+
+#ifndef BOOST_GEOMETRY_ALGORITHMS_NUM_SEGMENTS_HPP
+#define BOOST_GEOMETRY_ALGORITHMS_NUM_SEGMENTS_HPP
+
+#include
+
+#include
+
+#include
+#include
+#include
+
+#include