|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56932 - in sandbox/ggl/formal_review_request/boost/ggl: algorithms algorithms/overlay extensions/gis/io/wkb extensions/gis/io/wkb/detail extensions/gis/io/wkt iterators multi/algorithms multi/algorithms/overlay multi/iterators strategies/cartesian strategies/transform util
From: barend.gehrels_at_[hidden]
Date: 2009-10-16 15:58:52
Author: barendgehrels
Date: 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
New Revision: 56932
URL: http://svn.boost.org/trac/boost/changeset/56932
Log:
Merged assign_box_corner with assign
Added assign_point_to_box (also in assign)
Updated some headerfiles, too much or missing
Added non-const version of point_const_iterator and renamed to vertex_iterator
Removed wrong assertions in segment_iterator
Added extensions/.../wkb
Added:
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/endian.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/ogc.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/parser.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/read_wkb.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/utility.hpp (contents, props changed)
sandbox/ggl/formal_review_request/boost/ggl/iterators/vertex_iterator.hpp
- copied, changed from r56825, /sandbox/ggl/formal_review_request/boost/ggl/iterators/point_const_iterator.hpp
sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/vertex_iterator.hpp
- copied, changed from r56825, /sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/point_const_iterator.hpp
Removed:
sandbox/ggl/formal_review_request/boost/ggl/iterators/point_const_iterator.hpp
sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/point_const_iterator.hpp
sandbox/ggl/formal_review_request/boost/ggl/util/assign_box_corner.hpp
Text files modified:
sandbox/ggl/formal_review_request/boost/ggl/algorithms/assign.hpp | 91 ++++++++++++++++++++++++++++++++++++++++
sandbox/ggl/formal_review_request/boost/ggl/algorithms/buffer.hpp | 1
sandbox/ggl/formal_review_request/boost/ggl/algorithms/combine.hpp | 1
sandbox/ggl/formal_review_request/boost/ggl/algorithms/envelope.hpp | 3
sandbox/ggl/formal_review_request/boost/ggl/algorithms/get_section.hpp | 10 ++--
sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/copy_segments.hpp | 10 ++--
sandbox/ggl/formal_review_request/boost/ggl/algorithms/overlay/get_intersection_points.hpp | 8 +-
sandbox/ggl/formal_review_request/boost/ggl/algorithms/sectionalize.hpp | 3 -
sandbox/ggl/formal_review_request/boost/ggl/algorithms/transform.hpp | 4
sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkt/read_wkt.hpp | 14 ++++-
sandbox/ggl/formal_review_request/boost/ggl/iterators/segment_iterator.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/iterators/vertex_iterator.hpp | 68 ++++++++++++++++++++++-------
sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/get_section.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/overlay/get_intersection_points.hpp | 2
sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/vertex_iterator.hpp | 25 +++++++---
sandbox/ggl/formal_review_request/boost/ggl/strategies/cartesian/cart_intersect.hpp | 1
sandbox/ggl/formal_review_request/boost/ggl/strategies/transform/matrix_transformers.hpp | 4 +
17 files changed, 195 insertions(+), 54 deletions(-)
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -168,6 +168,64 @@
+template <std::size_t C1, std::size_t C2, typename Box, typename Point>
+inline void assign_box_2d_corner(Box const& box, Point& point)
+{
+ // Be sure both are 2-Dimensional
+ assert_dimension<Box, 2>();
+ assert_dimension<Point, 2>();
+
+ // Copy coordinates
+ typedef typename coordinate_type<Point>::type coordinate_type;
+
+ set<0>(point, boost::numeric_cast<coordinate_type>(get<C1, 0>(box)));
+ set<1>(point, boost::numeric_cast<coordinate_type>(get<C2, 1>(box)));
+}
+
+
+
+
+
+template
+<
+ typename Box, typename Point,
+ std::size_t Corner,
+ std::size_t Dimension, std::size_t Count
+>
+struct assign_point_to_box
+{
+ typedef typename coordinate_type<Box>::type coordinate_type;
+
+ static inline void apply(Point const& point, Box& box)
+ {
+ ggl::set<Corner, Dimension>
+ (
+ box,
+ boost::numeric_cast<coordinate_type>(ggl::get<Dimension>(point))
+ );
+
+ assign_point_to_box
+ <
+ Box, Point, Corner, Dimension + 1, Count
+ >::apply(point, box);
+ }
+};
+
+template
+<
+ typename Box, typename Point,
+ std::size_t Corner,
+ std::size_t Count
+>
+struct assign_point_to_box<Box, Point, Corner, Count, Count>
+{
+ static inline void apply(Point const& point, Box& box)
+ {
+ }
+};
+
+
+
}} // namespace detail::assign
#endif // DOXYGEN_NO_DETAIL
@@ -405,6 +463,39 @@
>::apply(geometry);
}
+
+/*!
+ \brief Assign the 4 points of a 2D box
+ \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)
+{
+ 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);
+ detail::assign::assign_box_2d_corner<max_corner, max_corner>(box, upper_right);
+}
+
+
+
+/*!
+ \brief Assign a box with the value of a point
+ \ingroup assign
+ \tparam Corner indicates which box-corner, min_corner (0) or max_corner (1)
+*/
+template <std::size_t Corner, typename Box, typename Point>
+inline void assign_point_to_box(Point const& point, Box& box)
+{
+ detail::assign::assign_point_to_box
+ <
+ Box, Point, Corner, 0, dimension<Box>::type::value
+ >::apply(point, box);
+}
+
+
+
} // namespace ggl
#endif // GGL_ALGORITHMS_ASSIGN_HPP
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -16,7 +16,6 @@
#include <ggl/arithmetic/arithmetic.hpp>
#include <ggl/core/concepts/box_concept.hpp>
#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/util/assign_box_corner.hpp>
// Buffer functions
// Was before: "grow" but then only for box
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -17,7 +17,6 @@
#include <ggl/core/coordinate_dimension.hpp>
#include <ggl/core/concepts/box_concept.hpp>
#include <ggl/core/concepts/point_concept.hpp>
-#include <ggl/util/assign_box_corner.hpp>
#include <ggl/util/select_coordinate_type.hpp>
/*!
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -101,6 +101,7 @@
{
static inline void apply(S const& s, B& mbr, Strategy const&)
{
+ // TODO: remove s.first/s.second, use strategies
ggl::assign_inverse(mbr);
ggl::combine(mbr, s.first);
ggl::combine(mbr, s.second);
@@ -165,7 +166,7 @@
{
/*!
\brief Calculate envelope of a box
- \details The envelope of a box is itself, provided for consistency
+ \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&)
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -20,7 +20,7 @@
#include <ggl/core/exterior_ring.hpp>
#include <ggl/core/interior_rings.hpp>
-#include <ggl/iterators/point_const_iterator.hpp>
+#include <ggl/iterators/vertex_iterator.hpp>
#include <ggl/geometries/segment.hpp>
@@ -37,7 +37,7 @@
template <typename Tag, typename Geometry, typename Section>
struct get_section
{
- typedef typename ggl::point_const_iterator<Geometry>::type iterator_type;
+ typedef typename ggl::vertex_iterator<Geometry, true>::type iterator_type;
static inline void apply(Geometry const& geometry, Section const& section,
iterator_type& begin, iterator_type& end)
{
@@ -49,7 +49,7 @@
template <typename Polygon, typename Section>
struct get_section<polygon_tag, Polygon, Section>
{
- typedef typename ggl::point_const_iterator<Polygon>::type iterator_type;
+ typedef typename ggl::vertex_iterator<Polygon, true>::type iterator_type;
static inline void apply(Polygon const& polygon, Section const& section,
iterator_type& begin, iterator_type& end)
{
@@ -83,8 +83,8 @@
*/
template <typename Geometry, typename Section>
inline void get_section(Geometry const& geometry, Section const& section,
- typename point_const_iterator<Geometry>::type& begin,
- typename point_const_iterator<Geometry>::type& end)
+ typename vertex_iterator<Geometry, true>::type& begin,
+ typename vertex_iterator<Geometry, true>::type& end)
{
dispatch::get_section
<
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -17,7 +17,7 @@
#include <ggl/algorithms/overlay/intersection_point.hpp>
#include <ggl/iterators/ever_circling_iterator.hpp>
-#include <ggl/iterators/point_const_iterator.hpp>
+#include <ggl/iterators/vertex_iterator.hpp>
namespace ggl
@@ -36,7 +36,7 @@
RangeOut& current_output)
{
- typedef typename ggl::point_const_iterator<Ring>::type iterator;
+ typedef typename ggl::vertex_iterator<Ring, true>::type iterator;
typedef ggl::ever_circling_iterator<iterator> ec_iterator;
// The problem: sometimes we want to from "3" to "2" -> end = "3" -> end == begin
@@ -63,8 +63,8 @@
{
// TODO: use 'copy coordinates' to handle different point types
#ifdef GGL_DEBUG_INTERSECTION
- std::cout << " add: ("
- << ggl::get<0>(*it) << ", " << ggl::get<1>(*it) << ")"
+ std::cout << " add: ("
+ << ggl::get<0>(*it) << ", " << ggl::get<1>(*it) << ")"
<< std::endl;
#endif
current_output.push_back(*it);
@@ -91,7 +91,7 @@
seg_id.ring_index < 0
? ggl::exterior_ring(polygon)
: ggl::interior_rings(polygon)[seg_id.ring_index],
- seg_id, to_index,
+ seg_id, to_index,
current_output
);
}
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -197,13 +197,13 @@
bool& trivial)
{
- typedef typename ggl::point_const_iterator
+ typedef typename ggl::vertex_iterator
<
- Geometry1
+ Geometry1, true
>::type range1_iterator;
- typedef typename ggl::point_const_iterator
+ typedef typename ggl::vertex_iterator
<
- Geometry2
+ Geometry2, true
>::type range2_iterator;
int const dir1 = sec1.directions[0];
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -23,9 +23,6 @@
#include <ggl/core/access.hpp>
#include <ggl/core/exterior_ring.hpp>
-#include <ggl/iterators/point_const_iterator.hpp>
-
-#include <ggl/util/assign_box_corner.hpp>
#include <ggl/util/math.hpp>
#include <ggl/geometries/segment.hpp>
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -84,8 +84,8 @@
typedef typename point_type<B2>::type point_type2;
point_type1 lower_left, upper_right;
- assign_box_corner<min_corner, min_corner>(b1, lower_left);
- assign_box_corner<max_corner, max_corner>(b1, upper_right);
+ detail::assign::assign_box_2d_corner<min_corner, min_corner>(b1, lower_left);
+ detail::assign::assign_box_2d_corner<max_corner, max_corner>(b1, upper_right);
point_type2 p1, p2;
if (strategy(lower_left, p1) && strategy(upper_right, p2))
Added: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/endian.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/endian.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,256 @@
+// Generic Geometry Library
+//
+// Copyright Mateusz Loskot <mateusz_at_[hidden]> 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)
+//
+// Load/Store values from/to stream of bytes across different endianness.
+//
+// Original design of unrolled_byte_loops templates based on
+// endian utility library from Boost C++ Libraries,
+// source: boost/spirit/home/support/detail/integer/endian.hpp
+// Copyright Darin Adler 2000
+// Copyright Beman Dawes 2006, 2009
+// Distributed under the Boost Software License, Version 1.0.
+
+#ifndef GGL_DETAIL_ENDIAN_HPP
+#define GGL_DETAIL_ENDIAN_HPP
+
+#include <cassert>
+#include <climits>
+#include <cstring>
+#include <cstddef>
+
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/static_assert.hpp>
+#include <boost/detail/endian.hpp>
+#include <boost/type_traits/is_signed.hpp>
+
+#if CHAR_BIT != 8
+#error Platforms with CHAR_BIT != 8 are not supported
+#endif
+
+// TODO: mloskot - add static asserts to validate compile-time pre-conditions
+
+namespace ggl { namespace detail { namespace endian {
+
+// Endianness tag used to indicate load/store directoin
+
+struct big_endian_tag {};
+struct little_endian_tag {};
+
+#ifdef BOOST_BIG_ENDIAN
+typedef big_endian_tag native_endian_tag;
+#else
+typedef little_endian_tag native_endian_tag;
+#endif
+
+// Unrolled loops for loading and storing streams of bytes.
+
+template <typename T, std::size_t N, bool Sign = boost::is_signed<T>::value>
+struct unrolled_byte_loops
+{
+ typedef unrolled_byte_loops<T, N - 1, Sign> next;
+
+ template <typename Iterator>
+ static T load_forward(Iterator& bytes)
+ {
+ T const value = *bytes;
+ ++bytes;
+ return value | (next::load_forward(bytes) << 8);
+ }
+
+ template <typename Iterator>
+ static T load_backward(Iterator& bytes)
+ {
+ T const value = *(bytes - 1);
+ --bytes;
+ return value | (next::load_backward(bytes) << 8);
+ }
+
+ template <typename Iterator>
+ static void store_forward(Iterator& bytes, T value)
+ {
+ *bytes = static_cast<char>(value);
+ next::store_forward(++bytes, value >> 8);
+ }
+
+ template <typename Iterator>
+ static void store_backward(Iterator& bytes, T value)
+ {
+ *(bytes - 1) = static_cast<char>(value);
+ next::store_backward(--bytes, value >> 8);
+ }
+};
+
+template <typename T>
+struct unrolled_byte_loops<T, 1, false>
+{
+ template <typename Iterator>
+ static T load_forward(Iterator& bytes)
+ {
+ return *bytes;
+ }
+
+ template <typename Iterator>
+ static T load_backward(Iterator& bytes)
+ {
+ return *(bytes - 1);
+ }
+
+ template <typename Iterator>
+ static void store_forward(Iterator& bytes, T value)
+ {
+ // typename Iterator::value_type
+ *bytes = static_cast<char>(value);
+ }
+
+ template <typename Iterator>
+ static void store_backward(Iterator& bytes, T value)
+ {
+ *(bytes - 1) = static_cast<char>(value);
+ }
+};
+
+template <typename T>
+struct unrolled_byte_loops<T, 1, true>
+{
+ template <typename Iterator>
+ static T load_forward(Iterator& bytes)
+ {
+ return *reinterpret_cast<const signed char*>(&*bytes);
+ }
+
+ template <typename Iterator>
+ static T load_backward(Iterator& bytes)
+ {
+ return *reinterpret_cast<const signed char*>(&*(bytes - 1));
+ }
+
+ template <typename Iterator>
+ static void store_forward(Iterator& bytes, T value)
+ {
+ BOOST_STATIC_ASSERT((boost::is_signed<typename Iterator::value_type>::value));
+
+ *bytes = static_cast<typename Iterator::value_type>(value);
+ }
+
+ template <typename Iterator>
+ static void store_backward(Iterator& bytes, T value)
+ {
+ BOOST_STATIC_ASSERT((boost::is_signed<typename Iterator::value_type>::value));
+
+ *(bytes - 1) = static_cast<typename Iterator::value_type>(value);
+ }
+};
+
+// load/store operation dispatch
+// E, E - source and target endianness is the same
+// E1, E2 - source and target endianness is different (big-endian <-> little-endian)
+
+template <typename T, std::size_t N, typename Iterator, typename E>
+T load_dispatch(Iterator& bytes, E, E)
+{
+ return unrolled_byte_loops<T, N>::load_forward(bytes);
+}
+
+template <typename T, std::size_t N, typename Iterator, typename E1, typename E2>
+T load_dispatch(Iterator& bytes, E1, E2)
+{
+ std::advance(bytes, N);
+ return unrolled_byte_loops<T, N>::load_backward(bytes);
+}
+
+template <typename T, std::size_t N, typename Iterator, typename E>
+void store_dispatch(Iterator& bytes, T value, E, E)
+{
+ return unrolled_byte_loops<T, N>::store_forward(bytes, value);
+}
+
+template <typename T, std::size_t N, typename Iterator, typename E1, typename E2>
+void store_dispatch(Iterator& bytes, T value, E1, E2)
+{
+ std::advance(bytes, N);
+ return unrolled_byte_loops<T, N>::store_backward(bytes, value);
+}
+
+// numeric value holder for load/store operation
+
+template <typename T>
+struct endian_value_base
+{
+ typedef T value_type;
+ typedef native_endian_tag endian_type;
+
+ endian_value_base() : value(T()) {}
+ explicit endian_value_base(T value) : value(value) {}
+
+ operator T() const
+ {
+ return value;
+ }
+
+protected:
+ T value;
+};
+
+template <typename T, std::size_t N = sizeof(T)>
+struct endian_value : public endian_value_base<T>
+{
+ typedef endian_value_base<T> base;
+
+ endian_value() {}
+ explicit endian_value(T value) : base(value) {}
+
+ template <typename E, typename Iterator>
+ void load(Iterator bytes)
+ {
+ base::value = load_dispatch<T, N>(bytes, typename base::endian_type(), E());
+ }
+
+ template <typename E, typename Iterator>
+ void store(Iterator bytes)
+ {
+ store_dispatch<T, N>(bytes, base::value, typename base::endian_type(), E());
+ }
+};
+
+template <>
+struct endian_value<double, 8> : public endian_value_base<double>
+{
+ typedef endian_value_base<double> base;
+
+ endian_value() {}
+ explicit endian_value(double value) : base(value) {}
+
+ template <typename E, typename Iterator>
+ void load(Iterator bytes)
+ {
+ endian_value<boost::uint64_t, 8> raw;
+ raw.load<E>(bytes);
+
+ double& target_value = base::value;
+ std::memcpy(&target_value, &raw, sizeof(double));
+ }
+
+ template <typename E, typename Iterator>
+ void store(Iterator bytes)
+ {
+ boost::uint64_t raw;
+ double const& source_value = base::value;
+ std::memcpy(&raw, &source_value, sizeof(boost::uint64_t));
+
+ store_dispatch
+ <
+ boost::uint64_t,
+ sizeof(boost::uint64_t)
+ >(bytes, raw, typename base::endian_type(), E());
+ }
+};
+
+}}} // namespace ggl::detail::endian
+
+#endif // GGL_DETAIL_ENDIAN_HPP
+
Added: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/ogc.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/ogc.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,82 @@
+// Generic Geometry Library
+//
+// Copyright Mateusz Loskot <mateusz_at_[hidden]> 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_IO_WKB_DETAIL_OGC_HPP
+#define GGL_IO_WKB_DETAIL_OGC_HPP
+
+#include <boost/cstdint.hpp>
+
+namespace ggl
+{
+
+// The well-known binary representation for OGC geometry (WKBGeometry),
+// provides a portable representation of a geometry value as a contiguous
+// stream of bytes. It permits geometry values to be exchanged between
+// a client application and an SQL database in binary form.
+//
+// Basic Type definitions
+// byte : 1 byte
+// uint32 : 32 bit unsigned integer (4 bytes)
+// double : double precision number (8 bytes)
+//
+// enum wkbByteOrder
+// {
+// wkbXDR = 0, // Big Endian
+// wkbNDR = 1 // Little Endian
+// };
+//
+// enum wkbGeometryType
+// {
+// wkbPoint = 1,
+// wkbLineString = 2,
+// wkbPolygon = 3,
+// wkbMultiPoint = 4,
+// wkbMultiLineString = 5,
+// wkbMultiPolygon = 6,
+// wkbGeometryCollection = 7
+// };
+
+#ifndef DOXYGEN_NO_IMPL
+namespace detail { namespace wkb {
+
+// TODO: Replace 'struct' with scoped enum from <boost/detail/scoped_enum_emulation.hpp>
+// For older Boost, copy
+// <boost/spirit/home/support/detail/scoped_enum_emulation.hpp>
+// to
+// <boost/ggl/detail/scoped_enum_emulation.hpp>
+// and use it.
+
+struct byte_order_type
+{
+ enum enum_t
+ {
+ xdr = 0, // wkbXDR, bit-endian
+ ndr = 1, // wkbNDR, little-endian
+ unknown = 2 // not defined by OGC
+ };
+};
+
+struct geometry_type
+{
+ enum enum_t
+ {
+ point = 1,
+ linestring = 2,
+ polygon = 3
+
+ // TODO: Not implemented
+ //multipoint = 4,
+ //multilinestring = 5,
+ //multipolygon = 6,
+ //collection = 7
+ };
+};
+
+}}} // namespace ggl::detail::wkb
+#endif // DOXYGEN_NO_IMPL
+
+#endif // GGL_IO_WKB_DETAIL_OGC_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/parser.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/detail/parser.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,310 @@
+// Generic Geometry Library
+//
+// Copyright Mateusz Loskot <mateusz_at_[hidden]> 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_IO_WKB_DETAIL_PARSER_HPP
+#define GGL_IO_WKB_DETAIL_PARSER_HPP
+
+#include <cassert>
+#include <cstddef>
+#include <algorithm>
+#include <iterator>
+#include <limits>
+
+#include <boost/cstdint.hpp>
+#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>
+#include <ggl/extensions/gis/io/wkb/detail/ogc.hpp>
+
+namespace ggl
+{
+
+#ifndef DOXYGEN_NO_IMPL
+namespace detail { namespace wkb {
+
+template <typename T>
+struct value_parser
+{
+ typedef T value_type;
+
+ template <typename Iterator>
+ static bool parse(Iterator& it, Iterator end, T& value, byte_order_type::enum_t order)
+ {
+ // Very basic pre-conditions check on stream of bytes passed in
+ BOOST_STATIC_ASSERT((
+ boost::is_integral<typename std::iterator_traits<Iterator>::value_type>::value
+ ));
+ BOOST_STATIC_ASSERT((sizeof(boost::uint8_t) ==
+ sizeof(typename std::iterator_traits<Iterator>::value_type)
+ ));
+
+ typedef typename std::iterator_traits<Iterator>::difference_type diff_type;
+ diff_type const required_size = sizeof(T);
+ if (it != end && std::distance(it, end) >= required_size)
+ {
+ typedef endian::endian_value<T> parsed_value_type;
+ parsed_value_type parsed_value;
+
+ // Decide on direcion of endianness translation, detault to native
+ if (byte_order_type::xdr == order)
+ {
+ parsed_value.template load<endian::big_endian_tag>(it);
+ }
+ else if (byte_order_type::ndr == order)
+ {
+ parsed_value.template load<endian::little_endian_tag>(it);
+ }
+ else
+ {
+ parsed_value.template load<endian::native_endian_tag>(it);
+ }
+
+ value = parsed_value;
+ std::advance(it, required_size);
+ return true;
+ }
+
+ return false;
+ }
+};
+
+struct byte_order_parser
+{
+ template <typename Iterator>
+ static bool parse(Iterator& it, Iterator end, byte_order_type::enum_t& order)
+ {
+ boost::uint8_t value;
+ if (value_parser<boost::uint8_t>::parse(it, end, value, byte_order_type::unknown))
+ {
+ if (byte_order_type::unknown > value)
+ {
+ order = byte_order_type::enum_t(value);
+ }
+ return true;
+ }
+ return false;
+ }
+};
+
+struct geometry_type_parser
+{
+ template <typename Iterator>
+ static bool parse(Iterator& it, Iterator end, geometry_type::enum_t& type,
+ byte_order_type::enum_t order)
+ {
+ boost::uint32_t value;
+ if (value_parser<boost::uint32_t>::parse(it, end, value, order))
+ {
+ // TODO: Refine the test when multi* geometries are supported
+
+ boost::uint32_t id = value & 0xff;
+ if (geometry_type::polygon >= id)
+ {
+ type = geometry_type::enum_t(id);
+ return true;
+ }
+ }
+ return false;
+ }
+};
+
+template <typename P, int I, int N>
+struct parsing_assigner
+{
+ template <typename Iterator>
+ static void run(Iterator& it, Iterator end, P& point, byte_order_type::enum_t order)
+ {
+ typedef typename coordinate_type<P>::type coordinate_type;
+
+ // coordinate type in WKB is always double
+ double value(0);
+ if (value_parser<double>::parse(it, end, value, order))
+ {
+ // actual coordinate type of point may be different
+ set<I>(point, static_cast<coordinate_type>(value));
+ }
+ else
+ {
+ // TODO: mloskot - Report premature termination at coordinate level
+ //throw failed to read coordinate value
+
+ // default initialized value as fallback
+ set<I>(point, coordinate_type());
+ }
+ parsing_assigner<P, I+1, N>::run(it, end, point, order);
+ }
+};
+
+template <typename P, int N>
+struct parsing_assigner<P, N, N>
+{
+ template <typename Iterator>
+ static void run(Iterator& it, Iterator end, P& point, byte_order_type::enum_t order)
+ {
+ // terminate
+ }
+};
+
+template <typename P>
+struct point_parser
+{
+ template <typename Iterator>
+ static bool parse(Iterator& it, Iterator end, P& point, byte_order_type::enum_t order)
+ {
+ // TODO: mloskot - Add assert on point dimension, 2d only
+
+ geometry_type::enum_t type;
+ if (geometry_type_parser::parse(it, end, type, order))
+ {
+ if (geometry_type::point == type && it != end)
+ {
+ parsing_assigner<P, 0, dimension<P>::value>::run(it, end, point, order);
+ }
+ return true;
+ }
+ return false;
+ }
+
+private:
+ BOOST_CONCEPT_ASSERT((concept::Point<P>));
+};
+
+template <typename C>
+struct point_container_parser
+{
+ template <typename Iterator>
+ static bool parse(Iterator& it, Iterator end, C& container, byte_order_type::enum_t order)
+ {
+ typedef typename point_type<C>::type point_type;
+
+ boost::uint32_t num_points(0);
+ if (!value_parser<boost::uint32_t>::parse(it, end, num_points, order))
+ {
+ return false;
+ }
+
+ typedef typename std::iterator_traits<Iterator>::difference_type size_type;
+ assert(num_points <= boost::uint32_t( (std::numeric_limits<size_type>::max)() ) );
+
+ size_type const container_size = static_cast<size_type>(num_points);
+ size_type const point_size = dimension<point_type>::value * sizeof(double);
+
+ if (std::distance(it, end) >= (container_size * point_size))
+ {
+ point_type point_buffer;
+ std::back_insert_iterator<C> output(std::back_inserter(container));
+
+ // Read coordinates into point and append point to line (ring)
+ size_type points_parsed = 0;
+ while (points_parsed < container_size && it != end)
+ {
+ parsing_assigner<point_type, 0, dimension<point_type>::value>::run(it, end, point_buffer, order);
+ output = point_buffer;
+ ++output;
+ ++points_parsed;
+ }
+
+ if (container_size != points_parsed)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+};
+
+template <typename L>
+struct linestring_parser
+{
+ template <typename Iterator>
+ static bool parse(Iterator& it, Iterator end, L& linestring, byte_order_type::enum_t order)
+ {
+ typedef typename point_type<L>::type point_type;
+
+ geometry_type::enum_t type;
+ if (!geometry_type_parser::parse(it, end, type, order))
+ {
+ return false;
+ }
+
+ if (geometry_type::linestring != type)
+ {
+ return false;
+ }
+
+ assert(it != end);
+ return point_container_parser<L>::parse(it, end, linestring, order);
+ }
+};
+
+template <typename Polygon>
+struct polygon_parser
+{
+ template <typename Iterator>
+ static bool parse(Iterator& it, Iterator end, Polygon& polygon, byte_order_type::enum_t order)
+ {
+ geometry_type::enum_t type;
+ if (!geometry_type_parser::parse(it, end, type, order))
+ {
+ return false;
+ }
+
+ boost::uint32_t num_rings(0);
+ if (geometry_type::polygon != type ||
+ !value_parser<boost::uint32_t>::parse(it, end, num_rings, order))
+ {
+ return false;
+ }
+
+ typedef typename ring_type<Polygon>::type ring_type;
+
+ std::size_t rings_parsed = 0;
+ while (rings_parsed < num_rings && it != end) //while (rings_parsed < num_rings && it != end)
+ {
+ if (0 == rings_parsed)
+ {
+ ring_type& ring0 = exterior_ring(polygon);
+ if (!point_container_parser<ring_type>::parse(it, end, ring0, order))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ interior_rings(polygon).resize(rings_parsed);
+ ring_type& ringN = interior_rings(polygon).back();
+ if (!point_container_parser<ring_type>::parse(it, end, ringN, order))
+ {
+ return false;
+ }
+ }
+ ++rings_parsed;
+ }
+
+ if (num_rings != rings_parsed)
+ {
+ return false;
+ }
+
+ return true;
+ }
+};
+
+}}} // namespace ggl::detail::wkb
+#endif // DOXYGEN_NO_IMPL
+
+#endif // GGL_IO_WKB_DETAIL_PARSER_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/read_wkb.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/read_wkb.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,107 @@
+// Generic Geometry Library
+//
+// Copyright Mateusz Loskot <mateusz_at_[hidden]> 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_IO_WKB_READ_WKB_HPP
+#define GGL_IO_WKB_READ_WKB_HPP
+
+#include <iterator>
+
+#include <boost/type_traits/is_convertible.hpp>
+#include <boost/static_assert.hpp>
+
+#include <ggl/core/tags.hpp>
+#include <ggl/extensions/gis/io/wkb/detail/parser.hpp>
+
+namespace ggl
+{
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace dispatch
+{
+
+template <typename Tag, typename G>
+struct read_wkb {};
+
+template <typename G>
+struct read_wkb<point_tag, G>
+{
+ template <typename Iterator>
+ static inline bool parse(Iterator& it, Iterator end, G& geometry,
+ detail::wkb::byte_order_type::enum_t order)
+ {
+ return detail::wkb::point_parser<G>::parse(it, end, geometry, order);
+ }
+};
+
+template <typename G>
+struct read_wkb<linestring_tag, G>
+{
+ template <typename Iterator>
+ static inline bool parse(Iterator& it, Iterator end, G& geometry,
+ detail::wkb::byte_order_type::enum_t order)
+ {
+ ggl::clear(geometry);
+ return detail::wkb::linestring_parser<G>::parse(it, end, geometry, order);
+ }
+};
+
+template <typename G>
+struct read_wkb<polygon_tag, G>
+{
+ template <typename Iterator>
+ static inline bool parse(Iterator& it, Iterator end, G& geometry,
+ detail::wkb::byte_order_type::enum_t order)
+ {
+ ggl::clear(geometry);
+ return detail::wkb::polygon_parser<G>::parse(it, end, geometry, order);
+ }
+};
+
+} // namespace dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+template <typename Iterator, typename G>
+inline bool read_wkb(Iterator begin, Iterator end, G& geometry)
+{
+ // Stream of bytes can only be parsed using random access iterator.
+ BOOST_STATIC_ASSERT((
+ boost::is_convertible
+ <
+ typename std::iterator_traits<Iterator>::iterator_category,
+ const std::random_access_iterator_tag&
+ >::value));
+
+ detail::wkb::byte_order_type::enum_t byte_order;
+ if (detail::wkb::byte_order_parser::parse(begin, end, byte_order))
+ {
+ return dispatch::read_wkb
+ <
+ typename tag<G>::type,
+ G
+ >::parse(begin, end, geometry, byte_order);
+ }
+
+ return false;
+}
+
+template <typename ByteType, typename G>
+inline bool read_wkb(ByteType const* bytes, std::size_t length, G& geometry)
+{
+ BOOST_STATIC_ASSERT((boost::is_integral<ByteType>::value));
+ BOOST_STATIC_ASSERT((sizeof(boost::uint8_t) == sizeof(ByteType)));
+
+ ByteType const* begin = bytes;
+ ByteType const* const end = bytes + length;
+
+ return read_wkb(begin, end, geometry);
+}
+
+
+} // namespace ggl
+
+#endif // GGL_IO_WKB_READ_WKB_HPP
Added: sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/utility.hpp
==============================================================================
--- (empty file)
+++ sandbox/ggl/formal_review_request/boost/ggl/extensions/gis/io/wkb/utility.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -0,0 +1,89 @@
+// Generic Geometry Library
+//
+// Copyright Mateusz Loskot <mateusz_at_[hidden]> 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_IO_WKB_UTILITY_HPP
+#define GGL_IO_WKB_UTILITY_HPP
+
+#include <iomanip>
+#include <iterator>
+#include <sstream>
+#include <string>
+
+#include <boost/cstdint.hpp>
+
+namespace ggl {
+
+// TODO: Waiting for errors handling design, eventually return bool
+// may be replaced to throw exception.
+
+template <typename OutputIterator>
+bool hex2wkb(std::string const& hex, OutputIterator bytes)
+{
+ // Bytes can be only written to output iterator.
+ BOOST_STATIC_ASSERT((boost::is_convertible<
+ typename std::iterator_traits<OutputIterator>::iterator_category,
+ const std::output_iterator_tag&>::value));
+
+ std::string::size_type const byte_size = 2;
+ if (0 != hex.size() % byte_size)
+ {
+ return false;
+ }
+
+ std::string::size_type const size = hex.size() / byte_size;
+ for (std::string::size_type i = 0; i < size; ++i)
+ {
+ // TODO: This is confirmed performance killer - to be replaced with static char-to-byte map --mloskot
+ std::istringstream iss(hex.substr(i * byte_size, byte_size));
+ unsigned int byte(0);
+ if (!(iss >> std::hex >> byte))
+ {
+ return false;
+ }
+ *bytes = static_cast<boost::uint8_t>(byte);
+ ++bytes;
+ }
+
+ return true;
+}
+
+template <typename Iterator>
+bool wkb2hex(Iterator begin, Iterator end, std::string& hex)
+{
+ // Stream of bytes can only be passed using random access iterator.
+ BOOST_STATIC_ASSERT((boost::is_convertible<
+ typename std::iterator_traits<Iterator>::iterator_category,
+ const std::random_access_iterator_tag&>::value));
+
+ const char hexalpha[] = "0123456789ABCDEF";
+ char hexbyte[3] = { 0 };
+ std::ostringstream oss;
+
+ Iterator it = begin;
+ while (it != end)
+ {
+ boost::uint8_t byte = static_cast<boost::uint8_t>(*it);
+ hexbyte[0] = hexalpha[(byte >> 4) & 0xf];
+ hexbyte[1] = hexalpha[byte & 0xf];
+ hexbyte[2] = '\0';
+ oss << std::setw(2) << hexbyte;
+ ++it;
+ }
+
+ // TODO: Binary streams can be big.
+ // Does it make sense to request stream buffer of proper (large) size or
+ // use incremental appends within while-loop?
+ hex = oss.str();
+
+ // Poor-man validation, no performance penalty expected
+ // because begin/end always are random access iterators.
+ return hex.size() == (2 * std::distance(begin, end));
+}
+
+} // namespace ggl
+
+#endif // GGL_IO_WKB_UTILITY_HPP
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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -21,13 +21,18 @@
#include <boost/type_traits.hpp>
+#include <ggl/algorithms/assign.hpp>
#include <ggl/algorithms/clear.hpp>
+
#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/extensions/gis/io/wkt/detail/wkt.hpp>
namespace ggl
@@ -417,6 +422,8 @@
+
+
/*!
\brief Supports box parsing
\note OGC does not define the box geometry, and WKT does not support boxes.
@@ -482,10 +489,9 @@
{
throw read_wkt_exception("Box should have 2,4 or 5 points", wkt);
}
- set<min_corner, 0>(box, get<0>(points[0]));
- set<min_corner, 1>(box, get<1>(points[0]));
- set<max_corner, 0>(box, get<0>(points[index]));
- set<max_corner, 1>(box, get<1>(points[index]));
+
+ assign_point_to_box<min_corner>(points.front(), box);
+ assign_point_to_box<max_corner>(points[index], box);
}
};
Deleted: sandbox/ggl/formal_review_request/boost/ggl/iterators/point_const_iterator.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/iterators/point_const_iterator.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
+++ (empty file)
@@ -1,76 +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_ITERATORS_POINT_CONST_ITERATOR_HPP
-#define GGL_ITERATORS_POINT_CONST_ITERATOR_HPP
-
-
-#include <boost/type_traits/remove_const.hpp>
-
-
-#include <ggl/core/tag.hpp>
-#include <ggl/core/tags.hpp>
-
-
-#include <boost/range/metafunctions.hpp>
-
-namespace ggl
-{
-
-
-#ifndef DOXYGEN_NO_DISPATCH
-namespace dispatch
-{
-
-template <typename Tag, typename Geometry>
-struct point_const_iterator
-{
- // The default: meta-forward this to boost
- // This enables calling this function using std::vector as well, even if they
- // are not registered.
- // It also requires less specializations
- typedef typename boost::range_const_iterator<Geometry>::type type;
-};
-
-
-template <typename Polygon>
-struct point_const_iterator<polygon_tag, Polygon>
-{
- typedef typename boost::range_const_iterator
- <
- typename ring_type<Polygon>::type
- >::type type;
-};
-
-
-
-
-} // namespace dispatch
-#endif
-
-
-/*!
- \brief Meta-function which defines point-const-iterator type
- \ingroup iterators
-*/
-template <typename Geometry>
-struct point_const_iterator
-{
- typedef typename boost::remove_const<Geometry>::type ncg;
- typedef typename dispatch::point_const_iterator<
- typename tag<Geometry>::type, ncg>::type type;
-};
-
-
-
-
-}
-
-
-#endif // GGL_ITERATORS_POINT_CONST_ITERATOR_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/iterators/segment_iterator.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/iterators/segment_iterator.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/iterators/segment_iterator.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -48,8 +48,6 @@
, m_it(end)
, m_end(end)
{
- BOOST_ASSERT(ggl::equals(point_type(), m_segment.first));
- BOOST_ASSERT(ggl::equals(point_type(), m_segment.second));
}
segment_iterator(Base const& it, Base const& end)
Copied: sandbox/ggl/formal_review_request/boost/ggl/iterators/vertex_iterator.hpp (from r56825, /sandbox/ggl/formal_review_request/boost/ggl/iterators/point_const_iterator.hpp)
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/iterators/point_const_iterator.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/iterators/vertex_iterator.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -7,19 +7,19 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_ITERATORS_POINT_CONST_ITERATOR_HPP
-#define GGL_ITERATORS_POINT_CONST_ITERATOR_HPP
+#ifndef GGL_ITERATORS_VERTEX_ITERATOR_HPP
+#define GGL_ITERATORS_VERTEX_ITERATOR_HPP
#include <boost/type_traits/remove_const.hpp>
+#include <boost/range/metafunctions.hpp>
#include <ggl/core/tag.hpp>
#include <ggl/core/tags.hpp>
+#include <ggl/core/ring_type.hpp>
-#include <boost/range/metafunctions.hpp>
-
namespace ggl
{
@@ -28,49 +28,85 @@
namespace dispatch
{
+template <typename Tag, typename Geometry, bool IsConst>
+struct vertex_iterator
+{};
+
+
template <typename Tag, typename Geometry>
-struct point_const_iterator
+struct vertex_iterator<Tag, Geometry, true>
{
- // The default: meta-forward this to boost
+ // For most geometries: meta-forward this to boost
// This enables calling this function using std::vector as well, even if they
// are not registered.
// It also requires less specializations
typedef typename boost::range_const_iterator<Geometry>::type type;
};
+template <typename Tag, typename Geometry>
+struct vertex_iterator<Tag, Geometry, false>
+{
+ typedef typename boost::range_iterator<Geometry>::type type;
+};
+
+
+
template <typename Polygon>
-struct point_const_iterator<polygon_tag, Polygon>
+struct vertex_iterator<polygon_tag, Polygon, false>
+{
+ typedef typename boost::range_iterator
+ <
+ typename ggl::ring_type<Polygon>::type
+ >::type type;
+};
+
+
+
+template <typename Polygon>
+struct vertex_iterator<polygon_tag, Polygon, true>
{
typedef typename boost::range_const_iterator
<
- typename ring_type<Polygon>::type
+ typename ggl::ring_type<Polygon>::type
>::type type;
};
+
} // namespace dispatch
#endif
/*!
- \brief Meta-function which defines point-const-iterator type
+ \brief Meta-function which defines vertex_iterator type
+ \details The vertex_iterator meta-function enables approaching
+ any geometry with the same type of iterator. It is used within
+ the library in conjuction with sections.
+ A section defines a part of a geometry (linestring, polygon:
+ outer ring or inner ring). The library, at that point, does not
+ need to know if it is a polygon, multi-polygon or ring. Using
+ this meta-function it still does not need to know that.
+ \tparam Geometry the geometry type
+ \tparam is_const: true if const iterator is defined, else false
\ingroup iterators
*/
-template <typename Geometry>
-struct point_const_iterator
+template <typename Geometry, bool IsConst>
+struct vertex_iterator
{
- typedef typename boost::remove_const<Geometry>::type ncg;
- typedef typename dispatch::point_const_iterator<
- typename tag<Geometry>::type, ncg>::type type;
+ typedef typename dispatch::vertex_iterator
+ <
+ typename tag<Geometry>::type,
+ typename boost::remove_const<Geometry>::type,
+ IsConst
+ >::type type;
};
-
}
-#endif // GGL_ITERATORS_POINT_CONST_ITERATOR_HPP
+#endif // GGL_ITERATORS_VERTEX_ITERATOR_HPP
Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/get_section.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/get_section.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/get_section.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -32,7 +32,7 @@
template <typename MultiPolygon, typename Section>
struct get_section<multi_polygon_tag, MultiPolygon, Section>
{
- typedef typename ggl::point_const_iterator<MultiPolygon>::type iterator_type;
+ typedef typename ggl::vertex_iterator<MultiPolygon, true>::type iterator_type;
static inline void apply(MultiPolygon const& multi_polygon, Section const& section,
iterator_type& begin, iterator_type& end)
Modified: sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/overlay/get_intersection_points.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/overlay/get_intersection_points.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/algorithms/overlay/get_intersection_points.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -15,7 +15,7 @@
#include <ggl/multi/algorithms/get_section.hpp>
#include <ggl/multi/algorithms/sectionalize.hpp>
-#include <ggl/multi/iterators/point_const_iterator.hpp>
+#include <ggl/multi/iterators/vertex_iterator.hpp>
#include <ggl/algorithms/overlay/get_intersection_points.hpp>
Deleted: sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/point_const_iterator.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/point_const_iterator.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
+++ (empty file)
@@ -1,50 +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_MULTI_ITERATORS_POINT_CONST_ITERATOR_HPP
-#define GGL_MULTI_ITERATORS_POINT_CONST_ITERATOR_HPP
-
-
-#include <boost/type_traits/remove_const.hpp>
-
-
-#include <ggl/iterators/point_const_iterator.hpp>
-
-
-namespace ggl
-{
-
-
-#ifndef DOXYGEN_NO_DISPATCH
-namespace dispatch
-{
-
-
-template <typename MultiPolygon>
-struct point_const_iterator<multi_polygon_tag, MultiPolygon>
-{
- typedef typename boost::range_value<MultiPolygon>::type polygon_type;
- typedef typename boost::range_const_iterator
- <
- typename ring_type<polygon_type>::type
- >::type type;
-};
-
-
-
-
-} // namespace dispatch
-#endif
-
-
-
-}
-
-
-#endif // GGL_MULTI_ITERATORS_POINT_CONST_ITERATOR_HPP
Copied: sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/vertex_iterator.hpp (from r56825, /sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/point_const_iterator.hpp)
==============================================================================
--- /sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/point_const_iterator.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/multi/iterators/vertex_iterator.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -7,14 +7,12 @@
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef GGL_MULTI_ITERATORS_POINT_CONST_ITERATOR_HPP
-#define GGL_MULTI_ITERATORS_POINT_CONST_ITERATOR_HPP
+#ifndef GGL_MULTI_ITERATORS_VERTEX_ITERATOR_HPP
+#define GGL_MULTI_ITERATORS_VERTEX_ITERATOR_HPP
-#include <boost/type_traits/remove_const.hpp>
-
-#include <ggl/iterators/point_const_iterator.hpp>
+#include <ggl/iterators/vertex_iterator.hpp>
namespace ggl
@@ -27,12 +25,23 @@
template <typename MultiPolygon>
-struct point_const_iterator<multi_polygon_tag, MultiPolygon>
+struct vertex_iterator<multi_polygon_tag, MultiPolygon, false>
+{
+ typedef typename boost::range_value<MultiPolygon>::type polygon_type;
+ typedef typename boost::range_iterator
+ <
+ typename ggl::ring_type<polygon_type>::type
+ >::type type;
+};
+
+
+template <typename MultiPolygon>
+struct vertex_iterator<multi_polygon_tag, MultiPolygon, true>
{
typedef typename boost::range_value<MultiPolygon>::type polygon_type;
typedef typename boost::range_const_iterator
<
- typename ring_type<polygon_type>::type
+ typename ggl::ring_type<polygon_type>::type
>::type type;
};
@@ -47,4 +56,4 @@
}
-#endif // GGL_MULTI_ITERATORS_POINT_CONST_ITERATOR_HPP
+#endif // GGL_MULTI_ITERATORS_VERTEX_ITERATOR_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-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -15,6 +15,7 @@
#include <ggl/core/concepts/point_concept.hpp>
#include <ggl/core/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/transform/matrix_transformers.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/strategies/transform/matrix_transformers.hpp (original)
+++ sandbox/ggl/formal_review_request/boost/ggl/strategies/transform/matrix_transformers.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
@@ -17,7 +17,11 @@
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
+#include <ggl/core/access.hpp>
#include <ggl/core/coordinate_dimension.hpp>
+#include <ggl/core/cs.hpp>
+#include <ggl/util/math.hpp>
+#include <ggl/util/select_coordinate_type.hpp>
namespace ggl
Deleted: sandbox/ggl/formal_review_request/boost/ggl/util/assign_box_corner.hpp
==============================================================================
--- sandbox/ggl/formal_review_request/boost/ggl/util/assign_box_corner.hpp 2009-10-16 15:58:50 EDT (Fri, 16 Oct 2009)
+++ (empty file)
@@ -1,59 +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_UTIL_ASSIGN_BOX_CORNER_HPP
-#define GGL_UTIL_ASSIGN_BOX_CORNER_HPP
-
-#include <cstddef>
-
-#include <boost/numeric/conversion/cast.hpp>
-
-#include <ggl/core/coordinate_dimension.hpp>
-
-// TODO: merge with "assign"
-
-namespace ggl
-{
-
-/*!
- \brief Assign one point of a 2D box
- \ingroup assign
- \todo will be merged with assign
-*/
-template <std::size_t C1, std::size_t C2, typename B, typename P>
-inline void assign_box_corner(B const& box, P& point)
-{
- // Be sure both are 2-Dimensional
- assert_dimension<B, 2>();
- assert_dimension<P, 2>();
-
- // Copy coordinates
- typedef typename coordinate_type<P>::type coordinate_type;
-
- set<0>(point, boost::numeric_cast<coordinate_type>(get<C1, 0>(box)));
- set<1>(point, boost::numeric_cast<coordinate_type>(get<C2, 1>(box)));
-}
-
-/*!
- \brief Assign the 4 points of a 2D box
- \ingroup assign
- \todo will be merged with 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)
-{
- assign_box_corner<min_corner, min_corner>(box, lower_left);
- assign_box_corner<max_corner, min_corner>(box, lower_right);
- assign_box_corner<min_corner, max_corner>(box, upper_left);
- assign_box_corner<max_corner, max_corner>(box, upper_right);
-}
-
-} // namespace
-
-#endif // GGL_UTIL_ASSIGN_BOX_CORNER_HPP
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk