|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62170 - in sandbox/geometry: boost/geometry/algorithms boost/geometry/algorithms/detail/equals boost/geometry/core boost/geometry/extensions/algorithms boost/geometry/geometries boost/geometry/multi/algorithms boost/geometry/util libs/geometry libs/geometry/doc/overlay libs/geometry/doc/testcases libs/geometry/example libs/geometry/example/extensions libs/geometry/example/extensions/gis libs/geometry/test libs/geometry/test/algorithms libs/geometry/test/extensions/algorithms
From: barend.gehrels_at_[hidden]
Date: 2010-05-24 05:07:12
Author: barendgehrels
Date: 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
New Revision: 62170
URL: http://svn.boost.org/trac/boost/changeset/62170
Log:
Added closed / closure
Updated jamfiles
Added:
sandbox/geometry/boost/geometry/core/closure.hpp (contents, props changed)
sandbox/geometry/boost/geometry/util/closure_as_bool.hpp (contents, props changed)
Binary files modified:
sandbox/geometry/libs/geometry/doc/overlay/de9im_polygons.ppt
sandbox/geometry/libs/geometry/doc/overlay/intersection.ppt
sandbox/geometry/libs/geometry/doc/overlay/overlay.ppt
sandbox/geometry/libs/geometry/doc/overlay/overlay_spatial_set_operations.ppt
sandbox/geometry/libs/geometry/doc/testcases/assemble.ppt
sandbox/geometry/libs/geometry/doc/testcases/multi_overlay_cases.ppt
sandbox/geometry/libs/geometry/doc/testcases/overlay_cases.ppt
Text files modified:
sandbox/geometry/boost/geometry/algorithms/area.hpp | 46 ++
sandbox/geometry/boost/geometry/algorithms/correct.hpp | 1
sandbox/geometry/boost/geometry/algorithms/detail/equals/collect_vectors.hpp | 6
sandbox/geometry/boost/geometry/algorithms/length.hpp | 28 +
sandbox/geometry/boost/geometry/algorithms/perimeter.hpp | 10
sandbox/geometry/boost/geometry/core/point_order.hpp | 9
sandbox/geometry/boost/geometry/extensions/algorithms/connect.hpp | 495 +++++++++++++++++++++++++++++++--------
sandbox/geometry/boost/geometry/geometries/linear_ring.hpp | 15
sandbox/geometry/boost/geometry/geometries/polygon.hpp | 33 +-
sandbox/geometry/boost/geometry/multi/algorithms/area.hpp | 6
sandbox/geometry/boost/geometry/multi/algorithms/length.hpp | 3
sandbox/geometry/boost/geometry/util/closeable_view.hpp | 2
sandbox/geometry/boost/geometry/util/reversible_view.hpp | 2
sandbox/geometry/libs/geometry/Jamroot | 7
sandbox/geometry/libs/geometry/example/02_linestring_example.cpp | 27 ++
sandbox/geometry/libs/geometry/example/Jamfile.v2 | 12
sandbox/geometry/libs/geometry/example/c04_b_custom_triangle_example.cpp | 4
sandbox/geometry/libs/geometry/example/extensions/Jamfile.v2 | 2
sandbox/geometry/libs/geometry/example/extensions/gis/Jamfile.v2 | 2
sandbox/geometry/libs/geometry/test/Jamfile.v2 | 3
sandbox/geometry/libs/geometry/test/algorithms/Jamfile.v2 | 2
sandbox/geometry/libs/geometry/test/algorithms/area.cpp | 33 ++
sandbox/geometry/libs/geometry/test/algorithms/perimeter.cpp | 10
sandbox/geometry/libs/geometry/test/extensions/algorithms/connect.cpp | 72 ++++-
sandbox/geometry/libs/geometry/test/geometry_test_common.hpp | 2
25 files changed, 619 insertions(+), 213 deletions(-)
Modified: sandbox/geometry/boost/geometry/algorithms/area.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/area.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/area.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -15,9 +15,10 @@
#include <boost/range/metafunctions.hpp>
-#include <boost/geometry/core/point_order.hpp>
+#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/interior_rings.hpp>
+#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
@@ -30,8 +31,10 @@
#include <boost/geometry/strategies/concepts/area_concept.hpp>
+#include <boost/geometry/util/closure_as_bool.hpp>
#include <boost/geometry/util/math.hpp>
#include <boost/geometry/util/order_as_direction.hpp>
+#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/util/reversible_view.hpp>
@@ -87,7 +90,13 @@
};
-template<typename Ring, iterate_direction Direction, typename Strategy>
+template
+<
+ typename Ring,
+ iterate_direction Direction,
+ closure_selector Closure,
+ typename Strategy
+>
struct ring_area
{
BOOST_CONCEPT_ASSERT( (geometry::concept::AreaStrategy<Strategy>) );
@@ -108,16 +117,24 @@
return type();
}
- typedef reversible_view<Ring const, Direction> view_type;
+
+ typedef reversible_view<Ring const, Direction> rview_type;
+ typedef closeable_view
+ <
+ rview_type const,
+ Closure == closed
+ > view_type;
typedef typename boost::range_iterator<view_type const>::type iterator_type;
- view_type view(ring);
+ rview_type rview(ring);
+ view_type view(rview);
typename Strategy::state_type state;
iterator_type it = boost::begin(view);
+ iterator_type end = boost::end(view);
for (iterator_type previous = it++;
- it != boost::end(view);
- previous = it++)
+ it != end;
+ ++previous, ++it)
{
strategy.apply(*previous, *it, state);
}
@@ -143,6 +160,7 @@
typename Tag,
typename Geometry,
order_selector Order,
+ closure_selector Closure,
typename Strategy
>
struct area
@@ -154,25 +172,26 @@
> {};
-template <typename Geometry, order_selector Order, typename Strategy>
-struct area<box_tag, Geometry, Order, Strategy>
+template <typename Geometry, order_selector Order, closure_selector Closure, typename Strategy>
+struct area<box_tag, Geometry, Order, Closure, Strategy>
: detail::area::box_area<Geometry, Strategy>
{};
-template <typename Geometry, order_selector Order, typename Strategy>
-struct area<ring_tag, Geometry, Order, Strategy>
+template <typename Geometry, order_selector Order, closure_selector Closure, typename Strategy>
+struct area<ring_tag, Geometry, Order, Closure, Strategy>
: detail::area::ring_area
<
Geometry,
order_as_direction<Order>::value,
+ Closure, //closure_as_bool<Closure>::value,
Strategy
>
{};
-template <typename Polygon, order_selector Order, typename Strategy>
-struct area<polygon_tag, Polygon, Order, Strategy>
+template <typename Polygon, order_selector Order, closure_selector Closure, typename Strategy>
+struct area<polygon_tag, Polygon, Order, Closure, Strategy>
: detail::calculate_polygon_sum
<
typename Strategy::return_type,
@@ -182,6 +201,7 @@
<
typename ring_type<Polygon>::type,
order_as_direction<Order>::value,
+ Closure, //closure_as_bool<Closure>::value,
Strategy
>
>
@@ -216,6 +236,7 @@
typename tag<Geometry>::type,
Geometry,
geometry::point_order<Geometry>::value,
+ geometry::closure<Geometry>::value,
strategy_type
>::apply(geometry, strategy_type());
}
@@ -240,6 +261,7 @@
typename tag<Geometry>::type,
Geometry,
geometry::point_order<Geometry>::value,
+ geometry::closure<Geometry>::value,
Strategy
>::apply(geometry, strategy);
}
Modified: sandbox/geometry/boost/geometry/algorithms/correct.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/correct.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/correct.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -103,6 +103,7 @@
<
Ring,
order_as_direction<geometry::point_order<Ring>::value>::value,
+ geometry::closure<Ring>::value,
strategy_type
> ring_area_type;
Modified: sandbox/geometry/boost/geometry/algorithms/detail/equals/collect_vectors.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/detail/equals/collect_vectors.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/detail/equals/collect_vectors.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -43,10 +43,14 @@
, y(py)
, dx(pdx)
, dy(pdy)
+ , dx_0(T())
+ , dy_0(T())
{}
T x, y;
T dx, dy;
+ T dx_0, dy_0;
+
bool collinear;
bool operator<(collected_vector<T> const& other) const
@@ -114,6 +118,8 @@
v.y = get<1>(*prev);
v.dx = get<0>(*it) - v.x;
v.dy = get<1>(*it) - v.y;
+ v.dx_0 = v.dx;
+ v.dy_0 = v.dy;
// Normalize the vector -> this results in points+direction
// and is comparible between geometries
Modified: sandbox/geometry/boost/geometry/algorithms/length.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/length.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/length.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -16,14 +16,13 @@
#include <boost/mpl/if.hpp>
#include <boost/type_traits.hpp>
-
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
#include <boost/geometry/algorithms/assign.hpp>
#include <boost/geometry/algorithms/detail/calculate_null.hpp>
-
+#include <boost/geometry/util/closeable_view.hpp>
#include <boost/geometry/strategies/distance.hpp>
#include <boost/geometry/strategies/length_result.hpp>
@@ -71,7 +70,7 @@
\note for_each could be used here, now that point_type is changed by boost
range iterator
*/
-template<typename Range, typename Strategy>
+template<typename Range, typename Strategy, bool Close>
struct range_length
{
typedef typename length_result<Range>::type return_type;
@@ -79,19 +78,24 @@
static inline return_type apply(
Range const& range, Strategy const& strategy)
{
- return_type sum = return_type();
+ typedef closeable_view<Range const, Close> view_type;
+ typedef typename boost::range_iterator
+ <
+ view_type const
+ >::type iterator_type;
- typedef typename boost::range_iterator<Range const>::type iterator_type;
- iterator_type it = boost::begin(range);
- if (it != boost::end(range))
+ return_type sum = return_type();
+ view_type view(range);
+ iterator_type it = boost::begin(view), end = boost::end(view);
+ if(it != end)
{
- iterator_type previous = it++;
- while(it != boost::end(range))
+ for(iterator_type previous = it++;
+ it != end;
+ ++previous, ++it)
{
// Add point-point distance using the return type belonging
// to strategy
sum += strategy.apply(*previous, *it);
- previous = it++;
}
}
@@ -99,9 +103,11 @@
}
};
+
}} // namespace detail::length
#endif // DOXYGEN_NO_DETAIL
+
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
@@ -119,7 +125,7 @@
template <typename Geometry, typename Strategy>
struct length<linestring_tag, Geometry, Strategy>
- : detail::length::range_length<Geometry, Strategy>
+ : detail::length::range_length<Geometry, Strategy, false>
{};
Modified: sandbox/geometry/boost/geometry/algorithms/perimeter.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/algorithms/perimeter.hpp (original)
+++ sandbox/geometry/boost/geometry/algorithms/perimeter.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -11,11 +11,9 @@
#include <boost/geometry/core/cs.hpp>
-
+#include <boost/geometry/core/closure.hpp>
#include <boost/geometry/geometries/concepts/check.hpp>
-
#include <boost/geometry/strategies/length_result.hpp>
-
#include <boost/geometry/algorithms/length.hpp>
#include <boost/geometry/algorithms/detail/calculate_null.hpp>
#include <boost/geometry/algorithms/detail/calculate_sum.hpp>
@@ -49,7 +47,8 @@
template <typename Geometry, typename Strategy>
struct perimeter<ring_tag, Geometry, Strategy>
- : detail::length::range_length<Geometry, Strategy>
+ : detail::length::range_length<Geometry, Strategy,
+ closure<Geometry>::value == closed>
{};
template <typename Polygon, typename Strategy>
@@ -62,7 +61,8 @@
detail::length::range_length
<
typename ring_type<Polygon>::type,
- Strategy
+ Strategy,
+ closure<Polygon>::value == closed
>
>
{};
Added: sandbox/geometry/boost/geometry/core/closure.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/core/closure.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -0,0 +1,98 @@
+// 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_CORE_CLOSURE_HPP
+#define BOOST_GEOMETRY_CORE_CLOSURE_HPP
+
+
+#include <boost/range.hpp>
+#include <boost/type_traits/remove_const.hpp>
+
+#include <boost/geometry/core/ring_type.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+namespace boost { namespace geometry
+{
+
+
+enum closure_selector { open = 0, closed = 1, closure_undertermined = -1 };
+
+namespace traits
+{
+
+/*!
+ \brief Traits class indicating if points within a
+ ring or (multi)polygon are closed (last point == first point),
+ open or not known.
+ \ingroup traits
+ \par Geometries:
+ - ring
+ \tparam G geometry
+*/
+template <typename G>
+struct closure
+{
+ static const closure_selector value = closed;
+};
+
+
+} // namespace traits
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct closure
+{
+ static const closure_selector value = closed;
+};
+
+
+template <typename Ring>
+struct closure<ring_tag, Ring>
+{
+ static const closure_selector value = geometry::traits::closure<Ring>::value;
+};
+
+// Specialization for polygon: the closure is the closure of its rings
+template <typename Polygon>
+struct closure<polygon_tag, Polygon>
+{
+ static const closure_selector value = core_dispatch::closure
+ <
+ ring_tag,
+ typename ring_type<polygon_tag, Polygon>::type
+ >::value ;
+};
+
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+ \brief Meta-function which defines closure of any geometry
+ \ingroup core
+*/
+template <typename Geometry>
+struct closure
+{
+ static const closure_selector value = core_dispatch::closure
+ <
+ typename tag<Geometry>::type,
+ typename boost::remove_const<Geometry>::type
+ >::value;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_CLOSURE_HPP
Modified: sandbox/geometry/boost/geometry/core/point_order.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/core/point_order.hpp (original)
+++ sandbox/geometry/boost/geometry/core/point_order.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -31,10 +31,6 @@
\ingroup traits
\par Geometries:
- ring
- - polygon
- - multi polygon
- \par Specializations should provide:
- - typedef P type (where P should fulfil the Point concept)
\tparam G geometry
*/
template <typename G>
@@ -81,17 +77,16 @@
/*!
- \brief Meta-function which defines point type of any geometry
+ \brief Meta-function which defines point order of any geometry
\ingroup core
*/
template <typename Geometry>
struct point_order
{
- typedef typename boost::remove_const<Geometry>::type ncg;
static const order_selector value = core_dispatch::point_order
<
typename tag<Geometry>::type,
- ncg
+ typename boost::remove_const<Geometry>::type
>::value;
};
Modified: sandbox/geometry/boost/geometry/extensions/algorithms/connect.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/extensions/algorithms/connect.hpp (original)
+++ sandbox/geometry/boost/geometry/extensions/algorithms/connect.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -21,6 +21,8 @@
#include <boost/geometry/geometries/concepts/check.hpp>
+#include <boost/geometry/util/write_dsv.hpp>
+
namespace boost { namespace geometry
@@ -31,65 +33,195 @@
namespace detail { namespace connect
{
-// Dissolve on multi_linestring tries to create larger linestrings from input,
-// or closed rings.
-template <typename Multi, typename GeometryOut>
-struct connect_multi_linestring
+template <typename Point>
+struct node
{
- typedef typename point_type<Multi>::type point_type;
- typedef typename boost::range_iterator<Multi const>::type iterator_type;
- typedef typename boost::range_value<Multi>::type linestring_type;
- typedef typename distance_result<point_type>::type distance_result_type;
+ Point point;
+ int index;
+ bool is_from;
+
+ node(int i, bool f, Point const& p)
+ : index(i)
+ , is_from(f)
+ , point(p)
+ {}
+
+ node()
+ : index(-1)
+ , is_from(false)
+ {}
+};
- struct mapped
- {
- int index;
- bool is_from;
- mapped(int i, bool f) : index(i), is_from(f)
- {}
- };
+template <typename Point>
+struct map_policy
+{
// Have a map<point, <index,start/end> > such that we can find
// the corresponding point on each end. Note that it uses the
// default "equals" for the point-type
- typedef std::multimap
+ typedef std::map
<
- point_type,
- mapped,
- boost::geometry::less<point_type>
+ Point,
+ std::vector<node<Point> >,
+ boost::geometry::less<Point>
> map_type;
typedef typename map_type::const_iterator map_iterator_type;
+ typedef typename std::vector<node<Point> >::const_iterator vector_iterator_type;
- static inline void copy(linestring_type const& ls,
- GeometryOut& target,
- bool copy_forward)
+ typedef Point point_type;
+ typedef typename distance_result<Point>::type distance_result_type;
+
+
+ map_type map;
+
+
+ inline bool find_start(node<Point>& object,
+ std::map<int, bool>& included,
+ int expected_count = 1)
{
- if (copy_forward)
+ for (map_iterator_type it = map.begin();
+ it != map.end();
+ ++it)
{
- std::copy(boost::begin(ls), boost::end(ls),
- std::back_inserter(target));
+ if ((expected_count == 1 && boost::size(it->second) == 1)
+ || (expected_count > 1 && boost::size(it->second) > 1))
+ {
+ for (vector_iterator_type vit = it->second.begin();
+ vit != it->second.end();
+ ++vit)
+ {
+ if (! included[vit->index])
+ {
+ included[vit->index] = true;
+ object = *vit;
+ return true;
+ }
+ }
+ }
}
- else
+
+ // Not found with one point, try one with two points
+ // to find rings
+ if (expected_count == 1)
{
- std::reverse_copy(boost::begin(ls), boost::end(ls),
- std::back_inserter(target));
+ return find_start(object, included, 2);
}
+
+ return false;
}
- static inline map_iterator_type find_start(map_type const& map,
- std::map<int, bool>& included, int expected_count = 1)
+ inline void add(int index, Point const& p, bool is_from)
+ {
+ map[p].push_back(node<Point>(index, is_from, p));
+ }
+
+
+ template <typename LineString>
+ inline void add(int index, LineString const& ls)
+ {
+ if (boost::size(ls) > 0)
+ {
+ add(index, *boost::begin(ls), true);
+ add(index, *(boost::end(ls) - 1), false);
+ }
+ }
+
+ inline node<Point> find_closest(Point const& p1, std::map<int, bool>& included)
+ {
+ std::vector<node<Point> > const& range = map[p1];
+
+ node<Point> closest;
+
+
+ // Alternatively, we might look for the closest points
+ if (boost::size(range) == 0)
+ {
+ std::cout << "nothing found" << std::endl;
+ return closest;
+ }
+
+ // 2c: for all candidates get closest one
+
+ // TODO: make utility to initalize distance result with large value
+ distance_result_type min_dist
+ = make_distance_result<distance_result_type>(100);
+ for (vector_iterator_type it = boost::begin(range);
+ it != boost::end(range);
+ ++it)
+ {
+ if (! included[it->index])
+ {
+ distance_result_type d = geometry::distance(p1, it->point);
+ if (d < min_dist)
+ {
+ closest = *it;
+ min_dist = d;
+
+ //std::cout << "TO " << geometry::wkt(p2) << std::endl;
+ }
+ }
+ }
+ return closest;
+ }
+
+};
+
+
+template <typename Point>
+struct fuzzy_policy
+{
+
+ // Have a map<point, <index,start/end> > such that we can find
+ // the corresponding point on each end. Note that it uses the
+ // default "equals" for the point-type
+ typedef std::vector
+ <
+ std::pair
+ <
+ Point,
+ std::vector<node<Point> >
+ >
+ > map_type;
+
+ typedef typename map_type::const_iterator map_iterator_type;
+ typedef typename std::vector<node<Point> >::const_iterator vector_iterator_type;
+
+ typedef Point point_type;
+ typedef typename distance_result<Point>::type distance_result_type;
+
+
+ map_type map;
+ typename coordinate_type<Point>::type m_limit;
+
+
+ fuzzy_policy(typename coordinate_type<Point>::type limit)
+ : m_limit(limit)
+ {}
+
+ inline bool find_start(node<Point>& object,
+ std::map<int, bool>& included,
+ int expected_count = 1)
{
for (map_iterator_type it = map.begin();
it != map.end();
++it)
{
- typename map_type::size_type count = map.count(it->first);
- if (count == expected_count && ! included[it->second.index])
+ if ((expected_count == 1 && boost::size(it->second) == 1)
+ || (expected_count > 1 && boost::size(it->second) > 1))
{
- included[it->second.index] = true;
- return it;
+ for (vector_iterator_type vit = it->second.begin();
+ vit != it->second.end();
+ ++vit)
+ {
+ if (! included[vit->index])
+ {
+ included[vit->index] = true;
+ object = *vit;
+ return true;
+ }
+ }
}
}
@@ -97,118 +229,228 @@
// to find rings
if (expected_count == 1)
{
- return find_start(map, included, 2);
+ return find_start(object, included, 2);
}
- return map.end();
+ return false;
}
+ inline typename boost::range_iterator<map_type>::type fuzzy_closest(Point const& p)
+ {
+ typename boost::range_iterator<map_type>::type closest = boost::end(map);
+
+ for (typename boost::range_iterator<map_type>::type it = boost::begin(map);
+ it != boost::end(map);
+ ++it)
+ {
+ distance_result_type d = geometry::distance(p, it->first);
+ if (d < m_limit)
+ {
+ if (closest == boost::end(map))
+ {
+ closest = it;
+ }
+ else
+ {
+ distance_result_type dc = geometry::distance(p, closest->first);
+ if (d < dc)
+ {
+ closest = it;
+ }
+ }
+ }
+ }
+ return closest;
+ }
+
+
+ inline void add(int index, Point const& p, bool is_from)
+ {
+ // Iterate through all points and get the closest one.
+ typename boost::range_iterator<map_type>::type it = fuzzy_closest(p);
+ if (it == map.end())
+ {
+ map.resize(map.size() + 1);
+ map.back().first = p;
+ it = map.end() - 1;
+ }
+ it->second.push_back(node<Point>(index, is_from, p));
+ }
+
+
+ template <typename LineString>
+ inline void add(int index, LineString const& ls)
+ {
+ if (boost::size(ls) > 0)
+ {
+ add(index, *boost::begin(ls), true);
+ add(index, *(boost::end(ls) - 1), false);
+ }
+ }
+
+ inline node<Point> find_closest(Point const& p1, std::map<int, bool>& included)
+ {
+ node<Point> closest;
+
+ typename boost::range_iterator<map_type>::type it = fuzzy_closest(p1);
+ if (it == map.end())
+ {
+ return closest;
+ }
+
+ std::vector<node<Point> > const& range = it->second;
+
+
+
+ // Alternatively, we might look for the closest points
+ if (boost::size(range) == 0)
+ {
+ std::cout << "nothing found" << std::endl;
+ return closest;
+ }
+
+ // 2c: for all candidates get closest one
+
+ // TODO: make utility to initalize distance result with large value
+ distance_result_type min_dist
+ = make_distance_result<distance_result_type>(100);
+ for (vector_iterator_type it = boost::begin(range);
+ it != boost::end(range);
+ ++it)
+ {
+ if (! included[it->index])
+ {
+ distance_result_type d = geometry::distance(p1, it->point);
+ if (d < min_dist)
+ {
+ closest = *it;
+ min_dist = d;
+
+ //std::cout << "TO " << geometry::wkt(p2) << std::endl;
+ }
+ }
+ }
+ return closest;
+ }
+};
+
+template <typename Policy>
+inline void debug(Policy const& policy)
+{
+ std::cout << "MAP" << std::endl;
+ typedef typename Policy::map_type::const_iterator iterator;
+ typedef typename Policy::point_type point_type;
+
+ for (iterator it=policy.map.begin(); it != policy.map.end(); ++it)
+ {
+ std::cout << geometry::dsv(it->first) << " => " ;
+ std::vector<node<point_type> > const& range =it->second;
+ for ( std::vector<node<point_type> >::const_iterator
+ vit = boost::begin(range); vit != boost::end(range); ++vit)
+ {
+ std::cout
+ << " (" << vit->index
+ << ", " << (vit->is_from ? "F" : "T")
+ << ")"
+ ;
+ }
+ std::cout << std::endl;
+ }
+}
+
+
+
+
+// Dissolve on multi_linestring tries to create larger linestrings from input,
+// or closed rings.
+
+template <typename Multi, typename GeometryOut, typename Policy>
+struct connect_multi_linestring
+{
+ typedef typename point_type<Multi>::type point_type;
+ typedef typename boost::range_iterator<Multi const>::type iterator_type;
+ typedef typename boost::range_value<Multi>::type linestring_type;
+
+
+ static inline void copy(linestring_type const& ls,
+ GeometryOut& target,
+ bool copy_forward)
+ {
+ if (copy_forward)
+ {
+ std::copy(boost::begin(ls), boost::end(ls),
+ std::back_inserter(target));
+ }
+ else
+ {
+ std::reverse_copy(boost::begin(ls), boost::end(ls),
+ std::back_inserter(target));
+ }
+ }
+
+
template <typename OutputIterator>
- static inline OutputIterator apply(Multi const& multi, OutputIterator out)
+ static inline OutputIterator apply(Multi const& multi, Policy& policy, OutputIterator out)
{
if (boost::size(multi) <= 0)
{
return out;
}
- map_type map;
-
// 1: fill the map.
int index = 0;
for (iterator_type it = boost::begin(multi);
it != boost::end(multi);
++it, ++index)
{
- linestring_type const& ls = *it;
- if (boost::size(ls) > 0)
- {
- map.insert(std::make_pair(*boost::begin(ls), mapped(index, true)));
- map.insert(std::make_pair(*(boost::end(ls) - 1), mapped(index, false)));
- }
+ policy.add(index, *it);
}
+ debug(policy);
+
std::map<int, bool> included;
// 2: connect the lines
// 2a: start with one having a unique starting point
- map_iterator_type first = find_start(map, included);
- bool found = first != map.end();
- if (! found)
+ node<point_type> starting_point;
+ if (! policy.find_start(starting_point, included))
{
return out;
}
- int current_index = first->second.index;
GeometryOut current;
- copy(multi[current_index], current, first->second.is_from);
+ copy(multi[starting_point.index], current, starting_point.is_from);
+ bool found = true;
while(found)
{
// 2b: get all candidates, by asking multi-map for range
- point_type const& p = *(boost::end(current) - 1);
- std::pair<map_iterator_type, map_iterator_type> range
- = map.equal_range(p);
+ point_type const& p1 = *(boost::end(current) - 1);
- // Alternatively, we might look for the closest points
- if (range.first == map.end())
- {
- std::cout << "nothing found" << std::endl;
- }
+ node<point_type> closest = policy.find_closest(p1, included);
- // 2c: for all candidates get closest one
found = false;
- int closest_index = -1;
- bool from_is_closest = false;
- // TODO: make utility to initalize distance result with large value
- distance_result_type min_dist
- = make_distance_result<distance_result_type>(100);
- for (map_iterator_type it = range.first;
- ! found && it != range.second;
- ++it)
- {
- if (it->second.index != current_index
- && ! included[it->second.index])
- {
- linestring_type const& ls = multi[it->second.index];
- point_type const& p = it->second.is_from
- ? *boost::begin(ls)
- : *(boost::end(ls) - 1);
-
- distance_result_type d = geometry::distance(it->first, p);
- if (! found || d < min_dist)
- {
- closest_index = it->second.index;
- from_is_closest = it->second.is_from;
- min_dist = d;
- //std::cout << "TO " << geometry::wkt(p) << std::endl;
- }
- found = true;
- }
- }
// 2d: if there is a closest one add it
- if (found && closest_index >= 0)
+ if (closest.index >= 0)
{
- current_index = closest_index;
- included[current_index] = true;
- copy(multi[current_index], current, from_is_closest);
+ found = true;
+ included[closest.index] = true;
+ copy(multi[closest.index], current, closest.is_from);
}
-
- if (! found && (included.size() != boost::size(multi)))
+ else if ((included.size() != boost::size(multi)))
{
// Get one which is NOT found and go again
- map_iterator_type next = find_start(map, included);
- found = next != map.end();
-
- if (found)
+ node<point_type> next;
+ if (policy.find_start(next, included))
{
- current_index = next->second.index;
+ found = true;
*out++ = current;
geometry::clear(current);
- copy(multi[current_index], current, next->second.is_from);
+ copy(multi[next.index], current, next.is_from);
}
}
}
@@ -235,15 +477,21 @@
typename GeometryTag,
typename GeometryOutTag,
typename Geometry,
- typename GeometryOut
+ typename GeometryOut,
+ typename Policy
>
struct connect
{};
-template<typename Multi, typename GeometryOut>
-struct connect<multi_linestring_tag, linestring_tag, Multi, GeometryOut>
- : detail::connect::connect_multi_linestring<Multi, GeometryOut>
+template<typename Multi, typename GeometryOut, typename Policy>
+struct connect<multi_linestring_tag, linestring_tag, Multi, GeometryOut, Policy>
+ : detail::connect::connect_multi_linestring
+ <
+ Multi,
+ GeometryOut,
+ Policy
+ >
{};
@@ -258,22 +506,59 @@
>
inline void connect(Geometry const& geometry, Collection& output_collection)
{
+ typedef typename boost::range_value<Collection>::type geometry_out;
+
concept::check<Geometry const>();
+ concept::check<geometry_out>();
+
+ typedef detail::connect::map_policy
+ <
+ typename point_type<Geometry>::type
+ > policy;
+
+ dispatch::connect
+ <
+ typename tag<Geometry>::type,
+ typename tag<geometry_out>::type,
+ Geometry,
+ geometry_out,
+ policy
+ >::apply(geometry, policy(), std::back_inserter(output_collection));
+}
+
+
+template
+<
+ typename Geometry,
+ typename Collection
+>
+inline void connect(Geometry const& geometry, Collection& output_collection,
+ typename coordinate_type<Geometry>::type const& limit)
+{
typedef typename boost::range_value<Collection>::type geometry_out;
+ concept::check<Geometry const>();
concept::check<geometry_out>();
+ typedef detail::connect::fuzzy_policy
+ <
+ typename point_type<Geometry>::type
+ > policy;
+
+
dispatch::connect
<
typename tag<Geometry>::type,
typename tag<geometry_out>::type,
Geometry,
- geometry_out
- >::apply(geometry, std::back_inserter(output_collection));
+ geometry_out,
+ policy
+ >::apply(geometry, policy(limit), std::back_inserter(output_collection));
}
+
}} // namespace boost::geometry
Modified: sandbox/geometry/boost/geometry/geometries/linear_ring.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/linear_ring.hpp (original)
+++ sandbox/geometry/boost/geometry/geometries/linear_ring.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -14,9 +14,10 @@
#include <boost/concept/assert.hpp>
+#include <boost/geometry/core/closure.hpp>
+#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
-#include <boost/geometry/core/point_order.hpp>
#include <boost/geometry/geometries/concepts/point_concept.hpp>
@@ -35,7 +36,7 @@
<
typename P,
template<typename, typename> class V = std::vector,
- bool ClockWise = true,
+ bool ClockWise = true, bool Closed = true,
template<typename> class A = std::allocator
>
class linear_ring : public V<P, A<P> >
@@ -51,10 +52,10 @@
<
typename P,
template<typename, typename> class V,
- bool ClockWise,
+ bool ClockWise, bool Closed,
template<typename> class A
>
-struct tag< linear_ring<P, V, ClockWise, A> >
+struct tag< linear_ring<P, V, ClockWise, Closed, A> >
{
typedef ring_tag type;
};
@@ -64,9 +65,10 @@
<
typename P,
template<typename, typename> class V,
+ bool Closed,
template<typename> class A
>
-struct point_order< linear_ring<P, V, false, A> >
+struct point_order< linear_ring<P, V, false, Closed, A> >
{
static const order_selector value = counterclockwise;
};
@@ -76,9 +78,10 @@
<
typename P,
template<typename, typename> class V,
+ bool Closed,
template<typename> class A
>
-struct point_order< linear_ring<P, V, true, A> >
+struct point_order< linear_ring<P, V, true, Closed, A> >
{
static const order_selector value = clockwise;
};
Modified: sandbox/geometry/boost/geometry/geometries/polygon.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/geometries/polygon.hpp (original)
+++ sandbox/geometry/boost/geometry/geometries/polygon.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -34,6 +34,8 @@
for example std::vector, std::list, std::deque
\tparam ClockWise optional parameter, true for clockwise direction,
false for CounterClockWise direction
+ \tparam Closed optional parameter, true for closed polygons (last point == first point),
+ false open points
\tparam PointAlloc container-allocator-type
\tparam RingAlloc container-allocator-type
\note The container collecting the points in the rings can be different
@@ -45,6 +47,7 @@
template<typename, typename> class PointList = std::vector,
template<typename, typename> class RingList = std::vector,
bool ClockWise = true,
+ bool Closed = true,
template<typename> class PointAlloc = std::allocator,
template<typename> class RingAlloc = std::allocator
>
@@ -56,7 +59,7 @@
// Member types
typedef Point point_type;
- typedef linear_ring<Point, PointList, ClockWise, PointAlloc> ring_type;
+ typedef linear_ring<Point, PointList, ClockWise, Closed, PointAlloc> ring_type;
typedef RingList<ring_type , RingAlloc<ring_type > > inner_container_type;
inline ring_type const& outer() const { return m_outer; }
@@ -88,11 +91,11 @@
typename Point,
template<typename, typename> class PointList,
template<typename, typename> class RingList,
- bool ClockWise,
+ bool ClockWise, bool Closed,
template<typename> class PointAlloc,
template<typename> class RingAlloc
>
-struct tag<polygon<Point, PointList, RingList, ClockWise, PointAlloc, RingAlloc> >
+struct tag<polygon<Point, PointList, RingList, ClockWise, Closed, PointAlloc, RingAlloc> >
{
typedef polygon_tag type;
};
@@ -102,15 +105,15 @@
typename Point,
template<typename, typename> class PointList,
template<typename, typename> class RingList,
- bool ClockWise,
+ bool ClockWise, bool Closed,
template<typename> class PointAlloc,
template<typename> class RingAlloc
>
-struct ring_type<polygon<Point, PointList, RingList, ClockWise, PointAlloc, RingAlloc> >
+struct ring_type<polygon<Point, PointList, RingList, ClockWise, Closed, PointAlloc, RingAlloc> >
{
typedef typename polygon
<
- Point, PointList, RingList, ClockWise, PointAlloc, RingAlloc
+ Point, PointList, RingList, ClockWise, Closed, PointAlloc, RingAlloc
>::ring_type type;
};
@@ -119,15 +122,15 @@
typename Point,
template<typename, typename> class PointList,
template<typename, typename> class RingList,
- bool ClockWise,
+ bool ClockWise, bool Closed,
template<typename> class PointAlloc,
template<typename> class RingAlloc
>
-struct interior_type< polygon<Point, PointList, RingList, ClockWise, PointAlloc, RingAlloc> >
+struct interior_type< polygon<Point, PointList, RingList, ClockWise, Closed, PointAlloc, RingAlloc> >
{
typedef typename polygon
<
- Point, PointList, RingList, ClockWise, PointAlloc, RingAlloc
+ Point, PointList, RingList, ClockWise, Closed, PointAlloc, RingAlloc
>::inner_container_type type;
};
@@ -136,13 +139,13 @@
typename Point,
template<typename, typename> class PointList,
template<typename, typename> class RingList,
- bool ClockWise,
+ bool ClockWise, bool Closed,
template<typename> class PointAlloc,
template<typename> class RingAlloc
>
-struct exterior_ring< polygon<Point, PointList, RingList, ClockWise, PointAlloc, RingAlloc> >
+struct exterior_ring< polygon<Point, PointList, RingList, ClockWise, Closed, PointAlloc, RingAlloc> >
{
- typedef polygon<Point, PointList, RingList, ClockWise, PointAlloc, RingAlloc> polygon_type;
+ typedef polygon<Point, PointList, RingList, ClockWise, Closed, PointAlloc, RingAlloc> polygon_type;
static inline typename polygon_type::ring_type& get(polygon_type& p)
{
@@ -160,13 +163,13 @@
typename Point,
template<typename, typename> class PointList,
template<typename, typename> class RingList,
- bool ClockWise,
+ bool ClockWise, bool Closed,
template<typename> class PointAlloc,
template<typename> class RingAlloc
>
-struct interior_rings< polygon<Point, PointList, RingList, ClockWise, PointAlloc, RingAlloc> >
+struct interior_rings< polygon<Point, PointList, RingList, ClockWise, Closed, PointAlloc, RingAlloc> >
{
- typedef polygon<Point, PointList, RingList, ClockWise, PointAlloc, RingAlloc> polygon_type;
+ typedef polygon<Point, PointList, RingList, ClockWise, Closed, PointAlloc, RingAlloc> polygon_type;
static inline typename polygon_type::inner_container_type& get(
polygon_type& p)
Modified: sandbox/geometry/boost/geometry/multi/algorithms/area.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/algorithms/area.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/algorithms/area.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -24,8 +24,8 @@
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
-template <typename MultiGeometry, order_selector Order, typename Strategy>
-struct area<multi_polygon_tag, MultiGeometry, Order, Strategy>
+template <typename MultiGeometry, order_selector Order, closure_selector Closure, typename Strategy>
+struct area<multi_polygon_tag, MultiGeometry, Order, Closure, Strategy>
: detail::multi_sum
<
typename Strategy::return_type,
@@ -35,7 +35,7 @@
<
polygon_tag,
typename boost::range_value<MultiGeometry>::type,
- Order,
+ Order, Closure,
Strategy
>
>
Modified: sandbox/geometry/boost/geometry/multi/algorithms/length.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/multi/algorithms/length.hpp (original)
+++ sandbox/geometry/boost/geometry/multi/algorithms/length.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -33,7 +33,8 @@
detail::length::range_length
<
typename boost::range_value<MultiLinestring>::type,
- Strategy
+ Strategy,
+ false
>
>
{};
Modified: sandbox/geometry/boost/geometry/util/closeable_view.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/util/closeable_view.hpp (original)
+++ sandbox/geometry/boost/geometry/util/closeable_view.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -50,7 +50,7 @@
template <typename Range>
struct closeable_view<Range, true>
{
- closeable_view(Range& r)
+ explicit closeable_view(Range& r)
: m_range(r)
{}
Added: sandbox/geometry/boost/geometry/util/closure_as_bool.hpp
==============================================================================
--- (empty file)
+++ sandbox/geometry/boost/geometry/util/closure_as_bool.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -0,0 +1,40 @@
+// 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_UTIL_CLOSURE_AS_BOOL_HPP
+#define BOOST_GEOMETRY_UTIL_CLOSURE_AS_BOOL_HPP
+
+#include <boost/geometry/core/closure.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+
+template<closure_selector Closure>
+struct closure_as_bool
+{};
+
+
+template<>
+struct closure_as_bool<closed>
+{
+ static const bool value = true;
+};
+
+
+template<>
+struct closure_as_bool<open>
+{
+ static const bool value = false;
+};
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_UTIL_CLOSURE_AS_BOOL_HPP
Modified: sandbox/geometry/boost/geometry/util/reversible_view.hpp
==============================================================================
--- sandbox/geometry/boost/geometry/util/reversible_view.hpp (original)
+++ sandbox/geometry/boost/geometry/util/reversible_view.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -30,7 +30,7 @@
template <typename Range>
struct reversible_view<Range, iterate_forward>
{
- reversible_view(Range& r)
+ explicit reversible_view(Range& r)
: m_range(r)
{}
Modified: sandbox/geometry/libs/geometry/Jamroot
==============================================================================
--- sandbox/geometry/libs/geometry/Jamroot (original)
+++ sandbox/geometry/libs/geometry/Jamroot 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -10,10 +10,9 @@
project
: requirements
- <warnings>all
- <toolset>intel:<warnings>on
+ <toolset>msvc
+ <define>_SCL_SECURE_NO_DEPRECATE # For Ublas
<toolset>gcc:<cxxflags>"-pedantic -Wall -Wstrict-aliasing -fstrict-aliasing -Wno-long-long"
<include>../..
- <include>.
- <include>/boost//headers
+ <dependency>/boost//headers
;
Modified: sandbox/geometry/libs/geometry/doc/overlay/de9im_polygons.ppt
==============================================================================
Binary files. No diff available.
Modified: sandbox/geometry/libs/geometry/doc/overlay/intersection.ppt
==============================================================================
Binary files. No diff available.
Modified: sandbox/geometry/libs/geometry/doc/overlay/overlay.ppt
==============================================================================
Binary files. No diff available.
Modified: sandbox/geometry/libs/geometry/doc/overlay/overlay_spatial_set_operations.ppt
==============================================================================
Binary files. No diff available.
Modified: sandbox/geometry/libs/geometry/doc/testcases/assemble.ppt
==============================================================================
Binary files. No diff available.
Modified: sandbox/geometry/libs/geometry/doc/testcases/multi_overlay_cases.ppt
==============================================================================
Binary files. No diff available.
Modified: sandbox/geometry/libs/geometry/doc/testcases/overlay_cases.ppt
==============================================================================
Binary files. No diff available.
Modified: sandbox/geometry/libs/geometry/example/02_linestring_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/02_linestring_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/02_linestring_example.cpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -38,6 +38,33 @@
}
};
+
+template<typename Point>
+struct round_coordinates
+{
+ typedef typename boost::geometry::coordinate_type<Point>::type coordinate_type;
+ coordinate_type m_factor;
+
+ inline round_coordinates(coordinate_type const& factor)
+ : m_factor(factor)
+ {}
+
+ template <int Dimension>
+ inline void round(Point& p)
+ {
+ coordinate_type c = boost::geometry::get<Dimension>(p) / m_factor;
+ int rounded = c;
+ boost::geometry::set<Dimension>(p, coordinate_type(rounded) * m_factor);
+ }
+
+ inline void operator()(Point& p)
+ {
+ round<0>(p);
+ round<1>(p);
+ }
+};
+
+
int main(void)
{
using namespace boost::geometry;
Modified: sandbox/geometry/libs/geometry/example/Jamfile.v2
==============================================================================
--- sandbox/geometry/libs/geometry/example/Jamfile.v2 (original)
+++ sandbox/geometry/libs/geometry/example/Jamfile.v2 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -6,16 +6,11 @@
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-project ggl-example
- :
- requirements
- <include>../../../boost
- <toolset>gcc:<cxxflags>-pedantic
+
+project boost-geometry-example
+ : # requirements
;
-#
-# Build core examples
-#
exe 01_point_example : 01_point_example.cpp ;
exe 02_linestring_example : 02_linestring_example.cpp ;
exe 03_polygon_example : 03_polygon_example.cpp ;
@@ -32,3 +27,4 @@
exe c04_b_custom_triangle_example : c04_b_custom_triangle_example.cpp ;
exe c06_custom_polygon_example : c06_custom_polygon_example.cpp ;
exe c07_custom_ring_pointer_example : c07_custom_ring_pointer_example.cpp ;
+# exe c08_custom_non_std_example : c08_custom_non_std_example.cpp ;
Modified: sandbox/geometry/libs/geometry/example/c04_b_custom_triangle_example.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/example/c04_b_custom_triangle_example.cpp (original)
+++ sandbox/geometry/libs/geometry/example/c04_b_custom_triangle_example.cpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -35,8 +35,8 @@
namespace boost { namespace geometry { namespace dispatch {
// Specializations of area dispatch structure, implement algorithm
-template<typename P, typename S>
-struct area<ring_tag, triangle<P>, clockwise, S>
+template<typename P, typename S, closure_selector Closure>
+struct area<ring_tag, triangle<P>, clockwise, Closure, S>
{
static inline double apply(triangle<P> const& t, S const&)
{
Modified: sandbox/geometry/libs/geometry/example/extensions/Jamfile.v2
==============================================================================
--- sandbox/geometry/libs/geometry/example/extensions/Jamfile.v2 (original)
+++ sandbox/geometry/libs/geometry/example/extensions/Jamfile.v2 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -5,7 +5,7 @@
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-project ggl-example-extensions
+project boost-geometry-extensions-examples
: # requirements
;
Modified: sandbox/geometry/libs/geometry/example/extensions/gis/Jamfile.v2
==============================================================================
--- sandbox/geometry/libs/geometry/example/extensions/gis/Jamfile.v2 (original)
+++ sandbox/geometry/libs/geometry/example/extensions/gis/Jamfile.v2 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -34,7 +34,7 @@
}
}
-project ggl-example-extensions-gis
+project boost-geometry-extensions-gis-examples
:
requirements
<include>.
Modified: sandbox/geometry/libs/geometry/test/Jamfile.v2
==============================================================================
--- sandbox/geometry/libs/geometry/test/Jamfile.v2 (original)
+++ sandbox/geometry/libs/geometry/test/Jamfile.v2 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -8,12 +8,13 @@
import testing ;
-project ggl-test
+project boost-geometry-test
:
requirements
<include>.
<toolset>msvc:<asynch-exceptions>on
;
+
build-project core ;
build-project point_concept ;
Modified: sandbox/geometry/libs/geometry/test/algorithms/Jamfile.v2
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/Jamfile.v2 (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/Jamfile.v2 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -6,7 +6,7 @@
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-test-suite ggl-algorithms
+test-suite boost-geometry-algorithms
:
[ run append.cpp ]
[ run area.cpp ]
Modified: sandbox/geometry/libs/geometry/test/algorithms/area.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/area.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/area.cpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -25,16 +25,14 @@
test_geometry<boost::geometry::box<P> >("POLYGON((0 0,2 2))", 4.0);
test_geometry<boost::geometry::box<P> >("POLYGON((2 2,0 0))", 4.0);
+ // Rotated square, length=sqrt(2) -> area=2
+ test_geometry<boost::geometry::polygon<P> >("POLYGON((1 1,2 2,3 1,2 0,1 1))", 2.0);
+
+
// clockwise rings (second is wrongly ordered)
test_geometry<boost::geometry::linear_ring<P> >("POLYGON((0 0,0 7,4 2,2 0,0 0))", 16.0);
test_geometry<boost::geometry::linear_ring<P> >("POLYGON((0 0,2 0,4 2,0 7,0 0))", -16.0);
- // counter clockwise rings (first is wrongly ordered)
- test_geometry<boost::geometry::linear_ring<P, std::vector, false> >
- ("POLYGON((0 0,0 7,4 2,2 0,0 0))", -16.0);
- test_geometry<boost::geometry::linear_ring<P, std::vector, false> >
- ("POLYGON((0 0,2 0,4 2,0 7,0 0))", 16.0);
-
test_geometry<boost::geometry::polygon<P> >("POLYGON((0 0,0 7,4 2,2 0,0 0))", 16.0);
test_geometry<boost::geometry::polygon<P> >("POLYGON((1 1,2 1,2 2,1 2,1 1))", -1.0);
test_geometry<boost::geometry::polygon<P> >
@@ -70,11 +68,30 @@
{
typedef boost::geometry::polygon<P, std::vector, std::vector, false> ccw_polygon;
// counterclockwise rings (second is wrongly ordered)
+ test_geometry<ccw_polygon>("POLYGON((1 1,2 2,3 1,2 0,1 1))", -2.0);
+ test_geometry<ccw_polygon>("POLYGON((1 1,2 0,3 1,2 2,1 1))", +2.0);
test_geometry<ccw_polygon>("POLYGON((0 0,0 7,4 2,2 0,0 0))", -16.0);
- test_geometry<ccw_polygon>("POLYGON((0 0,2 0,4 2,0 7,0 0))", 16.0);
+ test_geometry<ccw_polygon>("POLYGON((0 0,2 0,4 2,0 7,0 0))", +16.0);
+}
+
+template <typename P>
+void test_open()
+{
+ typedef boost::geometry::polygon<P, std::vector, std::vector, true, false> open_polygon;
+ test_geometry<open_polygon>("POLYGON((1 1,2 2,3 1,2 0))", 2.0);
+ // Note the triangular testcase used in CCW is not sensible for open/close
+}
+
+template <typename P>
+void test_open_ccw()
+{
+ typedef boost::geometry::polygon<P, std::vector, std::vector, false, false> open_polygon;
+ test_geometry<open_polygon>("POLYGON((1 1,2 0,3 1,2 2))", 2.0);
+ // Note the triangular testcase used in CCW is not sensible for open/close
}
+
int test_main(int, char* [])
{
test_all<boost::geometry::point<int, 2, boost::geometry::cs::cartesian> >();
@@ -84,6 +101,8 @@
test_spherical<boost::geometry::point<double, 2, boost::geometry::cs::spherical<boost::geometry::degree> > >();
test_ccw<boost::geometry::point<double, 2, boost::geometry::cs::cartesian> >();
+ test_open<boost::geometry::point<double, 2, boost::geometry::cs::cartesian> >();
+ test_open_ccw<boost::geometry::point<double, 2, boost::geometry::cs::cartesian> >();
#if defined(HAVE_CLN)
test_all<boost::geometry::point_xy<boost::numeric_adaptor::cln_value_type> >();
Modified: sandbox/geometry/libs/geometry/test/algorithms/perimeter.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/algorithms/perimeter.cpp (original)
+++ sandbox/geometry/libs/geometry/test/algorithms/perimeter.cpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -25,12 +25,22 @@
"POLYGON((0 0,0 4,4 4,4 0,0 0),(1 1,2 1,2 2,1 2,1 1))", 20);
}
+template <typename P>
+void test_open()
+{
+ typedef boost::geometry::polygon<P, std::vector, std::vector, true, false> open_polygon;
+ test_geometry<open_polygon>("POLYGON((0 0,0 1,1 1,1 0))", 4);
+}
+
+
int test_main(int, char* [])
{
//test_all<boost::geometry::point_xy<int> >();
test_all<boost::geometry::point_xy<float> >();
test_all<boost::geometry::point_xy<double> >();
+ test_open<boost::geometry::point_xy<double> >();
+
#if defined(HAVE_CLN)
test_all<boost::geometry::point_xy<boost::numeric_adaptor::cln_value_type> >();
#endif
Modified: sandbox/geometry/libs/geometry/test/extensions/algorithms/connect.cpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/extensions/algorithms/connect.cpp (original)
+++ sandbox/geometry/libs/geometry/test/extensions/algorithms/connect.cpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -12,6 +12,7 @@
#include <boost/geometry/geometries/geometries.hpp>
+#include <boost/geometry/algorithms/buffer.hpp>
#include <boost/geometry/algorithms/num_points.hpp>
#include <boost/geometry/algorithms/unique.hpp>
#include <boost/geometry/extensions/algorithms/connect.hpp>
@@ -31,36 +32,46 @@
#endif
+
+
template <typename GeometryOut, typename Geometry>
-void test_connect(std::string const& caseid, Geometry const& geometry,
- std::size_t expected_point_count,
- double expected_length, double percentage)
+void test_connect(std::string const& caseid, Geometry const& geometry,
+ std::size_t expected_count, std::size_t expected_point_count,
+ double expected_length, double limit = -1, double percentage = 0.001)
{
namespace bg = boost::geometry;
typedef typename bg::coordinate_type<Geometry>::type coordinate_type;
std::vector<GeometryOut> connected_vector;
- bg::connect(geometry, connected_vector);
+ if (limit > 0)
+ {
+ bg::connect(geometry, connected_vector, limit);
+ }
+ else
+ {
+ bg::connect(geometry, connected_vector);
+ }
typename bg::length_result<Geometry>::type length = 0;
- std::size_t count = 0;
+ std::size_t count = boost::size(connected_vector);
+ std::size_t point_count = 0;
BOOST_FOREACH(GeometryOut& connected, connected_vector)
{
bg::unique(connected);
length += bg::length(connected);
- count += bg::num_points(connected);
+ point_count += bg::num_points(connected);
}
- BOOST_CHECK_MESSAGE(count == expected_point_count,
+ BOOST_CHECK_MESSAGE(count == expected_count,
"connect: " << caseid
- << " #points expected: " << expected_point_count
+ << " #lines expected: " << expected_count
<< " detected: " << count
<< " type: " << string_from_type<coordinate_type>::name()
);
- //BOOST_CHECK_EQUAL(holes, expected_hole_count);
+ BOOST_CHECK_EQUAL(point_count, expected_point_count);
BOOST_CHECK_CLOSE(length, expected_length, percentage);
@@ -80,6 +91,12 @@
> mapper(svg, 500, 500);
mapper.add(geometry);
+ bg::box<typename bg::point_type<Geometry>::type> extent;
+ bg::envelope(geometry, extent);
+ bg::buffer(extent, extent, 0.1);
+ mapper.add(extent);
+
+
mapper.map(geometry, "opacity:0.6;fill:rgb(0,0,255);stroke:rgb(0,0,0);stroke-width:1");
BOOST_FOREACH(GeometryOut& connected, connected_vector)
{
@@ -92,15 +109,15 @@
template <typename Geometry, typename GeometryOut>
void test_one(std::string const& caseid, std::string const& wkt,
- std::size_t expected_point_count,
- double expected_length, double percentage = 0.001)
+ std::size_t expected_count, std::size_t expected_point_count,
+ double expected_length, double limit = -1, double percentage = 0.001)
{
Geometry geometry;
boost::geometry::read_wkt(wkt, geometry);
test_connect<GeometryOut>(caseid, geometry,
- expected_point_count,
- expected_length, percentage);
+ expected_count, expected_point_count,
+ expected_length, limit, percentage);
#ifdef BOOST_GEOMETRY_TEST_MULTI_PERMUTATIONS
// Test different combinations of a multi-polygon
@@ -144,32 +161,45 @@
typedef bg::linestring<P> linestring;
typedef bg::multi_linestring<linestring> multi_linestring;
+ goto disconnected;
+
test_one<multi_linestring, linestring>("ls_simplex",
"MULTILINESTRING((0 0,1 1),(1 1,2 2))",
- 3, 2 * std::sqrt(2.0));
+ 1, 3, 2 * std::sqrt(2.0));
// Opposites, forming one line
test_one<multi_linestring, linestring>("ls_simplex_opposite_to",
"MULTILINESTRING((0 0,1 1),(2 2,1 1))",
- 3, 2 * std::sqrt(2.0));
+ 1, 3, 2 * std::sqrt(2.0));
test_one<multi_linestring, linestring>("ls_simplex_opposite_from",
"MULTILINESTRING((1 1,0 0),(1 1,2 2))",
- 3, 2 * std::sqrt(2.0));
+ 1, 3, 2 * std::sqrt(2.0));
// Two output linestrings
test_one<multi_linestring, linestring>("ls_simplex_two",
"MULTILINESTRING((0 0,1 1),(1 1,2 2),(3 3,4 4),(4 4,5 5))",
- 6, 4 * std::sqrt(2.0));
+ 2, 6, 4 * std::sqrt(2.0));
// Linestrings forming a ring
test_one<multi_linestring, linestring>("ls_simplex_ring",
"MULTILINESTRING((0 0,0 1),(1 1,1 0),(0 1,1 1),(1 0,0 0))",
- 5, 4.0);
+ 1, 5, 4.0);
- // disconnected ring
- test_one<multi_linestring, linestring>("ls_disconnected_ring",
+ // disconnected rings
+ test_one<multi_linestring, linestring>("ls_disconnected_ring1",
"MULTILINESTRING((0 0,0 1.01),(1.02 1.03,0.99 0),(0 0.98,1.001 1),(1.01 0,0 0))",
- 5, 4.0);
+ 1, 8, 4.137147, 0.5);
+ test_one<multi_linestring, linestring>("ls_disconnected_ring2",
+ "MULTILINESTRING((0 0,0 1.01),(1.02 1.03,0.99 0),(0 0.98,1.001 1),(1.01 0,0 0))",
+ 1, 8, 4.137147, 0.1);
+ test_one<multi_linestring, linestring>("ls_disconnected_ring3",
+ "MULTILINESTRING((0 0,0 1.01),(1.02 1.03,0.99 0),(0 0.98,1.001 1),(1.01 0,0 0))",
+ 3, 7, 4.05163658, 0.01);
+
+disconnected:
+ test_one<multi_linestring, linestring>("ls_disconnected_ring4",
+ "MULTILINESTRING((0.01 0,0 1.01),(1.02 1.03,0.99 0),(0 0.98,1.001 1),(1.01 0,0.02 0))",
+ 1, 8, 4.137147, 0.1);
}
Modified: sandbox/geometry/libs/geometry/test/geometry_test_common.hpp
==============================================================================
--- sandbox/geometry/libs/geometry/test/geometry_test_common.hpp (original)
+++ sandbox/geometry/libs/geometry/test/geometry_test_common.hpp 2010-05-24 05:07:05 EDT (Mon, 24 May 2010)
@@ -26,6 +26,8 @@
#if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
# include <boost/test/floating_point_comparison.hpp>
# include <boost/test/included/test_exec_monitor.hpp>
+//# include <boost/test/included/prg_exec_monitor.hpp>
+# include <boost/test/impl/execution_monitor.ipp>
#endif
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