|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57147 - in sandbox/ggl/formal_review_request/boost/ggl: . algorithms algorithms/overlay arithmetic core core/concepts extensions/gis/geographic/strategies extensions/gis/io/wkb/detail extensions/gis/io/wkt extensions/io/svg geometries geometries/concepts geometries/concepts/detail multi/algorithms multi/geometries strategies strategies/agnostic strategies/cartesian strategies/concepts strategies/spherical util
From: barend.gehrels_at_[hidden]
Date: 2009-10-25 06:28:47
Author: barendgehrels
Date: 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
New Revision: 57147
URL: http://svn.boost.org/trac/boost/changeset/57147
Log:
Added concept checks / solved them generic now
Updated concepts for strategies (within, area, centroid)
Many changes in layout/template parameter names
Added:
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/geographic/strategies/area_huiller_earth.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/
- copied from r56825, /sandbox/ggl/formal_review_request/boost/ggl/core/concepts/
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/check.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/detail/
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/detail/check_append.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/detail/check_clear.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/point_in_poly_winding.hpp
- copied, changed from r56825, /sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/agn_within.hpp
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/area_by_triangles.hpp
- copied, changed from r56825, /sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_area.hpp
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/centroid_bashein_detmer.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/point_in_poly_crossings_multiply.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/point_in_poly_franklin.hpp
- copied, changed from r56825, /sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_within.hpp
sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/area_concept.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/centroid_concept.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/within_concept.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/area_huiller.hpp
- copied, changed from r57036, /sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/sph_area.hpp
sandbox/ggl/formal_review_request/boost/ggl/util/select_calculation_type.hpp (contents, props changed)
Removed:
sandbox/ggl/formal_review_request/boost/ggl/core/concepts/
sandbox/ggl/formal_review_request/boost/ggl/core/radius.hpp
sandbox/ggl/formal_review_request/boost/ggl/geometries/nsphere.hpp
sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/agn_within.hpp
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_area.hpp
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_centroid.hpp
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_within.hpp
sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/sph_area.hpp
Text files modified:
sandbox/ggl/formal_review_request/boost/ggl/algorithms/append.hpp | 87 ++----
sandbox/ggl/formal_review_request/boost/ggl/algorithms/area.hpp | 166 ++++++------
sandbox/ggl/formal_review_request/boost/ggl/algorithms/assign.hpp | 142 ++++-------
sandbox/ggl/formal_review_request/boost/ggl/algorithms/buffer.hpp | 14
sandbox/ggl/formal_review_request/boost/ggl/algorithms/centroid.hpp | 330 ++++++++++++++++++---------
sandbox/ggl/formal_review_request/boost/ggl/algorithms/clear.hpp | 106 +++-----
sandbox/ggl/formal_review_request/boost/ggl/algorithms/combine.hpp | 10
sandbox/ggl/formal_review_request/boost/ggl/algorithms/convert.hpp | 19 +
sandbox/ggl/formal_review_request/boost/ggl/algorithms/convex_hull.hpp | 26 +
sandbox/ggl/formal_review_request/boost/ggl/algorithms/correct.hpp | 35 +-
sandbox/ggl/formal_review_request/boost/ggl/algorithms/disjoint.hpp | 6
sandbox/ggl/formal_review_request/boost/ggl/algorithms/distance.hpp | 3
sandbox/ggl/formal_review_request/boost/ggl/algorithms/envelope.hpp | 215 ++++++++---------
sandbox/ggl/formal_review_request/boost/ggl/algorithms/equals.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/algorithms/for_each.hpp | 83 +++--
sandbox/ggl/formal_review_request/boost/ggl/algorithms/get_section.hpp | 4
sandbox/ggl/formal_review_request/boost/ggl/algorithms/intermediate.hpp | 33 +
sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersection.hpp | 3
sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersects.hpp | 4
sandbox/ggl/formal_review_request/boost/ggl/algorithms/length.hpp | 57 +++-
sandbox/ggl/formal_review_request/boost/ggl/algorithms/make.hpp | 16 +
sandbox/ggl/formal_review_request/boost/ggl/algorithms/num_points.hpp | 9
sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlaps.hpp | 8
sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/adapt_turns.hpp | 6
sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/copy_segments.hpp | 4
sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/enrich_intersection_points.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/get_intersection_points.hpp | 5
sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/self_intersection_points.hpp | 4
sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/traverse.hpp | 6
sandbox/ggl/formal_review_request/boost/ggl/algorithms/perimeter.hpp | 26 +
sandbox/ggl/formal_review_request/boost/ggl/algorithms/sectionalize.hpp | 7
sandbox/ggl/formal_review_request/boost/ggl/algorithms/selected.hpp | 33 +-
sandbox/ggl/formal_review_request/boost/ggl/algorithms/simplify.hpp | 14
sandbox/ggl/formal_review_request/boost/ggl/algorithms/transform.hpp | 20 +
sandbox/ggl/formal_review_request/boost/ggl/algorithms/within.hpp | 484 +++++++++++++++++----------------------
sandbox/ggl/formal_review_request/boost/ggl/arithmetic/arithmetic.hpp | 6
sandbox/ggl/formal_review_request/boost/ggl/arithmetic/dot_product.hpp | 16
sandbox/ggl/formal_review_request/boost/ggl/core/access.hpp | 89 ++++--
sandbox/ggl/formal_review_request/boost/ggl/core/cs.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/core/geometry_id.hpp | 4
sandbox/ggl/formal_review_request/boost/ggl/core/replace_point_type.hpp | 7
sandbox/ggl/formal_review_request/boost/ggl/core/tags.hpp | 3
sandbox/ggl/formal_review_request/boost/ggl/core/topological_dimension.hpp | 7
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/parser.hpp | 5
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/read_wkt.hpp | 17
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/stream_wkt.hpp | 8
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/write_wkt.hpp | 24
sandbox/ggl/formal_review_request/boost/ggl/extensions/io/svg/write_svg.hpp | 23 -
sandbox/ggl/formal_review_request/boost/ggl/geometries/box.hpp | 6
sandbox/ggl/formal_review_request/boost/ggl/geometries/cartesian2d.hpp | 1
sandbox/ggl/formal_review_request/boost/ggl/geometries/cartesian3d.hpp | 1
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/box_concept.hpp | 138 ++++++-----
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/linestring_concept.hpp | 77 +++---
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/point_concept.hpp | 80 +++---
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/polygon_concept.hpp | 130 +++++-----
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/ring_concept.hpp | 78 +++---
sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/segment_concept.hpp | 130 +++++-----
sandbox/ggl/formal_review_request/boost/ggl/geometries/geometries.hpp | 1
sandbox/ggl/formal_review_request/boost/ggl/geometries/linear_ring.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/geometries/linestring.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/geometries/polygon.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/geometries/segment.hpp | 8
sandbox/ggl/formal_review_request/boost/ggl/ggl.hpp | 10
sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/centroid.hpp | 107 ++++++--
sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/envelope.hpp | 30 +-
sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/perimeter.hpp | 8
sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/within.hpp | 106 +++-----
sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_linestring.hpp | 5
sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_point.hpp | 5
sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_polygon.hpp | 5
sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/point_in_poly_winding.hpp | 275 ++++++++++++----------
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/area_by_triangles.hpp | 149 ++++++-----
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_envelope.hpp | 3
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_intersect.hpp | 5
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_side.hpp | 26 +
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/point_in_poly_franklin.hpp | 140 +++++-----
sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/distance_concept.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/area_huiller.hpp | 262 ++++++++++-----------
sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/distance_cross_track.hpp | 5
sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/distance_haversine.hpp | 1
sandbox/ggl/formal_review_request/boost/ggl/strategies/strategies.hpp | 11
sandbox/ggl/formal_review_request/boost/ggl/strategies/strategy_transform.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/util/copy.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/util/for_each_coordinate.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/util/write_dsv.hpp | 22 -
85 files changed, 2113 insertions(+), 1926 deletions(-)
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/append.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/append.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/append.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,114 +12,93 @@
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <boost/type_traits/remove_const.hpp>
-#include <boost/concept_check.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/point_type.hpp>
#include <ggl/core/tags.hpp>
-#include <ggl/util/copy.hpp>
-namespace ggl
-{
+#include <ggl/geometries/concepts/check.hpp>
-namespace traits
-{
+#include <ggl/util/copy.hpp>
-/*!
- \brief Traits class, optional, might be implemented to append a point
- \details If a geometry type should not use the std "push_back" then it can specialize
- the "use_std" traits class to false, it should then implement (a.o.) append_point
- \ingroup traits
- \par Geometries:
- - linestring
- - linear_ring
- \par Specializations should provide:
- - run
- */
-template <typename G, typename P>
-struct append_point
+namespace ggl
{
-};
-
-} // namespace traits
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace append {
-template <typename G, typename P, bool Std>
+template <typename Geometry, typename Point, bool UseStd>
struct append_point {};
-template <typename G, typename P>
-struct append_point<G, P, true>
+template <typename Geometry, typename Point>
+struct append_point<Geometry, Point, true>
{
- static inline void apply(G& geometry, P const& point, int , int )
+ static inline void apply(Geometry& geometry, Point const& point, int , int )
{
- typename point_type<G>::type point_type;
+ typename point_type<Geometry>::type point_type;
copy_coordinates(point, point_type);
geometry.push_back(point_type);
}
};
-template <typename G, typename P>
-struct append_point<G, P, false>
+template <typename Geometry, typename Point>
+struct append_point<Geometry, Point, false>
{
- static inline void apply(G& geometry, P const& point, int ring_index, int multi_index)
+ static inline void apply(Geometry& geometry, Point const& point, int ring_index, int multi_index)
{
- traits::append_point<G, P>::apply(geometry, point, ring_index, multi_index);
+ traits::append_point<Geometry, Point>::apply(geometry, point, ring_index, multi_index);
}
};
-template <typename G, typename R, bool Std>
+template <typename Geometry, typename Range, bool UseStd>
struct append_range
{
- typedef typename boost::range_value<R>::type point_type;
+ typedef typename boost::range_value<Range>::type point_type;
- static inline void apply(G& geometry, R const& range, int ring_index, int multi_index)
+ static inline void apply(Geometry& geometry, Range const& range, int ring_index, int multi_index)
{
- for (typename boost::range_const_iterator<R>::type it = boost::begin(range);
+ for (typename boost::range_const_iterator<Range>::type it = boost::begin(range);
it != boost::end(range); ++it)
{
- append_point<G, point_type, Std>::apply(geometry, *it, ring_index, multi_index);
+ append_point<Geometry, point_type, UseStd>::apply(geometry, *it, ring_index, multi_index);
}
}
};
-template <typename P, typename T, bool Std>
+template <typename Polygon, typename Point, bool Std>
struct point_to_poly
{
- typedef typename ring_type<P>::type range_type;
+ typedef typename ring_type<Polygon>::type range_type;
- static inline void apply(P& polygon, T const& point, int ring_index, int multi_index)
+ static inline void apply(Polygon& polygon, Point const& point, int ring_index, int )
{
- boost::ignore_unused_variable_warning(multi_index);
-
if (ring_index == -1)
{
- append_point<range_type, T, Std>::apply(exterior_ring(polygon), point, -1, -1);
+ append_point<range_type, Point, Std>::apply(exterior_ring(polygon), point, -1, -1);
}
else if (ring_index < boost::size(interior_rings(polygon)))
{
- append_point<range_type, T, Std>::apply(interior_rings(polygon)[ring_index], point, -1, -1);
+ append_point<range_type, Point, Std>::apply(interior_rings(polygon)[ring_index], point, -1, -1);
}
}
};
-template <typename P, typename R, bool Std>
+template <typename Polygon, typename Range, bool Std>
struct range_to_poly
{
- typedef typename ring_type<P>::type ring_type;
+ typedef typename ring_type<Polygon>::type ring_type;
- static inline void apply(P& polygon, R const& range, int ring_index, int multi_index)
+ static inline void apply(Polygon& polygon, Range const& range, int ring_index, int )
{
if (ring_index == -1)
{
- append_range<ring_type, R, Std>::apply(exterior_ring(polygon), range, -1, -1);
+ append_range<ring_type, Range, Std>::apply(exterior_ring(polygon), range, -1, -1);
}
else if (ring_index < boost::size(interior_rings(polygon)))
{
- append_range<ring_type, R, Std>::apply(interior_rings(polygon)[ring_index], range, -1, -1);
+ append_range<ring_type, Range, Std>::apply(interior_rings(polygon)[ring_index], range, -1, -1);
}
}
};
@@ -150,8 +129,6 @@
template <typename TagRoP, typename B, typename RoP, bool Std>
struct append<box_tag, TagRoP, B, RoP, Std> {};
-template <typename TagRoP, typename N, typename RoP, bool Std>
-struct append<nsphere_tag, TagRoP, N, RoP, Std> {};
template <typename P, typename TAG_R, typename R, bool Std>
struct append<polygon_tag, TAG_R, P, R, Std>
@@ -176,15 +153,17 @@
interior ring index
\param multi_index reserved for multi polygons
*/
-template <typename G, typename RoP>
-inline void append(G& geometry, const RoP& range_or_point,
+template <typename Geometry, typename RoP>
+inline void append(Geometry& geometry, RoP const& range_or_point,
int ring_index = -1, int multi_index = 0)
{
- typedef typename boost::remove_const<G>::type ncg_type;
+ concept::check<Geometry>();
+
+ typedef typename boost::remove_const<Geometry>::type ncg_type;
dispatch::append
<
- typename tag<G>::type,
+ typename tag<Geometry>::type,
typename tag<RoP>::type,
ncg_type,
RoP,
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/area.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/area.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/area.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -9,7 +9,6 @@
#ifndef GGL_ALGORITHMS_AREA_HPP
#define GGL_ALGORITHMS_AREA_HPP
-#include <boost/concept/requires.hpp>
#include <boost/mpl/if.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
@@ -19,8 +18,8 @@
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
#include <ggl/core/ring_type.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/core/concepts/nsphere_concept.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
#include <ggl/algorithms/detail/calculate_null.hpp>
#include <ggl/algorithms/detail/calculate_sum.hpp>
@@ -28,25 +27,29 @@
#include <ggl/strategies/strategies.hpp>
#include <ggl/strategies/area_result.hpp>
-#include <ggl/util/loop.hpp>
+#include <ggl/strategies/concepts/area_concept.hpp>
+
#include <ggl/util/math.hpp>
/*!
\defgroup area area calculation
\par Performance
-2776 * 1000 area calculations are done in 0.11 seconds (other libraries: 0.125 seconds, 0.125 seconds, 0.5 seconds)
+2776 * 1000 area calculations are done in 0.11 seconds
+(other libraries: 0.125 seconds, 0.125 seconds, 0.5 seconds)
\par Coordinate systems and strategies
-Area calculation can be done in Cartesian and in spherical/geographic coordinate systems.
+Area calculation can be done in Cartesian and in spherical/geographic
+coordinate systems.
\par Geometries
-The area algorithm calculates the surface area of all geometries having a surface:
-box, circle, polygon, multi_polygon. The units are the square of the units used for the points
-defining the surface. If the polygon is defined in meters, the area is in square meters.
+The area algorithm calculates the surface area of all geometries
+having a surface: box, polygon, multi_polygon. The units are the square of
+the units used for the points defining the surface. If the polygon is defined
+in meters, the area is in square meters.
\par Example:
-Example showing area calculation of polygons built of xy-points and of latlong-points
+Example showing area calculation of polygons built
\dontinclude doxygen_examples.cpp
\skip example_area_polygon()
\line {
@@ -59,96 +62,85 @@
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace area {
-template<typename B, typename S>
+template<typename Box, typename Strategy>
struct box_area
{
- typedef typename coordinate_type<B>::type return_type;
+ typedef typename coordinate_type<Box>::type return_type;
- static inline return_type apply(B const& b, S const&)
+ static inline return_type apply(Box const& box, Strategy const&)
{
- // Currently only works for Cartesian boxes
- // Todo: use strategy
- // Todo: use concept
- assert_dimension<B, 2>();
-
- return_type const dx = get<max_corner, 0>(b) - get<min_corner, 0>(b);
- return_type const dy = get<max_corner, 1>(b) - get<min_corner, 1>(b);
+ // Currently only works for 2D Cartesian boxes
+ // Todo: use extreme-strategy
+ assert_dimension<Box, 2>();
+
+ return_type const dx = get<max_corner, 0>(box)
+ - get<min_corner, 0>(box);
+ return_type const dy = get<max_corner, 1>(box)
+ - get<min_corner, 1>(box);
return dx * dy;
}
};
-template<typename C, typename S>
-struct circle_area
-{
- typedef typename coordinate_type<C>::type coordinate_type;
-
- // Returning the coordinate precision, but if integer, returning a double
- typedef typename boost::mpl::if_c
- <
- boost::is_integral<coordinate_type>::type::value,
- double,
- coordinate_type
- >::type return_type;
-
- static inline return_type apply(C const& c, S const&)
- {
- // Currently only works for Cartesian circles
- // Todo: use strategy
- // Todo: use concept
- assert_dimension<C, 2>();
-
- return_type r = get_radius<0>(c);
- r *= r * ggl::math::pi;
- return r;
- }
-};
-// Area of a linear linear_ring
+/*!
+ \brief Calculate area of a ring, specialized per order
+ */
template
<
- typename R,
+ typename Ring,
order_selector Order,
// closing_selector Closed -- for now assuming CLOSED, p(0) == p(n-1)
- typename S
+ typename Strategy
>
struct ring_area
{};
-template<typename R, typename S>
-struct ring_area<R, clockwise, S>
+template<typename Ring, typename Strategy>
+struct ring_area<Ring, clockwise, Strategy>
{
- typedef typename S::return_type type;
- static inline type apply(R const& ring, S const& strategy)
+ BOOST_CONCEPT_ASSERT( (ggl::concept::AreaStrategy<Strategy>) );
+
+ typedef typename Strategy::return_type type;
+
+ static inline type apply(Ring const& ring, Strategy const& strategy)
{
- assert_dimension<R, 2>();
+ assert_dimension<Ring, 2>();
// A closed linear_ring has at least four points,
// if not, there is no (zero) area
- if (boost::size(ring) >= 4)
+ if (boost::size(ring) < 4)
+ {
+ return type();
+ }
+
+ typedef typename boost::range_const_iterator<Ring>::type iterator_type;
+
+ typename Strategy::state_type state = strategy.init();
+
+ iterator_type it = boost::begin(ring);
+ for (iterator_type previous = it++;
+ it != boost::end(ring);
+ previous = it++)
{
- typename S::state_type state_type;
- if (loop(ring, strategy, state_type))
- {
- return state_type.area();
- }
+ Strategy::apply(*previous, *it, state);
}
+ return Strategy::result(state);
- return type();
}
};
-template<typename R, typename S>
-struct ring_area<R, counterclockwise, S>
+template<typename Ring, typename Strategy>
+struct ring_area<Ring, counterclockwise, Strategy>
{
- typedef typename S::return_type type;
- static inline type apply(R const& ring, S const& strategy)
+ typedef typename Strategy::return_type type;
+ static inline type apply(Ring const& ring, Strategy const& strategy)
{
// Counter clockwise rings negate the area result
- return -ring_area<R, clockwise, S>::apply(ring, strategy);
+ return -ring_area<Ring, clockwise, Strategy>::apply(ring, strategy);
}
};
@@ -157,10 +149,18 @@
#endif // DOXYGEN_NO_DETAIL
+
+
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch {
-template <typename Tag, typename Geometry, order_selector Order, typename Strategy>
+template
+<
+ typename Tag,
+ typename Geometry,
+ order_selector Order,
+ typename Strategy
+>
struct area
: detail::calculate_null
<
@@ -172,21 +172,17 @@
template <typename Geometry, order_selector Order, typename Strategy>
struct area<box_tag, Geometry, Order, Strategy>
- : detail::area::box_area<Geometry, Strategy>
+ : detail::area::box_area<Geometry, Strategy>
{};
-template <typename Geometry, order_selector Order, typename Strategy>
-struct area<nsphere_tag, Geometry, Order, Strategy>
- : detail::area::circle_area<Geometry, Strategy>
-{};
// Area of ring currently returns area of closed rings but it might be argued
// that it is 0.0, because a ring is just a line.
template <typename Geometry, order_selector Order, typename Strategy>
struct area<ring_tag, Geometry, Order, Strategy>
- : detail::area::ring_area<Geometry, Order, Strategy>
+ : detail::area::ring_area<Geometry, Order, Strategy>
{};
template <typename Polygon, order_selector Order, typename Strategy>
@@ -194,16 +190,16 @@
: detail::calculate_polygon_sum
<
typename Strategy::return_type,
- Polygon,
- Strategy,
+ Polygon,
+ Strategy,
detail::area::ring_area
<
- typename ring_type<Polygon>::type,
- Order,
+ typename ring_type<Polygon>::type,
+ Order,
Strategy
- >
+ >
>
- //: detail::area::polygon_area<Geometry, Order, Strategy>
+ //: detail::area::polygon_area<Geometry, Order, Strategy>
{};
} // namespace dispatch
@@ -214,17 +210,19 @@
/*!
\brief Calculate area of a geometry
\ingroup area
- \details The function area returns the area of a polygon, ring, box or circle,
+ \details The function area returns the area of a polygon, ring, box
using the default area-calculation strategy. Strategies are
provided for cartesian and spherical coordinate systems
- The geometries should correct, polygons should be closed and orientated clockwise, holes,
- if any, must be orientated counter clockwise
+ The geometries should correct, polygons should be closed
+ and according to the specified orientation (clockwise/counter clockwise)
\param geometry a geometry
\return the area
*/
template <typename Geometry>
inline typename area_result<Geometry>::type area(Geometry const& geometry)
{
+ concept::check<const Geometry>();
+
typedef typename area_result<Geometry>::strategy_type strategy_type;
return dispatch::area
@@ -241,14 +239,16 @@
\ingroup area
\details This version of area calculation takes a strategy
\param geometry a geometry
- \param strategy the strategy to calculate area. Especially for spherical areas there are
- some approaches.
+ \param strategy the strategy to calculate area.
+ Especially for spherical areas there are some approaches.
\return the area
*/
template <typename Geometry, typename Strategy>
inline typename Strategy::return_type area(
Geometry const& geometry, Strategy const& strategy)
{
+ concept::check<const Geometry>();
+
return dispatch::area
<
typename tag<Geometry>::type,
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/assign.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/assign.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/assign.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -20,9 +20,11 @@
#include <ggl/algorithms/clear.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/exterior_ring.hpp>
-#include <ggl/core/radius.hpp>
#include <ggl/core/tags.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
+
#include <ggl/util/copy.hpp>
#include <ggl/util/for_each_coordinate.hpp>
@@ -287,62 +289,6 @@
-
-
-template <typename S>
-struct assign<nsphere_tag, S, 2>
-{
- typedef typename coordinate_type<S>::type coordinate_type;
- typedef typename radius_type<S>::type radius_type;
-
- /// 2-value version for an n-sphere is valid for circle and sets the center
- template <typename T>
- static inline void apply(S& sphercle, T const& c1, T const& c2)
- {
- set<0>(sphercle, boost::numeric_cast<coordinate_type>(c1));
- set<1>(sphercle, boost::numeric_cast<coordinate_type>(c2));
- }
-
- template <typename T, typename R>
- static inline void apply(S& sphercle, T const& c1,
- T const& c2, R const& radius)
- {
- set<0>(sphercle, boost::numeric_cast<coordinate_type>(c1));
- set<1>(sphercle, boost::numeric_cast<coordinate_type>(c2));
- set_radius<0>(sphercle, boost::numeric_cast<radius_type>(radius));
- }
-};
-
-template <typename S>
-struct assign<nsphere_tag, S, 3>
-{
- typedef typename coordinate_type<S>::type coordinate_type;
- typedef typename radius_type<S>::type radius_type;
-
- /// 4-value version for an n-sphere is valid for a sphere and sets the center and the radius
- template <typename T>
- static inline void apply(S& sphercle, T const& c1, T const& c2, T const& c3)
- {
- set<0>(sphercle, boost::numeric_cast<coordinate_type>(c1));
- set<1>(sphercle, boost::numeric_cast<coordinate_type>(c2));
- set<2>(sphercle, boost::numeric_cast<coordinate_type>(c3));
- }
-
- /// 4-value version for an n-sphere is valid for a sphere and sets the center and the radius
- template <typename T, typename R>
- static inline void apply(S& sphercle, T const& c1,
- T const& c2, T const& c3, R const& radius)
- {
-
- set<0>(sphercle, boost::numeric_cast<coordinate_type>(c1));
- set<1>(sphercle, boost::numeric_cast<coordinate_type>(c2));
- set<2>(sphercle, boost::numeric_cast<coordinate_type>(c3));
- set_radius<0>(sphercle, boost::numeric_cast<radius_type>(radius));
- }
-
-};
-
-
template <typename GeometryTag, typename Geometry>
struct assign_zero {};
@@ -375,44 +321,50 @@
\brief assign two values to a 2D point
\ingroup access
*/
-template <typename G, typename T>
-inline void assign(G& geometry, T const& c1, T const& c2)
+template <typename Geometry, typename T>
+inline void assign(Geometry& geometry, T const& c1, T const& c2)
{
+ concept::check<Geometry>();
+
dispatch::assign
<
- typename tag<G>::type,
- G,
- ggl::dimension<G>::type::value
+ typename tag<Geometry>::type,
+ Geometry,
+ ggl::dimension<Geometry>::type::value
>::apply(geometry, c1, c2);
}
/*!
- \brief assign three values to a 3D point or the center + radius to a circle
+ \brief assign three values to a 3D point [or the center + radius to a circle]
\ingroup access
*/
-template <typename G, typename T>
-inline void assign(G& geometry, T const& c1, T const& c2, T const& c3)
+template <typename Geometry, typename T>
+inline void assign(Geometry& geometry, T const& c1, T const& c2, T const& c3)
{
+ concept::check<Geometry>();
+
dispatch::assign
<
- typename tag<G>::type,
- G,
- ggl::dimension<G>::type::value
+ typename tag<Geometry>::type,
+ Geometry,
+ ggl::dimension<Geometry>::type::value
>::apply(geometry, c1, c2, c3);
}
/*!
- \brief assign center + radius to a sphere
+ \brief assign center + radius to a sphere [for extension]
\ingroup access
*/
-template <typename G, typename T>
-inline void assign(G& geometry, T const& c1, T const& c2, T const& c3, T const& c4)
+template <typename Geometry, typename T>
+inline void assign(Geometry& geometry, T const& c1, T const& c2, T const& c3, T const& c4)
{
+ concept::check<Geometry>();
+
dispatch::assign
<
- typename tag<G>::type,
- G,
- ggl::dimension<G>::type::value
+ typename tag<Geometry>::type,
+ Geometry,
+ ggl::dimension<Geometry>::type::value
>::apply(geometry, c1, c2, c3, c4);
}
@@ -422,9 +374,11 @@
\note The point-type of the range might be different from the point-type of the geometry
\ingroup access
*/
-template <typename G, typename R>
-inline void assign(G& geometry, R const& range)
+template <typename Geometry, typename R>
+inline void assign(Geometry& geometry, R const& range)
{
+ concept::check<Geometry>();
+
clear(geometry);
ggl::append(geometry, range, -1, 0);
}
@@ -437,13 +391,15 @@
collect the minimum bounding box of a geometry.
\ingroup access
*/
-template <typename G>
-inline void assign_inverse(G& geometry)
+template <typename Geometry>
+inline void assign_inverse(Geometry& geometry)
{
+ concept::check<Geometry>();
+
dispatch::assign_inverse
<
- typename tag<G>::type,
- G
+ typename tag<Geometry>::type,
+ Geometry
>::apply(geometry);
}
@@ -451,15 +407,17 @@
\brief assign zero values to a box, point
\ingroup access
\details The assign_zero function initializes a 2D or 3D point or box with coordinates of zero
- \tparam G the geometry type
+ \tparam Geometry the geometry type
*/
-template <typename G>
-inline void assign_zero(G& geometry)
+template <typename Geometry>
+inline void assign_zero(Geometry& geometry)
{
+ concept::check<Geometry>();
+
dispatch::assign_zero
<
- typename tag<G>::type,
- G
+ typename tag<Geometry>::type,
+ Geometry
>::apply(geometry);
}
@@ -469,9 +427,14 @@
\ingroup assign
\note The order can be crucial. Most logical is LOWER, UPPER and sub-order LEFT, RIGHT
*/
-template <typename B, typename P>
-inline void assign_box_corners(B const& box, P& lower_left, P& lower_right, P& upper_left, P& upper_right)
+template <typename Box, typename Point>
+inline void assign_box_corners(Box const& box,
+ Point& lower_left, Point& lower_right,
+ Point& upper_left, Point& upper_right)
{
+ concept::check<const Box>();
+ concept::check<Point>();
+
detail::assign::assign_box_2d_corner<min_corner, min_corner>(box, lower_left);
detail::assign::assign_box_2d_corner<max_corner, min_corner>(box, lower_right);
detail::assign::assign_box_2d_corner<min_corner, max_corner>(box, upper_left);
@@ -488,6 +451,9 @@
template <std::size_t Corner, typename Box, typename Point>
inline void assign_point_to_box(Point const& point, Box& box)
{
+ concept::check<const Point>();
+ concept::check<Box>();
+
detail::assign::assign_point_to_box
<
Box, Point, Corner, 0, dimension<Box>::type::value
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/buffer.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/buffer.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/buffer.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -13,9 +13,9 @@
#include <boost/numeric/conversion/cast.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/arithmetic/arithmetic.hpp>
-#include <ggl/core/concepts/box_concept.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
// Buffer functions
// Was before: "grow" but then only for box
@@ -108,9 +108,12 @@
BOX + distance -> BOX: it is allowed that "geometry_out" the same object as "geometry_in"
*/
template <typename Input, typename Output, typename T>
-inline void buffer(const Input& geometry_in, Output& geometry_out,
+inline void buffer(Input const& geometry_in, Output& geometry_out,
T const& distance, T const& chord_length = -1)
{
+ concept::check<const Input>();
+ concept::check<Output>();
+
dispatch::buffer
<
typename tag<Input>::type,
@@ -131,8 +134,11 @@
\note See also: buffer
*/
template <typename Output, typename Input, typename T>
-Output make_buffer(const Input& geometry, T const& distance, T const& chord_length = -1)
+Output make_buffer(Input const& geometry, T const& distance, T const& chord_length = -1)
{
+ concept::check<const Input>();
+ concept::check<Output>();
+
Output geometry_out;
dispatch::buffer
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/centroid.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/centroid.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/centroid.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,7 +11,6 @@
#include <cstddef>
-#include <boost/concept/requires.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
@@ -19,27 +18,31 @@
#include <ggl/core/exception.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/strategies/strategies.hpp>
+#include <ggl/strategies/concepts/centroid_concept.hpp>
#include <ggl/util/copy.hpp>
-#include <ggl/util/loop.hpp>
/*!
\defgroup centroid centroid calculation
\par Source descriptions:
-- OGC description: The mathematical centroid for this Surface as a Point. The result is not guaranteed to be on this Surface.
+- OGC description: The mathematical centroid for this Surface as a Point. The
+ result is not guaranteed to be on this Surface.
- From Wikipedia: Informally, it is the "average" of all points
\see http://en.wikipedia.org/wiki/Centroid
-\note The "centroid" functions are taking a non const reference to the centroid. The "make_centroid" functions
-return the centroid, the type has to be specified.
+\note The "centroid" functions are taking a non const reference to the centroid.
+ The "make_centroid" functions return the centroid, the type has to be
+ specified.
-\note There are versions where the centroid calculation strategy can be specified
+\note There are versions where a centroid calculation strategy can be specified
\par Geometries:
- RING: \image html centroid_ring.png
- BOX: the centroid of a 2D or 3D box is the center of the box
-- CIRCLE: the centroid of a circle or a sphere is its center
- POLYGON \image html centroid_polygon.png
-- POINT, LINESTRING, SEGMENT: trying to calculate the centroid will result in a compilation error
+- POINT, LINESTRING, SEGMENT: trying to calculate the centroid will result in a
+ compilation error
*/
namespace ggl
@@ -49,11 +52,12 @@
{
public:
- centroid_exception() {}
+ inline centroid_exception()
+ {}
virtual char const* what() const throw()
{
- return "centroid calculation exception";
+ return "GGL Centroid calculation exception";
}
};
@@ -62,29 +66,74 @@
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace centroid {
-/*!
- \brief Generic function which checks if enough points are present
-*/
-template<typename P, typename R>
-inline bool ring_ok(R const& ring, P& c)
+
+template<typename Point, typename PointCentroid, typename Strategy>
+struct centroid_point
{
- std::size_t const n = boost::size(ring);
- if (n > 1)
+ static inline bool apply(Point const& point, PointCentroid& centroid,
+ Strategy const&, typename Strategy::state_type&)
{
- return true;
+ copy_coordinates(point, centroid);
+ return false;
}
- else if (n <= 0)
+};
+
+
+template
+<
+ typename Box,
+ typename Point,
+ std::size_t Dimension,
+ std::size_t DimensionCount
+>
+struct centroid_box_calculator
+{
+ typedef typename select_coordinate_type
+ <
+ Box, Point
+ >::type coordinate_type;
+ static inline void apply(Box const& box, Point& centroid)
{
- throw centroid_exception();
+ coordinate_type const c1 = get<min_corner, Dimension>(box);
+ coordinate_type const c2 = get<max_corner, Dimension>(box);
+ coordinate_type m = c1 + c2;
+ m /= 2.0;
+
+ set<Dimension>(centroid, m);
+
+ centroid_box_calculator
+ <
+ Box, Point,
+ Dimension + 1, DimensionCount
+ >::apply(box, centroid);
}
- else
+};
+
+
+template<typename Box, typename Point, std::size_t DimensionCount>
+struct centroid_box_calculator<Box, Point, DimensionCount, DimensionCount>
+{
+ static inline void apply(Box const& , Point& )
{
- // n == 1: Take over the first point in a "coordinate neutral way"
- copy_coordinates(ring.front(), c);
+ }
+};
+
+
+template<typename Box, typename Point, typename Strategy>
+struct centroid_box
+{
+ static inline bool apply(Box const& box, Point& centroid,
+ Strategy const&, typename Strategy::state_type&)
+ {
+ centroid_box_calculator
+ <
+ Box, Point,
+ 0, dimension<Box>::type::value
+ >::apply(box, centroid);
return false;
}
- return true;
-}
+};
+
/*!
\brief Calculate the centroid of a ring.
@@ -92,14 +141,35 @@
template<typename Ring, typename Point, typename Strategy>
struct centroid_ring
{
- static inline void apply(Ring const& ring, Point& c, Strategy const& strategy)
+ static inline bool apply(Ring const& ring, Point& centroid,
+ Strategy const& strategy, typename Strategy::state_type& state)
{
- if (ring_ok(ring, c))
+ typedef typename boost::range_const_iterator<Ring>::type iterator_type;
+
+ // There is one thing where centroid is different from e.g. within.
+ // If the ring has only one point, it might make sense that
+ // that point is the centroid. So then, pass it twice, as a trick
+ // to avoid adding another method.
+
+ switch(boost::size(ring))
+ {
+ case 0 : // will cause exception in the end
+ return true;
+ case 1 :
+ Strategy::apply(ring.front(), ring.front(), state);
+ return false;
+ }
+
+ // Normal behaviour:
+
+ iterator_type it = boost::begin(ring);
+ for (iterator_type previous = it++;
+ it != boost::end(ring);
+ previous = it++)
{
- typename Strategy::state_type state;
- loop(ring, strategy, state);
- state.centroid(c);
+ Strategy::apply(*previous, *it, state);
}
+ return true;
}
};
@@ -112,45 +182,31 @@
template<typename Polygon, typename Point, typename Strategy>
struct centroid_polygon
{
- static inline void apply(Polygon const& poly, Point& c, Strategy const& strategy)
+ static inline bool apply(Polygon const& poly, Point& centroid,
+ Strategy const& strategy, typename Strategy::state_type& state)
{
- if (ring_ok(exterior_ring(poly), c))
- {
- typename Strategy::state_type state;
+ typedef centroid_ring
+ <
+ typename ring_type<Polygon>::type,
+ Point,
+ Strategy
+ > per_ring;
- loop(exterior_ring(poly), strategy, state);
+ per_ring::apply(exterior_ring(poly), centroid, strategy, state);
- typedef typename boost::range_const_iterator
+ for (typename boost::range_const_iterator
<
typename interior_type<Polygon>::type
- >::type iterator_type;
-
- for (iterator_type it = boost::begin(interior_rings(poly));
- it != boost::end(interior_rings(poly));
- ++it)
- {
- loop(*it, strategy, state);
- }
- state.centroid(c);
+ >::type it = boost::begin(interior_rings(poly));
+ it != boost::end(interior_rings(poly));
+ ++it)
+ {
+ per_ring::apply(*it, centroid, strategy, state);
}
+ return true; // always check exception
}
};
-/*!
- \brief Calculate centroid (==center) of a box
- \todo Implement strategy
-*/
-template<typename Box, typename Point, typename Strategy>
-struct centroid_box
-{
- static inline void apply(Box const& box, Point& c, Strategy const&)
- {
- // TODO: adapt using strategies
- assert_dimension<Box, 2>();
- set<0>(c, (get<min_corner, 0>(box) + get<max_corner, 0>(box)) / 2);
- set<1>(c, (get<min_corner, 1>(box) + get<max_corner, 1>(box)) / 2);
- }
-};
}} // namespace detail::centroid
#endif // DOXYGEN_NO_DETAIL
@@ -160,21 +216,45 @@
namespace dispatch
{
-template <typename Tag, typename Geometry, typename Point, typename Strategy>
+template
+<
+ typename Tag,
+ std::size_t Dimension,
+ typename Geometry,
+ typename Point,
+ typename Strategy
+>
struct centroid {};
-template <typename Box, typename Point, typename Strategy>
-struct centroid<box_tag, Box, Point, Strategy>
+template
+<
+ std::size_t Dimension,
+ typename Geometry,
+ typename Point,
+ typename Strategy
+>
+struct centroid<point_tag, Dimension, Geometry, Point, Strategy>
+ : detail::centroid::centroid_point<Geometry, Point, Strategy>
+{};
+
+template
+<
+ std::size_t Dimension,
+ typename Box,
+ typename Point,
+ typename Strategy
+>
+struct centroid<box_tag, Dimension, Box, Point, Strategy>
: detail::centroid::centroid_box<Box, Point, Strategy>
{};
template <typename Ring, typename Point, typename Strategy>
-struct centroid<ring_tag, Ring, Point, Strategy>
+struct centroid<ring_tag, 2, Ring, Point, Strategy>
: detail::centroid::centroid_ring<Ring, Point, Strategy>
{};
template <typename Polygon, typename Point, typename Strategy>
-struct centroid<polygon_tag, Polygon, Point, Strategy>
+struct centroid<polygon_tag, 2, Polygon, Point, Strategy>
: detail::centroid::centroid_polygon<Polygon, Point, Strategy>
{};
@@ -183,15 +263,60 @@
#endif // DOXYGEN_NO_DISPATCH
+
+/*!
+ \brief Calculate centroid using a specified strategy
+ \ingroup centroid
+ \param geometry the geometry to calculate centroid from
+ \param c reference to point which will contain the centroid
+ \param strategy Calculation strategy for centroid
+ \exception centroid_exception if calculation is not successful,
+ e.g. because polygon didn't contain points
+ */
+template<typename Geometry, typename Point, typename Strategy>
+inline void centroid(Geometry const& geometry, Point& c,
+ Strategy const& strategy)
+{
+ BOOST_CONCEPT_ASSERT( (ggl::concept::CentroidStrategy<Strategy>) );
+
+ concept::check<const Geometry>();
+ concept::check<Point>();
+
+ assert_dimension_equal<Geometry, Point>();
+ typedef typename point_type<Geometry>::type point_type;
+
+ typename Strategy::state_type state;
+
+ // Call dispatch apply method. That one returns true if centroid
+ // should be taken from state.
+ if (dispatch::centroid
+ <
+ typename tag<Geometry>::type,
+ dimension<point_type>::type::value,
+ Geometry,
+ Point,
+ Strategy
+ >::apply(geometry, c, strategy, state))
+ {
+ if (! Strategy::result(state, c))
+ {
+ throw centroid_exception();
+ }
+ }
+}
+
+
+
/*!
\brief Calculate centroid
\ingroup centroid
- \details The function centroid calculates the centroid of a geometry using the default strategy.
- A polygon should be closed and orientated clockwise, holes, if any, must be orientated
- counter clockwise
+ \details The function centroid calculates the centroid of a geometry
+ using the default strategy.
+ Polygon should be closed, and can be orientated either way
\param geometry a geometry (e.g. closed ring or polygon)
\param c reference to point which will contain the centroid
- \exception centroid_exception if calculation is not successful, e.g. because polygon didn't contain points
+ \exception centroid_exception if calculation is not successful,
+ e.g. because polygon didn't contain points
\par Example:
Example showing centroid calculation
\dontinclude doxygen_examples.cpp
@@ -199,44 +324,21 @@
\line {
\until }
*/
-template<typename G, typename P>
-inline void centroid(const G& geometry, P& c)
+template<typename Geometry, typename Point>
+inline void centroid(Geometry const& geometry, Point& c)
{
- typedef typename point_type<G>::type point_type;
+ concept::check<const Geometry>();
+ concept::check<Point>();
+
+ typedef typename point_type<Geometry>::type point_type;
typedef typename strategy_centroid
<
typename cs_tag<point_type>::type,
- P,
+ Point,
point_type
>::type strategy_type;
- dispatch::centroid
- <
- typename tag<G>::type,
- G,
- P,
- strategy_type
- >::apply(geometry, c, strategy_type());
-}
-
-/*!
- \brief Calculate centroid using a specified strategy
- \ingroup centroid
- \param geometry the geometry to calculate centroid from
- \param c reference to point which will contain the centroid
- \param strategy Calculation strategy for centroid
- \exception centroid_exception if calculation is not successful, e.g. because polygon didn't contain points
- */
-template<typename G, typename P, typename S>
-inline void centroid(const G& geometry, P& c, S const& strategy)
-{
- dispatch::centroid
- <
- typename tag<G>::type,
- G,
- P,
- S
- >::apply(geometry, c, strategy);
+ centroid(geometry, c, strategy_type());
}
// Versions returning a centroid
@@ -246,12 +348,16 @@
\ingroup centroid
\param geometry the geometry to calculate centroid from
\return the centroid
- \exception centroid_exception if calculation is not successful, e.g. because polygon didn't contain points
+ \exception centroid_exception if calculation is not successful,
+ e.g. because polygon didn't contain points
*/
-template<typename P, typename G>
-inline P make_centroid(const G& geometry)
+template<typename Point, typename Geometry>
+inline Point make_centroid(Geometry const& geometry)
{
- P c;
+ concept::check<const Geometry>();
+ concept::check<Point>();
+
+ Point c;
centroid(geometry, c);
return c;
}
@@ -262,12 +368,18 @@
\param geometry the geometry to calculate centroid from
\param strategy Calculation strategy for centroid
\return the centroid
- \exception centroid_exception if calculation is not successful, e.g. because polygon didn't contain points
+ \exception centroid_exception if calculation is not successful,
+ e.g. because polygon didn't contain points
*/
-template<typename P, typename G, typename S>
-inline P make_centroid(const G& geometry, S const& strategy)
+template<typename Point, typename Geometry, typename Strategy>
+inline Point make_centroid(Geometry const& geometry, Strategy const& strategy)
{
- P c;
+ BOOST_CONCEPT_ASSERT( (ggl::concept::CentroidStrategy<Strategy>) );
+
+ concept::check<const Geometry>();
+ concept::check<Point>();
+
+ Point c;
centroid(geometry, c, strategy);
return c;
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/clear.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/clear.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/clear.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -9,72 +9,53 @@
#ifndef GGL_ALGORITHMS_CLEAR_HPP
#define GGL_ALGORITHMS_CLEAR_HPP
+#include <boost/type_traits/remove_const.hpp>
+
#include <ggl/core/access.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
-namespace ggl
-{
+#include <ggl/geometries/concepts/check.hpp>
-// This traits is currently NOT defined in ../core/ but here, just because it default
-// does not have to be implemented
-namespace traits
-{
-/*!
- \brief Traits class, optional, might be implemented to clear a geometry
- \details If a geometry type should not use the std ".clear()" then it can specialize
- the "use_std" traits class to false, it should then implement (a.o.) clear
- \ingroup traits
- \par Geometries:
- - linestring
- - linear_ring
- \par Specializations should provide:
- - apply
- */
-template <typename G>
-struct clear
+namespace ggl
{
-};
-
-} // namespace traits
-
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace clear {
-template <typename G>
+template <typename Geometry>
struct use_std_clear
{
- static inline void apply(G& geometry)
+ static inline void apply(Geometry& geometry)
{
geometry.clear();
}
};
-template <typename G>
+template <typename Geometry>
struct use_traits_clear
{
- static inline void apply(G& geometry)
+ static inline void apply(Geometry& geometry)
{
- traits::clear<G>::apply(geometry);
+ traits::clear<Geometry>::apply(geometry);
}
};
-template <typename P>
+template <typename Polygon>
struct polygon_clear
{
- static inline void apply(P& polygon)
+ static inline void apply(Polygon& polygon)
{
interior_rings(polygon).clear();
exterior_ring(polygon).clear();
}
};
-template <typename G>
+template <typename Geometry>
struct no_action
{
- static inline void apply(G& geometry)
+ static inline void apply(Geometry& geometry)
{
}
};
@@ -86,50 +67,46 @@
namespace dispatch
{
-template <typename Tag, bool Std, typename G>
+template <typename Tag, bool UseStd, typename Geometry>
struct clear
{};
// True (default for all geometry types, unless otherwise implemented in traits)
// uses std::clear
-template <typename Tag, typename G>
-struct clear<Tag, true, G>
- : detail::clear::use_std_clear<G>
+template <typename Tag, typename Geometry>
+struct clear<Tag, true, Geometry>
+ : detail::clear::use_std_clear<Geometry>
{};
-// If any geometry specializes use_std<G> to false, specialize to use the traits clear.
-template <typename Tag, typename G>
-struct clear<Tag, false, G>
- : detail::clear::use_traits_clear<G>
+// If any geometry specializes use_std<Geometry> to false, specialize to use the traits clear.
+template <typename Tag, typename Geometry>
+struct clear<Tag, false, Geometry>
+ : detail::clear::use_traits_clear<Geometry>
{};
-// Point/box/nsphere/segment do not have clear. So specialize to do nothing.
-template <typename G>
-struct clear<point_tag, true, G>
- : detail::clear::no_action<G>
+// Point/box/segment do not have clear. So specialize to do nothing.
+template <typename Geometry>
+struct clear<point_tag, true, Geometry>
+ : detail::clear::no_action<Geometry>
{};
-template <typename G>
-struct clear<box_tag, true, G>
- : detail::clear::no_action<G>
+template <typename Geometry>
+struct clear<box_tag, true, Geometry>
+ : detail::clear::no_action<Geometry>
{};
-template <typename G>
-struct clear<segment_tag, true, G>
- : detail::clear::no_action<G>
+template <typename Geometry>
+struct clear<segment_tag, true, Geometry>
+ : detail::clear::no_action<Geometry>
{};
-template <typename G>
-struct clear<nsphere_tag, true, G>
- : detail::clear::no_action<G>
-{};
// Polygon can (indirectly) use std for clear
-template <typename P>
-struct clear<polygon_tag, true, P>
- : detail::clear::polygon_clear<P>
+template <typename Polygon>
+struct clear<polygon_tag, true, Polygon>
+ : detail::clear::polygon_clear<Polygon>
{};
@@ -143,16 +120,19 @@
\ingroup access
\note points and boxes cannot be cleared, instead they can be set to zero by "assign_zero"
*/
-template <typename G>
-inline void clear(G& geometry)
+template <typename Geometry>
+inline void clear(Geometry& geometry)
{
- typedef typename boost::remove_const<G>::type ncg_type;
+ concept::check<Geometry>();
dispatch::clear
<
- typename tag<G>::type,
- traits::use_std<ncg_type>::value,
- ncg_type
+ typename tag<Geometry>::type,
+ traits::use_std
+ <
+ typename boost::remove_const<Geometry>::type
+ >::value,
+ Geometry
>::apply(geometry);
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/combine.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/combine.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/combine.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -13,10 +13,11 @@
#include <boost/numeric/conversion/cast.hpp>
-#include <ggl/arithmetic/arithmetic.hpp>
#include <ggl/core/coordinate_dimension.hpp>
-#include <ggl/core/concepts/box_concept.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
+#include <ggl/arithmetic/arithmetic.hpp>
+
#include <ggl/util/select_coordinate_type.hpp>
/*!
@@ -175,6 +176,9 @@
template <typename Box, typename Geometry>
inline void combine(Box& box, Geometry const& geometry)
{
+ concept::check<const Geometry>();
+ concept::check<Box>();
+
assert_dimension_equal<Box, Geometry>();
dispatch::combine
<
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/convert.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/convert.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/convert.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -16,8 +16,12 @@
#include <boost/range/metafunctions.hpp>
#include <ggl/algorithms/append.hpp>
+#include <ggl/algorithms/assign.hpp>
#include <ggl/algorithms/for_each.hpp>
+
#include <ggl/core/cs.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/geometries/segment.hpp>
#include <ggl/strategies/strategies.hpp>
@@ -59,20 +63,20 @@
namespace dispatch
{
-template
+template
<
- typename T1, typename T2,
- std::size_t Dimensions,
+ typename T1, typename T2,
+ std::size_t Dimensions,
typename G1, typename G2
>
struct convert
{
};
-template
+template
<
- typename T,
- std::size_t Dimensions,
+ typename T,
+ std::size_t Dimensions,
typename G1, typename G2
>
struct convert<T, T, Dimensions, G1, G2>
@@ -157,6 +161,9 @@
template <typename G1, typename G2>
inline void convert(G1 const& geometry1, G2& geometry2)
{
+ concept::check<const G1>();
+ concept::check<G2>();
+
assert_dimension_equal<G1, G2>();
dispatch::convert
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/convex_hull.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/convex_hull.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/convex_hull.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -17,7 +17,7 @@
#include <ggl/core/point_order.hpp>
#include <ggl/core/exterior_ring.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/check.hpp>
#include <ggl/strategies/strategies.hpp>
@@ -27,20 +27,22 @@
/*!
\defgroup convex_hull convex hull calculation
\par Source descriptions:
-- OGC description: Returns a geometric object that represents the convex hull of this geometric
-object. Convex hulls, being dependent on straight lines, can be accurately represented in linear interpolations
-for any geometry restricted to linear interpolations.
+- OGC description: Returns a geometric object that represents the convex hull of
+ this geometric object. Convex hulls, being dependent on straight lines, can
+ be accurately represented in linear interpolations
+ for any geometry restricted to linear interpolations.
\see http://en.wikipedia.org/wiki/Convex_hull
\par Performance
2776 counties of US are "hulled" in 0.9 seconds (other libraries: 0.9, 4.1, 3.3, 1.4 seconds)
-\note The convex hull is always a ring, holes are not possible. Therefore it is modelled as an output iterator.
-This gives the most flexibility, the user can decide what to do with it.
+\note The convex hull is always a ring, holes are not possible. Therefore it is
+ can also be used in combination with an output iterator.
\par Geometries:
In the images below the convex hull is painted in red.
- POINT: will not compile
-- POLYGON: will deliver a polygon without holes \image html convexhull_polygon_polygon.png
+- POLYGON: will deliver a polygon without holes
+ \image html convexhull_polygon_polygon.png
*/
namespace ggl {
@@ -212,6 +214,9 @@
inline void convex_hull(Geometry1 const& geometry,
Geometry2& out)
{
+ concept::check<const Geometry1>();
+ concept::check<Geometry2>();
+
dispatch::convex_hull
<
typename tag<Geometry1>::type,
@@ -231,13 +236,18 @@
\param out an output iterator outputing points of the convex hull
\note This overloaded version outputs to an output iterator.
In this case, nothing is known about its point-type or
- about its clockwise order. Therefore, the input point-type and order are copied
+ about its clockwise order. Therefore, the input point-type
+ and order are copied
*/
template<typename Geometry, typename OutputIterator>
inline OutputIterator convex_hull_inserter(Geometry const& geometry,
OutputIterator out)
{
+ // Concept: output point type = point type of input geometry
+ concept::check<const Geometry>();
+ concept::check<typename point_type<Geometry>::type>();
+
return dispatch::convex_hull_inserter
<
typename tag<Geometry>::type,
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/correct.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/correct.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/correct.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -9,6 +9,7 @@
#ifndef GGL_ALGORITHMS_CORRECT_HPP
#define GGL_ALGORITHMS_CORRECT_HPP
+#include <cstddef>
#include <algorithm>
#include <functional>
@@ -20,7 +21,7 @@
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/check.hpp>
#include <ggl/algorithms/area.hpp>
#include <ggl/algorithms/disjoint.hpp>
@@ -33,7 +34,7 @@
namespace detail { namespace correct {
-template <typename Box, int Dimension, int DimensionCount>
+template <typename Box, std::size_t Dimension, std::size_t DimensionCount>
struct correct_box_loop
{
typedef typename coordinate_type<Box>::type coordinate_type;
@@ -58,7 +59,7 @@
-template <typename Box, int DimensionCount>
+template <typename Box, std::size_t DimensionCount>
struct correct_box_loop<Box, DimensionCount, DimensionCount>
{
static inline void apply(Box& box)
@@ -156,32 +157,34 @@
namespace dispatch
{
-template <typename Tag, typename G>
+template <typename Tag, typename Geometry>
struct correct {};
-template <typename B>
-struct correct<box_tag, B>
- : detail::correct::correct_box<B>
+template <typename Box>
+struct correct<box_tag, Box>
+ : detail::correct::correct_box<Box>
{};
-template <typename R>
-struct correct<ring_tag, R>
- : detail::correct::correct_ring<R, std::less<double> >
+template <typename Ring>
+struct correct<ring_tag, Ring>
+ : detail::correct::correct_ring<Ring, std::less<double> >
{};
-template <typename P>
-struct correct<polygon_tag, P>
- : detail::correct::correct_polygon<P>
+template <typename Polygon>
+struct correct<polygon_tag, Polygon>
+ : detail::correct::correct_polygon<Polygon>
{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
-template <typename G>
-inline void correct(G& geometry)
+template <typename Geometry>
+inline void correct(Geometry& geometry)
{
- dispatch::correct<typename tag<G>::type, G>::apply(geometry);
+ concept::check<const Geometry>();
+
+ dispatch::correct<typename tag<Geometry>::type, Geometry>::apply(geometry);
}
} // namespace ggl
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/disjoint.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/disjoint.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/disjoint.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -18,6 +18,9 @@
#include <ggl/core/coordinate_dimension.hpp>
#include <ggl/core/is_multi.hpp>
#include <ggl/core/reverse_dispatch.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/util/math.hpp>
#include <ggl/util/select_coordinate_type.hpp>
@@ -184,6 +187,9 @@
inline bool disjoint(const Geometry1& geometry1,
const Geometry2& geometry2)
{
+ concept::check<const Geometry1>();
+ concept::check<const Geometry2>();
+
assert_dimension_equal<Geometry1, Geometry2>();
typedef typename boost::remove_const<Geometry1>::type ncg1_type;
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/distance.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/distance.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/distance.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -328,6 +328,9 @@
inline typename distance_result<Geometry1, Geometry2>::type distance(
Geometry1 const& geometry1, Geometry2 const& geometry2)
{
+ concept::check<const Geometry1>();
+ concept::check<const Geometry2>();
+
typedef typename point_type<Geometry1>::type point1_type;
typedef typename point_type<Geometry2>::type point2_type;
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/envelope.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/envelope.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/envelope.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -9,7 +9,6 @@
#ifndef GGL_ALGORITHMS_ENVELOPE_HPP
#define GGL_ALGORITHMS_ENVELOPE_HPP
-#include <boost/concept/requires.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <boost/numeric/conversion/cast.hpp>
@@ -18,24 +17,26 @@
#include <ggl/algorithms/convert.hpp>
#include <ggl/core/cs.hpp>
#include <ggl/core/exterior_ring.hpp>
-#include <ggl/core/concepts/box_concept.hpp>
-#include <ggl/core/concepts/linestring_concept.hpp>
-#include <ggl/core/concepts/nsphere_concept.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/core/concepts/polygon_concept.hpp>
-#include <ggl/core/concepts/ring_concept.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
+
#include <ggl/strategies/strategies.hpp>
/*!
\defgroup envelope envelope calculation
\par Source descriptions:
-- OGC: Envelope (): Geometry - The minimum bounding rectangle (MBR) for this Geometry,
-returned as a Geometry. The polygon is defined by the corner points of the bounding
-box [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].
+- OGC: Envelope (): Geometry - The minimum bounding rectangle (MBR) for this
+ Geometry,
+returned as a Geometry. The polygon is defined by the corner points of the
+ bounding box
+ [(MINX, MINY), (MAXX, MINY), (MAXX, MAXY), (MINX, MAXY), (MINX, MINY)].
-\note Implemented in the Generic Geometry Library: The minimum bounding box, always as a box, having min <= max
+\note Implemented in the Generic Geometry Library: The minimum bounding box,
+ always as a box, having min <= max
-The envelope algorithm calculates the bounding box, or envelope, of a geometry. There are two versions:
+The envelope algorithm calculates the bounding box, or envelope, of a geometry.
+There are two versions:
- envelope, taking a reference to a box as second parameter
- make_envelope, returning a newly constructed box (type as a template parameter in the function call)
- either of them has an optional strategy
@@ -43,10 +44,11 @@
\par Geometries:
- POINT: a box with zero area, the maximum and the minimum point of the box are
set to the point itself.
-- LINESTRING, RING or RANGE is the smallest box that contains all points of the specified
-point sequence.
-If the linestring is empty, the envelope is the inverse infinite box, that is, the minimum point is very
-large (max infinite) and the maximum point is very small (min infinite).
+- LINESTRING, RING or RANGE is the smallest box that contains all points of the
+ specified point sequence.
+If the linestring is empty, the envelope is the inverse infinite box, that is,
+ the minimum point is very large (max infinite) and the maximum point is
+ very small (min infinite).
- POLYGON, the envelope of the outer ring
\image html envelope_polygon.png
@@ -64,31 +66,16 @@
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace envelope {
-/// Calculate envelope of an n-sphere, circle or sphere (currently only for Cartesian 2D points)
-template<typename B, typename S, typename Strategy>
-struct envelope_nsphere
-{
- static inline void apply(S const& s, B& mbr, Strategy const&)
- {
- assert_dimension<S, 2>();
- assert_dimension<B, 2>();
-
- typename radius_type<S>::type r = get_radius<0>(s);
- set<min_corner, 0>(mbr, get<0>(s) - r);
- set<min_corner, 1>(mbr, get<1>(s) - r);
- set<max_corner, 0>(mbr, get<0>(s) + r);
- set<max_corner, 1>(mbr, get<1>(s) + r);
- }
-};
/// Calculate envelope of an 2D or 3D point
-template<typename P, typename B, typename Strategy>
+template<typename Point, typename Box, typename Strategy>
struct envelope_point
{
- static inline void apply(P const& p, B& mbr, Strategy const&)
+ static inline void apply(Point const& p, Box& mbr, Strategy const&)
{
- // Envelope of a point is an empty box, a box with zero volume, located at the point.
+ // Envelope of a point is an empty box, a box with zero volume, located
+ // at the point.
// We just use the convert algorithm here
ggl::convert(p, mbr);
}
@@ -96,10 +83,10 @@
/// Calculate envelope of an 2D or 3D segment
-template<typename S, typename B, typename Strategy>
+template<typename Segment, typename Box, typename Strategy>
struct envelope_segment
{
- static inline void apply(S const& s, B& mbr, Strategy const&)
+ static inline void apply(Segment const& s, Box& mbr, Strategy const&)
{
// TODO: remove s.first/s.second, use strategies
ggl::assign_inverse(mbr);
@@ -110,12 +97,15 @@
/// Version with state iterating through range (also used in multi*)
-template<typename R, typename Strategy>
-inline void envelope_range_state(R const& range, Strategy const& strategy, typename Strategy::state_type& state)
-{
- typedef typename boost::range_const_iterator<R>::type iterator_type;
-
- for (iterator_type it = boost::begin(range); it != boost::end(range); it++)
+template<typename Range, typename Strategy>
+inline void envelope_range_state(Range const& range,
+ Strategy const& strategy, typename Strategy::state_type& state)
+{
+ typedef typename boost::range_const_iterator<Range>::type iterator_type;
+
+ for (iterator_type it = boost::begin(range);
+ it != boost::end(range);
+ ++it)
{
strategy(*it, state);
}
@@ -124,11 +114,12 @@
/// Generic range dispatching struct
-template <typename R, typename B, typename Strategy>
+template <typename Range, typename Box, typename Strategy>
struct envelope_range
{
/// Calculate envelope of range using a strategy
- static inline void apply(R const& range, B& mbr, Strategy const& strategy)
+ static inline void apply(Range const& range, Box& mbr,
+ Strategy const& strategy)
{
typename Strategy::state_type state(mbr);
envelope_range_state(range, strategy, state);
@@ -151,87 +142,62 @@
struct envelope {};
-template <typename P, typename B, typename Strategy>
-struct envelope<point_tag, box_tag, P, B, Strategy>
- : detail::envelope::envelope_point<P, B, Strategy>
-{
-private:
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P>) );
- BOOST_CONCEPT_ASSERT( (concept::Box<B>) );
-};
+template <typename Point, typename Box, typename Strategy>
+struct envelope<point_tag, box_tag, Point, Box, Strategy>
+ : detail::envelope::envelope_point<Point, Box, Strategy>
+{};
-template <typename B, typename Strategy>
-struct envelope<box_tag, box_tag, B, B, Strategy>
+template <typename Box, typename Strategy>
+struct envelope<box_tag, box_tag, Box, Box, Strategy>
{
/*!
\brief Calculate envelope of a box
\details The envelope of a box is itself, provided
for consistency, on itself it is not useful.
*/
- static inline void apply(B const& b, B& mbr, Strategy const&)
+ static inline void apply(Box const& box, Box& mbr, Strategy const&)
{
- mbr = b;
+ mbr = box;
}
-
-private:
- BOOST_CONCEPT_ASSERT( (concept::Box<B>) );
};
-template <typename S, typename B, typename Strategy>
-struct envelope<segment_tag, box_tag, S, B, Strategy>
- : detail::envelope::envelope_segment<S, B, Strategy>
+template <typename Segment, typename Box, typename Strategy>
+struct envelope<segment_tag, box_tag, Segment, Box, Strategy>
+ : detail::envelope::envelope_segment<Segment, Box, Strategy>
{};
-template <typename S, typename B, typename Strategy>
-struct envelope<nsphere_tag, box_tag, S, B, Strategy>
- : detail::envelope::envelope_nsphere<S, B, Strategy>
-{
-private:
- BOOST_CONCEPT_ASSERT( (concept::ConstNsphere<S>) );
- BOOST_CONCEPT_ASSERT( (concept::Box<B>) );
-};
-template <typename L, typename B, typename Strategy>
-struct envelope<linestring_tag, box_tag, L, B, Strategy>
- : detail::envelope::envelope_range<L, B, Strategy>
-{
-private:
- BOOST_CONCEPT_ASSERT( (concept::ConstLinestring<L>) );
- BOOST_CONCEPT_ASSERT( (concept::Box<B>) );
-};
+template <typename Linestring, typename Box, typename Strategy>
+struct envelope<linestring_tag, box_tag, Linestring, Box, Strategy>
+ : detail::envelope::envelope_range<Linestring, Box, Strategy>
+{};
-template <typename R, typename B, typename Strategy>
-struct envelope<ring_tag, box_tag, R, B, Strategy>
- : detail::envelope::envelope_range<R, B, Strategy>
-{
-private:
- BOOST_CONCEPT_ASSERT( (concept::ConstRing<R>) );
- BOOST_CONCEPT_ASSERT( (concept::Box<B>) );
-};
+template <typename Ring, typename Box, typename Strategy>
+struct envelope<ring_tag, box_tag, Ring, Box, Strategy>
+ : detail::envelope::envelope_range<Ring, Box, Strategy>
+{};
-template <typename P, typename B, typename Strategy>
-struct envelope<polygon_tag, box_tag, P, B, Strategy>
+template <typename Polygon, typename Box, typename Strategy>
+struct envelope<polygon_tag, box_tag, Polygon, Box, Strategy>
{
- static inline void apply(P const& poly, B& mbr, Strategy const& strategy)
+ static inline void apply(Polygon const& poly, Box& mbr,
+ Strategy const& strategy)
{
- // For polygon inspecting outer linear_ring is sufficient
+ // For polygon, inspecting outer ring is sufficient
detail::envelope::envelope_range
<
- typename ring_type<P>::type,
- B,
+ typename ring_type<Polygon>::type,
+ Box,
Strategy
>::apply(exterior_ring(poly), mbr, strategy);
}
-private:
- BOOST_CONCEPT_ASSERT( (concept::ConstPolygon<P>) );
- BOOST_CONCEPT_ASSERT( (concept::Box<B>) );
};
@@ -246,13 +212,17 @@
\param mbr the box receiving the envelope
\param strategy strategy to be used
*/
-template<typename G, typename B, typename S>
-inline void envelope(G const& geometry, B& mbr, S const& strategy)
+template<typename Geometry, typename Box, typename Strategy>
+inline void envelope(Geometry const& geometry,
+ Box& mbr, Strategy const& strategy)
{
+ concept::check<const Geometry>();
+ concept::check<Box>();
+
dispatch::envelope
<
- typename tag<G>::type, typename tag<B>::type,
- G, B, S
+ typename tag<Geometry>::type, typename tag<Box>::type,
+ Geometry, Box, Strategy
>::apply(geometry, mbr, strategy);
}
@@ -271,15 +241,18 @@
\line {
\until }
*/
-template<typename G, typename B>
-inline void envelope(G const& geometry, B& mbr)
+template<typename Geometry, typename Box>
+inline void envelope(Geometry const& geometry, Box& mbr)
{
+ concept::check<const Geometry>();
+ concept::check<Box>();
+
typename strategy_envelope
<
- typename cs_tag<typename point_type<G>::type>::type,
- typename cs_tag<typename point_type<B>::type>::type,
- typename point_type<G>::type,
- B
+ typename cs_tag<typename point_type<Geometry>::type>::type,
+ typename cs_tag<typename point_type<Box>::type>::type,
+ typename point_type<Geometry>::type,
+ Box
>::type strategy;
envelope(geometry, mbr, strategy);
@@ -292,14 +265,17 @@
\param geometry the geometry
\param strategy the strategy to be used
*/
-template<typename B, typename G, typename S>
-inline B make_envelope(G const& geometry, S const& strategy)
+template<typename Box, typename Geometry, typename Strategy>
+inline Box make_envelope(Geometry const& geometry, Strategy const& strategy)
{
- B box;
+ concept::check<const Geometry>();
+ concept::check<Box>();
+
+ Box box;
dispatch::envelope
<
- typename tag<G>::type, typename tag<B>::type,
- G, B, S
+ typename tag<Geometry>::type, typename tag<Box>::type,
+ Geometry, Box, Strategy
>::apply(geometry, box, strategy);
return box;
@@ -311,17 +287,20 @@
\ingroup envelope
\param geometry the geometry
*/
-template<typename B, typename G>
-inline B make_envelope(G const& geometry)
+template<typename Box, typename Geometry>
+inline Box make_envelope(Geometry const& geometry)
{
+ concept::check<const Geometry>();
+ concept::check<Box>();
+
typename strategy_envelope
<
- typename cs_tag<typename point_type<G>::type>::type,
- typename cs_tag<typename point_type<B>::type>::type,
- typename point_type<G>::type,
- B
+ typename cs_tag<typename point_type<Geometry>::type>::type,
+ typename cs_tag<typename point_type<Box>::type>::type,
+ typename point_type<Geometry>::type,
+ Box
>::type strategy;
- return make_envelope<B>(geometry, strategy);
+ return make_envelope<Box>(geometry, strategy);
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/equals.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/equals.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/equals.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -110,6 +110,8 @@
template <typename Geometry1, typename Geometry2>
inline bool equals(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
+ concept::check<const Geometry1>();
+ concept::check<const Geometry2>();
assert_dimension_equal<Geometry1, Geometry2>();
// TODO: assert types equal:
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/for_each.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/for_each.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/for_each.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,15 +12,14 @@
/*!
\defgroup loop loops and for-each functionality
There are several algorithms provided which walk through the points or segments
-of linestrings and polygons. They are called for_each_point, for_each_segment, after
-the standard library, and \b loop which is more adapted and of which the functor
-could break out if necessary.
+of linestrings and polygons. They are called for_each_point, for_each_segment,
+after the standard library, and \b loop which is more adapted
+and of which the functor could break out if necessary.
Of the for_each algorithms there is a \b const and a non-const version provided.
*/
#include <algorithm>
-#include <boost/concept/requires.hpp>
#include <boost/mpl/if.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
@@ -28,7 +27,9 @@
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
#include <ggl/core/is_multi.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/geometries/segment.hpp>
#include <ggl/iterators/vertex_iterator.hpp>
@@ -104,7 +105,10 @@
typename c_nc<Range, IsConst>::type& range,
Functor f)
{
- typedef typename ggl::vertex_iterator<Range, IsConst>::type iterator_type;
+ typedef typename ggl::vertex_iterator
+ <
+ Range, IsConst
+ >::type iterator_type;
typedef typename c_nc
<
@@ -134,14 +138,14 @@
{
typedef typename c_nc_range
<
- typename interior_type<Polygon>::type,
+ typename interior_type<Polygon>::type,
IsConst
>::type iterator_type;
typedef fe_range_per_point
<
- typename ring_type<Polygon>::type,
- Functor,
+ typename ring_type<Polygon>::type,
+ Functor,
IsConst
> per_ring;
@@ -169,14 +173,14 @@
{
typedef typename c_nc_range
<
- typename interior_type<Polygon>::type,
+ typename interior_type<Polygon>::type,
IsConst
>::type iterator_type;
typedef fe_range_per_segment
<
- typename ring_type<Polygon>::type,
- Functor,
+ typename ring_type<Polygon>::type,
+ Functor,
IsConst
> per_ring;
@@ -202,12 +206,12 @@
namespace dispatch
{
-template
+template
<
- typename Tag,
- bool IsMulti,
- typename Geometry,
- typename Functor,
+ typename Tag,
+ bool IsMulti,
+ typename Geometry,
+ typename Functor,
bool IsConst
>
struct for_each_point {};
@@ -235,12 +239,12 @@
-template
+template
<
- typename Tag,
- bool IsMulti,
- typename Geometry,
- typename Functor,
+ typename Tag,
+ bool IsMulti,
+ typename Geometry,
+ typename Functor,
bool IsConst
>
struct for_each_segment {};
@@ -279,12 +283,14 @@
template<typename Geometry, typename Functor>
inline Functor for_each_point(Geometry const& geometry, Functor f)
{
+ concept::check<const Geometry>();
+
return dispatch::for_each_point
<
- typename tag<Geometry>::type,
+ typename tag<Geometry>::type,
is_multi<Geometry>::type::value,
- Geometry,
- Functor,
+ Geometry,
+ Functor,
true
>::apply(geometry, f);
}
@@ -299,12 +305,14 @@
template<typename Geometry, typename Functor>
inline Functor for_each_point(Geometry& geometry, Functor f)
{
+ concept::check<Geometry>();
+
return dispatch::for_each_point
<
- typename tag<Geometry>::type,
+ typename tag<Geometry>::type,
is_multi<Geometry>::type::value,
- Geometry,
- Functor,
+ Geometry,
+ Functor,
false
>::apply(geometry, f);
}
@@ -314,17 +322,20 @@
\ingroup loop
\param geometry geometry to loop through
\param f functor to use
- \details Calls the functor all \b const segments of the specified \b const geometry
+ \details Calls the functor all \b const segments of the
+ specified \b const geometry
*/
template<typename Geometry, typename Functor>
inline Functor for_each_segment(Geometry const& geometry, Functor f)
{
+ concept::check<const Geometry>();
+
return dispatch::for_each_segment
<
- typename tag<Geometry>::type,
+ typename tag<Geometry>::type,
is_multi<Geometry>::type::value,
- Geometry,
- Functor,
+ Geometry,
+ Functor,
true
>::apply(geometry, f);
}
@@ -340,12 +351,14 @@
template<typename Geometry, typename Functor>
inline Functor for_each_segment(Geometry& geometry, Functor f)
{
+ concept::check<Geometry>();
+
return dispatch::for_each_segment
<
- typename tag<Geometry>::type,
+ typename tag<Geometry>::type,
is_multi<Geometry>::type::value,
- Geometry,
- Functor,
+ Geometry,
+ Functor,
false
>::apply(geometry, f);
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/get_section.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/get_section.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/get_section.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -10,8 +10,6 @@
#define GGL_ALGORITHMS_GET_SECTION_HPP
-#include <boost/concept_check.hpp>
-#include <boost/concept/requires.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
@@ -86,6 +84,8 @@
typename vertex_iterator<Geometry, true>::type& begin,
typename vertex_iterator<Geometry, true>::type& end)
{
+ concept::check<const Geometry>();
+
dispatch::get_section
<
typename tag<Geometry>::type,
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/intermediate.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/intermediate.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/intermediate.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -16,7 +16,7 @@
#include <boost/range/metafunctions.hpp>
#include <ggl/core/cs.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/check.hpp>
#include <ggl/strategies/strategies.hpp>
/*!
@@ -52,19 +52,20 @@
}
};
-template<typename R, typename Iterator>
+template<typename Range, typename Iterator>
struct range_intermediate
{
- static inline void apply(R const& range, bool start_and_end, Iterator out)
+ static inline void apply(Range const& range,
+ bool start_and_end, Iterator out)
{
- typedef typename point_type<R>::type point_type;
- typedef typename boost::range_const_iterator<R>::type iterator_type;
+ typedef typename point_type<Range>::type point_type;
+ typedef typename boost::range_const_iterator<Range>::type iterator_type;
iterator_type it = boost::begin(range);
if (start_and_end)
{
- (*out++) = *it;
+ *out++ = *it;
}
iterator_type prev = it++;
@@ -78,12 +79,12 @@
0,
dimension<point_type>::type::value
>::apply(*prev, *it, p);
- *(out++) = p;
+ *out++ = p;
}
if (start_and_end)
{
- (*out++) = *prev;
+ *out++ = *prev;
}
}
};
@@ -115,10 +116,18 @@
\brief Calculate intermediate of a geometry
\ingroup intermediate
*/
-template<typename G, typename Iterator>
-inline void intermediate(const G& geometry, bool start_and_end, Iterator out)
-{
- dispatch::intermediate<typename tag<G>::type, G, Iterator>::apply(geometry, start_and_end, out);
+template<typename Geometry, typename Iterator>
+inline void intermediate(Geometry const& geometry,
+ bool start_and_end, Iterator out)
+{
+ concept::check<const Geometry>();
+
+ dispatch::intermediate
+ <
+ typename tag<Geometry>::type,
+ Geometry,
+ Iterator
+ >::apply(geometry, start_and_end, out);
}
} // namespace ggl
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersection.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersection.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersection.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -13,6 +13,7 @@
#include <boost/mpl/if.hpp>
+#include <ggl/geometries/concepts/check.hpp>
#include <ggl/algorithms/intersection_linestring.hpp>
@@ -428,6 +429,8 @@
Geometry2 const& geometry2,
OutputIterator out)
{
+ concept::check<const Geometry1>();
+ concept::check<const Geometry2>();
return boost::mpl::if_c
<
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersects.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersects.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/intersects.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -9,6 +9,8 @@
#ifndef GGL_ALGORITHMS_INTERSECTS_HPP
#define GGL_ALGORITHMS_INTERSECTS_HPP
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/algorithms/intersection_linestring.hpp>
#include <ggl/algorithms/overlay/get_intersection_points.hpp>
@@ -39,6 +41,8 @@
template <typename Geometry>
inline bool intersects(Geometry const& geometry)
{
+ concept::check<const Geometry>();
+
typedef typename boost::remove_const<Geometry>::type ncg_type;
typedef std::vector<ggl::detail::intersection::intersection_point
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/length.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/length.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/length.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -18,16 +18,20 @@
#include <boost/type_traits.hpp>
-#include <ggl/algorithms/detail/calculate_null.hpp>
#include <ggl/core/cs.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
+#include <ggl/algorithms/detail/calculate_null.hpp>
+
#include <ggl/strategies/strategies.hpp>
#include <ggl/strategies/length_result.hpp>
/*!
\defgroup length length calculation
-The length algorithm is implemented for the linestring and the multi_linestring geometry and results
-in the length of the linestring. If the points of a linestring have coordinates expressed in kilometers,
+The length algorithm is implemented for the linestring and the multi_linestring
+geometry and results in the length of the linestring. If the points of
+a linestring have coordinates expressed in kilometers,
the length of the line is expressed in kilometers as well.
\par Example:
Example showing length calculation
@@ -53,15 +57,18 @@
Segment const& segment, Strategy const& strategy)
{
// BSG 10 APR 2009
- // TODO: the segment concept has to be such that it is easy to return a point from it.
+ // TODO: the segment concept has to be such that it is easy
+ // to return a point from it.
// Now it only accesses per coordinate
return strategy(segment.first, segment.second);
}
};
/*!
-\brief Internal, calculates length of a linestring using iterator pairs and specified strategy
-\note for_each could be used here, now that point_type is changed by boost range iterator
+\brief Internal, calculates length of a linestring using iterator pairs and
+ specified strategy
+\note for_each could be used here, now that point_type is changed by boost
+ range iterator
*/
template<typename Range, typename Strategy>
struct range_length
@@ -80,7 +87,8 @@
iterator_type previous = it++;
while(it != boost::end(range))
{
- // Add point-point distance using the return type belonging to strategy
+ // Add point-point distance using the return type belonging
+ // to strategy
sum += strategy(*previous, *it);
previous = it++;
}
@@ -101,8 +109,8 @@
template <typename Tag, typename Geometry, typename Strategy>
struct length : detail::calculate_null
<
- typename length_result<Geometry>::type,
- Geometry,
+ typename length_result<Geometry>::type,
+ Geometry,
Strategy
>
{};
@@ -114,11 +122,11 @@
{};
-// RING: length is currently 0.0 but it might be argued that it is the "perimeter"
+// RING: length is currently 0; it might be argued that it is the "perimeter"
template <typename Geometry, typename Strategy>
-struct length<segment_tag, Geometry, Strategy>
+struct length<segment_tag, Geometry, Strategy>
: detail::length::segment_length<Geometry, Strategy>
{};
@@ -134,8 +142,10 @@
/*!
\brief Calculate length of a geometry
\ingroup length
- \details The function length returns the length of a geometry, using the default distance-calculation-strategy
- \param geometry the geometry, being a ggl::linestring, vector, iterator pair, or any other boost compatible range
+ \details The function length returns the length of a geometry, using the
+ default distance-calculation-strategy
+ \param geometry the geometry, being a ggl::linestring, vector,
+ iterator pair, or any other boost compatible range
\return the length
Example showing length calculation on a vector
\dontinclude doxygen_examples.cpp
@@ -147,6 +157,8 @@
inline typename length_result<Geometry>::type length(
Geometry const& geometry)
{
+ concept::check<const Geometry>();
+
typedef typename point_type<Geometry>::type point_type;
typedef typename cs_tag<point_type>::type cs_tag;
typedef typename strategy_distance
@@ -168,12 +180,15 @@
/*!
\brief Calculate length of a geometry
\ingroup length
- \details The function length returns the length of a geometry, using specified strategy
- \param geometry the geometry, being a ggl::linestring, vector, iterator pair, or any other boost compatible range
+ \details The function length returns the length of a geometry,
+ using specified strategy
+ \param geometry the geometry, being a ggl::linestring, vector,
+ iterator pair, or any other boost compatible range
\param strategy strategy to be used for distance calculations.
\return the length
\par Example:
- Example showing length calculation using iterators and the Vincenty strategy
+ Example showing length calculation using iterators
+ and the Vincenty strategy
\dontinclude doxygen_examples.cpp
\skip example_length_linestring_iterators3
\line {
@@ -183,10 +198,12 @@
inline typename length_result<Geometry>::type length(
Geometry const& geometry, Strategy const& strategy)
{
+ concept::check<const Geometry>();
+
return dispatch::length
- <
- typename tag<Geometry>::type,
- Geometry,
+ <
+ typename tag<Geometry>::type,
+ Geometry,
Strategy
>::apply(geometry, strategy);
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/make.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/make.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/make.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,6 +11,8 @@
#include <ggl/algorithms/assign.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
namespace ggl
{
@@ -27,6 +29,8 @@
template <typename G, typename T>
inline G make(T const& c1, T const& c2)
{
+ concept::check<G>();
+
G geometry;
dispatch::assign
<
@@ -40,11 +44,13 @@
/*!
\brief Make a geometry
\ingroup access
- \return a 3D point, a circle
+ \return a 3D point
*/
template <typename G, typename T>
inline G make(T const& c1, T const& c2, T const& c3)
{
+ concept::check<G>();
+
G geometry;
dispatch::assign
<
@@ -58,6 +64,8 @@
template <typename G, typename T>
inline G make(T const& c1, T const& c2, T const& c3, T const& c4)
{
+ concept::check<G>();
+
G geometry;
dispatch::assign
<
@@ -73,6 +81,8 @@
template <typename G, typename R>
inline G make(R const& range)
{
+ concept::check<G>();
+
G geometry;
append(geometry, range);
return geometry;
@@ -90,6 +100,8 @@
template <typename G>
inline G make_inverse()
{
+ concept::check<G>();
+
G geometry;
dispatch::assign_inverse
<
@@ -109,6 +121,8 @@
template <typename G>
inline G make_zero()
{
+ concept::check<G>();
+
G geometry;
dispatch::assign_zero
<
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/num_points.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/num_points.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/num_points.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -17,6 +17,8 @@
#include <ggl/core/is_linear.hpp>
#include <ggl/core/interior_rings.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
namespace ggl
{
@@ -102,11 +104,6 @@
{
};
-template <typename Geometry>
-struct num_points<nsphere_tag, false, Geometry>
- : detail::num_points::other_count<Geometry, 1>
-{
-};
template <typename Geometry>
struct num_points<polygon_tag, false, Geometry>
@@ -131,6 +128,8 @@
template <typename Geometry>
inline std::size_t num_points(Geometry const& geometry)
{
+ concept::check<const Geometry>();
+
typedef typename boost::remove_const<Geometry>::type ncg_type;
return dispatch::num_points
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlaps.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlaps.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlaps.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,6 +11,7 @@
#include <ggl/core/access.hpp>
+#include <ggl/geometries/concepts/check.hpp>
namespace ggl
{
@@ -32,9 +33,12 @@
where is stated that "inside" is not an "overlap", this is probably true and should then be implemented as such.
*/
-template <typename B>
-inline bool overlaps(const B& b1, const B& b2)
+template <typename Geometry1, typename Geometry2>
+inline bool overlaps(Geometry1 const& b1, Geometry2 const& b2)
{
+ concept::check<const Geometry1>();
+ concept::check<const Geometry2>();
+
return !(
get<max_corner, 0>(b1) <= get<min_corner, 0>(b2) ||
get<min_corner, 0>(b1) >= get<max_corner, 0>(b2) ||
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/adapt_turns.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/adapt_turns.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/adapt_turns.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -6,8 +6,8 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_ADAPT_TURNS_HPP
-#define GGL_ADAPT_TURNS_HPP
+#ifndef GGL_ALGORITHMS_OVERLAY_ADAPT_TURNS_HPP
+#define GGL_ALGORITHMS_OVERLAY_ADAPT_TURNS_HPP
#include <algorithm>
@@ -553,4 +553,4 @@
} // namespace ggl
-#endif // GGL_ADAPT_TURNS_HPP
+#endif // GGL_ALGORITHMS_OVERLAY_ADAPT_TURNS_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/copy_segments.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/copy_segments.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/copy_segments.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -14,6 +14,8 @@
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/algorithms/overlay/intersection_point.hpp>
#include <ggl/iterators/ever_circling_iterator.hpp>
@@ -196,6 +198,8 @@
SegmentIdentifier const& seg_id, int to_index,
RangeOut& range_out)
{
+ concept::check<const Geometry>();
+
dispatch::copy_segments
<
typename tag<Geometry>::type,
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/enrich_intersection_points.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/enrich_intersection_points.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/enrich_intersection_points.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -17,7 +17,7 @@
#include <iostream>
#endif
-#include <boost/concept_check.hpp>
+#include <boost/assert.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/get_intersection_points.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/get_intersection_points.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/get_intersection_points.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -26,6 +26,8 @@
#include <ggl/core/interior_rings.hpp>
#include <ggl/core/ring_type.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/util/math.hpp>
#include <ggl/geometries/box.hpp>
@@ -682,6 +684,9 @@
inline bool get_intersection_points(Geometry1 const& geometry1,
Geometry2 const& geometry2, IntersectionPoints& intersection_points)
{
+ concept::check<const Geometry1>();
+ concept::check<const Geometry2>();
+
assert_dimension_equal<Geometry1, Geometry2>();
typedef typename boost::remove_const<Geometry1>::type ncg1_type;
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/self_intersection_points.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/self_intersection_points.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/self_intersection_points.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -19,6 +19,8 @@
#include <ggl/core/coordinate_dimension.hpp>
#include <ggl/core/is_multi.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/algorithms/overlay/get_intersection_points.hpp>
@@ -149,6 +151,8 @@
inline bool get_intersection_points(Geometry const& geometry,
IntersectionPoints& intersection_points)
{
+ concept::check<Geometry>();
+
typedef typename boost::remove_const<Geometry>::type ncg_type;
return dispatch::self_intersection_points
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/traverse.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/traverse.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/traverse.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -17,6 +17,8 @@
#include <ggl/algorithms/overlay/copy_segments.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
#ifdef GGL_DEBUG_INTERSECTION
#include <ggl/extensions/gis/io/wkt/write_wkt.hpp>
#endif
@@ -305,6 +307,10 @@
bool trivial,
OutputIterator out)
{
+ concept::check<const Geometry1>();
+ concept::check<const Geometry2>();
+
+
typedef typename boost::range_iterator
<IntersectionPoints>::type ip_iterator;
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/perimeter.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/perimeter.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/perimeter.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -9,15 +9,11 @@
#ifndef GGL_ALGORITHMS_PERIMETER_HPP
#define GGL_ALGORITHMS_PERIMETER_HPP
-#include <cmath>
-#include <iterator>
-
-#include <boost/range/functions.hpp>
-#include <boost/range/metafunctions.hpp>
#include <ggl/core/cs.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/strategies/strategies.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/strategies/length_result.hpp>
#include <ggl/algorithms/length.hpp>
@@ -77,14 +73,18 @@
/*!
\brief Calculate perimeter of a geometry
\ingroup perimeter
- \details The function perimeter returns the perimeter of a geometry, using the default distance-calculation-strategy
- \param geometry the geometry, be it a ggl::ring, vector, iterator pair, or any other boost compatible range
+ \details The function perimeter returns the perimeter of a geometry,
+ using the default distance-calculation-strategy
+ \param geometry the geometry, be it a ggl::ring, vector, iterator pair,
+ or any other boost compatible range
\return the perimeter
*/
template<typename Geometry>
inline typename length_result<Geometry>::type perimeter(
Geometry const& geometry)
{
+ concept::check<const Geometry>();
+
typedef typename point_type<Geometry>::type point_type;
typedef typename cs_tag<point_type>::type cs_tag;
typedef typename strategy_distance
@@ -106,8 +106,10 @@
/*!
\brief Calculate perimeter of a geometry
\ingroup perimeter
- \details The function perimeter returns the perimeter of a geometry, using specified strategy
- \param geometry the geometry, be it a ggl::ring, vector, iterator pair, or any other boost compatible range
+ \details The function perimeter returns the perimeter of a geometry,
+ using specified strategy
+ \param geometry the geometry, be it a ggl::ring, vector, iterator pair,
+ or any other boost compatible range
\param strategy strategy to be used for distance calculations.
\return the perimeter
*/
@@ -115,6 +117,8 @@
inline typename length_result<Geometry>::type perimeter(
Geometry const& geometry, Strategy const& strategy)
{
+ concept::check<const Geometry>();
+
return dispatch::perimeter
<
typename tag<Geometry>::type,
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/sectionalize.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/sectionalize.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/sectionalize.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -13,7 +13,7 @@
#include <vector>
#include <boost/concept_check.hpp>
-#include <boost/concept/requires.hpp>
+
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
@@ -23,6 +23,9 @@
#include <ggl/core/access.hpp>
#include <ggl/core/exterior_ring.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
+
#include <ggl/util/math.hpp>
#include <ggl/geometries/segment.hpp>
@@ -552,6 +555,8 @@
template<typename Geometry, typename Sections>
inline void sectionalize(Geometry const& geometry, Sections& sections)
{
+ concept::check<const Geometry>();
+
// A maximum of 10 segments per section seems to give the fastest results
static const std::size_t max_segments_per_section = 10;
typedef dispatch::sectionalize
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/selected.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/selected.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/selected.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,15 +12,15 @@
#include <cmath>
#include <cstddef>
-#include <boost/concept/requires.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <ggl/algorithms/within.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/topological_dimension.hpp>
-#include <ggl/core/concepts/nsphere_concept.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
/*!
\defgroup selected selection: check if a geometry is "selected" by a point
@@ -209,9 +209,7 @@
{
static inline bool apply(G const& geometry, P const& selection_point, T const& search_radius)
{
- // Note the reversion, point-in-poly -> first point, then poly
- // Selected-at-point -> first geometry, then point
- return dispatch::within<point_tag, Tag, P, G>::apply(selection_point, geometry);
+ return ggl::within(selection_point, geometry);
}
};
@@ -249,8 +247,8 @@
/*!
\brief Checks if one geometry is selected by a point lying within or in the neighborhood of that geometry
\ingroup selected
- \tparam G type of geometry to check
- \tparam P type of point to check
+ \tparam Geometry type of geometry to check
+ \tparam Point type of point to check
\tparam T type of search radius
\param geometry geometry which might be located in the neighborhood
\param selection_point point to select the geometry
@@ -258,16 +256,21 @@
\return true if point is within or close to the other geometry
*/
-template<typename G, typename P, typename T>
-inline bool selected(G const& geometry, P const& selection_point, T const& search_radius)
+template<typename Geometry, typename Point, typename RadiusType>
+inline bool selected(Geometry const& geometry,
+ Point const& selection_point,
+ RadiusType const& search_radius)
{
+ concept::check<const Geometry>();
+ concept::check<const Point>();
+
typedef dispatch::selected
<
- typename tag<G>::type,
- G,
- topological_dimension<G>::value,
- P,
- T
+ typename tag<Geometry>::type,
+ Geometry,
+ topological_dimension<Geometry>::value,
+ Point,
+ RadiusType
> selector_type;
return selector_type::apply(geometry, selection_point, search_radius);
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/simplify.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/simplify.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/simplify.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,14 +12,14 @@
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
-#include <boost/concept/requires.hpp>
-#include <boost/concept_check.hpp>
#include <ggl/core/cs.hpp>
#include <ggl/core/ring_type.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/strategies/strategies.hpp>
#include <ggl/strategies/agnostic/simplify_douglas_peucker.hpp>
#include <ggl/strategies/concepts/simplify_concept.hpp>
@@ -256,6 +256,8 @@
inline void simplify(Geometry const& geometry, Geometry& out,
double max_distance, Strategy const& strategy)
{
+ concept::check<Geometry>();
+
BOOST_CONCEPT_ASSERT( (ggl::concept::SimplifyStrategy<Strategy>) );
ggl::clear(out);
@@ -284,6 +286,8 @@
inline void simplify(Geometry const& geometry, Geometry& out,
double max_distance)
{
+ concept::check<Geometry>();
+
typedef typename point_type<Geometry>::type point_type;
typedef typename cs_tag<point_type>::type cs_tag;
typedef typename strategy_distance_segment
@@ -323,6 +327,7 @@
inline void simplify_inserter(Geometry const& geometry, OutputIterator out,
double max_distance, Strategy const& strategy)
{
+ concept::check<const Geometry>();
BOOST_CONCEPT_ASSERT( (ggl::concept::SimplifyStrategy<Strategy>) );
dispatch::simplify_inserter
@@ -353,6 +358,11 @@
double max_distance)
{
typedef typename point_type<Geometry>::type point_type;
+
+ // Concept: output point type = point type of input geometry
+ concept::check<const Geometry>();
+ concept::check<point_type>();
+
typedef typename cs_tag<point_type>::type cs_tag;
typedef typename strategy_distance_segment
<
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/transform.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/transform.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/transform.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -16,11 +16,15 @@
#include <boost/range/metafunctions.hpp>
#include <ggl/algorithms/clear.hpp>
+#include <ggl/algorithms/assign.hpp>
+
#include <ggl/core/cs.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
#include <ggl/core/ring_type.hpp>
-#include <ggl/geometries/segment.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
#include <ggl/strategies/strategies.hpp>
@@ -257,12 +261,15 @@
template <typename G1, typename G2, typename S>
inline bool transform(G1 const& geometry1, G2& geometry2, S const& strategy)
{
+ concept::check<const G1>();
+ concept::check<G2>();
+
typedef dispatch::transform
<
- typename tag<G1>::type,
- typename tag<G2>::type,
- G1,
- G2
+ typename tag<G1>::type,
+ typename tag<G2>::type,
+ G1,
+ G2
> transform_type;
return transform_type::apply(geometry1, geometry2, strategy);
@@ -280,6 +287,9 @@
template <typename G1, typename G2>
inline bool transform(G1 const& geometry1, G2& geometry2)
{
+ concept::check<const G1>();
+ concept::check<G2>();
+
typename detail::transform::select_strategy<G1, G2>::type strategy;
return transform(geometry1, geometry2, strategy);
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/algorithms/within.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/algorithms/within.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/algorithms/within.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -9,21 +9,24 @@
#ifndef GGL_ALGORITHMS_WITHIN_HPP
#define GGL_ALGORITHMS_WITHIN_HPP
-#include <boost/concept/requires.hpp>
+
+#include <cstddef>
+
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <ggl/algorithms/distance.hpp>
#include <ggl/algorithms/make.hpp>
+
#include <ggl/core/access.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/core/concepts/nsphere_concept.hpp>
#include <ggl/core/cs.hpp>
-#include <ggl/strategies/strategies.hpp>
-#include <ggl/util/loop.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
+#include <ggl/strategies/strategies.hpp>
+#include <ggl/strategies/concepts/within_concept.hpp>
@@ -34,180 +37,173 @@
namespace detail { namespace within {
-//-------------------------------------------------------------------------------------------------------
-// Implementation for boxes. Supports boxes in 2 or 3 dimensions, in Euclidian system
-// Todo: implement as strategy
-//-------------------------------------------------------------------------------------------------------
-template <typename P, typename B, size_t D, size_t N>
+/*!
+ \brief Implementation for boxes
+ \ingroup boolean_relations
+ \note Should have strategy for e.g. Wrangel
+ */
+template
+<
+ typename Point,
+ typename Box,
+ typename Strategy,
+ std::size_t Dimension,
+ std::size_t DimensionCount
+>
struct point_in_box
{
- static bool inside(P const& p, B const& b)
+ static inline bool apply(Point const& p, Box const& b, Strategy const& s)
{
- if (get<D>(p) <= get<min_corner, D>(b)
- || get<D>(p) >= get<max_corner, D>(b))
+ assert_dimension_equal<Point, Box>();
+
+ if (get<Dimension>(p) <= get<min_corner, Dimension>(b)
+ || get<Dimension>(p) >= get<max_corner, Dimension>(b))
{
return false;
}
- return point_in_box<P, B, D + 1, N>::inside(p, b);
+ return point_in_box
+ <
+ Point,
+ Box,
+ Strategy,
+ Dimension + 1,
+ DimensionCount
+ >::apply(p, b, s);
}
};
-template <typename P, typename B, size_t N>
-struct point_in_box<P, B, N, N>
+template
+<
+ typename Point,
+ typename Box,
+ typename Strategy,
+ std::size_t DimensionCount
+>
+struct point_in_box<Point, Box, Strategy, DimensionCount, DimensionCount>
{
- static bool inside(P const& p, B const& b)
+ static inline bool apply(Point const& p, Box const& b, Strategy const& s)
{
return true;
}
};
-//-------------------------------------------------------------------------------------------------------
-// Box-in-box, for 2/3 dimensions
-//-------------------------------------------------------------------------------------------------------
-template <typename B1, typename B2, size_t D, size_t N>
+
+template
+<
+ typename Box1,
+ typename Box2,
+ typename Strategy,
+ std::size_t Dimension,
+ std::size_t DimensionCount
+>
struct box_in_box
{
- static inline bool inside(B1 const& b1, B2 const& b2)
+ static inline bool apply(Box1 const& b1, Box2 const& b2, Strategy const& s)
{
- if (get<min_corner, D>(b1) <= get<min_corner, D>(b2)
- || get<max_corner, D>(b1) >= get<max_corner, D>(b2))
+ assert_dimension_equal<Box1, Box2>();
+
+ if (get<min_corner, Dimension>(b1) <= get<min_corner, Dimension>(b2)
+ || get<max_corner, Dimension>(b1) >= get<max_corner, Dimension>(b2))
{
return false;
}
- return box_in_box<B1, B2, D + 1, N>::inside(b1, b2);
+ return box_in_box
+ <
+ Box1,
+ Box2,
+ Strategy,
+ Dimension + 1,
+ DimensionCount
+ >::apply(b1, b2, s);
}
};
-template <typename B1, typename B2, size_t N>
-struct box_in_box<B1, B2, N, N>
+template
+<
+ typename Box1,
+ typename Box2,
+ typename Strategy,
+ std::size_t DimensionCount
+>
+struct box_in_box<Box1, Box2, Strategy, DimensionCount, DimensionCount>
{
- static inline bool inside(B1 const& b1, B2 const& b2)
+ static inline bool apply(Box1 const& , Box2 const& , Strategy const&)
{
return true;
}
};
-//-------------------------------------------------------------------------------------------------------
-// Implementation for n-spheres. Supports circles or spheres, in 2 or 3 dimensions, in Euclidian system
-// Circle center might be of other point-type as geometry
-// Todo: implement as strategy
-//-------------------------------------------------------------------------------------------------------
-template<typename P, typename C>
-inline bool point_in_circle(P const& p, C const& c)
-{
- assert_dimension<C, 2>();
-
- typedef typename point_type<C>::type point_type;
- typedef typename strategy_distance
- <
- typename cs_tag<P>::type,
- typename cs_tag<point_type>::type,
- P,
- point_type
- >::type strategy_type;
- typedef typename strategy_type::return_type return_type;
-
- P const center = ggl::make<P>(get<0>(c), get<1>(c));
- strategy_type distance;
- return_type const r = distance(p, center);
- return_type const rad = make_distance_result<return_type>(get_radius<0>(c));
-
- return r < rad;
-}
-/// 2D version
-template<typename T, typename C>
-inline bool point_in_circle(const T& c1, const T& c2, C const& c)
-{
- typedef typename point_type<C>::type point_type;
-
- point_type p = ggl::make<point_type>(c1, c2);
- return point_in_circle(p, c);
-}
-
-template<typename B, typename C>
-inline bool box_in_circle(B const& b, C const& c)
-{
- typedef typename point_type<B>::type point_type;
-
- // Currently only implemented for 2d geometries
- assert_dimension<point_type, 2>();
- assert_dimension<C, 2>();
-
- // Box: all four points must lie within circle
-
- // Check points lower-left and upper-right, then lower-right and upper-left
- return point_in_circle(get<min_corner, 0>(b), get<min_corner, 1>(b), c)
- && point_in_circle(get<max_corner, 0>(b), get<max_corner, 1>(b), c)
- && point_in_circle(get<min_corner, 0>(b), get<max_corner, 1>(b), c)
- && point_in_circle(get<max_corner, 0>(b), get<min_corner, 1>(b), c);
-}
-
-// Generic "range-in-circle", true if all points within circle
-template<typename R, typename C>
-inline bool range_in_circle(R const& range, C const& c)
+template<typename Point, typename Ring, typename Strategy>
+struct point_in_ring
{
- assert_dimension<R, 2>();
- assert_dimension<C, 2>();
+ BOOST_CONCEPT_ASSERT( (ggl::concept::WithinStrategy<Strategy>) );
- for (typename boost::range_const_iterator<R>::type it = boost::begin(range);
- it != boost::end(range); ++it)
+ static inline bool apply(Point const& point, Ring const& ring,
+ Strategy const& strategy)
{
- if (! point_in_circle(*it, c))
+ if (boost::size(ring) < 4)
{
return false;
}
- }
- return true;
-}
+ typedef typename boost::range_const_iterator<Ring>::type iterator_type;
-template<typename Y, typename C>
-inline bool polygon_in_circle(Y const& poly, C const& c)
-{
- return range_in_circle(exterior_ring(poly), c);
-}
-
-template<typename P, typename R, typename S>
-inline bool point_in_ring(P const& p, R const& r, S const& strategy)
-{
- if (boost::size(r) < 4)
- {
- return false;
- }
+ typename Strategy::state_type state;
- typename S::state_type state(p);
- if (loop(r, strategy, state))
- {
- return state.within();
+ iterator_type it = boost::begin(ring);
+ for (iterator_type previous = it++;
+ it != boost::end(ring);
+ previous = it++)
+ {
+ if (! Strategy::apply(point, *previous, *it, state))
+ {
+ return false;
+ }
+ }
+ return Strategy::result(state);
}
-
- return false;
-}
+};
// Polygon: in exterior ring, and if so, not within interior ring(s)
-template<typename P, typename Y, typename S>
-inline bool point_in_polygon(P const& p, Y const& poly, S const& strategy)
+template<typename Point, typename Polygon, typename Strategy>
+struct point_in_polygon
{
- if (point_in_ring(p, exterior_ring(poly), strategy))
+ BOOST_CONCEPT_ASSERT( (ggl::concept::WithinStrategy<Strategy>) );
+
+ static inline bool apply(Point const& point, Polygon const& poly,
+ Strategy const& strategy)
{
- typedef typename boost::range_const_iterator
- <typename interior_type<Y>::type>::type iterator_type;
- for (iterator_type it = boost::begin(interior_rings(poly));
- it != boost::end(interior_rings(poly)); ++it)
+ typedef point_in_ring
+ <
+ Point,
+ typename ring_type<Polygon>::type,
+ Strategy
+ > per_ring;
+
+ if (per_ring::apply(point, exterior_ring(poly), strategy))
{
- if (point_in_ring(p, *it, strategy))
+
+ for (typename boost::range_const_iterator
+ <
+ typename interior_type<Polygon>::type
+ >::type it = boost::begin(interior_rings(poly));
+ it != boost::end(interior_rings(poly));
+ ++it)
{
- return false;
+ if (per_ring::apply(point, *it, strategy))
+ {
+ return false;
+ }
}
+ return true;
}
- return true;
+ return false;
}
- return false;
-}
+};
}} // namespace detail::within
#endif // DOXYGEN_NO_DETAIL
@@ -217,130 +213,55 @@
namespace dispatch
{
-template <typename Tag1, typename Tag2, typename G1, typename G2>
-struct within {};
+template
+<
+ typename Tag1,
+ typename Tag2,
+ typename Geometry1,
+ typename Geometry2,
+ typename Strategy
+>
+struct within
+{};
-template <typename P, typename B>
-struct within<point_tag, box_tag, P, B>
-{
- static inline bool apply(P const& p, B const& b)
- {
- assert_dimension_equal<P, B>();
- return detail::within::point_in_box
+template <typename Point, typename Box, typename Strategy>
+struct within<point_tag, box_tag, Point, Box, Strategy>
+ : detail::within::point_in_box
<
- P,
- B,
+ Point,
+ Box,
+ Strategy,
0,
- dimension<P>::type::value
- >::inside(p, b);
- }
-};
-
-template <typename B1, typename B2>
-struct within<box_tag, box_tag, B1, B2>
-{
- static inline bool apply(B1 const& b1, B2 const& b2)
- {
- assert_dimension_equal<B1, B2>();
-
- return detail::within::box_in_box
+ dimension<Point>::type::value
+ >
+{};
+
+template <typename Box1, typename Box2, typename Strategy>
+struct within<box_tag, box_tag, Box1, Box2, Strategy>
+ : detail::within::box_in_box
<
- B1,
- B2,
+ Box1,
+ Box2,
+ Strategy,
0,
- dimension<B1>::type::value
- >::inside(b1, b2);
- }
-};
+ dimension<Box1>::type::value
+ >
+{};
-template <typename P, typename C>
-struct within<point_tag, nsphere_tag, P, C>
-{
- static inline bool apply(P const& p, C const& c)
- {
- return detail::within::point_in_circle(p, c);
- }
-};
-template <typename B, typename C>
-struct within<box_tag, nsphere_tag, B, C>
-{
- static inline bool apply(B const& b, C const& c)
- {
- return detail::within::box_in_circle(b, c);
- }
-};
-
-template <typename R, typename C>
-struct within<linestring_tag, nsphere_tag, R, C>
-{
- static inline bool apply(R const& ln, C const& c)
- {
- return detail::within::range_in_circle(ln, c);
- }
-};
-
-template <typename R, typename C>
-struct within<ring_tag, nsphere_tag, R, C>
-{
- static inline bool apply(R const& r, C const& c)
- {
- return detail::within::range_in_circle(r, c);
- }
-};
-
-template <typename Y, typename C>
-struct within<polygon_tag, nsphere_tag, Y, C>
-{
- static inline bool apply(Y const& poly, C const& c)
- {
- return detail::within::polygon_in_circle(poly, c);
- }
-};
-
-template <typename P, typename R>
-struct within<point_tag, ring_tag, P, R>
-{
- static inline bool apply(P const& p, R const& r)
- {
- typedef typename boost::range_value<R>::type point_type;
- typedef typename strategy_within
- <
- typename cs_tag<P>::type,
- typename cs_tag<point_type>::type,
- P,
- point_type
- >::type strategy_type;
-
- return detail::within::point_in_ring(p, r, strategy_type());
- }
-};
-
-template <typename P, typename Y>
-struct within<point_tag, polygon_tag, P, Y>
-{
- static inline bool apply(P const& point, Y const& poly)
- {
- typedef typename point_type<Y>::type point_type;
- typedef typename strategy_within
- <
- typename cs_tag<P>::type,
- typename cs_tag<point_type>::type,
- P,
- point_type
- >::type strategy_type;
-
- return detail::within::point_in_polygon(point, poly, strategy_type());
- }
-
- template<typename S>
- static inline bool apply(P const& point, Y const& poly, S const& strategy)
- {
- return detail::within::point_in_polygon(point, poly, strategy);
- }
-};
+template <typename Point, typename Ring, typename Strategy>
+struct within<point_tag, ring_tag, Point, Ring, Strategy>
+ : detail::within::point_in_ring
+ <Point, Ring, Strategy>
+{};
+
+template <typename Point, typename Polygon, typename Strategy>
+struct within<point_tag, polygon_tag, Point, Polygon, Strategy>
+ : detail::within::point_in_polygon
+ <Point, Polygon, Strategy>
+{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
@@ -348,18 +269,22 @@
/*!
\brief Within check
- \details Examine if one geometry is within another geometry (a.o. point in polygon)
+ \details Examine if one geometry is within another geometry
+ (a.o. point in polygon)
\ingroup boolean_relations
\param geometry1 geometry which might be within the second geometry
\param geometry2 geometry which might contain the first geometry
- \return true if geometry1 is completely contained within geometry2, else false
+ \return true if geometry1 is completely contained within geometry2,
+ else false
\note The default strategy is used for within detection
\par Source descriptions:
-- OGC: Returns 1 (TRUE) if this geometric object is "spatially within" another Geometry.
+- OGC: Returns 1 (TRUE) if this geometric object is "spatially within"
+ another Geometry.
\par Performance
-2776 within determinations using bounding box and polygon are done in 0.09 seconds (other libraries: 0.14 seconds, 3.0 seconds, 3.8)
+2776 within determinations using bounding box and polygon are done
+ in 0.09 seconds (other libraries: 0.14 seconds, 3.0 seconds, 3.8)
\par Example:
The within algorithm is used as following:
@@ -368,23 +293,38 @@
\line {
\until }
\par Geometries:
-- POINT + POLYGON: The well-known point-in-polygon, returning true if a point falls within a polygon (and not
+- POINT + POLYGON: The well-known point-in-polygon, returning true if
+ a point falls within a polygon (and not
within one of its holes) \image html within_polygon.png
-- POINT + RING: returns true if point is completely within a ring \image html within_ring.png
+- POINT + RING: returns true if point is completely within
+ a ring \image html within_ring.png
*/
-template<typename G1, typename G2>
-inline bool within(G1 const& geometry1, G2 const& geometry2)
+template<typename Geometry1, typename Geometry2>
+inline bool within(Geometry1 const& geometry1, Geometry2 const& geometry2)
{
- typedef dispatch::within
+ concept::check<const Geometry1>();
+ concept::check<const Geometry2>();
+
+ typedef typename point_type<Geometry1>::type point_type1;
+ typedef typename point_type<Geometry2>::type point_type2;
+
+ typedef typename strategy_within
<
- typename tag<G1>::type,
- typename tag<G2>::type,
- G1,
- G2
- > within_type;
+ typename cs_tag<point_type1>::type,
+ typename cs_tag<point_type2>::type,
+ point_type1,
+ point_type2
+ >::type strategy_type;
- return within_type::apply(geometry1, geometry2);
+ return dispatch::within
+ <
+ typename tag<Geometry1>::type,
+ typename tag<Geometry2>::type,
+ Geometry1,
+ Geometry2,
+ strategy_type
+ >::apply(geometry1, geometry2, strategy_type());
}
/*!
@@ -393,20 +333,28 @@
\param geometry1 geometry which might be within the second geometry
\param geometry2 geometry which might contain the first geometry
\param strategy strategy to be used
- \return true if geometry1 is completely contained within geometry2, else false
+ \return true if geometry1 is completely contained within geometry2,
+ else false
*/
-template<typename G1, typename G2, typename S>
-inline bool within(G1 const& geometry1, G2 const& geometry2, S const& strategy)
-{
- typedef dispatch::within
- <
- typename tag<G1>::type,
- typename tag<G2>::type,
- G1,
- G2
- > within_type;
+template<typename Geometry1, typename Geometry2, typename Strategy>
+inline bool within(Geometry1 const& geometry1, Geometry2 const& geometry2,
+ Strategy const& strategy)
+{
+ // Always assume a point-in-polygon strategy here.
+ // Because for point-in-box, it makes no sense to specify one.
+ BOOST_CONCEPT_ASSERT( (ggl::concept::WithinStrategy<Strategy>) );
+
+ concept::check<const Geometry1>();
+ concept::check<const Geometry2>();
- return within_type::apply(geometry1, geometry2, strategy);
+ return dispatch::within
+ <
+ typename tag<Geometry1>::type,
+ typename tag<Geometry2>::type,
+ Geometry1,
+ Geometry2,
+ Strategy
+ >::apply(geometry1, geometry2, strategy);
}
} // namespace ggl
Modified: sandbox/ggl/formal_review_request/boost/ggl/arithmetic/arithmetic.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/arithmetic/arithmetic.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/arithmetic/arithmetic.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -15,7 +15,7 @@
#include <boost/concept/requires.hpp>
#include <ggl/core/coordinate_type.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
#include <ggl/util/for_each_coordinate.hpp>
/*!
@@ -43,7 +43,7 @@
{
C m_value;
- inline value_operation(const C& value)
+ inline value_operation(C const &value)
: m_value(value)
{}
@@ -60,7 +60,7 @@
typedef typename coordinate_type<PointSrc>::type coordinate_type;
PointSrc const& m_source_point;
- inline point_operation(const PointSrc& point)
+ inline point_operation(PointSrc const& point)
: m_source_point(point)
{}
Modified: sandbox/ggl/formal_review_request/boost/ggl/arithmetic/dot_product.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/arithmetic/dot_product.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/arithmetic/dot_product.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,7 +11,8 @@
#include <boost/concept/requires.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
+#include <ggl/util/select_coordinate_type.hpp>
namespace ggl
{
@@ -23,8 +24,9 @@
template <typename P1, typename P2, std::size_t Dimension, std::size_t DimensionCount>
struct dot_product_maker
{
- static inline typename coordinate_type<P1>::type
- apply(P1 const& p1, P2 const& p2)
+ typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+
+ static inline coordinate_type apply(P1 const& p1, P2 const& p2)
{
return get<Dimension>(p1) * get<Dimension>(p2)
+ dot_product_maker<P1, P2, Dimension+1, DimensionCount>::apply(p1, p2);
@@ -34,8 +36,9 @@
template <typename P1, typename P2, std::size_t DimensionCount>
struct dot_product_maker<P1, P2, DimensionCount, DimensionCount>
{
- static inline typename coordinate_type<P1>::type
- apply(P1 const& p1, P2 const& p2)
+ typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
+
+ static inline coordinate_type apply(P1 const& p1, P2 const& p2)
{
return get<DimensionCount>(p1) * get<DimensionCount>(p2);
}
@@ -53,7 +56,8 @@
\return the dot product
*/
template <typename P1, typename P2>
-inline typename coordinate_type<P1>::type dot_product(P1 const& p1, P2 const& p2)
+inline typename select_coordinate_type<P1, P2>::type dot_product(
+ P1 const& p1, P2 const& p2)
{
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P1>) );
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P2>) );
Modified: sandbox/ggl/formal_review_request/boost/ggl/core/access.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/core/access.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/core/access.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -32,7 +32,6 @@
\ingroup traits
\par Geometries:
- point
- - n-sphere (circle,sphere) for their center
\par Specializations should provide, per Dimension
- static inline T get(const G&)
- static inline void set(G&, T const&)
@@ -79,6 +78,45 @@
static const bool value = true;
};
+
+
+/*!
+ \brief Traits class, optional, might be implemented to clear a geometry
+ \details If a geometry type should not use the std ".clear()" then it can specialize
+ the "use_std" traits class to false, it should then implement (a.o.) clear
+ \ingroup traits
+ \par Geometries:
+ - linestring
+ - linear_ring
+ \par Specializations should provide:
+ - apply
+ */
+template <typename Geometry>
+struct clear
+{};
+
+
+
+/*!
+ \brief Traits class, optional, might be implemented to append a point
+ \details If a geometry type should not use the std "push_back" then it can specialize
+ the "use_std" traits class to false, it should then implement (a.o.) append_point
+ \ingroup traits
+ \par Geometries:
+ - linestring
+ - linear_ring
+ \par Specializations should provide:
+ - run
+ */
+template <typename Geometry, typename Point>
+struct append_point
+{
+};
+
+
+
+
+
} // namespace traits
@@ -86,11 +124,11 @@
namespace core_dispatch
{
-template
+template
<
- typename Tag,
- typename Geometry,
- typename
+ typename Tag,
+ typename Geometry,
+ typename
CoordinateType, std::size_t Dimension
>
struct access
@@ -99,12 +137,12 @@
//static inline void set(G& g, T const& value) {}
};
-template
+template
<
- typename Tag,
- typename Geometry,
- typename CoordinateType,
- std::size_t Index,
+ typename Tag,
+ typename Geometry,
+ typename CoordinateType,
+ std::size_t Index,
std::size_t Dimension
>
struct indexed_access
@@ -126,24 +164,11 @@
}
};
-template <typename Nsphere, typename CoordinateType, std::size_t Dimension>
-struct access<nsphere_tag, Nsphere, CoordinateType, Dimension>
-{
- static inline CoordinateType get(Nsphere const& nsphere)
- {
- return traits::access<Nsphere, Dimension>::get(nsphere);
- }
- static inline void set(Nsphere& s, CoordinateType const& value)
- {
- traits::access<Nsphere, Dimension>::set(s, value);
- }
-};
-
-template
+template
<
- typename Box,
- typename CoordinateType,
- std::size_t Index,
+ typename Box,
+ typename CoordinateType,
+ std::size_t Index,
std::size_t Dimension
>
struct indexed_access<box_tag, Box, CoordinateType, Index, Dimension>
@@ -158,11 +183,11 @@
}
};
-template
+template
<
- typename Segment,
- typename CoordinateType,
- std::size_t Index,
+ typename Segment,
+ typename CoordinateType,
+ std::size_t Index,
std::size_t Dimension
>
struct indexed_access<segment_tag, Segment, CoordinateType, Index, Dimension>
@@ -197,7 +222,7 @@
/*!
- \brief get a coordinate value of a point / nsphere
+ \brief get a coordinate value of a point
\return coordinate value
\ingroup access
\tparam D dimension
Modified: sandbox/ggl/formal_review_request/boost/ggl/core/cs.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/core/cs.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/core/cs.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -152,7 +152,7 @@
{
typedef typename traits::cs_tag
<
- typename ggl::coordinate_system<G>::type
+ typename ggl::coordinate_system<G>::type
>::type type;
};
Modified: sandbox/ggl/formal_review_request/boost/ggl/core/geometry_id.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/core/geometry_id.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/core/geometry_id.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -43,10 +43,6 @@
template <>
-struct geometry_id<nsphere_tag> : boost::mpl::int_<91> {};
-
-
-template <>
struct geometry_id<segment_tag> : boost::mpl::int_<92> {};
Deleted: sandbox/ggl/formal_review_request/boost/ggl/core/radius.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/core/radius.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
+++ (empty file)
@@ -1,152 +0,0 @@
-// Generic Geometry Library
-//
-// Copyright Bruno Lalande 2008, 2009
-// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_CORE_RADIUS_HPP
-#define GGL_CORE_RADIUS_HPP
-
-
-#include <cstddef>
-
-
-#include <boost/type_traits/remove_const.hpp>
-
-
-#include <ggl/core/tag.hpp>
-
-
-namespace ggl {
-
-namespace traits {
-
-/*!
- \brief Traits class to get/set radius of a circle/sphere/(ellipse)
- \details the radius access meta-functions give read/write access to the radius of a circle or a sphere,
- or to the major/minor axis or an ellipse, or to one of the 3 equatorial radii of an ellipsoid.
-
- It should be specialized per geometry, in namespace core_dispatch. Those specializations should
- forward the call via traits to the geometry class, which could be specified by the user.
-
- There is a corresponding generic radius_get and radius_set function
- \par Geometries:
- - n-sphere (circle,sphere)
- - upcoming ellipse
- \par Specializations should provide:
- - inline static T get(const G& geometry)
- - inline static void set(G& geometry, const T& radius)
- \ingroup traits
-*/
-template <typename G, typename T, std::size_t D>
-struct radius_access {};
-
-
-/*!
- \brief Traits class indicating the type (double,float,...) of the radius of a circle or a sphere
- \par Geometries:
- - n-sphere (circle,sphere)
- - upcoming ellipse
- \par Specializations should provide:
- - typedef T type (double,float,int,etc)
- \ingroup traits
-*/
-template <typename G>
-struct radius_type {};
-
-} // namespace traits
-
-
-#ifndef DOXYGEN_NO_DISPATCH
-namespace core_dispatch
-{
-
-template <typename Tag, typename G>
-struct radius_type
-{
- //typedef core_dispatch_specialization_required type;
-};
-
-/*!
- \brief radius access meta-functions, used by concept n-sphere and upcoming ellipse.
-*/
-template <typename Tag, typename G, typename T, std::size_t D>
-struct radius_access
-{
- //static inline T get(const G& ) {}
- //static inline void set(G& g, const T& value) {}
-};
-
-template <typename S>
-struct radius_type<nsphere_tag, S>
-{
- typedef typename traits::radius_type<S>::type type;
-};
-
-template <typename S, typename T, std::size_t D>
-struct radius_access<nsphere_tag, S, T, D>
-{
- BOOST_STATIC_ASSERT((D == 0));
- static inline T get(const S& s)
- {
- return traits::radius_access<S, T, D>::get(s);
- }
- static inline void set(S& s, const T& radius)
- {
- traits::radius_access<S, T, D>::set(s, radius);
- }
-};
-
-} // namespace core_dispatch
-#endif // DOXYGEN_NO_DISPATCH
-
-
-template <typename G>
-struct radius_type
-{
- typedef typename boost::remove_const<G>::type rconst;
- typedef typename core_dispatch::radius_type<typename tag<G>::type, rconst>::type type;
-};
-
-/*!
- \brief Function to get radius
- \return radius of a circle / sphere / ellipse
- \ingroup access
- \param geometry the geometry to get the radius from
- \tparam I index, for circle/sphere always zero, for ellipse major/minor axis,
- for ellipsoid one of the 3 equatorial radii
-*/
-template <std::size_t I, typename G>
-inline typename radius_type<G>::type get_radius(const G& geometry)
-{
- typedef typename boost::remove_const<G>::type rconst;
-
- return core_dispatch::radius_access<typename tag<G>::type, rconst,
- typename radius_type<G>::type, I>::get(geometry);
-}
-
-/*!
- \brief Function to set the radius of a circle / sphere / (ellipse)
- \ingroup access
- \tparam I index, for circle/sphere always zero, for ellipse major/minor axis,
- for ellipsoid one of the 3 equatorial radii
- \param geometry the geometry to change
- \param radius the radius to set
-*/
-template <std::size_t I, typename G>
-inline void set_radius(G& geometry, const typename radius_type<G>::type& radius)
-{
- typedef typename boost::remove_const<G>::type rconst;
-
- core_dispatch::radius_access<typename tag<G>::type, G,
- typename radius_type<G>::type, I>::set(geometry, radius);
-}
-
-
-} // namespace ggl
-
-
-#endif // GGL_RADIUS_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/core/replace_point_type.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/core/replace_point_type.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/core/replace_point_type.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -27,7 +27,6 @@
#include <ggl/geometries/polygon.hpp>
#include <ggl/geometries/segment.hpp>
#include <ggl/geometries/box.hpp>
-#include <ggl/geometries/nsphere.hpp>
namespace ggl {
@@ -74,12 +73,6 @@
typedef polygon<NewPointType> type;
};
-template <typename Geometry, typename NewPointType>
-struct replace_point_type<nsphere_tag, Geometry, NewPointType>
-{
- typedef typename ggl::coordinate_type<Geometry>::type coortype;
- typedef nsphere<NewPointType, coortype> type;
-};
} // namespace core_dispatch
#endif // DOXYGEN_NO_DISPATCH
Modified: sandbox/ggl/formal_review_request/boost/ggl/core/tags.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/core/tags.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/core/tags.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -53,9 +53,6 @@
/// Convenience 2D or 3D box (mbr) identifying tag
struct box_tag {};
-/// Convenience 2D (circle) or 3D (sphere) n-sphere identifying tag
-struct nsphere_tag {};
-
/// Convenience segment (2-points) identifying tag
struct segment_tag {};
Modified: sandbox/ggl/formal_review_request/boost/ggl/core/topological_dimension.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/core/topological_dimension.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/core/topological_dimension.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -55,13 +55,6 @@
struct top_dim<polygon_tag> : boost::mpl::int_<2> {};
-// nsphere: 2, but there is discussion. Is it CLOSED? Then 2, but
-// then it should be called "disk"...
-template <>
-struct top_dim<nsphere_tag> : boost::mpl::int_<2> {};
-
-
-
} // namespace core_dispatch
#endif
Added: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/geographic/strategies/area_huiller_earth.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/geographic/strategies/area_huiller_earth.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,60 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// 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 GGL_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_AREA_HUILLER_EARTH_HPP
+#define GGL_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_AREA_HUILLER_EARTH_HPP
+
+
+
+#include <ggl/strategies/spherical/area_huiller.hpp>
+
+
+namespace ggl
+{
+
+namespace strategy { namespace area {
+
+
+
+template
+<
+ typename PointOfSegment,
+ typename CalculationType = void
+>
+class huiller_earth
+ : public huiller<PointOfSegment, CalculationType>
+{
+public :
+ // By default the average earth radius.
+ // Uses can specify another radius.
+ // Note that the earth is still spherical
+ inline huiller_earth(double radius = 6372795.0)
+ : huiller<PointOfSegment, CalculationType>(radius)
+ {}
+};
+
+
+
+}} // namespace strategy::area
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+template <typename Point>
+struct strategy_area<geographic_tag, Point>
+{
+ typedef strategy::area::huiller_earth<Point> type;
+};
+
+#endif
+
+
+} // namespace ggl
+
+
+#endif // GGL_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_AREA_HUILLER_EARTH_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/parser.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/parser.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/parser.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -18,12 +18,10 @@
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/static_assert.hpp>
-#include <boost/concept/requires.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/coordinate_dimension.hpp>
#include <ggl/core/coordinate_type.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
#include <ggl/extensions/gis/io/wkb/detail/endian.hpp>
@@ -177,9 +175,6 @@
}
return false;
}
-
-private:
- BOOST_CONCEPT_ASSERT((concept::Point<P>));
};
template <typename C>
Modified: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/read_wkt.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/read_wkt.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/read_wkt.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -14,7 +14,6 @@
#include <boost/tokenizer.hpp>
#include <boost/algorithm/string.hpp>
-#include <boost/concept/requires.hpp>
#include <boost/mpl/if.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
@@ -27,11 +26,11 @@
#include <ggl/core/access.hpp>
#include <ggl/core/coordinate_dimension.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
#include <ggl/core/exception.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
+#include <ggl/geometries/concepts/check.hpp>
#include <ggl/extensions/gis/io/wkt/detail/wkt.hpp>
@@ -517,10 +516,7 @@
detail::wkt::point_parser,
detail::wkt::prefix_point
>
-{
-private :
- BOOST_CONCEPT_ASSERT( (concept::Point<Point>) );
-};
+{};
template <typename L>
@@ -594,6 +590,7 @@
template <typename Geometry>
inline void read_wkt(std::string const& wkt, Geometry& geometry)
{
+ ggl::concept::check<Geometry>();
dispatch::read_wkt<typename tag<Geometry>::type, Geometry>::apply(wkt, geometry);
}
@@ -611,18 +608,20 @@
\line {
\until }
*/
-template <typename P, typename Out>
+template <typename Point, typename Out>
inline void read_wkt(std::string const& wkt, Out out)
{
+ ggl::concept::check<Point>();
+
// Todo: maybe take this from the string, or do not call initialize, such that
// any coordinate string is parsed and outputted
std::string const& tag = "linestring";
detail::wkt::tokenizer tokens(wkt, boost::char_separator<char>(" ", ",()"));
detail::wkt::tokenizer::iterator it;
- if (detail::wkt::initialize<P>(tokens, tag, wkt, it))
+ if (detail::wkt::initialize<Point>(tokens, tag, wkt, it))
{
- detail::wkt::container_inserter<P>::apply(it, tokens.end(), wkt, out);
+ detail::wkt::container_inserter<Point>::apply(it, tokens.end(), wkt, out);
}
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/stream_wkt.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/stream_wkt.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/stream_wkt.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -24,8 +24,12 @@
\brief Streams a geometry as Well-Known Text
\ingroup wkt
*/
-template<typename CH, typename TR, typename G>
-inline std::basic_ostream<CH,TR>& operator<<(std::basic_ostream<CH,TR> &os, const G& geometry)
+template<typename Char, typename Traits, typename Geometry>
+inline std::basic_ostream<Char,Traits>& operator<<
+ (
+ std::basic_ostream<Char,Traits> &os,
+ Geometry const& geometry
+ )
{
os << ggl::wkt(geometry);
return os;
Modified: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/write_wkt.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/write_wkt.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/write_wkt.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -16,10 +16,11 @@
#include <boost/range/metafunctions.hpp>
#include <ggl/algorithms/convert.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
#include <ggl/core/ring_type.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
#include <ggl/geometries/linear_ring.hpp>
#include <ggl/extensions/gis/io/wkt/detail/wkt.hpp>
@@ -99,9 +100,6 @@
stream_coordinate<Point, 0, dimension<Point>::type::value>::apply(os, p);
os << ")";
}
-
- private:
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point>) );
};
/*!
@@ -128,16 +126,18 @@
++it)
{
os << (first ? "" : ",");
- stream_coordinate<point, 0, dimension<point>::type::value>::apply(os, *it);
+ stream_coordinate
+ <
+ point_type, 0, dimension<point_type>::type::value
+ >::apply(os, *it);
first = false;
}
os << SuffixPolicy::apply();
}
- private:
- typedef typename boost::range_value<Range>::type point;
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point>) );
+private:
+ typedef typename boost::range_value<Range>::type point_type;
};
/*!
@@ -182,9 +182,6 @@
}
os << ")";
}
-
- private:
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<typename point_type<Polygon>::type>) );
};
@@ -207,7 +204,6 @@
}
private:
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
inline wkt_box()
{
@@ -344,6 +340,8 @@
template <typename Geometry>
inline wkt_manipulator<Geometry> wkt(Geometry const& geometry)
{
+ concept::check<const Geometry>();
+
return wkt_manipulator<Geometry>(geometry);
}
@@ -352,6 +350,8 @@
template <typename Geometry>
inline wkt_manipulator<Geometry> make_wkt(Geometry const& geometry)
{
+ concept::check<const Geometry>();
+
return wkt_manipulator<Geometry>(geometry);
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/extensions/io/svg/write_svg.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/extensions/io/svg/write_svg.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/io/svg/write_svg.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,15 +12,15 @@
#include <iostream>
#include <string>
-#include <boost/concept/assert.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
#include <ggl/core/ring_type.hpp>
+#include <ggl/geometries/concepts/check.hpp>
+
/*!
\defgroup svg x Extension svg: Stream SVG (Scalable Vector Graphics)
*/
@@ -44,9 +44,6 @@
<< "\" r=\"" << (size < 0 ? 5 : size)
<< "\" style=\"" << style << "\"/>";
}
-
- private:
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point>) );
};
@@ -66,10 +63,6 @@
<< "\" width=\"" << width << "\" height=\"" << height
<< "\" style=\"" << style << "\"/>";
}
-
- private:
- typedef typename ggl::point_type<Box>::type point_type;
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
};
@@ -98,10 +91,6 @@
}
os << "\" style=\"" << style << Policy::style() << "\"/>";
}
-
- private:
- typedef typename boost::range_value<Range>::type point;
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point>) );
};
@@ -149,12 +138,6 @@
os << " z \" style=\"" << style << "\"/></g>";
}
-
- private:
- BOOST_CONCEPT_ASSERT
- (
- (concept::ConstPoint<typename point_type<Polygon>::type>)
- );
};
@@ -255,6 +238,8 @@
template <typename Geometry>
inline svg_manipulator<Geometry> svg(Geometry const& t, std::string const& style, int size = -1)
{
+ concept::check<const Geometry>();
+
return svg_manipulator<Geometry>(t, style, size);
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/box.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/box.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/box.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,8 +11,10 @@
#include <cstddef>
-#include <ggl/algorithms/assign.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <boost/concept/assert.hpp>
+
+#include <ggl/geometries/concepts/point_concept.hpp>
+
#include <ggl/util/copy.hpp>
namespace ggl
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/cartesian2d.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/cartesian2d.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/cartesian2d.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -22,7 +22,6 @@
typedef polygon<point_2d> polygon_2d;
typedef box<point_2d> box_2d;
typedef segment<point_2d> segment_2d;
-typedef nsphere<point_2d, double> circle;
} // namespace ggl
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/cartesian3d.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/cartesian3d.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/cartesian3d.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -21,7 +21,6 @@
typedef polygon<point_3d> polygon_3d;
typedef box<point_3d> box_3d;
-typedef nsphere<point_3d, double> sphere;
}
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/box_concept.hpp
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/core/concepts/box_concept.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/box_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -7,14 +7,17 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_CORE_CONCEPTS_BOX_CONCEPT_HPP
-#define GGL_CORE_CONCEPTS_BOX_CONCEPT_HPP
+#ifndef GGL_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
+#define GGL_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
+#include <cstddef>
+
#include <boost/concept_check.hpp>
#include <ggl/core/access.hpp>
+#include <ggl/core/coordinate_dimension.hpp>
#include <ggl/core/point_type.hpp>
@@ -23,87 +26,92 @@
/*!
- \brief Checks box concept, using Boost Concept Check Library and metafunctions
+ \brief Checks box concept
\ingroup concepts
*/
-template <typename B>
-struct Box
+template <typename Geometry>
+class Box
{
- private :
- typedef typename point_type<B>::type P;
-
- /// Internal structure to check if access is OK for all dimensions
- template <size_t C, size_t D, size_t N>
- struct dimension_checker
- {
- static void check()
- {
- B* b;
- ggl::set<C, D>(*b, ggl::get<C, D>(*b));
- dimension_checker<C, D + 1, N>::check();
- }
- };
+ typedef typename point_type<Geometry>::type point_type;
- template <size_t C, size_t N>
- struct dimension_checker<C, N, N>
- {
- static void check() {}
- };
- public :
- /// BCCL macro to check the Box concept
- BOOST_CONCEPT_USAGE(Box)
- {
- static const size_t N = dimension<B>::value;
- dimension_checker<min_corner, 0, N>::check();
- dimension_checker<max_corner, 0, N>::check();
+ template
+ <
+ std::size_t Index,
+ std::size_t Dimension,
+ std::size_t DimensionCount
+ >
+ struct dimension_checker
+ {
+ static void apply()
+ {
+ Geometry* b;
+ ggl::set<Index, Dimension>(*b, ggl::get<Index, Dimension>(*b));
+ dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
}
+ };
+
+ template <std::size_t Index, std::size_t DimensionCount>
+ struct dimension_checker<Index, DimensionCount, DimensionCount>
+ {
+ static void apply() {}
+ };
+
+public :
+ BOOST_CONCEPT_USAGE(Box)
+ {
+ static const std::size_t n = dimension<Geometry>::type::value;
+ dimension_checker<min_corner, 0, n>::apply();
+ dimension_checker<max_corner, 0, n>::apply();
+ }
};
/*!
\brief Checks Box concept (const version)
\ingroup concepts
- \details The ConstBox concept check the same as the Box concept,
- but does not check write access.
+ \details The ConstBox concept apply the same as the Box concept,
+ but does not apply write access.
*/
-template <typename B>
-struct ConstBox
+template <typename Geometry>
+class ConstBox
{
- private :
- typedef typename point_type<B>::type P;
- typedef typename coordinate_type<B>::type T;
-
- /// Internal structure to check if access is OK for all dimensions
- template <size_t C, size_t D, size_t N>
- struct dimension_checker
- {
- static void check()
- {
- const B* b = 0;
- T coord(ggl::get<C, D>(*b));
- boost::ignore_unused_variable_warning(coord);
- dimension_checker<C, D + 1, N>::check();
- }
- };
-
- template <size_t C, size_t N>
- struct dimension_checker<C, N, N>
- {
- static void check() {}
- };
+ typedef typename point_type<Geometry>::type point_type;
+ typedef typename coordinate_type<Geometry>::type coordinate_type;
- public :
- /// BCCL macro to check the ConstBox concept
- BOOST_CONCEPT_USAGE(ConstBox)
- {
- static const size_t N = dimension<B>::value;
- dimension_checker<min_corner, 0, N>::check();
- dimension_checker<max_corner, 0, N>::check();
+ template
+ <
+ std::size_t Index,
+ std::size_t Dimension,
+ std::size_t DimensionCount
+ >
+ struct dimension_checker
+ {
+ static void apply()
+ {
+ const Geometry* b = 0;
+ coordinate_type coord(ggl::get<Index, Dimension>(*b));
+ boost::ignore_unused_variable_warning(coord);
+ dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
}
+ };
+
+ template <std::size_t Index, std::size_t DimensionCount>
+ struct dimension_checker<Index, DimensionCount, DimensionCount>
+ {
+ static void apply() {}
+ };
+
+public :
+ BOOST_CONCEPT_USAGE(ConstBox)
+ {
+ static const std::size_t n = dimension<Geometry>::type::value;
+ dimension_checker<min_corner, 0, n>::apply();
+ dimension_checker<max_corner, 0, n>::apply();
+ }
};
}} // namespace ggl::concept
-#endif // GGL_CORE_CONCEPTS_BOX_CONCEPT_HPP
+#endif // GGL_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/check.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/check.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,148 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 2009, Geodan, Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef GGL_GEOMETRIES_CONCEPTS_CHECK_HPP
+#define GGL_GEOMETRIES_CONCEPTS_CHECK_HPP
+
+
+#include <boost/concept_check.hpp>
+#include <boost/concept/requires.hpp>
+
+#include <boost/type_traits/is_const.hpp>
+
+#include <ggl/core/tag.hpp>
+
+#include <ggl/geometries/concepts/box_concept.hpp>
+#include <ggl/geometries/concepts/linestring_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/polygon_concept.hpp>
+#include <ggl/geometries/concepts/ring_concept.hpp>
+
+
+namespace ggl {
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail { namespace concept_check {
+
+template <typename Concept>
+class check
+{
+ BOOST_CONCEPT_ASSERT((Concept ));
+};
+
+}} // namespace detail::check
+#endif // DOXYGEN_NO_DETAIL
+
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename GeometryTag, typename Geometry, bool IsConst>
+struct check
+{};
+
+
+template <typename Geometry>
+struct check<point_tag, Geometry, true>
+ : detail::concept_check::check<concept::ConstPoint<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<point_tag, Geometry, false>
+ : detail::concept_check::check<concept::Point<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<linestring_tag, Geometry, true>
+ : detail::concept_check::check<concept::ConstLinestring<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<linestring_tag, Geometry, false>
+ : detail::concept_check::check<concept::Linestring<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<polygon_tag, Geometry, true>
+ : detail::concept_check::check<concept::ConstPolygon<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<polygon_tag, Geometry, false>
+ : detail::concept_check::check<concept::Polygon<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<box_tag, Geometry, true>
+ : detail::concept_check::check<concept::ConstBox<Geometry> >
+{};
+
+
+template <typename Geometry>
+struct check<box_tag, Geometry, false>
+ : detail::concept_check::check<concept::Box<Geometry> >
+{};
+
+
+
+} // namespace dispatch
+#endif
+
+
+
+
+namespace concept {
+
+
+namespace detail {
+
+/*!
+ \brief Checks, in compile-time, the concept of any geometry
+ \ingroup core
+*/
+template <typename Geometry, bool IsConst>
+struct checker : dispatch::check
+ <
+ typename tag<Geometry>::type,
+ Geometry,
+ IsConst
+ >
+{};
+
+}
+
+
+/*!
+ \brief Checks, in compile-time, the concept of any geometry
+ \ingroup core
+*/
+template <typename Geometry>
+inline void check()
+{
+ detail::checker<Geometry, boost::is_const<Geometry>::type::value> c;
+ boost::ignore_unused_variable_warning(c);
+}
+
+
+
+} // namespace concept
+
+
+} // namespace ggl
+
+
+#endif // GGL_GEOMETRIES_CONCEPTS_CHECK_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/detail/check_append.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/detail/check_append.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,57 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// 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 GGL_GEOMETRIES_CONCEPTS_DETAIL_CHECK_APPEND_HPP
+#define GGL_GEOMETRIES_CONCEPTS_DETAIL_CHECK_APPEND_HPP
+
+
+#include <boost/type_traits/remove_const.hpp>
+
+#include <ggl/core/access.hpp>
+
+
+
+namespace ggl { namespace concept {
+
+namespace detail
+{
+
+ template <typename Geometry, typename Point, bool UseStd>
+ struct check_append
+ {};
+
+ template <typename Geometry, typename Point>
+ struct check_append<Geometry, Point, true>
+ {
+ static void apply(Geometry& geometry, Point const& p)
+ {
+ geometry.push_back(p);
+ }
+ };
+
+ template <typename Geometry, typename Point>
+ struct check_append<Geometry, Point, false>
+ {
+ static void apply(Geometry& geometry, Point const& p)
+ {
+ ggl::traits::append_point
+ <
+ typename boost::remove_const<Geometry>::type,
+ Point
+ >::apply(geometry, p, -1, -1);
+ }
+ };
+}
+
+
+
+}} // namespace ggl::concept
+
+
+#endif // GGL_GEOMETRIES_CONCEPTS_DETAIL_CHECK_APPEND_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/detail/check_clear.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/detail/check_clear.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,57 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// 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 GGL_GEOMETRIES_CONCEPTS_DETAIL_CHECK_CLEAR_HPP
+#define GGL_GEOMETRIES_CONCEPTS_DETAIL_CHECK_CLEAR_HPP
+
+
+#include <boost/type_traits/remove_const.hpp>
+
+#include <ggl/core/access.hpp>
+
+
+
+namespace ggl { namespace concept {
+
+namespace detail
+{
+ template <typename Geometry, bool UseStd>
+ struct check_clear
+ {};
+
+ template <typename Geometry>
+ struct check_clear<Geometry, true>
+ {
+ static void apply(Geometry& geometry)
+ {
+ geometry.clear();
+ }
+ };
+
+ template <typename Geometry>
+ struct check_clear<Geometry, false>
+ {
+ static void apply(Geometry& geometry)
+ {
+ ggl::traits::clear
+ <
+ typename boost::remove_const<Geometry>::type
+ >::apply(geometry);
+ }
+ };
+
+
+}
+
+
+
+}} // namespace ggl::concept
+
+
+#endif // GGL_GEOMETRIES_CONCEPTS_DETAIL_CHECK_CLEAR_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/linestring_concept.hpp
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/core/concepts/linestring_concept.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/linestring_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -7,51 +7,55 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_CORE_CONCEPTS_LINESTRING_CONCEPT_HPP
-#define GGL_CORE_CONCEPTS_LINESTRING_CONCEPT_HPP
+#ifndef GGL_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP
+#define GGL_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP
#include <boost/concept_check.hpp>
#include <boost/range/concepts.hpp>
-
-#include <ggl/core/concepts/point_concept.hpp>
-
-
+#include <boost/type_traits/remove_const.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/point_type.hpp>
-#include <ggl/algorithms/clear.hpp>
-#include <ggl/algorithms/append.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/detail/check_clear.hpp>
+#include <ggl/geometries/concepts/detail/check_append.hpp>
namespace ggl { namespace concept {
/*!
- \brief Checks linestring concept, using Boost Concept Check Library and metafunctions
+ \brief Checks linestring concept
\ingroup concepts
*/
-template <typename L>
-struct Linestring
+template <typename Geometry>
+class Linestring
{
- private :
- typedef typename point_type<L>::type P;
+ typedef typename point_type<Geometry>::type point_type;
+
+ BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
+ BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
- BOOST_CONCEPT_ASSERT( (concept::Point<P>) );
- BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<L>) );
- public :
- /// BCCL macro to check the Linestring concept
- BOOST_CONCEPT_USAGE(Linestring)
- {
-
- // Check if it can be modified
- L* ls;
- clear(*ls);
- append(*ls, P());
- }
+public :
+
+ BOOST_CONCEPT_USAGE(Linestring)
+ {
+ // Check if it can be modified
+ static const bool use_std = traits::use_std
+ <
+ typename boost::remove_const<Geometry>::type
+ >::value;
+
+ Geometry* ls;
+ detail::check_clear<Geometry, use_std>::apply(*ls);
+
+ point_type* p;
+ detail::check_append<Geometry, point_type, use_std>::apply(*ls, *p);
+ }
};
@@ -61,24 +65,23 @@
\details The ConstLinestring concept check the same as the Linestring concept,
but does not check write access.
*/
-template <typename L>
-struct ConstLinestring
+template <typename Geometry>
+class ConstLinestring
{
- private :
- typedef typename point_type<L>::type P;
+ typedef typename point_type<Geometry>::type point_type;
+
+ BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
+ BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P>) );
- BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<L>) );
+public :
- public :
- /// BCCL macro to check the ConstLinestring concept
- BOOST_CONCEPT_USAGE(ConstLinestring)
- {
- }
+ BOOST_CONCEPT_USAGE(ConstLinestring)
+ {
+ }
};
}} // namespace ggl::concept
-#endif // GGL_CORE_CONCEPTS_LINESTRING_CONCEPT_HPP
+#endif // GGL_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/point_concept.hpp
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/core/concepts/point_concept.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/point_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -6,8 +6,8 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_CORE_CONCEPTS_POINT_CONCEPT_HPP
-#define GGL_CORE_CONCEPTS_POINT_CONCEPT_HPP
+#ifndef GGL_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
+#define GGL_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
#include <cstddef>
@@ -20,14 +20,14 @@
/*!
\defgroup concepts concept checking
-Concepts are used to check if pointtypes provide required implementation. Concept checking
+Concepts are used to apply if pointtypes provide required implementation. Concept checking
is done using BCCL (Boost Concept Check Library) and MPL (Meta Programming Library)
*/
namespace ggl { namespace concept {
/*!
- \brief Checks point concept, using Boost Concept Check Library and metafunctions
+ \brief Checks point concept
\ingroup concepts
\details The concept is separated into 4 metafunctions:
- \ref ggl::traits::coordinate_type "coordinate_type": provides the type of the coordinates of a point
@@ -57,41 +57,40 @@
\until //:\\
*/
-template <typename X>
-struct Point
+template <typename Geometry>
+class Point
{
-private:
- typedef typename coordinate_type<X>::type ctype;
- typedef typename coordinate_system<X>::type csystem;
+ typedef typename coordinate_type<Geometry>::type ctype;
+ typedef typename coordinate_system<Geometry>::type csystem;
- enum { ccount = dimension<X>::value };
+ enum { ccount = dimension<Geometry>::value };
- /// Internal structure to check if access is OK for all dimensions
- template <typename P, std::size_t I, std::size_t Count>
+
+ template <typename P, std::size_t Dimension, std::size_t DimensionCount>
struct dimension_checker
{
- static void check()
+ static void apply()
{
P* p;
- ggl::set<I>(*p, ggl::get<I>(*p));
- dimension_checker<P, I+1, Count>::check();
+ ggl::set<Dimension>(*p, ggl::get<Dimension>(*p));
+ dimension_checker<P, Dimension+1, DimensionCount>::apply();
}
};
- /// Internal structure to check if access is OK for all dimensions
- template <typename P, std::size_t Count>
- struct dimension_checker<P, Count, Count>
+
+ template <typename P, std::size_t DimensionCount>
+ struct dimension_checker<P, DimensionCount, DimensionCount>
{
- static void check() {}
+ static void apply() {}
};
public:
- /// BCCL macro to check the Point concept
+ /// BCCL macro to apply the Point concept
BOOST_CONCEPT_USAGE(Point)
{
- dimension_checker<X, 0, ccount>::check();
+ dimension_checker<Geometry, 0, ccount>::apply();
}
};
@@ -99,48 +98,47 @@
/*!
\brief Checks point concept (const version)
\ingroup concepts
- \details The ConstPoint concept check the same as the Point concept,
- but does not check write access.
+ \details The ConstPoint concept apply the same as the Point concept,
+ but does not apply write access.
*/
-template <typename X>
-struct ConstPoint
+template <typename Geometry>
+class ConstPoint
{
-private:
- typedef typename coordinate_type<X>::type ctype;
- typedef typename coordinate_system<X>::type csystem;
+ typedef typename coordinate_type<Geometry>::type ctype;
+ typedef typename coordinate_system<Geometry>::type csystem;
- enum { ccount = dimension<X>::value };
+ enum { ccount = dimension<Geometry>::value };
- /// Internal structure to check if access is OK for all dimensions
- template <typename P, std::size_t I, std::size_t Count>
+
+ template <typename P, std::size_t Dimension, std::size_t DimensionCount>
struct dimension_checker
{
- static void check()
+ static void apply()
{
const P* p = 0;
- ctype coord(ggl::get<I>(*p));
+ ctype coord(ggl::get<Dimension>(*p));
boost::ignore_unused_variable_warning(coord);
- dimension_checker<P, I+1, Count>::check();
+ dimension_checker<P, Dimension+1, DimensionCount>::apply();
}
};
- /// Internal structure to check if access is OK for all dimensions
- template <typename P, std::size_t Count>
- struct dimension_checker<P, Count, Count>
+
+ template <typename P, std::size_t DimensionCount>
+ struct dimension_checker<P, DimensionCount, DimensionCount>
{
- static void check() {}
+ static void apply() {}
};
public:
- /// BCCL macro to check the ConstPoint concept
+ /// BCCL macro to apply the ConstPoint concept
BOOST_CONCEPT_USAGE(ConstPoint)
{
- dimension_checker<X, 0, ccount>::check();
+ dimension_checker<Geometry, 0, ccount>::apply();
}
};
}} // namespace ggl::concept
-#endif // GGL_CORE_CONCEPTS_POINT_CONCEPT_HPP
+#endif // GGL_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/polygon_concept.hpp
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/core/concepts/polygon_concept.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/polygon_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -6,84 +6,73 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_CORE_CONCEPTS_POLYGON_CONCEPT_HPP
-#define GGL_CORE_CONCEPTS_POLYGON_CONCEPT_HPP
+#ifndef GGL_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP
+#define GGL_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP
#include <boost/concept_check.hpp>
#include <boost/range/concepts.hpp>
-#include <ggl/algorithms/append.hpp>
-#include <ggl/algorithms/clear.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
#include <ggl/core/point_type.hpp>
#include <ggl/core/ring_type.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/core/concepts/ring_concept.hpp>
-namespace ggl { namespace concept {
-
-
-#ifndef DOXYGEN_NO_DETAIL
-namespace detail
-{
-
-template <typename P>
-struct PolygonChecker
-{
- typedef typename point_type<P>::type PNT;
- typedef typename ring_type<P>::type R;
- typedef typename interior_type<P>::type I;
-
- BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<I>) );
+#include <ggl/geometries/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/ring_concept.hpp>
- void constraints()
- {
- P* poly;
- R& e = exterior_ring(*poly);
- const R& ce = exterior_ring(*poly);
-
- I& i = interior_rings(*poly);
- const I& ci = interior_rings(*poly);
-
- boost::ignore_unused_variable_warning(e);
- boost::ignore_unused_variable_warning(ce);
- boost::ignore_unused_variable_warning(i);
- boost::ignore_unused_variable_warning(ci);
- }
-};
+namespace ggl { namespace concept {
-} // namespace detail
-#endif // DOXYGEN_NO_DETAIL
/*!
- \brief Checks polygon concept, using Boost Concept Check Library and metafunctions
+ \brief Checks polygon concept
\ingroup concepts
*/
-template <typename P>
-struct Polygon : detail::PolygonChecker<P>
+template <typename Geometry>
+class Polygon
{
-private:
+ typedef typename point_type<Geometry>::type point_type;
+ typedef typename ring_type<Geometry>::type ring_type;
+ typedef typename interior_type<Geometry>::type interior_type;
+
+ BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
+ BOOST_CONCEPT_ASSERT( (concept::Ring<ring_type>) );
- typedef typename point_type<P>::type PNT;
- typedef typename ring_type<P>::type R;
- typedef typename interior_type<P>::type I;
+ BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<interior_type>) );
- BOOST_CONCEPT_ASSERT( (concept::Point<PNT>) );
- BOOST_CONCEPT_ASSERT( (concept::Ring<R>) );
+ struct checker
+ {
+ static inline void apply()
+ {
+ Geometry* poly;
+ ring_type& e = exterior_ring(*poly);
+ ring_type const& ce = exterior_ring(*poly);
+
+ interior_type& i = interior_rings(*poly);
+ interior_type const& ci = interior_rings(*poly);
+
+ boost::ignore_unused_variable_warning(e);
+ boost::ignore_unused_variable_warning(ce);
+ boost::ignore_unused_variable_warning(i);
+ boost::ignore_unused_variable_warning(ci);
+ boost::ignore_unused_variable_warning(poly);
+ }
+
+ };
public:
- /// BCCL macro to check the Polygon concept
+
BOOST_CONCEPT_USAGE(Polygon)
{
// Check if it can be modified
- P* poly;
- clear(*poly);
- append(*poly, PNT());
+ // TODO
- this->constraints();
+ //Geometry* poly;
+ //clear(*poly);
+ //append(*poly, point_type());
+
+ checker::apply();
}
};
@@ -94,27 +83,42 @@
\details The ConstPolygon concept check the same as the Polygon concept,
but does not check write access.
*/
-template <typename P>
-struct ConstPolygon : detail::PolygonChecker<P>
+template <typename Geometry>
+class ConstPolygon
{
-private:
- typedef typename point_type<P>::type PNT;
- typedef typename ring_type<P>::type R;
- typedef typename interior_type<P>::type I;
+ typedef typename point_type<Geometry>::type point_type;
+ typedef typename ring_type<Geometry>::type ring_type;
+ typedef typename interior_type<Geometry>::type interior_type;
+
+ BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
+ BOOST_CONCEPT_ASSERT( (concept::ConstRing<ring_type>) );
+
+ BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<interior_type>) );
+
+ struct checker
+ {
+ static inline void apply()
+ {
+ Geometry* poly;
+ ring_type const& ce = exterior_ring(*poly);
+ interior_type const& ci = interior_rings(*poly);
+
+ boost::ignore_unused_variable_warning(ce);
+ boost::ignore_unused_variable_warning(ci);
+ boost::ignore_unused_variable_warning(poly);
+ }
+ };
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<PNT>) );
- BOOST_CONCEPT_ASSERT( (concept::ConstRing<R>) );
public:
- /// BCCL macro to check the ConstPolygon concept
BOOST_CONCEPT_USAGE(ConstPolygon)
{
- this->constraints();
+ checker::apply();
}
};
}} // namespace ggl::concept
-#endif // GGL_CORE_CONCEPTS_POLYGON_CONCEPT_HPP
+#endif // GGL_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/ring_concept.hpp
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/core/concepts/ring_concept.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/ring_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -7,77 +7,81 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_CORE_CONCEPTS_RING_CONCEPT_HPP
-#define GGL_CORE_CONCEPTS_RING_CONCEPT_HPP
+#ifndef GGL_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP
+#define GGL_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP
#include <boost/concept_check.hpp>
#include <boost/range/concepts.hpp>
-
-#include <ggl/core/concepts/point_concept.hpp>
-
-
+#include <boost/type_traits/remove_const.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/point_type.hpp>
-#include <ggl/algorithms/clear.hpp>
-#include <ggl/algorithms/append.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/detail/check_clear.hpp>
+#include <ggl/geometries/concepts/detail/check_append.hpp>
namespace ggl { namespace concept {
/*!
- \brief Checks (linear) Ring concept, using Boost Concept Check Library and metafunctions
+ \brief Checks (linear) ring concept
\ingroup concepts
*/
-template <typename R>
-struct Ring
+template <typename Geometry>
+class Ring
{
- private :
- typedef typename point_type<R>::type P;
+ typedef typename point_type<Geometry>::type point_type;
+
+ BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
+ BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
- BOOST_CONCEPT_ASSERT( (concept::Point<P>) );
- BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<R>) );
+public :
- public :
- /// BCCL macro to check the Ring concept
- BOOST_CONCEPT_USAGE(Ring)
- {
- // Check if it can be modified
- R* ls;
- clear(*ls);
- append(*ls, P());
- }
+ BOOST_CONCEPT_USAGE(Ring)
+ {
+ // Check if it can be modified
+ static const bool use_std = traits::use_std
+ <
+ typename boost::remove_const<Geometry>::type
+ >::value;
+
+ Geometry* ring;
+ detail::check_clear<Geometry, use_std>::apply(*ring);
+
+ point_type* p;
+ detail::check_append<Geometry, point_type, use_std>::apply(*ring, *p);
+ }
};
/*!
\brief Checks (linear) ring concept (const version)
\ingroup concepts
- \details The ConstLinearRing concept check the same as the Ring concept,
+ \details The ConstLinearRing concept check the same as the Geometry concept,
but does not check write access.
*/
-template <typename R>
-struct ConstRing
+template <typename Geometry>
+class ConstRing
{
- private :
- typedef typename point_type<R>::type P;
+ typedef typename point_type<Geometry>::type point_type;
+
+ BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
+ BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<Geometry>) );
+
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P>) );
- BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept<R>) );
+public :
- public :
- /// BCCL macro to check the ConstLinearRing concept
- BOOST_CONCEPT_USAGE(ConstRing)
- {
- }
+ BOOST_CONCEPT_USAGE(ConstRing)
+ {
+ }
};
}} // namespace ggl::concept
-#endif // GGL_CORE_CONCEPTS_RING_CONCEPT_HPP
+#endif // GGL_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/segment_concept.hpp
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/core/concepts/segment_concept.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/concepts/segment_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -7,13 +7,13 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_CORE_CONCEPTS_SEGMENT_CONCEPT_HPP
-#define GGL_CORE_CONCEPTS_SEGMENT_CONCEPT_HPP
+#ifndef GGL_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
+#define GGL_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
#include <boost/concept_check.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
@@ -26,94 +26,90 @@
/*!
- \brief Checks segment concept, using Boost Concept Check Library and metafunctions
+ \brief Checks segment concept
\ingroup concepts
*/
-template <typename S>
-struct Segment
+template <typename Geometry>
+class Segment
{
- private :
- typedef typename point_type<S>::type P;
+ typedef typename point_type<Geometry>::type point_type;
- BOOST_CONCEPT_ASSERT( (concept::Point<P>) );
+ BOOST_CONCEPT_ASSERT( (concept::Point<point_type>) );
- /// Internal structure to check if access is OK for all dimensions
- template <size_t C, size_t D, size_t N>
- struct dimension_checker
+ template <size_t Index, size_t Dimension, size_t DimensionCount>
+ struct dimension_checker
+ {
+ static void apply()
{
- static void check()
- {
- S* s;
- ggl::set<C, D>(*s, ggl::get<C, D>(*s));
- dimension_checker<C, D + 1, N>::check();
- }
- };
-
- template <size_t C, size_t N>
- struct dimension_checker<C, N, N>
- {
- static void check() {}
- };
-
- public :
- /// BCCL macro to check the Segment concept
- BOOST_CONCEPT_USAGE(Segment)
- {
- static const size_t N = dimension<P>::value;
- dimension_checker<0, 0, N>::check();
- dimension_checker<1, 0, N>::check();
+ Geometry* s;
+ ggl::set<Index, Dimension>(*s, ggl::get<Index, Dimension>(*s));
+ dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
}
+ };
+
+ template <size_t Index, size_t DimensionCount>
+ struct dimension_checker<Index, DimensionCount, DimensionCount>
+ {
+ static void apply() {}
+ };
+
+public :
+
+ BOOST_CONCEPT_USAGE(Segment)
+ {
+ static const size_t n = dimension<point_type>::type::value;
+ dimension_checker<0, 0, n>::apply();
+ dimension_checker<1, 0, n>::apply();
+ }
};
/*!
\brief Checks Segment concept (const version)
\ingroup concepts
- \details The ConstSegment concept check the same as the Segment concept,
- but does not check write access.
+ \details The ConstSegment concept verifies the same as the Segment concept,
+ but does not verify write access.
*/
-template <typename S>
-struct ConstSegment
+template <typename Geometry>
+class ConstSegment
{
- private :
- typedef typename point_type<S>::type P;
- typedef typename coordinate_type<S>::type T;
+ typedef typename point_type<Geometry>::type point_type;
+ typedef typename coordinate_type<Geometry>::type coordinate_type;
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P>) );
+ BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point_type>) );
- /// Internal structure to check if access is OK for all dimensions
- template <size_t C, size_t D, size_t N>
- struct dimension_checker
+ template <size_t Index, size_t Dimension, size_t DimensionCount>
+ struct dimension_checker
+ {
+ static void apply()
{
- static void check()
- {
- const S* s = 0;
- T coord(ggl::get<C, D>(*s));
- boost::ignore_unused_variable_warning(coord);
- dimension_checker<C, D + 1, N>::check();
- }
- };
-
- template <size_t C, size_t N>
- struct dimension_checker<C, N, N>
- {
- static void check() {}
- };
-
- public :
- /// BCCL macro to check the ConstSegment concept
- BOOST_CONCEPT_USAGE(ConstSegment)
- {
- static const size_t N = dimension<P>::value;
- dimension_checker<0, 0, N>::check();
- dimension_checker<1, 0, N>::check();
+ const Geometry* s = 0;
+ coordinate_type coord(ggl::get<Index, Dimension>(*s));
+ boost::ignore_unused_variable_warning(coord);
+ dimension_checker<Index, Dimension + 1, DimensionCount>::apply();
}
+ };
+
+ template <size_t Index, size_t DimensionCount>
+ struct dimension_checker<Index, DimensionCount, DimensionCount>
+ {
+ static void apply() {}
+ };
+
+public :
+
+ BOOST_CONCEPT_USAGE(ConstSegment)
+ {
+ static const size_t n = dimension<point_type>::type::value;
+ dimension_checker<0, 0, n>::apply();
+ dimension_checker<1, 0, n>::apply();
+ }
};
}} // namespace ggl::concept
-#endif // GGL_CORE_CONCEPTS_SEGMENT_CONCEPT_HPP
+#endif // GGL_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/geometries.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/geometries.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/geometries.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -19,7 +19,6 @@
#include <ggl/geometries/polygon.hpp>
#include <ggl/geometries/box.hpp>
-#include <ggl/geometries/nsphere.hpp>
#include <ggl/geometries/segment.hpp>
#endif // GGL_GEOMETRIES_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/linear_ring.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/linear_ring.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/linear_ring.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -18,7 +18,7 @@
#include <ggl/core/tags.hpp>
#include <ggl/core/point_order.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
namespace ggl
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/linestring.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/linestring.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/linestring.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -18,7 +18,7 @@
#include <ggl/core/tag.hpp>
#include <ggl/core/tags.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
namespace ggl
Deleted: sandbox/ggl/formal_review_request/boost/ggl/geometries/nsphere.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/nsphere.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
+++ (empty file)
@@ -1,128 +0,0 @@
-// Generic Geometry Library
-//
-// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
-// Copyright Bruno Lalande 2008, 2009
-// 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 GGL_GEOMETRIES_NSPHERE_HPP
-#define GGL_GEOMETRIES_NSPHERE_HPP
-
-#include <cstddef>
-
-#include <ggl/algorithms/assign.hpp>
-#include <ggl/core/concepts/nsphere_concept.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/util/copy.hpp>
-
-namespace ggl
-{
-
-/*!
- \brief Class nsphere: defines a circle or a sphere: a point with radius
- \ingroup Geometry
- \details The name nsphere is quite funny but the best description of the class. It can be a circle (2D),
- a sphere (3D), or higher (hypersphere) or lower. According to Wikipedia this name is the most appropriate.
- It was mentioned on the Boost list.
- An alternative is the more fancy name "sphercle" but that might be a bit too much an invention.
- \note Circle is currently used for selections, for example polygon_in_circle. Currently not all
- algorithms are implemented for n-spheres.
- \tparam P point type of the center
- \tparam T number type of the radius
- */
-template <typename P, typename T>
-class nsphere
-{
- BOOST_CONCEPT_ASSERT( (concept::Point<P>) );
-
-public:
-
- typedef T radius_type;
- typedef typename coordinate_type<P>::type coordinate_type;
-
- nsphere()
- : m_radius(0)
- {
- detail::assign::assign_value(m_center, coordinate_type());
- }
-
- nsphere(P const& center, T const& radius)
- : m_radius(radius)
- {
- copy_coordinates(center, m_center);
- }
-
- inline P const& center() const { return m_center; }
- inline T const& radius() const { return m_radius; }
-
- inline void radius(T const& r) { m_radius = r; }
- inline P& center() { return m_center; }
-
-private:
-
- P m_center;
- T m_radius;
-};
-
-// Traits specializations for n-sphere above
-#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
-namespace traits
-{
-
-template <typename Point, typename RadiusType>
-struct tag< nsphere<Point, RadiusType> >
-{
- typedef nsphere_tag type;
-};
-
-template <typename Point, typename RadiusType>
-struct point_type<nsphere<Point, RadiusType> >
-{
- typedef Point type;
-};
-
-template <typename Point, typename RadiusType>
-struct radius_type<nsphere<Point, RadiusType> >
-{
- typedef RadiusType type;
-};
-
-template <typename Point, typename CoordinateType, std::size_t Dimension>
-struct access<nsphere<Point, CoordinateType>, Dimension>
-{
- typedef nsphere<Point, CoordinateType> nsphere_type;
-
- static inline CoordinateType get(nsphere_type const& s)
- {
- return ggl::get<Dimension>(s.center());
- }
-
- static inline void set(nsphere_type& s, CoordinateType const& value)
- {
- ggl::set<Dimension>(s.center(), value);
- }
-};
-
-template <typename Point, typename RadiusType>
-struct radius_access<nsphere<Point, RadiusType>, RadiusType, 0>
-{
- typedef nsphere<Point, RadiusType> nsphere_type;
-
- static inline RadiusType get(nsphere_type const& s)
- {
- return s.radius();
- }
-
- static inline void set(nsphere_type& s, RadiusType const& value)
- {
- s.radius(value);
- }
-};
-
-} // namespace traits
-#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
-
-} // namespace ggl
-
-#endif // GGL_GEOMETRIES_NSPHERE_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/polygon.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/polygon.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/polygon.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -18,7 +18,7 @@
#include <ggl/core/interior_rings.hpp>
#include <ggl/core/point_type.hpp>
#include <ggl/core/ring_type.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
#include <ggl/geometries/linear_ring.hpp>
namespace ggl
Modified: sandbox/ggl/formal_review_request/boost/ggl/geometries/segment.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/geometries/segment.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/geometries/segment.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -15,7 +15,7 @@
#include <boost/mpl/if.hpp>
#include <boost/type_traits/is_const.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
namespace ggl
{
@@ -26,11 +26,11 @@
\details From Wikipedia: In geometry, a line segment is a part of a line that is bounded
by two distinct end points, and contains every point on the line between its end points.
\note The structure is like std::pair, and can often be used interchangeable.
-Difference is that it refers to points, does not have points.
-\note Like std::pair, points are public available.
+Difference is that it refers to points, does not have points.
+\note Like std::pair, points are public available.
\note type is const or non const, so ggl::segment<P> or ggl::segment<const P>
\note We cannot derive from std::pair<P&, P&> because of
-reference assignments.
+reference assignments.
\tparam ConstOrNonConstPoint point type of the segment, maybe a point or a const point
*/
template<typename ConstOrNonConstPoint>
Modified: sandbox/ggl/formal_review_request/boost/ggl/ggl.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/ggl.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/ggl.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,14 +11,6 @@
// Shortcut to include all header files
-#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/core/concepts/ring_concept.hpp>
-#include <ggl/core/concepts/linestring_concept.hpp>
-#include <ggl/core/concepts/polygon_concept.hpp>
-
-#include <ggl/core/concepts/box_concept.hpp>
-#include <ggl/core/concepts/nsphere_concept.hpp>
-#include <ggl/core/concepts/segment_concept.hpp>
#include <ggl/core/cs.hpp>
#include <ggl/core/tag.hpp>
@@ -60,6 +52,8 @@
#include <ggl/algorithms/transform.hpp>
#include <ggl/algorithms/within.hpp>
+// check includes all concepts
+#include <ggl/geometries/concepts/check.hpp>
#include <ggl/util/copy.hpp>
#include <ggl/util/for_each_coordinate.hpp>
Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/centroid.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/centroid.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/centroid.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -19,39 +19,55 @@
#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace centroid {
-template<typename MultiPolygon, typename Point, typename Strategy>
-struct centroid_multi_polygon
+template
+<
+ typename Multi,
+ typename Point,
+ typename Strategy
+>
+struct centroid_multi_point
{
- static inline void apply(MultiPolygon const& multi, Point& c, Strategy const& strategy)
+ static inline bool apply(Multi const& multi, Point& centroid,
+ Strategy const& strategy, typename Strategy::state_type& state)
{
- typedef typename boost::range_const_iterator<MultiPolygon>::type iterator;
+ assign_zero(centroid);
+ int n = 0;
- typename Strategy::state_type state;
+ for (typename boost::range_const_iterator<Multi>::type
+ it = boost::begin(multi);
+ it != boost::end(multi);
+ ++it)
+ {
+ add_point(centroid, *it);
+ n++;
+ }
+ divide_value(centroid, n);
+
+ return false;
+ }
+};
- for (iterator it = boost::begin(multi); it != boost::end(multi); ++it)
+
+template
+<
+ typename Multi,
+ typename Point,
+ typename Strategy,
+ typename Policy
+>
+struct centroid_multi
+{
+ static inline bool apply(Multi const& multi, Point& centroid,
+ Strategy const& strategy, typename Strategy::state_type& state)
+ {
+ for (typename boost::range_const_iterator<Multi>::type
+ it = boost::begin(multi);
+ it != boost::end(multi);
+ ++it)
{
-// TODO: make THIS the building block!
- typedef typename boost::range_value<MultiPolygon>::type polygon_type;
- polygon_type const& poly = *it;
- if (ring_ok(exterior_ring(poly), c))
- {
-
- loop(exterior_ring(poly), strategy, state);
-
- typedef typename boost::range_const_iterator
- <
- typename interior_type<polygon_type>::type
- >::type iterator_type;
-
- for (iterator_type it = boost::begin(interior_rings(poly));
- it != boost::end(interior_rings(poly));
- ++it)
- {
- loop(*it, strategy, state);
- }
- }
+ Policy::apply(*it, centroid, strategy, state);
}
- state.centroid(c);
+ return true;
}
};
@@ -65,10 +81,39 @@
#ifndef DOXYGEN_NO_DISPATCH
namespace dispatch
{
- template <typename MultiPolygon, typename Point, typename Strategy>
- struct centroid<multi_polygon_tag, MultiPolygon, Point, Strategy>
- : detail::centroid::centroid_multi_polygon<MultiPolygon, Point, Strategy>
- {};
+
+template <typename MultiPolygon, typename Point, typename Strategy>
+struct centroid<multi_polygon_tag, 2, MultiPolygon, Point, Strategy>
+ : detail::centroid::centroid_multi
+ <
+ MultiPolygon,
+ Point,
+ Strategy,
+ detail::centroid::centroid_polygon
+ <
+ typename boost::range_value<MultiPolygon>::type,
+ Point,
+ Strategy
+ >
+ >
+{};
+
+
+template
+<
+ std::size_t Dimensions,
+ typename MultiPoint,
+ typename Point,
+ typename Strategy
+>
+struct centroid<multi_point_tag, Dimensions, MultiPoint, Point, Strategy>
+ : detail::centroid::centroid_multi_point
+ <
+ MultiPoint,
+ Point,
+ Strategy
+ >
+{};
} // namespace dispatch
Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/envelope.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/envelope.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/envelope.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -6,8 +6,8 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_MULTI_ENVELOPE_HPP
-#define GGL_MULTI_ENVELOPE_HPP
+#ifndef GGL_MULTI_ALGORITHMS_ENVELOPE_HPP
+#define GGL_MULTI_ALGORITHMS_ENVELOPE_HPP
#include <vector>
@@ -28,7 +28,8 @@
template<typename MultiLinestring, typename Box, typename Strategy>
struct envelope_multi_linestring
{
- static inline void apply(MultiLinestring const& mp, Box& mbr, Strategy const& strategy)
+ static inline void apply(MultiLinestring const& mp, Box& mbr,
+ Strategy const& strategy)
{
typename Strategy::state_type state(mbr);
for (typename boost::range_const_iterator<MultiLinestring>::type
@@ -46,7 +47,8 @@
template<typename MultiPolygon, typename Box, typename Strategy>
struct envelope_multi_polygon
{
- static inline void apply(MultiPolygon const& mp, Box& mbr, Strategy const& strategy)
+ static inline void apply(MultiPolygon const& mp, Box& mbr,
+ Strategy const& strategy)
{
typename Strategy::state_type state(mbr);
for (typename boost::range_const_iterator<MultiPolygon>::type
@@ -69,20 +71,20 @@
namespace dispatch
{
-template <typename M, typename B, typename S>
-struct envelope<multi_point_tag, box_tag, M, B, S>
- : detail::envelope::envelope_range<M, B, S>
+template <typename Multi, typename Box, typename Strategy>
+struct envelope<multi_point_tag, box_tag, Multi, Box, Strategy>
+ : detail::envelope::envelope_range<Multi, Box, Strategy>
{};
-template <typename M, typename B, typename S>
-struct envelope<multi_linestring_tag, box_tag, M, B, S>
- : detail::envelope::envelope_multi_linestring<M, B, S>
+template <typename Multi, typename Box, typename Strategy>
+struct envelope<multi_linestring_tag, box_tag, Multi, Box, Strategy>
+ : detail::envelope::envelope_multi_linestring<Multi, Box, Strategy>
{};
-template <typename M, typename B, typename S>
-struct envelope<multi_polygon_tag, box_tag, M, B, S>
- : detail::envelope::envelope_multi_polygon<M, B, S>
+template <typename Multi, typename Box, typename Strategy>
+struct envelope<multi_polygon_tag, box_tag, Multi, Box, Strategy>
+ : detail::envelope::envelope_multi_polygon<Multi, Box, Strategy>
{};
@@ -95,4 +97,4 @@
} // namespace ggl
-#endif // GGL_MULTI_ENVELOPE_HPP
+#endif // GGL_MULTI_ALGORITHMS_ENVELOPE_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/perimeter.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/perimeter.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/perimeter.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -25,16 +25,16 @@
struct perimeter<multi_polygon_tag, MultiPolygon, Strategy>
: detail::multi_sum
<
- typename length_result<MultiPolygon>::type,
- MultiPolygon,
+ typename length_result<MultiPolygon>::type,
+ MultiPolygon,
Strategy,
perimeter
<
polygon_tag,
- typename boost::range_value<MultiPolygon>::type,
+ typename boost::range_value<MultiPolygon>::type,
Strategy
>
- >
+ >
{};
} // namespace dispatch
Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/within.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/within.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/within.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -9,7 +9,9 @@
#ifndef GGL_MULTI_ALGORITHMS_WITHIN_HPP
#define GGL_MULTI_ALGORITHMS_WITHIN_HPP
-#include <vector>
+
+#include <boost/range/functions.hpp>
+#include <boost/range/metafunctions.hpp>
#include <ggl/algorithms/within.hpp>
#include <ggl/multi/core/tags.hpp>
@@ -21,33 +23,33 @@
namespace detail { namespace within {
-template<typename P, typename I, typename S>
-inline bool point_in_multi_polygon(const P& p, const I& m, const S& strategy)
-{
- for (typename I::const_iterator i = m.begin(); i != m.end(); i++)
- {
- // Point within a multi-polygon: true if within one of the polygons
- if (point_in_polygon(p, *i, strategy))
+template
+<
+ typename Geometry,
+ typename MultiGeometry,
+ typename Strategy,
+ typename Policy
+>
+struct geometry_in_multi
+{
+ static inline bool apply(Geometry const& geometry,
+ MultiGeometry const& multi,
+ Strategy const& strategy)
+ {
+ for (typename boost::range_const_iterator<MultiGeometry>::type it
+ = boost::begin(multi);
+ it != boost::end(multi);
+ ++it)
{
- return true;
+ // Geometry within a multi: true if within one of them
+ if (Policy::apply(geometry, *it, strategy))
+ {
+ return true;
+ }
}
+ return false;
}
- return false;
-}
-
-
-template<typename I, typename C>
-inline bool multi_polygon_in_circle(const I& m, const C& c)
-{
- for (typename I::const_iterator i = m.begin(); i != m.end(); i++)
- {
- if (! polygon_in_circle(*i, c))
- {
- return false;
- }
- }
- return true;
-}
+};
}} // namespace detail::within
#endif // DOXYGEN_NO_DETAIL
@@ -56,45 +58,21 @@
namespace dispatch
{
-/*
-template <typename M, typename B>
-struct within<multi_polygon_tag, box_tag, M, B>
-{
- static inline bool apply(const M& m, const B& b)
- {
- return detail::within::multi_polygon_in_box(m, b);
- }
-};
-*/
-
-template <typename M, typename C>
-struct within<multi_polygon_tag, nsphere_tag, M, C>
-{
- static inline bool apply(const M& m, const C& c)
- {
- return detail::within::multi_polygon_in_circle(m, c);
- }
-};
-
-template <typename P, typename M>
-struct within<point_tag, multi_polygon_tag, P, M>
-{
- template <typename S>
- static inline bool apply(const P& p, const M& m, const S& strategy)
- {
- return detail::within::point_in_multi_polygon(p, m, strategy);
- }
-
- static inline bool apply(const P& p, const M& m)
- {
- typedef typename point_type<M>::type PM;
- typename strategy_within<
- typename cs_tag<P>::type, typename cs_tag<PM>::type, P, PM
- >::type strategy;
- return apply(p, m, strategy);
- }
-
-};
+template <typename Point, typename MultiPolygon, typename Strategy>
+struct within<point_tag, multi_polygon_tag, Point, MultiPolygon, Strategy>
+ : detail::within::geometry_in_multi
+ <
+ Point,
+ MultiPolygon,
+ Strategy,
+ detail::within::point_in_polygon
+ <
+ Point,
+ typename boost::range_value<MultiPolygon>::type,
+ Strategy
+ >
+ >
+{};
} // namespace dispatch
#endif // DOXYGEN_NO_DISPATCH
Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_linestring.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_linestring.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_linestring.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,7 +12,10 @@
#include <memory>
#include <vector>
-#include <ggl/core/concepts/linestring_concept.hpp>
+#include <boost/concept/requires.hpp>
+
+#include <ggl/geometries/concepts/linestring_concept.hpp>
+
#include <ggl/multi/core/tags.hpp>
namespace ggl
Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_point.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_point.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_point.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,7 +12,10 @@
#include <memory>
#include <vector>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <boost/concept/requires.hpp>
+
+#include <ggl/geometries/concepts/point_concept.hpp>
+
#include <ggl/multi/core/tags.hpp>
namespace ggl
Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_polygon.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_polygon.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/geometries/multi_polygon.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,10 +12,13 @@
#include <memory>
#include <vector>
+#include <boost/concept/requires.hpp>
+
#include <ggl/multi/core/tags.hpp>
-#include <ggl/core/concepts/polygon_concept.hpp>
#include <ggl/multi/core/tags.hpp>
+#include <ggl/geometries/concepts/polygon_concept.hpp>
+
namespace ggl
{
Deleted: sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/agn_within.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/agn_within.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
+++ (empty file)
@@ -1,162 +0,0 @@
-// Generic Geometry Library
-//
-// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
-// Copyright Bruno Lalande 2008, 2009
-// 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 GGL_STRATEGY_AGNOSTIC_WITHIN_HPP
-#define GGL_STRATEGY_AGNOSTIC_WITHIN_HPP
-
-
-
-#include <ggl/geometries/segment.hpp>
-
-#include <ggl/strategies/strategy_traits.hpp>
-
-
-
-namespace ggl
-{
-namespace strategy
-{
- namespace within
- {
-
- /*!
- \brief Within detection using winding rule
- \tparam P point type of point to examine
- \tparam PS point type of segments, defaults to P
- \author Barend Gehrels
- \note The implementation is inspired by terralib http://www.terralib.org (LGPL)
- \note but totally revised afterwards, especially for cases on segments
- \note More efficient (less comparisons and no divison) than the cross count algorithm
- \note Only dependant on "side", -> agnostic, suitable for latlong
- */
- template<typename P, typename PS = P>
- class winding
- {
- private :
- typedef typename coordinate_type<P>::type PT;
- typedef typename coordinate_type<PS>::type ST;
-
- /*! subclass to keep state */
- struct windings
- {
- int count;
- bool touches;
- const P& p;
- inline explicit windings(const P& ap)
- : count(0)
- , touches(false)
- , p(ap)
- {}
- inline bool within() const
- {
- return ! touches && count != 0;
- }
- };
-
- template <size_t D>
- static inline int check_touch(const segment<const PS>& s, windings& state)
- {
- const PT& p = get<D>(state.p);
- const ST& s1 = get<0, D>(s);
- const ST& s2 = get<1, D>(s);
- if ((s1 <= p && s2 >= p) || (s2 <= p && s1 >= p))
- {
- state.touches = true;
- }
- return 0;
- }
-
-
- template <size_t D>
- static inline int check_segment(const segment<const PS>& s, windings& state)
- {
- const PT& p = get<D>(state.p);
- const ST& s1 = get<0, D>(s);
- const ST& s2 = get<1, D>(s);
-
- // Check if one of segment endpoints is at same level of point
- bool eq1 = math::equals(s1, p);
- bool eq2 = math::equals(s2, p);
-
- if (eq1 && eq2)
- {
- // Both equal p -> segment is horizontal (or vertical for D=0)
- // The only thing which has to be done is check if point is ON segment
- return check_touch<1 - D>(s, state);
- }
-
- return
- eq1 ? (s2 > p ? 1 : -1) // P on level s1, UP/DOWN depending on s2
- : eq2 ? (s1 > p ? -1 : 1) // idem
- : s1 < p && s2 > p ? 2 // P between s1 -> s2 --> UP
- : s2 < p && s1 > p ? -2 // P between s2 -> s1 --> DOWN
- : 0;
- }
-
-
- public :
-
- typedef windings state_type;
-
- inline bool operator()(const segment<const PS>& s, state_type& state) const
- {
- int cnt = check_segment<1>(s, state);
- if (cnt != 0)
- {
- typedef typename strategy_side<typename cs_tag<P>::type, P, PS>::type SS;
-
- typename select_coordinate_type<P, PS>::type side = SS::side(s, state.p);
-
- if (math::equals(side, 0))
- {
- // Point is lying on segment
- state.touches = true;
- state.count = 0;
- return false;
- }
-
- // Side is NEG for right, POS for left.
- // CNT is -2 for down, 2 for up (or -1/1)
- // Side positive thus means UP and LEFTSIDE or DOWN and RIGHTSIDE
- // See accompagnying figure (TODO)
- int sd = (side > 0 ? 1 : -1) * cnt;
- if (sd > 0)
- {
- state.count += cnt;
- }
-
- }
- return ! state.touches;
- }
-
- };
-
- } // namespace within
-
-} // namespace strategy
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-template <typename P, typename PS>
-struct strategy_within<cartesian_tag, cartesian_tag, P, PS>
-{
- typedef strategy::within::winding<P, PS> type;
-};
-
-template <typename P, typename PS>
-struct strategy_within<geographic_tag, geographic_tag, P, PS>
-{
- typedef strategy::within::winding<P, PS> type;
-};
-#endif
-
-
-} // namespace ggl
-
-
-#endif // GGL_STRATEGY_AGNOSTIC_WITHIN_HPP
Copied: sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/point_in_poly_winding.hpp (from r56825, /sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/agn_within.hpp)
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/agn_within.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/agnostic/point_in_poly_winding.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -6,12 +6,12 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_STRATEGY_AGNOSTIC_WITHIN_HPP
-#define GGL_STRATEGY_AGNOSTIC_WITHIN_HPP
+#ifndef GGL_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
+#define GGL_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
-#include <ggl/geometries/segment.hpp>
+#include <ggl/util/select_calculation_type.hpp>
#include <ggl/strategies/strategy_traits.hpp>
@@ -19,144 +19,173 @@
namespace ggl
{
-namespace strategy
+
+namespace strategy { namespace within {
+
+/*!
+ \brief Within detection using winding rule
+ \tparam Point point type of point to examine
+ \tparam PointOfSegment point type of segments, defaults to Point
+ \author Barend Gehrels
+ \note The implementation is inspired by terralib http://www.terralib.org (LGPL)
+ \note but totally revised afterwards, especially for cases on segments
+ \note Only dependant on "side", -> agnostic, suitable for spherical/latlong
+ */
+template
+<
+ typename Point,
+ typename PointOfSegment = Point,
+ typename CalculationType = void
+>
+class winding
{
- namespace within
+ typedef typename select_calculation_type
+ <
+ Point,
+ PointOfSegment,
+ CalculationType
+ >::type calculation_type;
+
+
+ typedef typename strategy_side
+ <
+ typename cs_tag<Point>::type,
+ Point,
+ PointOfSegment
+ >::type strategy_side_type;
+
+
+ /*! subclass to keep state */
+ class counter
+ {
+ int count;
+ bool touches;
+
+ inline bool within_no_touch() const
+ {
+ return ! touches && count != 0;
+ }
+ public :
+ friend class winding;
+
+ inline counter()
+ : count(0)
+ , touches(false)
+ {}
+
+ };
+
+
+ template <size_t D>
+ static inline int check_touch(Point const& point,
+ PointOfSegment const& seg1, PointOfSegment const& seg2,
+ counter& state)
+ {
+ calculation_type const p = get<D>(point);
+ calculation_type const s1 = get<D>(seg1);
+ calculation_type const s2 = get<D>(seg2);
+ if ((s1 <= p && s2 >= p) || (s2 <= p && s1 >= p))
+ {
+ state.touches = true;
+ }
+ return 0;
+ }
+
+
+ template <size_t D>
+ static inline int check_segment(Point const& point,
+ PointOfSegment const& seg1, PointOfSegment const& seg2,
+ counter& state)
{
+ calculation_type const p = get<D>(point);
+ calculation_type const s1 = get<D>(seg1);
+ calculation_type const s2 = get<D>(seg2);
+
+ // Check if one of segment endpoints is at same level of point
+ bool eq1 = math::equals(s1, p);
+ bool eq2 = math::equals(s2, p);
- /*!
- \brief Within detection using winding rule
- \tparam P point type of point to examine
- \tparam PS point type of segments, defaults to P
- \author Barend Gehrels
- \note The implementation is inspired by terralib http://www.terralib.org (LGPL)
- \note but totally revised afterwards, especially for cases on segments
- \note More efficient (less comparisons and no divison) than the cross count algorithm
- \note Only dependant on "side", -> agnostic, suitable for latlong
- */
- template<typename P, typename PS = P>
- class winding
+ if (eq1 && eq2)
{
- private :
- typedef typename coordinate_type<P>::type PT;
- typedef typename coordinate_type<PS>::type ST;
-
- /*! subclass to keep state */
- struct windings
- {
- int count;
- bool touches;
- const P& p;
- inline explicit windings(const P& ap)
- : count(0)
- , touches(false)
- , p(ap)
- {}
- inline bool within() const
- {
- return ! touches && count != 0;
- }
- };
-
- template <size_t D>
- static inline int check_touch(const segment<const PS>& s, windings& state)
- {
- const PT& p = get<D>(state.p);
- const ST& s1 = get<0, D>(s);
- const ST& s2 = get<1, D>(s);
- if ((s1 <= p && s2 >= p) || (s2 <= p && s1 >= p))
- {
- state.touches = true;
- }
- return 0;
- }
-
-
- template <size_t D>
- static inline int check_segment(const segment<const PS>& s, windings& state)
- {
- const PT& p = get<D>(state.p);
- const ST& s1 = get<0, D>(s);
- const ST& s2 = get<1, D>(s);
-
- // Check if one of segment endpoints is at same level of point
- bool eq1 = math::equals(s1, p);
- bool eq2 = math::equals(s2, p);
-
- if (eq1 && eq2)
- {
- // Both equal p -> segment is horizontal (or vertical for D=0)
- // The only thing which has to be done is check if point is ON segment
- return check_touch<1 - D>(s, state);
- }
-
- return
- eq1 ? (s2 > p ? 1 : -1) // P on level s1, UP/DOWN depending on s2
- : eq2 ? (s1 > p ? -1 : 1) // idem
- : s1 < p && s2 > p ? 2 // P between s1 -> s2 --> UP
- : s2 < p && s1 > p ? -2 // P between s2 -> s1 --> DOWN
- : 0;
- }
-
-
- public :
-
- typedef windings state_type;
-
- inline bool operator()(const segment<const PS>& s, state_type& state) const
- {
- int cnt = check_segment<1>(s, state);
- if (cnt != 0)
- {
- typedef typename strategy_side<typename cs_tag<P>::type, P, PS>::type SS;
-
- typename select_coordinate_type<P, PS>::type side = SS::side(s, state.p);
-
- if (math::equals(side, 0))
- {
- // Point is lying on segment
- state.touches = true;
- state.count = 0;
- return false;
- }
-
- // Side is NEG for right, POS for left.
- // CNT is -2 for down, 2 for up (or -1/1)
- // Side positive thus means UP and LEFTSIDE or DOWN and RIGHTSIDE
- // See accompagnying figure (TODO)
- int sd = (side > 0 ? 1 : -1) * cnt;
- if (sd > 0)
- {
- state.count += cnt;
- }
-
- }
- return ! state.touches;
- }
+ // Both equal p -> segment is horizontal (or vertical for D=0)
+ // The only thing which has to be done is check if point is ON segment
+ return check_touch<1 - D>(point, seg1, seg2,state);
+ }
+
+ return
+ eq1 ? (s2 > p ? 1 : -1) // Point on level s1, UP/DOWN depending on s2
+ : eq2 ? (s1 > p ? -1 : 1) // idem
+ : s1 < p && s2 > p ? 2 // Point between s1 -> s2 --> UP
+ : s2 < p && s1 > p ? -2 // Point between s2 -> s1 --> DOWN
+ : 0;
+ }
- };
- } // namespace within
-} // namespace strategy
+
+public :
+
+ // Typedefs and static methods to fulfill the concept
+ typedef Point point_type;
+ typedef PointOfSegment segment_point_type;
+ typedef counter state_type;
+
+ static inline bool apply(Point const& point,
+ PointOfSegment const& s1, PointOfSegment const& s2,
+ counter& state)
+ {
+ int count = check_segment<1>(point, s1, s2, state);
+ if (count != 0)
+ {
+ int side = strategy_side_type::side(s1, s2, point);
+ if (side == 0)
+ {
+ // Point is lying on segment
+ state.touches = true;
+ state.count = 0;
+ return false;
+ }
+
+ // Side is NEG for right, POS for left.
+ // The count is -2 for down, 2 for up (or -1/1)
+ // Side positive thus means UP and LEFTSIDE or DOWN and RIGHTSIDE
+ // See accompagnying figure (TODO)
+ if (side * count > 0)
+ {
+ state.count += count;
+ }
+
+ }
+ return ! state.touches;
+ }
+
+ static inline bool result(counter const& state)
+ {
+ return state.within_no_touch();
+ }
+};
+
+}} // namespace strategy::within
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-template <typename P, typename PS>
-struct strategy_within<cartesian_tag, cartesian_tag, P, PS>
+
+template <typename Point, typename PointOfSegment>
+struct strategy_within<cartesian_tag, cartesian_tag, Point, PointOfSegment>
{
- typedef strategy::within::winding<P, PS> type;
+ typedef strategy::within::winding<Point, PointOfSegment> type;
};
-template <typename P, typename PS>
-struct strategy_within<geographic_tag, geographic_tag, P, PS>
+template <typename Point, typename PointOfSegment>
+struct strategy_within<geographic_tag, geographic_tag, Point, PointOfSegment>
{
- typedef strategy::within::winding<P, PS> type;
+ typedef strategy::within::winding<Point, PointOfSegment> type;
};
+
#endif
} // namespace ggl
-#endif // GGL_STRATEGY_AGNOSTIC_WITHIN_HPP
+#endif // GGL_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
Copied: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/area_by_triangles.hpp (from r56825, /sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_area.hpp)
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_area.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/area_by_triangles.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -6,97 +6,110 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_STRATEGY_CARTESIAN_AREA_HPP
-#define GGL_STRATEGY_CARTESIAN_AREA_HPP
+#ifndef GGL_STRATEGY_CARTESIAN_AREA_BY_TRIANGLES_HPP
+#define GGL_STRATEGY_CARTESIAN_AREA_BY_TRIANGLES_HPP
#include <boost/mpl/if.hpp>
#include <boost/type_traits.hpp>
#include <ggl/geometries/point_xy.hpp>
-#include <ggl/geometries/segment.hpp>
namespace ggl
+
{
-namespace strategy
+namespace strategy { namespace area {
+
+/*!
+ \brief Strategy functor for area calculation on point_xy points
+ \details Calculates area using well-known triangulation algorithm
+ \tparam PointOfSegment point type of segments
+*/
+template
+<
+ typename PointOfSegment,
+ typename CalculationType = void
+>
+class by_triangles
{
- namespace area
+public :
+ // If user specified a calculation type, use that type,
+ // whatever it is and whatever the point-type is.
+ // Else, use the pointtype, but at least double
+ typedef typename
+ boost::mpl::if_c
+ <
+ boost::is_void<CalculationType>::type::value,
+ typename select_most_precise
+ <
+ typename coordinate_type<PointOfSegment>::type,
+ double
+ >::type,
+ CalculationType
+ >::type return_type;
+
+
+private :
+
+ class summation
{
+ friend class by_triangles;
+
+ return_type sum;
+ public :
- /*!
- \brief Strategy functor for area calculation on point_xy points
- \details Calculates area using well-known triangulation algorithm
- \tparam PS point type of segments
- \par Concepts for PS:
- - specialized point_traits class
- */
- template<typename PS, typename CalculationType = void>
- class by_triangles
+ inline summation() : sum(return_type())
{
- public :
- // If user specified a calculation type, use that type,
- // whatever it is and whatever the point-type is.
- // Else, use the pointtype, but at least double
- typedef typename
- boost::mpl::if_c
- <
- boost::is_void<CalculationType>::type::value,
- typename select_most_precise
- <
- typename coordinate_type<PS>::type,
- double
- >::type,
- CalculationType
- >::type return_type;
-
-
- private :
-
- struct summation
- {
- return_type sum;
-
- inline summation() : sum(return_type())
- {
- // Currently only 2D areas are supported
- assert_dimension<PS, 2>();
- }
- inline return_type area() const
- {
- return_type result = sum;
- result *= 0.5;
- return result;
- }
- };
-
- public :
- typedef summation state_type;
-
- inline bool operator()(segment<const PS> const& s,
- state_type& state) const
- {
- // SUM += x2 * y1 - x1 * y2;
- state.sum += get<1, 0>(s) * get<0, 1>(s)
- - get<0, 0>(s) * get<1, 1>(s);
- return true;
- }
+ // Strategy supports only 2D areas
+ assert_dimension<PointOfSegment, 2>();
+ }
+ inline return_type area() const
+ {
+ return_type result = sum;
+ result *= 0.5;
+ return result;
+ }
+ };
+
+public :
+ typedef summation state_type;
+ typedef PointOfSegment segment_point_type;
+
+ inline state_type init() const
+ {
+ return summation();
+ }
+
+ static inline void apply(PointOfSegment const& p1,
+ PointOfSegment const& p2,
+ summation& state)
+ {
+ // SUM += x2 * y1 - x1 * y2;
+ state.sum += get<0>(p2) * get<1>(p1) - get<0>(p1) * get<1>(p2);
+ }
+
+ static inline return_type result(summation const& state)
+ {
+ return state.area();
+ }
- };
+};
- } // namespace area
-} // namespace strategy
+}} // namespace strategy::area
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-template <typename P>
-struct strategy_area<cartesian_tag, P>
+
+template <typename Point>
+struct strategy_area<cartesian_tag, Point>
{
- typedef strategy::area::by_triangles<P> type;
+ typedef strategy::area::by_triangles<Point> type;
};
+
#endif
} // namespace ggl
-#endif // GGL_STRATEGY_CARTESIAN_AREA_HPP
+#endif // GGL_STRATEGY_CARTESIAN_AREA_BY_TRIANGLES_HPP
Deleted: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_area.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_area.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
+++ (empty file)
@@ -1,102 +0,0 @@
-// Generic Geometry Library
-//
-// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
-// Copyright Bruno Lalande 2008, 2009
-// 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 GGL_STRATEGY_CARTESIAN_AREA_HPP
-#define GGL_STRATEGY_CARTESIAN_AREA_HPP
-
-
-#include <boost/mpl/if.hpp>
-#include <boost/type_traits.hpp>
-
-#include <ggl/geometries/point_xy.hpp>
-#include <ggl/geometries/segment.hpp>
-
-
-namespace ggl
-{
-namespace strategy
-{
- namespace area
- {
-
- /*!
- \brief Strategy functor for area calculation on point_xy points
- \details Calculates area using well-known triangulation algorithm
- \tparam PS point type of segments
- \par Concepts for PS:
- - specialized point_traits class
- */
- template<typename PS, typename CalculationType = void>
- class by_triangles
- {
- public :
- // If user specified a calculation type, use that type,
- // whatever it is and whatever the point-type is.
- // Else, use the pointtype, but at least double
- typedef typename
- boost::mpl::if_c
- <
- boost::is_void<CalculationType>::type::value,
- typename select_most_precise
- <
- typename coordinate_type<PS>::type,
- double
- >::type,
- CalculationType
- >::type return_type;
-
-
- private :
-
- struct summation
- {
- return_type sum;
-
- inline summation() : sum(return_type())
- {
- // Currently only 2D areas are supported
- assert_dimension<PS, 2>();
- }
- inline return_type area() const
- {
- return_type result = sum;
- result *= 0.5;
- return result;
- }
- };
-
- public :
- typedef summation state_type;
-
- inline bool operator()(segment<const PS> const& s,
- state_type& state) const
- {
- // SUM += x2 * y1 - x1 * y2;
- state.sum += get<1, 0>(s) * get<0, 1>(s)
- - get<0, 0>(s) * get<1, 1>(s);
- return true;
- }
-
- };
-
- } // namespace area
-} // namespace strategy
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-template <typename P>
-struct strategy_area<cartesian_tag, P>
-{
- typedef strategy::area::by_triangles<P> type;
-};
-#endif
-
-} // namespace ggl
-
-
-#endif // GGL_STRATEGY_CARTESIAN_AREA_HPP
Deleted: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_centroid.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_centroid.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
+++ (empty file)
@@ -1,292 +0,0 @@
-// Generic Geometry Library
-//
-// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
-// Copyright Bruno Lalande 2008, 2009
-// 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 GGL_STRATEGY_CARTESIAN_CENTROID_HPP
-#define GGL_STRATEGY_CARTESIAN_CENTROID_HPP
-
-
-#include <boost/mpl/if.hpp>
-#include <boost/numeric/conversion/cast.hpp>
-#include <boost/type_traits.hpp>
-
-#include <ggl/geometries/point_xy.hpp>
-#include <ggl/geometries/segment.hpp>
-
-#include <ggl/algorithms/assign.hpp>
-
-#include <ggl/util/select_coordinate_type.hpp>
-#include <ggl/util/copy.hpp>
-
-
-namespace ggl
-{
-
-namespace strategy
-{
- namespace centroid
- {
- /*!
- \brief Centroid calculation
- \details Geolib original version,
- \par Template parameters and concepts: see bashein_detmer
- \author Barend and Maarten, 1995/1996
- \author Revised for templatized library, Barend Gehrels, 2007
- \note The results are slightly different from Bashein/Detmer, so probably slightly wrong.
- */
-
- template<typename PC, typename PS = PC>
- class geolib1995
- {
- private :
- typedef typename select_most_precise
- <
- typename select_coordinate_type<PC, PS>::type,
- double
- >::type T;
-
- /*! subclass to keep state */
- struct sums
- {
- PC sum_ms, sum_m;
-
- sums()
- {
- assign_point(sum_m, T());
- assign_point(sum_ms, T());
- }
- void centroid(PC& point)
- {
- point = sum_ms;
-
- if (get<0>(sum_m) != 0 && get<1>(sum_m) != 0)
- {
- multiply_value(point, 0.5);
- divide_point(point, sum_m);
- }
- else
- {
- // exception?
- }
- }
- };
-
- public :
- typedef sums state_type;
- inline bool operator()(const segment<const PS>& s, state_type& state) const
- {
- /* Algorithm:
- For each segment:
- begin
- dx = x2 - x1;
- dy = y2 - y1;
- sx = x2 + x1;
- sy = y2 + y1;
- mx = dx * sy;
- my = sx * dy;
-
- sum_mx += mx;
- sum_my += my;
- sum_msx += mx * sx;
- sum_msy += my * sy;
- end;
- return POINT(0.5 * sum_msx / sum_mx, 0.5 * sum_msy / sum_my);
- */
-
- PS diff = s.second, sum = s.second;
- subtract_point(diff, s.first);
- add_point(sum, s.first);
-
- // We might create an arithmatic operation for this.
- PS m;
- get<0>(m) = get<0>(diff) * get<1>(sum);
- get<1>(m) = get<0>(sum) * get<1>(diff);
-
- add_point(state.sum_m, m);
- multiply_point(m, sum);
- add_point(state.sum_ms, m);
-
- return true;
- }
-
- };
-
-
- /*!
- \brief Centroid calculation using algorith Bashein / Detmer
- \details Calculates centroid using triangulation method published by Bashein / Detmer
- \tparam PC point type of centroid to calculate
- \tparam PS point type of segments, defaults to PC
- \par Concepts for PC and PS:
- - specialized point_traits class
- \author Adapted from "Centroid of a Polygon" by Gerard Bashein and Paul R. Detmer<em>,
- in "Graphics Gems IV", Academic Press, 1994</em>
- \par Research notes
- The algorithm gives the same results as Oracle and PostGIS but differs from MySQL
- (tried 5.0.21 / 5.0.45 / 5.0.51a / 5.1.23).
-
- Without holes:
- - this: POINT(4.06923363095238 1.65055803571429)
- - geolib: POINT(4.07254 1.66819)
- - MySQL: POINT(3.6636363636364 1.6272727272727)'
- - PostGIS: POINT(4.06923363095238 1.65055803571429)
- - Oracle: 4.06923363095238 1.65055803571429
- - SQL Server: POINT(4.06923362245959 1.65055804168294)
-
- Statements:
- - \b MySQL/PostGIS: select AsText(Centroid(GeomFromText('POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2
- ,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))')))
- - \b Oracle: select sdo_geom.sdo_centroid(sdo_geometry(2003, null, null,
- sdo_elem_info_array(1, 1003, 1), sdo_ordinate_array(2,1.3,2.4,1.7,2.8,1.8
- ,3.4,1.2,3.7,1.6,3.4,2,4.1,3,5.3,2.6,5.4,1.2,4.9,0.8,2.9,0.7,2,1.3))
- , mdsys.sdo_dim_array(mdsys.sdo_dim_element('x',0,10,.00000005)
- ,mdsys.sdo_dim_element('y',0,10,.00000005)))
- from dual
- - \b SQL Server 2008: select geometry::STGeomFromText('POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2
- ,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))',0)
- .STCentroid()
- .STAsText()
-
- With holes:
- - this: POINT(4.04663 1.6349)
- - geolib: POINT(4.04675 1.65735)
- - MySQL: POINT(3.6090580503834 1.607573932092)
- - PostGIS: POINT(4.0466265060241 1.63489959839357)
- - Oracle: 4.0466265060241 1.63489959839357
- - SQL Server: POINT(4.0466264962959677 1.6348996057331333)
-
- Statements:
- - \b MySQL/PostGIS: select AsText(Centroid(GeomFromText('POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2
- ,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)
- ,(4 2,4.2 1.4,4.8 1.9,4.4 2.2,4 2))')));
- - \b Oracle: select sdo_geom.sdo_centroid(sdo_geometry(2003, null, null
- , sdo_elem_info_array(1, 1003, 1, 25, 2003, 1)
- , sdo_ordinate_array(2,1.3,2.4,1.7,2.8,1.8,3.4,1.2,3.7,1.6,3.4,2,4.1,3,5.3
- ,2.6,5.4,1.2,4.9,0.8,2.9,0.7,2,1.3,4,2, 4.2,1.4, 4.8,1.9, 4.4,2.2, 4,2))
- , mdsys.sdo_dim_array(mdsys.sdo_dim_element('x',0,10,.00000005)
- ,mdsys.sdo_dim_element('y',0,10,.00000005)))
- from dual
- */
- template
- <
- typename CentroidPointType,
- typename SegmentPointType = CentroidPointType,
- typename CalculationType = void
- >
- class bashein_detmer
- {
- private :
- // If user specified a calculation type, use that type,
- // whatever it is and whatever the point-type(s) are.
- // Else, use the most appropriate coordinate type
- // of the two points, but at least double
- typedef typename
- boost::mpl::if_c
- <
- boost::is_void<CalculationType>::type::value,
- typename select_most_precise
- <
- typename select_coordinate_type
- <
- CentroidPointType,
- SegmentPointType
- >::type,
- double
- >::type,
- CalculationType
- >::type calc_type;
-
- /*! subclass to keep state */
- struct sums
- {
- calc_type sum_a2;
- calc_type sum_x;
- calc_type sum_y;
- inline sums()
- : sum_a2(calc_type())
- , sum_x(calc_type())
- , sum_y(calc_type())
- {
- typedef calc_type ct;
- //std::cout << "-> calctype: " << typeid(ct).name()
- // << " size: " << sizeof(ct)
- // << " init: " << sum_a2
- // << std::endl;
- }
-
- inline void centroid(CentroidPointType& point)
- {
- if (sum_a2 != 0)
- {
- calc_type const v3 = 3;
- calc_type const a3 = v3 * sum_a2;
-
- typedef typename ggl::coordinate_type
- <
- CentroidPointType
- >::type coordinate_type;
-
- set<0>(point,
- boost::numeric_cast<coordinate_type>(sum_x / a3));
- set<1>(point,
- boost::numeric_cast<coordinate_type>(sum_y / a3));
- }
- else
- {
- // exception?
- }
- }
-
- };
-
- public :
- typedef sums state_type;
-
- inline bool operator()(segment<const SegmentPointType> const& s, state_type& state) const
- {
- /* Algorithm:
- For each segment:
- begin
- ai = x1 * y2 - x2 * y1;
- sum_a2 += ai;
- sum_x += ai * (x1 + x2);
- sum_y += ai * (y1 + y2);
- end
- return POINT(sum_x / (3 * sum_a2), sum_y / (3 * sum_a2) )
- */
-
- // Get coordinates and promote them to calc_type
- calc_type const x1 = boost::numeric_cast<calc_type>(get<0, 0>(s));
- calc_type const y1 = boost::numeric_cast<calc_type>(get<0, 1>(s));
- calc_type const x2 = boost::numeric_cast<calc_type>(get<1, 0>(s));
- calc_type const y2 = boost::numeric_cast<calc_type>(get<1, 1>(s));
- calc_type const ai = x1 * y2 - x2 * y1;
- state.sum_a2 += ai;
- state.sum_x += ai * (x1 + x2);
- state.sum_y += ai * (y1 + y2);
-
- return true;
- }
-
- };
- } // namespace centroid
-
-} // namespace strategy
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-template <typename P, typename PS>
-struct strategy_centroid<cartesian_tag, P, PS>
-{
- typedef strategy::centroid::bashein_detmer<P, PS> type;
-};
-#endif
-
-} // namespace ggl
-
-
-#endif // GGL_STRATEGY_CARTESIAN_CENTROID_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_envelope.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_envelope.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_envelope.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,9 +11,6 @@
-#include <ggl/geometries/point_xy.hpp>
-#include <ggl/geometries/segment.hpp>
-
#include <ggl/algorithms/combine.hpp>
Modified: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_intersect.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_intersect.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_intersect.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,8 +12,9 @@
#include <algorithm>
#include <ggl/core/exception.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/core/concepts/segment_concept.hpp>
+
+#include <ggl/geometries/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/segment_concept.hpp>
#include <ggl/util/math.hpp>
#include <ggl/util/select_coordinate_type.hpp>
Modified: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_side.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_side.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_side.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,7 +11,6 @@
-#include <ggl/geometries/point_xy.hpp>
#include <ggl/geometries/segment.hpp>
#include <ggl/util/select_coordinate_type.hpp>
@@ -28,27 +27,34 @@
template <typename P, typename PS>
struct xy_side
{
+ typedef typename select_coordinate_type<P, PS>::type coordinate_type;
// Check at which side of a segment a point lies:
// left of segment (> 0), right of segment (< 0), on segment (0)
// In fact this is twice the area of a triangle
- static inline typename select_coordinate_type<P, PS>::type
- side(const segment<const PS>& s, const P& p)
+ static inline coordinate_type
+ side(segment<const PS> const& s, P const& p)
{
- typedef typename select_coordinate_type<P, PS>::type T;
+ coordinate_type const x = get<0>(p);
+ coordinate_type const y = get<1>(p);
+
+ coordinate_type const sx1 = get<0, 0>(s);
+ coordinate_type const sy1 = get<0, 1>(s);
+ coordinate_type const sx2 = get<1, 0>(s);
+ coordinate_type const sy2 = get<1, 1>(s);
// Todo: might be changed to subtract_point
- T dx = get<1, 0>(s) - get<0, 0>(s);
- T dy = get<1, 1>(s) - get<0, 1>(s);
- T dpx = get<0>(p) - get<0, 0>(s);
- T dpy = get<1>(p) - get<0, 1>(s);
+ coordinate_type dx = sx2 - sx1;
+ coordinate_type dy = sy2 - sy1;
+ coordinate_type dpx = x - sx1;
+ coordinate_type dpy = y - sy1;
return dx * dpy - dy * dpx;
}
- static inline int side(const P& p0, const P& p1, const P& p2)
+ static inline int side(PS const& p0, PS const& p1, P const& p2)
{
- typename coordinate_type<P>::type s = side(segment<const P>(p0, p1), p2);
+ coordinate_type s = side(segment<const PS>(p0, p1), p2);
return s > 0 ? 1 : s < 0 ? -1 : 0;
}
};
Deleted: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_within.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_within.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
+++ (empty file)
@@ -1,100 +0,0 @@
-// Generic Geometry Library
-//
-// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
-// Copyright Bruno Lalande 2008, 2009
-// 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 GGL_STRATEGY_CARTESIAN_WITHIN_HPP
-#define GGL_STRATEGY_CARTESIAN_WITHIN_HPP
-
-
-
-#include <ggl/geometries/segment.hpp>
-
-
-
-namespace ggl
-{
-namespace strategy
-{
- namespace within
- {
- /*!
- \brief Within detection using cross counting
-
- \author adapted from Randolph Franklin algorithm
- \author Barend and Maarten, 1995
- \author Revised for templatized library, Barend Gehrels, 2007
- \return true if point is in ring, works for closed rings in both directions
- \note Does NOT work correctly for point ON border
- */
-
- template<typename P, typename PS = P>
- struct franklin
- {
- private :
- /*! subclass to keep state */
- struct crossings
- {
- P p;
- bool crosses;
- explicit crossings(const P& ap)
- : p(ap)
- , crosses(false)
- {}
- bool within() const
- {
- return crosses;
- }
- };
-
- public :
-
- typedef crossings state_type;
-
- inline bool operator()(const segment<const PS>& s, state_type& state) const
- {
- /* Algorithm:
- if (
- ( (y2 <= py && py < y1)
- || (y1 <= py && py < y2) )
- && (px < (x1 - x2)
- * (py - y2)
- / (y1 - y2) + x2)
- )
- crosses = ! crosses
- */
-
-
- if (
- ((get<1, 1>(s) <= get<1>(state.p) && get<1>(state.p) < get<0, 1>(s))
- || (get<0, 1>(s) <= get<1>(state.p) && get<1>(state.p) < get<1, 1>(s)))
- && (get<0>(state.p) < (get<0, 0>(s) - get<1, 0>(s))
- * (get<1>(state.p) - get<1, 1>(s))
- / (get<0, 1>(s) - get<1, 1>(s)) + get<1, 0>(s))
- )
- {
- state.crosses = ! state.crosses;
- }
- return true;
- }
- };
-
-
-
- } // namespace within
-
-
-
-} // namespace strategy
-
-
-
-
-
-} // namespace ggl
-
-
-#endif // GGL_STRATEGY_CARTESIAN_WITHIN_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/centroid_bashein_detmer.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/centroid_bashein_detmer.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,214 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
+// Copyright Bruno Lalande 2008, 2009
+// 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 GGL_STRATEGY_CARTESIAN_CENTROID_BASHEIN_DETMER_HPP
+#define GGL_STRATEGY_CARTESIAN_CENTROID_BASHEIN_DETMER_HPP
+
+
+#include <boost/mpl/if.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/type_traits.hpp>
+
+#include <ggl/util/select_coordinate_type.hpp>
+#include <ggl/util/copy.hpp>
+
+
+namespace ggl
+{
+
+namespace strategy { namespace centroid {
+
+
+
+/*!
+ \brief Centroid calculation using algorith Bashein / Detmer
+ \details Calculates centroid using triangulation method published by
+ Bashein / Detmer
+ \tparam Point point type of centroid to calculate
+ \tparam PointOfSegment point type of segments, defaults to Point
+ \par Concepts for Point and PointOfSegment:
+ - specialized point_traits class
+ \author Adapted from "Centroid of a Polygon" by
+ Gerard Bashein and Paul R. Detmer<em>,
+ in "Graphics Gems IV", Academic Press, 1994</em>
+ \par Research notes
+ The algorithm gives the same results as Oracle and PostGIS but
+ differs from MySQL
+ (tried 5.0.21 / 5.0.45 / 5.0.51a / 5.1.23).
+
+ Without holes:
+ - this: POINT(4.06923363095238 1.65055803571429)
+ - geolib: POINT(4.07254 1.66819)
+ - MySQL: POINT(3.6636363636364 1.6272727272727)'
+ - PostGIS: POINT(4.06923363095238 1.65055803571429)
+ - Oracle: 4.06923363095238 1.65055803571429
+ - SQL Server: POINT(4.06923362245959 1.65055804168294)
+
+ Statements:
+ - \b MySQL/PostGIS: select AsText(Centroid(GeomFromText(
+ 'POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6
+ ,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))')))
+ - \b Oracle: select sdo_geom.sdo_centroid(sdo_geometry(2003, null, null,
+ sdo_elem_info_array(1, 1003, 1), sdo_ordinate_array(
+ 2,1.3,2.4,1.7,2.8,1.8,3.4,1.2,3.7,1.6,3.4,2,4.1,3,5.3,2.6
+ ,5.4,1.2,4.9,0.8,2.9,0.7,2,1.3))
+ , mdsys.sdo_dim_array(mdsys.sdo_dim_element('x',0,10,.00000005)
+ ,mdsys.sdo_dim_element('y',0,10,.00000005)))
+ from dual
+ - \b SQL Server 2008: select geometry::STGeomFromText(
+ 'POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2,3.7 1.6,3.4 2,4.1 3,5.3 2.6
+ ,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3))',0)
+ .STCentroid()
+ .STAsText()
+
+ With holes:
+ - this: POINT(4.04663 1.6349)
+ - geolib: POINT(4.04675 1.65735)
+ - MySQL: POINT(3.6090580503834 1.607573932092)
+ - PostGIS: POINT(4.0466265060241 1.63489959839357)
+ - Oracle: 4.0466265060241 1.63489959839357
+ - SQL Server: POINT(4.0466264962959677 1.6348996057331333)
+
+ Statements:
+ - \b MySQL/PostGIS: select AsText(Centroid(GeomFromText(
+ 'POLYGON((2 1.3,2.4 1.7,2.8 1.8,3.4 1.2
+ ,3.7 1.6,3.4 2,4.1 3,5.3 2.6,5.4 1.2,4.9 0.8,2.9 0.7,2 1.3)
+ ,(4 2,4.2 1.4,4.8 1.9,4.4 2.2,4 2))')));
+ - \b Oracle: select sdo_geom.sdo_centroid(sdo_geometry(2003, null, null
+ , sdo_elem_info_array(1, 1003, 1, 25, 2003, 1)
+ , sdo_ordinate_array(2,1.3,2.4,1.7,2.8,1.8,3.4,1.2,3.7,1.6,3.4,
+ 2,4.1,3,5.3,2.6,5.4,1.2,4.9,0.8,2.9,0.7,2,1.3,4,2, 4.2,1.4,
+ 4.8,1.9, 4.4,2.2, 4,2))
+ , mdsys.sdo_dim_array(mdsys.sdo_dim_element('x',0,10,.00000005)
+ ,mdsys.sdo_dim_element('y',0,10,.00000005)))
+ from dual
+ */
+template
+<
+ typename Point,
+ typename PointOfSegment = Point,
+ typename CalculationType = void
+>
+class bashein_detmer
+{
+private :
+ // If user specified a calculation type, use that type,
+ // whatever it is and whatever the point-type(s) are.
+ // Else, use the most appropriate coordinate type
+ // of the two points, but at least double
+ typedef typename
+ boost::mpl::if_c
+ <
+ boost::is_void<CalculationType>::type::value,
+ typename select_most_precise
+ <
+ typename select_coordinate_type
+ <
+ Point,
+ PointOfSegment
+ >::type,
+ double
+ >::type,
+ CalculationType
+ >::type calculation_type;
+
+ /*! subclass to keep state */
+ class sums
+ {
+ friend class bashein_detmer;
+ int count;
+ calculation_type sum_a2;
+ calculation_type sum_x;
+ calculation_type sum_y;
+
+ public :
+ inline sums()
+ : count(0)
+ , sum_a2(calculation_type())
+ , sum_x(calculation_type())
+ , sum_y(calculation_type())
+ {
+ typedef calculation_type ct;
+ //std::cout << "-> calctype: " << typeid(ct).name()
+ // << " size: " << sizeof(ct)
+ // << " init: " << sum_a2
+ // << std::endl;
+ }
+ };
+
+public :
+ typedef sums state_type;
+ typedef Point point_type;
+ typedef PointOfSegment segment_point_type;
+
+ static inline void apply(PointOfSegment const& p1,
+ PointOfSegment const& p2, sums& state)
+ {
+ /* Algorithm:
+ For each segment:
+ begin
+ ai = x1 * y2 - x2 * y1;
+ sum_a2 += ai;
+ sum_x += ai * (x1 + x2);
+ sum_y += ai * (y1 + y2);
+ end
+ return POINT(sum_x / (3 * sum_a2), sum_y / (3 * sum_a2) )
+ */
+
+ // Get coordinates and promote them to calculation_type
+ calculation_type const x1 = boost::numeric_cast<calculation_type>(get<0>(p1));
+ calculation_type const y1 = boost::numeric_cast<calculation_type>(get<1>(p1));
+ calculation_type const x2 = boost::numeric_cast<calculation_type>(get<0>(p2));
+ calculation_type const y2 = boost::numeric_cast<calculation_type>(get<1>(p2));
+ calculation_type const ai = x1 * y2 - x2 * y1;
+ state.count++;
+ state.sum_a2 += ai;
+ state.sum_x += ai * (x1 + x2);
+ state.sum_y += ai * (y1 + y2);
+ }
+
+ static inline bool result(sums const& state, Point& centroid)
+ {
+ if (state.count > 0 && state.sum_a2 != 0)
+ {
+ calculation_type const v3 = 3;
+ calculation_type const a3 = v3 * state.sum_a2;
+
+ typedef typename ggl::coordinate_type
+ <
+ Point
+ >::type coordinate_type;
+
+ set<0>(centroid,
+ boost::numeric_cast<coordinate_type>(state.sum_x / a3));
+ set<1>(centroid,
+ boost::numeric_cast<coordinate_type>(state.sum_y / a3));
+ return true;
+ }
+
+ return false;
+ }
+
+};
+
+
+}} // namespace strategy::centroid
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+template <typename Point, typename PointOfSegment>
+struct strategy_centroid<cartesian_tag, Point, PointOfSegment>
+{
+ typedef strategy::centroid::bashein_detmer<Point, PointOfSegment> type;
+};
+#endif
+
+} // namespace ggl
+
+
+#endif // GGL_STRATEGY_CARTESIAN_CENTROID_BASHEIN_DETMER_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/point_in_poly_crossings_multiply.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/point_in_poly_crossings_multiply.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,202 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 2009, Geodan, Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef GGL_STRATEGY_CARTESIAN_POINT_IN_POLY_CROSSINGS_MULTIPLY_HPP
+#define GGL_STRATEGY_CARTESIAN_POINT_IN_POLY_CROSSINGS_MULTIPLY_HPP
+
+
+#include <ggl/core/coordinate_type.hpp>
+#include <ggl/util/select_calculation_type.hpp>
+
+
+namespace ggl
+
+{
+namespace strategy { namespace within {
+
+/*!
+ \brief Within detection using cross counting,
+ \see http://tog.acm.org/resources/GraphicsGems/gemsiv/ptpoly_haines/ptinpoly.c
+ \note Does NOT work correctly for point ON border
+ */
+
+template
+<
+ typename Point,
+ typename PointOfSegment = Point,
+ typename CalculationType = void
+>
+class crossings_multiply
+{
+ typedef typename select_calculation_type
+ <
+ Point,
+ PointOfSegment,
+ CalculationType
+ >::type calculation_type;
+
+ class flags
+ {
+ bool inside_flag;
+ bool first;
+ bool yflag0;
+
+ public :
+
+ friend class crossings_multiply;
+
+ inline flags()
+ : inside_flag(false)
+ , first(true)
+ , yflag0(false)
+ {}
+ };
+
+public :
+
+ typedef Point point_type;
+ typedef PointOfSegment segment_point_type;
+ typedef flags state_type;
+
+ static inline bool apply(Point const& point,
+ PointOfSegment const& seg1, PointOfSegment const& seg2,
+ flags& state)
+ {
+ calculation_type const tx = get<0>(point);
+ calculation_type const ty = get<1>(point);
+ calculation_type const x0 = get<0>(seg1);
+ calculation_type const y0 = get<1>(seg1);
+ calculation_type const x1 = get<0>(seg2);
+ calculation_type const y1 = get<1>(seg2);
+
+ if (state.first)
+ {
+ state.first = false;
+ state.yflag0 = y0 >= ty;
+ }
+
+
+ bool yflag1 = y1 >= ty;
+ if (state.yflag0 != yflag1)
+ {
+ if ( ((y1-ty) * (x0-x1) >= (x1-tx) * (y0-y1)) == yflag1 )
+ {
+ state.inside_flag = ! state.inside_flag;
+ }
+ }
+ state.yflag0 = yflag1;
+ return true;
+ }
+
+ static inline bool result(flags const& state)
+ {
+ return state.inside_flag;
+ }
+};
+
+
+
+}} // namespace strategy::within
+
+
+} // namespace ggl
+
+
+#ifdef ORIGINAL_CODE
+
+See http://tog.acm.org/resources/GraphicsGems/gemsiv/ptpoly_haines/ptinpoly.c
+
+/* ======= Crossings Multiply algorithm =================================== */
+
+/*
+ * This version is usually somewhat faster than the original published in
+ * Graphics Gems IV; by turning the division for testing the X axis crossing
+ * into a tricky multiplication test this part of the test became faster,
+ * which had the additional effect of making the test for "both to left or
+ * both to right" a bit slower for triangles than simply computing the
+ * intersection each time. The main increase is in triangle testing speed,
+ * which was about 15% faster; all other polygon complexities were pretty much
+ * the same as before. On machines where division is very expensive (not the
+ * case on the HP 9000 series on which I tested) this test should be much
+ * faster overall than the old code. Your mileage may (in fact, will) vary,
+ * depending on the machine and the test data, but in general I believe this
+ * code is both shorter and faster. This test was inspired by unpublished
+ * Graphics Gems submitted by Joseph Samosky and Mark Haigh-Hutchinson.
+ * Related work by Samosky is in:
+ *
+ * Samosky, Joseph, "SectionView: A system for interactively specifying and
+ * visualizing sections through three-dimensional medical image data",
+ * M.S. Thesis, Department of Electrical Engineering and Computer Science,
+ * Massachusetts Institute of Technology, 1993.
+ *
+ */
+
+/* Shoot a test ray along +X axis. The strategy is to compare vertex Y values
+ * to the testing point's Y and quickly discard edges which are entirely to one
+ * side of the test ray. Note that CONVEX and WINDING code can be added as
+ * for the CrossingsTest() code; it is left out here for clarity.
+ *
+ * Input 2D polygon _pgon_ with _numverts_ number of vertices and test point
+ * _point_, returns 1 if inside, 0 if outside.
+ */
+int CrossingsMultiplyTest( pgon, numverts, point )
+double pgon[][2] ;
+int numverts ;
+double point[2] ;
+{
+register int j, yflag0, yflag1, inside_flag ;
+register double ty, tx, *vtx0, *vtx1 ;
+
+ tx = point[X] ;
+ ty = point[Y] ;
+
+ vtx0 = pgon[numverts-1] ;
+ /* get test bit for above/below X axis */
+ yflag0 = ( vtx0[Y] >= ty ) ;
+ vtx1 = pgon[0] ;
+
+ inside_flag = 0 ;
+ for ( j = numverts+1 ; --j ; ) {
+
+ yflag1 = ( vtx1[Y] >= ty ) ;
+ /* Check if endpoints straddle (are on opposite sides) of X axis
+ * (i.e. the Y's differ); if so, +X ray could intersect this edge.
+ * The old test also checked whether the endpoints are both to the
+ * right or to the left of the test point. However, given the faster
+ * intersection point computation used below, this test was found to
+ * be a break-even proposition for most polygons and a loser for
+ * triangles (where 50% or more of the edges which survive this test
+ * will cross quadrants and so have to have the X intersection computed
+ * anyway). I credit Joseph Samosky with inspiring me to try dropping
+ * the "both left or both right" part of my code.
+ */
+ if ( yflag0 != yflag1 ) {
+ /* Check intersection of pgon segment with +X ray.
+ * Note if >= point's X; if so, the ray hits it.
+ * The division operation is avoided for the ">=" test by checking
+ * the sign of the first vertex wrto the test point; idea inspired
+ * by Joseph Samosky's and Mark Haigh-Hutchinson's different
+ * polygon inclusion tests.
+ */
+ if ( ((vtx1[Y]-ty) * (vtx0[X]-vtx1[X]) >=
+ (vtx1[X]-tx) * (vtx0[Y]-vtx1[Y])) == yflag1 ) {
+ inside_flag = !inside_flag ;
+ }
+ }
+
+ /* Move to the next pair of vertices, retaining info as possible. */
+ yflag0 = yflag1 ;
+ vtx0 = vtx1 ;
+ vtx1 += 2 ;
+ }
+
+ return( inside_flag ) ;
+}
+#endif
+
+
+#endif // GGL_STRATEGY_CARTESIAN_POINT_IN_POLY_CROSSINGS_MULTIPLY_HPP
Copied: sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/point_in_poly_franklin.hpp (from r56825, /sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_within.hpp)
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_within.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/point_in_poly_franklin.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -6,89 +6,93 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_STRATEGY_CARTESIAN_WITHIN_HPP
-#define GGL_STRATEGY_CARTESIAN_WITHIN_HPP
+#ifndef GGL_STRATEGY_CARTESIAN_POINT_IN_POLY_FRANKLIN_HPP
+#define GGL_STRATEGY_CARTESIAN_POINT_IN_POLY_FRANKLIN_HPP
-
-#include <ggl/geometries/segment.hpp>
-
+#include <ggl/core/coordinate_type.hpp>
+#include <ggl/util/select_calculation_type.hpp>
namespace ggl
+
{
-namespace strategy
-{
- namespace within
- {
- /*!
- \brief Within detection using cross counting
+namespace strategy { namespace within {
+
+/*!
+ \brief Within detection using cross counting
- \author adapted from Randolph Franklin algorithm
- \author Barend and Maarten, 1995
- \author Revised for templatized library, Barend Gehrels, 2007
- \return true if point is in ring, works for closed rings in both directions
- \note Does NOT work correctly for point ON border
- */
+ \author adapted from Randolph Franklin algorithm
+ \author Barend and Maarten, 1995
+ \author Revised for templatized library, Barend Gehrels, 2007
+ \return true if point is in ring, works for closed rings in both directions
+ \note Does NOT work correctly for point ON border
+ */
+
+template
+<
+ typename Point,
+ typename PointOfSegment = Point,
+ typename CalculationType = void
+>
+class franklin
+{
+ typedef typename select_calculation_type
+ <
+ Point,
+ PointOfSegment,
+ CalculationType
+ >::type calculation_type;
- template<typename P, typename PS = P>
- struct franklin
+ /*! subclass to keep state */
+ class crossings
{
- private :
- /*! subclass to keep state */
- struct crossings
- {
- P p;
- bool crosses;
- explicit crossings(const P& ap)
- : p(ap)
- , crosses(false)
- {}
- bool within() const
- {
- return crosses;
- }
- };
-
- public :
-
- typedef crossings state_type;
-
- inline bool operator()(const segment<const PS>& s, state_type& state) const
- {
- /* Algorithm:
- if (
- ( (y2 <= py && py < y1)
- || (y1 <= py && py < y2) )
- && (px < (x1 - x2)
- * (py - y2)
- / (y1 - y2) + x2)
- )
- crosses = ! crosses
- */
-
-
- if (
- ((get<1, 1>(s) <= get<1>(state.p) && get<1>(state.p) < get<0, 1>(s))
- || (get<0, 1>(s) <= get<1>(state.p) && get<1>(state.p) < get<1, 1>(s)))
- && (get<0>(state.p) < (get<0, 0>(s) - get<1, 0>(s))
- * (get<1>(state.p) - get<1, 1>(s))
- / (get<0, 1>(s) - get<1, 1>(s)) + get<1, 0>(s))
- )
- {
- state.crosses = ! state.crosses;
- }
- return true;
- }
+ bool crosses;
+
+ public :
+
+ friend class franklin;
+ inline crossings()
+ : crosses(false)
+ {}
};
+public :
+ typedef Point point_type;
+ typedef PointOfSegment segment_point_type;
+ typedef crossings state_type;
+
+ static inline bool apply(Point const& point,
+ PointOfSegment const& seg1, PointOfSegment const& seg2,
+ crossings& state)
+ {
+ calculation_type const& px = get<0>(point);
+ calculation_type const& py = get<1>(point);
+ calculation_type const& x1 = get<0>(seg1);
+ calculation_type const& y1 = get<1>(seg1);
+ calculation_type const& x2 = get<0>(seg2);
+ calculation_type const& y2 = get<1>(seg2);
+
+ if (
+ ( (y2 <= py && py < y1) || (y1 <= py && py < y2) )
+ && (px < (x1 - x2) * (py - y2) / (y1 - y2) + x2)
+ )
+ {
+ state.crosses = ! state.crosses;
+ }
+ return true;
+ }
- } // namespace within
+ static inline bool result(crossings const& state)
+ {
+ return state.crosses;
+ }
+};
-} // namespace strategy
+}} // namespace strategy::within
@@ -97,4 +101,4 @@
} // namespace ggl
-#endif // GGL_STRATEGY_CARTESIAN_WITHIN_HPP
+#endif // GGL_STRATEGY_CARTESIAN_POINT_IN_POLY_FRANKLIN_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/area_concept.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/area_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,66 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_STRATEGIES_CONCEPTS_AREA_CONCEPT_HPP
+#define GGL_STRATEGIES_CONCEPTS_AREA_CONCEPT_HPP
+
+
+
+#include <boost/concept_check.hpp>
+
+
+namespace ggl { namespace concept {
+
+
+/*!
+ \brief Checks strategy for area
+ \ingroup concepts
+*/
+template <typename Strategy>
+class AreaStrategy
+{
+
+ // 1) must define state_type,
+ typedef typename Strategy::state_type state_type;
+
+ // 2) must define return_type,
+ typedef typename Strategy::return_type return_type;
+
+ // 3) must define point_type, of polygon (segments)
+ typedef typename Strategy::segment_point_type spoint_type;
+
+ struct check_methods
+ {
+ static void apply()
+ {
+ Strategy const* st;
+
+ // 4) must implement an init-method
+ state_type s = st->init();
+
+ // 5) must implement a static method apply with the following signature
+ spoint_type *sp;
+ Strategy::apply(*sp, *sp, s);
+
+ // 6) must implement a static method result with the following signature
+ return_type r = Strategy::result(s);
+ boost::ignore_unused_variable_warning(r);
+ }
+ };
+
+public :
+ BOOST_CONCEPT_USAGE(AreaStrategy)
+ {
+ check_methods::apply();
+ }
+};
+
+
+
+}} // namespace ggl::concept
+
+#endif // GGL_STRATEGIES_CONCEPTS_AREA_CONCEPT_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/centroid_concept.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/centroid_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,66 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP
+#define GGL_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP
+
+
+
+#include <boost/concept_check.hpp>
+
+
+namespace ggl { namespace concept {
+
+
+/*!
+ \brief Checks strategy for area
+ \ingroup concepts
+*/
+template <typename Strategy>
+class CentroidStrategy
+{
+
+ // 1) must define state_type,
+ typedef typename Strategy::state_type state_type;
+
+ // 2) must define point_type,
+ typedef typename Strategy::point_type point_type;
+
+ // 3) must define point_type, of polygon (segments)
+ typedef typename Strategy::segment_point_type spoint_type;
+
+ struct check_methods
+ {
+ static void apply()
+ {
+ state_type *s;
+
+ // 4) must implement a static method apply,
+ // getting two segment-points
+ spoint_type *sp;
+ Strategy::apply(*sp, *sp, *s);
+
+ // 5) must implement a static method result
+ // getting the centroid
+ point_type *c;
+ bool r = Strategy::result(*s, *c);
+ boost::ignore_unused_variable_warning(r);
+ }
+ };
+
+public :
+ BOOST_CONCEPT_USAGE(CentroidStrategy)
+ {
+ check_methods::apply();
+ }
+};
+
+
+
+}} // namespace ggl::concept
+
+#endif // GGL_STRATEGIES_CONCEPTS_CENTROID_CONCEPT_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/distance_concept.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/distance_concept.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/distance_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -13,7 +13,7 @@
#include <boost/concept_check.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
#include <ggl/geometries/segment.hpp>
Added: sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/within_concept.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/concepts/within_concept.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,59 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. 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 GGL_STRATEGIES_CONCEPTS_WITHIN_CONCEPT_HPP
+#define GGL_STRATEGIES_CONCEPTS_WITHIN_CONCEPT_HPP
+
+
+
+#include <boost/concept_check.hpp>
+
+
+namespace ggl { namespace concept {
+
+
+/*!
+ \brief Checks strategy for within (point-in-polygon)
+ \ingroup concepts
+*/
+template <typename Strategy>
+class WithinStrategy
+{
+
+ // 1) must define state_type,
+ typedef typename Strategy::state_type state_type;
+
+ // 2) must define point_type (of "point" in poly)
+ typedef typename Strategy::point_type point_type;
+
+ // 3) must define point_type, of polygon (segments)
+ typedef typename Strategy::segment_point_type spoint_type;
+
+ // 4) must implement a static method apply with the following signature
+ typedef bool (*ApplyType)(point_type const&,
+ spoint_type const&, spoint_type const&,
+ state_type &);
+
+ // 5) must implement a static method result with the following signature
+ typedef bool (*ResultType)(state_type const&) ;
+
+public :
+ BOOST_CONCEPT_USAGE(WithinStrategy)
+ {
+ ApplyType a = &Strategy::apply;
+ ResultType r = &Strategy::result;
+
+ boost::ignore_unused_variable_warning(a);
+ boost::ignore_unused_variable_warning(r);
+ }
+};
+
+
+
+}} // namespace ggl::concept
+
+#endif // GGL_STRATEGIES_CONCEPTS_WITHIN_CONCEPT_HPP
Copied: sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/area_huiller.hpp (from r57036, /sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/sph_area.hpp)
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/sph_area.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/area_huiller.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -6,162 +6,154 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_STRATEGIES_SPHERICAL_SPH_AREA_HPP
-#define GGL_STRATEGIES_SPHERICAL_SPH_AREA_HPP
+#ifndef GGL_STRATEGIES_SPHERICAL_AREA_HUILLER_HPP
+#define GGL_STRATEGIES_SPHERICAL_AREA_HUILLER_HPP
+
-#include <ggl/geometries/segment.hpp>
#include <ggl/strategies/spherical/distance_haversine.hpp>
-#include <ggl/strategies/strategy_transform.hpp>
-#include <ggl/util/get_cs_as_radian.hpp>
+#include <ggl/core/radian_access.hpp>
+
namespace ggl
{
-namespace strategy
+
+namespace strategy { namespace area {
+
+
+
+/*!
+ \brief Area calculation by spherical excess / Huiller's formula
+ \tparam P type of points of rings/polygons
+ \author Barend Gehrels. Adapted from:
+ - http://www.soe.ucsc.edu/~pang/160/f98/Gems/GemsIV/sph_poly.c
+ - http://williams.best.vwh.net/avform.htm
+ \note The version in Gems didn't account for polygons crossing the 180 meridian.
+ \note This version works for convex and non-convex polygons, for 180 meridian
+ crossing polygons and for polygons with holes. However, some cases (especially
+ 180 meridian cases) must still be checked.
+ \note The version which sums angles, which is often seen, doesn't handle non-convex
+ polygons correctly.
+ \note The version which sums longitudes, see
+ http://trs-new.jpl.nasa.gov/dspace/bitstream/2014/40409/1/07-03.pdf, is simple
+ and works well in most cases but not in 180 meridian crossing cases. This probably
+ could be solved.
+*/
+template
+<
+ typename PointOfSegment,
+ typename CalculationType = void
+>
+class huiller
{
- namespace area
+protected :
+ struct excess_sum
{
+ double sum;
+ double radius;
+ // Distances are calculated on unit sphere here
+ strategy::distance::haversine<PointOfSegment, PointOfSegment>
+ distance_over_unit_sphere;
- /*!
- \brief Area calculation by spherical excess
- \tparam P type of points of rings/polygons
- \author Barend Gehrels. Adapted from:
- - http://www.soe.ucsc.edu/~pang/160/f98/Gems/GemsIV/sph_poly.c
- - http://williams.best.vwh.net/avform.htm
- \note The version in Gems didn't account for polygons crossing the 180 meridian.
- \note This version works for convex and non-convex polygons, for 180 meridian
- crossing polygons and for polygons with holes. However, some cases (especially
- 180 meridian cases) must still be checked.
- \note The version which sums angles, which is often seen, doesn't handle non-convex
- polygons correctly.
- \note The version which sums longitudes, see
- http://trs-new.jpl.nasa.gov/dspace/bitstream/2014/40409/1/07-03.pdf, is simple
- and works well in most cases but not in 180 meridian crossing cases. This probably
- could be solved.
- */
- template<typename P>
- class by_spherical_excess
+ inline excess_sum(double sphere_radius = 1.0)
+ : sum(0)
+ , radius(sphere_radius)
+ , distance_over_unit_sphere(1)
+ {}
+ inline double area() const
{
- private :
- struct excess_sum
- {
- double m_sum;
- double m_radius;
-
- // TODO: make this 1.0 & implement other construct to let user specify
- inline excess_sum(double radius = 1.0) //constants::average_earth_radius)
- : m_sum(0)
- , m_radius(radius)
- {}
- inline double area() const
- {
- return - m_sum * m_radius * m_radius;
- //constants::average_earth_radius * constants::average_earth_radius;
- }
- };
-
- // Distances are calculated on unit sphere here
- strategy::distance::haversine<P, P> m_unit_sphere;
- double m_radius;
-
- public :
- typedef double return_type;
- typedef excess_sum state_type;
-
- by_spherical_excess(double radius = 1.0)
- : m_unit_sphere(1)
- , m_radius(radius)
- {}
-
- inline bool operator()(segment<const P> const& segment, state_type& state) const
- {
- if (get<0>(segment.first) != get<0>(segment.second))
- {
- typedef point
- <
- typename coordinate_type<P>::type,
- 2,
- typename ggl::detail::get_cs_as_radian
- <
- typename coordinate_system<P>::type
- >::type
- > PR;
- PR p1, p2;
-
- // Select transformation strategy and transform to radians (if necessary)
- typename strategy_transform<
- typename cs_tag<P>::type,
- typename cs_tag<PR>::type,
- typename coordinate_system<P>::type,
- typename coordinate_system<PR>::type,
- dimension<P>::value,
- dimension<PR>::value,
- P, PR>::type transform_strategy;
-
- transform_strategy(segment.first, p1);
- transform_strategy(segment.second, p2);
-
- // Distance p1 p2
- double a = m_unit_sphere(segment.first, segment.second);
- // Sides on unit sphere to south pole
- double b = 0.5 * math::pi - ggl::get<1>(p2);
- double c = 0.5 * math::pi - ggl::get<1>(p1);
- // Semi parameter
- double s = 0.5 * (a + b + c);
-
- // E: spherical excess, using l'Huiller's formula
- // [tg(e / 4)]2 = tg[s / 2] tg[(s-a) / 2] tg[(s-b) / 2] tg[(s-c) / 2]
- double E = 4.0 * atan(sqrt(fabs(tan(s / 2)
- * tan((s - a) / 2)
- * tan((s - b) / 2)
- * tan((s - c) / 2))));
-
- E = fabs(E);
-
- // In right direction: positive, add area. In left direction: negative, subtract area.
- // Longitude comparisons are not so obvious. If one is negative, other is positive,
- // we have to take the date into account.
- // TODO: check this / enhance this, should be more robust. See also the "grow" for ll
- // TODO: use minmax or "smaller"/"compare" strategy for this
- double lon1 = ggl::get<0>(p1) < 0
- ? ggl::get<0>(p1) + math::two_pi
- : ggl::get<0>(p1);
- double lon2 = ggl::get<0>(p2) < 0
- ? ggl::get<0>(p2) + math::two_pi
- : ggl::get<0>(p2);
-
- if (lon2 < lon1)
- {
- E= -E;
- }
-
- state.m_sum += E;
- }
- return true;
- }
- };
+ return - sum * radius * radius;
+ }
+ };
+
+public :
+ typedef double return_type;
+ typedef PointOfSegment segment_point_type;
+ typedef excess_sum state_type;
+
+ inline huiller(double radius = 1.0)
+ : m_radius(radius)
+ {}
- } // namespace area
+ inline state_type init() const
+ {
+ return excess_sum(m_radius);
+ }
-} // namespace strategy
+ static inline void apply(PointOfSegment const& p1,
+ PointOfSegment const& p2,
+ excess_sum& state)
+ {
+ if (! ggl::math::equals(get<0>(p1), get<0>(p2)))
+ {
+ // Distance p1 p2
+ double a = state.distance_over_unit_sphere(p1, p2);
+ // Sides on unit sphere to south pole
+ double b = 0.5 * math::pi - ggl::get_as_radian<1>(p2);
+ double c = 0.5 * math::pi - ggl::get_as_radian<1>(p1);
+
+ // Semi parameter
+ double s = 0.5 * (a + b + c);
+
+ // E: spherical excess, using l'Huiller's formula
+ // [tg(e / 4)]2 = tg[s / 2] tg[(s-a) / 2] tg[(s-b) / 2] tg[(s-c) / 2]
+ double E = 4.0 * atan(sqrt(std::abs(tan(s / 2)
+ * tan((s - a) / 2)
+ * tan((s - b) / 2)
+ * tan((s - c) / 2))));
+
+ E = std::abs(E);
+
+ // In right direction: positive, add area. In left direction: negative, subtract area.
+ // Longitude comparisons are not so obvious. If one is negative, other is positive,
+ // we have to take the dateline into account.
+ // TODO: check this / enhance this, should be more robust. See also the "grow" for ll
+ // TODO: use minmax or "smaller"/"compare" strategy for this
+ double lon1 = ggl::get_as_radian<0>(p1) < 0
+ ? ggl::get_as_radian<0>(p1) + math::two_pi
+ : ggl::get_as_radian<0>(p1);
+
+ double lon2 = ggl::get_as_radian<0>(p2) < 0
+ ? ggl::get_as_radian<0>(p2) + math::two_pi
+ : ggl::get_as_radian<0>(p2);
+
+ if (lon2 < lon1)
+ {
+ E = -E;
+ }
+
+ state.sum += E;
+ }
+ }
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-template <typename LL>
-struct strategy_area<spherical_tag, LL>
-{
- typedef strategy::area::by_spherical_excess<LL> type;
+ static inline return_type result(excess_sum const& state)
+ {
+ return state.area();
+ }
+
+private :
+ /// Radius of the sphere
+ double m_radius;
};
-template <typename LL>
-struct strategy_area<geographic_tag, LL>
+
+}} // namespace strategy::area
+
+
+
+#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
+
+template <typename Point>
+struct strategy_area<spherical_tag, Point>
{
- typedef strategy::area::by_spherical_excess<LL> type;
+ typedef strategy::area::huiller<Point> type;
};
+
#endif
} // namespace ggl
-#endif // GGL_STRATEGIES_SPHERICAL_SPH_AREA_HPP
+#endif // GGL_STRATEGIES_SPHERICAL_AREA_HUILLER_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/distance_cross_track.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/distance_cross_track.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/distance_cross_track.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,7 +11,6 @@
#include <ggl/core/cs.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/radian_access.hpp>
@@ -49,13 +48,13 @@
typedef P point_type;
typedef typename strategy_distance
<
- typename ggl::cs_tag<P>::type,
+ typename ggl::cs_tag<P>::type,
typename ggl::cs_tag<P>::type,
P, P
>::type point_strategy_type;
- inline cross_track(double r = 1.0)
+ inline cross_track(double r = 1.0)
: m_radius(r)
, m_strategy(1.0) // Keep this 1.0 and not r
{}
Modified: sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/distance_haversine.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/distance_haversine.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/distance_haversine.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,7 +11,6 @@
#include <ggl/core/cs.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/radian_access.hpp>
Deleted: sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/sph_area.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/spherical/sph_area.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
+++ (empty file)
@@ -1,167 +0,0 @@
-// Generic Geometry Library
-//
-// Copyright Barend Gehrels 1995-2009, Geodan Holding B.V. Amsterdam, the Netherlands.
-// Copyright Bruno Lalande 2008, 2009
-// 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 GGL_STRATEGIES_SPHERICAL_SPH_AREA_HPP
-#define GGL_STRATEGIES_SPHERICAL_SPH_AREA_HPP
-
-#include <ggl/geometries/segment.hpp>
-#include <ggl/strategies/spherical/distance_haversine.hpp>
-#include <ggl/strategies/strategy_transform.hpp>
-
-#include <ggl/util/get_cs_as_radian.hpp>
-
-namespace ggl
-{
-namespace strategy
-{
- namespace area
- {
-
-
-
- /*!
- \brief Area calculation by spherical excess
- \tparam P type of points of rings/polygons
- \author Barend Gehrels. Adapted from:
- - http://www.soe.ucsc.edu/~pang/160/f98/Gems/GemsIV/sph_poly.c
- - http://williams.best.vwh.net/avform.htm
- \note The version in Gems didn't account for polygons crossing the 180 meridian.
- \note This version works for convex and non-convex polygons, for 180 meridian
- crossing polygons and for polygons with holes. However, some cases (especially
- 180 meridian cases) must still be checked.
- \note The version which sums angles, which is often seen, doesn't handle non-convex
- polygons correctly.
- \note The version which sums longitudes, see
- http://trs-new.jpl.nasa.gov/dspace/bitstream/2014/40409/1/07-03.pdf, is simple
- and works well in most cases but not in 180 meridian crossing cases. This probably
- could be solved.
- */
- template<typename P>
- class by_spherical_excess
- {
- private :
- struct excess_sum
- {
- double m_sum;
- double m_radius;
-
- // TODO: make this 1.0 & implement other construct to let user specify
- inline excess_sum(double radius = 1.0) //constants::average_earth_radius)
- : m_sum(0)
- , m_radius(radius)
- {}
- inline double area() const
- {
- return - m_sum * m_radius * m_radius;
- //constants::average_earth_radius * constants::average_earth_radius;
- }
- };
-
- // Distances are calculated on unit sphere here
- strategy::distance::haversine<P, P> m_unit_sphere;
- double m_radius;
-
- public :
- typedef double return_type;
- typedef excess_sum state_type;
-
- by_spherical_excess(double radius = 1.0)
- : m_unit_sphere(1)
- , m_radius(radius)
- {}
-
- inline bool operator()(segment<const P> const& segment, state_type& state) const
- {
- if (get<0>(segment.first) != get<0>(segment.second))
- {
- typedef point
- <
- typename coordinate_type<P>::type,
- 2,
- typename ggl::detail::get_cs_as_radian
- <
- typename coordinate_system<P>::type
- >::type
- > PR;
- PR p1, p2;
-
- // Select transformation strategy and transform to radians (if necessary)
- typename strategy_transform<
- typename cs_tag<P>::type,
- typename cs_tag<PR>::type,
- typename coordinate_system<P>::type,
- typename coordinate_system<PR>::type,
- dimension<P>::value,
- dimension<PR>::value,
- P, PR>::type transform_strategy;
-
- transform_strategy(segment.first, p1);
- transform_strategy(segment.second, p2);
-
- // Distance p1 p2
- double a = m_unit_sphere(segment.first, segment.second);
- // Sides on unit sphere to south pole
- double b = 0.5 * math::pi - ggl::get<1>(p2);
- double c = 0.5 * math::pi - ggl::get<1>(p1);
- // Semi parameter
- double s = 0.5 * (a + b + c);
-
- // E: spherical excess, using l'Huiller's formula
- // [tg(e / 4)]2 = tg[s / 2] tg[(s-a) / 2] tg[(s-b) / 2] tg[(s-c) / 2]
- double E = 4.0 * atan(sqrt(fabs(tan(s / 2)
- * tan((s - a) / 2)
- * tan((s - b) / 2)
- * tan((s - c) / 2))));
-
- E = fabs(E);
-
- // In right direction: positive, add area. In left direction: negative, subtract area.
- // Longitude comparisons are not so obvious. If one is negative, other is positive,
- // we have to take the date into account.
- // TODO: check this / enhance this, should be more robust. See also the "grow" for ll
- // TODO: use minmax or "smaller"/"compare" strategy for this
- double lon1 = ggl::get<0>(p1) < 0
- ? ggl::get<0>(p1) + math::two_pi
- : ggl::get<0>(p1);
- double lon2 = ggl::get<0>(p2) < 0
- ? ggl::get<0>(p2) + math::two_pi
- : ggl::get<0>(p2);
-
- if (lon2 < lon1)
- {
- E= -E;
- }
-
- state.m_sum += E;
- }
- return true;
- }
- };
-
- } // namespace area
-
-} // namespace strategy
-
-
-#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
-template <typename LL>
-struct strategy_area<spherical_tag, LL>
-{
- typedef strategy::area::by_spherical_excess<LL> type;
-};
-
-template <typename LL>
-struct strategy_area<geographic_tag, LL>
-{
- typedef strategy::area::by_spherical_excess<LL> type;
-};
-#endif
-
-} // namespace ggl
-
-#endif // GGL_STRATEGIES_SPHERICAL_SPH_AREA_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/strategies/strategies.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/strategies.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/strategies.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -12,23 +12,24 @@
#include <ggl/strategies/strategy_traits.hpp>
-#include <ggl/strategies/cartesian/cart_area.hpp>
-#include <ggl/strategies/cartesian/cart_centroid.hpp>
+#include <ggl/strategies/cartesian/area_by_triangles.hpp>
+#include <ggl/strategies/cartesian/centroid_bashein_detmer.hpp>
#include <ggl/strategies/cartesian/cart_compare.hpp>
#include <ggl/strategies/cartesian/cart_distance.hpp>
#include <ggl/strategies/cartesian/cart_envelope.hpp>
#include <ggl/strategies/cartesian/cart_side.hpp>
-#include <ggl/strategies/cartesian/cart_within.hpp>
+#include <ggl/strategies/cartesian/point_in_poly_franklin.hpp>
+#include <ggl/strategies/cartesian/point_in_poly_crossings_multiply.hpp>
#include <ggl/strategies/spherical/distance_haversine.hpp>
#include <ggl/strategies/spherical/distance_cross_track.hpp>
-#include <ggl/strategies/spherical/sph_area.hpp>
+#include <ggl/strategies/spherical/area_huiller.hpp>
#include <ggl/strategies/spherical/sph_envelope.hpp>
#include <ggl/strategies/agnostic/agn_convex_hull.hpp>
#include <ggl/strategies/agnostic/simplify_douglas_peucker.hpp>
-#include <ggl/strategies/agnostic/agn_within.hpp>
+#include <ggl/strategies/agnostic/point_in_poly_winding.hpp>
#include <ggl/strategies/strategy_transform.hpp>
Modified: sandbox/ggl/formal_review_request/boost/ggl/strategies/strategy_transform.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/strategy_transform.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/strategy_transform.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -18,7 +18,7 @@
#include <ggl/arithmetic/arithmetic.hpp>
#include <ggl/core/access.hpp>
#include <ggl/core/coordinate_dimension.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+
#include <ggl/util/copy.hpp>
#include <ggl/util/math.hpp>
#include <ggl/util/select_coordinate_type.hpp>
Modified: sandbox/ggl/formal_review_request/boost/ggl/util/copy.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/util/copy.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/util/copy.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -14,7 +14,7 @@
#include <boost/concept/requires.hpp>
#include <boost/concept_check.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
#include <boost/numeric/conversion/cast.hpp>
Modified: sandbox/ggl/formal_review_request/boost/ggl/util/for_each_coordinate.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/util/for_each_coordinate.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/util/for_each_coordinate.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -10,7 +10,7 @@
#define GGL_UTIL_FOR_EACH_COORDINATE_HPP
#include <boost/concept/requires.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+#include <ggl/geometries/concepts/point_concept.hpp>
namespace ggl
{
Added: sandbox/ggl/formal_review_request/boost/ggl/util/select_calculation_type.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/util/select_calculation_type.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -0,0 +1,52 @@
+// Generic Geometry Library
+//
+// Copyright Barend Gehrels 2009, Geodan, Amsterdam, the Netherlands.
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef GGL_UTIL_SELECT_CALCULATION_TYPE_HPP
+#define GGL_UTIL_SELECT_CALCULATION_TYPE_HPP
+
+
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits.hpp>
+
+#include <ggl/util/select_coordinate_type.hpp>
+
+/*!
+\defgroup utility utility: utilities
+*/
+
+namespace ggl
+{
+
+
+/*!
+ \brief Utility selecting the "calculation" type
+ \details Based on two input point types, and an input calculation type,
+ (which usually defaults to void), this meta-function selects the
+ most appropriate:
+ - if calculation type is specified, that one is used,
+ - if it is void, the most precise of the two points is used
+ \ingroup utility
+ */
+template <typename Point1, typename Point2, typename CalculationType>
+struct select_calculation_type
+{
+ typedef typename
+ boost::mpl::if_c
+ <
+ boost::is_void<CalculationType>::type::value,
+ typename select_coordinate_type
+ <
+ Point1,
+ Point2
+ >::type,
+ CalculationType
+ >::type type;
+};
+
+} // namespace ggl
+
+#endif // GGL_UTIL_SELECT_CALCULATION_TYPE_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/util/write_dsv.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/util/write_dsv.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/util/write_dsv.hpp 2009-10-25 06:28:38 EDT (Sun, 25 Oct 2009)
@@ -11,17 +11,18 @@
#include <iostream>
#include <string>
-#include <boost/concept/assert.hpp>
#include <boost/range/functions.hpp>
#include <boost/range/metafunctions.hpp>
#include <ggl/algorithms/convert.hpp>
-#include <ggl/core/concepts/point_concept.hpp>
+
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
#include <ggl/core/ring_type.hpp>
#include <ggl/core/is_multi.hpp>
-#include <ggl/geometries/linear_ring.hpp>
+
+#include <ggl/geometries/concepts/check.hpp>
+
@@ -146,9 +147,6 @@
stream_coordinate<Point, 0, dimension<Point>::type::value>::apply(os, p, settings);
os << settings.point_close;
}
-
- private:
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<Point>) );
};
/*!
@@ -180,7 +178,7 @@
stream_coordinate
<
- point, 0, dimension<point>::type::value
+ point_type, 0, dimension<point_type>::type::value
>::apply(os, *it, settings);
os << settings.point_close;
@@ -190,9 +188,8 @@
os << settings.list_close;
}
- private:
- typedef typename boost::range_value<Range>::type point;
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point>) );
+private:
+ typedef typename boost::range_value<Range>::type point_type;
};
/*!
@@ -230,9 +227,6 @@
}
os << settings.list_close;
}
-
- private:
- BOOST_CONCEPT_ASSERT( (concept::ConstPoint<typename point_type<Polygon>::type>) );
};
template <typename Geometry, std::size_t Index>
@@ -382,6 +376,8 @@
, std::string const& list_separator = ", "
)
{
+ concept::check<const Geometry>();
+
return dsv_manipulator<Geometry>(geometry,
detail::dsv::dsv_settings(coordinate_separator,
point_open, point_close, point_separator,
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