diff --git a/include/boost/geometry/geometries/adapted/boost_array.hpp b/include/boost/geometry/geometries/adapted/boost_array.hpp new file mode 100644 index 000000000..db5efb244 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_array.hpp @@ -0,0 +1,112 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010 Alfredo Correa +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP + + +#ifdef BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED +#error Include either "boost_array_as_point" or \ + "boost_array_as_linestring" or "boost_array_as_ring" \ + or "boost_array_as_multi_point" to adapt a boost_array +#endif + +#define BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED + + +#include + +#include + +#include +#include +#include +#include +#include + +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + + +// Create class and specialization to indicate the tag +// for normal cases and the case that the type of the c-array is arithmetic +template +struct boost_array_tag +{ + typedef geometry_not_recognized_tag type; +}; + + +template <> +struct boost_array_tag +{ + typedef point_tag type; +}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +// Assign the point-tag, preventing arrays of points getting a point-tag +template +struct tag > + : detail::boost_array_tag::value> {}; + + +template +struct coordinate_type > +{ + typedef CoordinateType type; +}; + + +template +struct dimension >: boost::mpl::int_ {}; + + +template +struct access, Dimension> +{ + static inline CoordinateType get(boost::array const& a) + { + return a[Dimension]; + } + + static inline void set(boost::array& a, + CoordinateType const& value) + { + a[Dimension] = value; + } +}; + +// The library user has +// 1) either to specify the coordinate system +// 2) or include where @=cartesian,geographic,... + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp b/include/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp new file mode 100644 index 000000000..7e6396fa0 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_array_as_linestring.hpp @@ -0,0 +1,87 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_AS_LINESTRING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_AS_LINESTRING_HPP + + +#ifdef BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED +#error Include either "boost_array_as_point" or \ + "boost_array_as_linestring" or "boost_array_as_ring" \ + or "boost_array_as_multi_point" to adapt a boost_array +#endif + +#define BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED + + +#include +#include + +#include + +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag< boost::array > +{ + typedef linestring_tag type; +}; + +// boost::array is immutable with respect to size +// Therefore, prohibit compilation +template +struct clear< boost::array > +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_BOOST_ARRAY_OF, (types) + ); +}; + +template +struct resize< boost::array > +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_BOOST_ARRAY_OF, (types) + ); +}; + +template +struct push_back< boost::array > +{ + BOOST_MPL_ASSERT_MSG + ( + false, NOT_IMPLEMENTED_FOR_BOOST_ARRAY_OF, (types) + ); +}; + +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_AS_LINESTRING_HPP diff --git a/include/boost/geometry/geometries/adapted/boost_array_as_ring.hpp b/include/boost/geometry/geometries/adapted/boost_array_as_ring.hpp new file mode 100644 index 000000000..c71019672 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_array_as_ring.hpp @@ -0,0 +1,56 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_AS_RING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_AS_RING_HPP + + +#ifdef BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED +#error Include either "boost_array_as_point" or \ + "boost_array_as_linestring" or "boost_array_as_ring" \ + or "boost_array_as_multi_point" to adapt a boost_array +#endif + +#define BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED + + +#include + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + + template + struct tag< boost::array > + { + typedef ring_tag type; + }; + +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_AS_RING_HPP diff --git a/include/boost/geometry/geometries/adapted/boost_array_cartesian.hpp b/include/boost/geometry/geometries/adapted/boost_array_cartesian.hpp new file mode 100644 index 000000000..a11c9e2bb --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_array_cartesian.hpp @@ -0,0 +1,42 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010 Alfredo Correa +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_CARTESIAN_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_CARTESIAN_HPP + +#ifdef BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_COORDINATE_SYSTEM_DEFINED +#error Include only one headerfile to register coordinate coordinate_system for adapted boost array +#endif + +#define BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_COORDINATE_SYSTEM_DEFINED + + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + template + struct coordinate_system > + { typedef cs::cartesian type; }; + +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_CARTESIAN_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_array_geographic.hpp b/include/boost/geometry/geometries/adapted/boost_array_geographic.hpp new file mode 100644 index 000000000..ca103520e --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_array_geographic.hpp @@ -0,0 +1,40 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010 Alfredo Correa +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_GEOGRAPHIC_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_GEOGRAPHIC_HPP + +#ifdef BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_COORDINATE_SYSTEM_DEFINED +#error Include only one headerfile to register coordinate coordinate_system for adapted boost array +#endif + +#define BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_COORDINATE_SYSTEM_DEFINED + + +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + template + struct coordinate_system > + { typedef cs::geographic type; }; + +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_GEOGRAPHIC_HPP diff --git a/include/boost/geometry/geometries/adapted/boost_polygon/box.hpp b/include/boost/geometry/geometries/adapted/boost_polygon/box.hpp new file mode 100644 index 000000000..a7c9767d7 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon/box.hpp @@ -0,0 +1,141 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP + +// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry +// boost::polygon::rectangle_data -> boost::geometry::box + + +#include + +#include +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + + +template +struct tag > +{ + typedef box_tag type; +}; + + +template +struct point_type > +{ + // Not sure what to do here. Boost.Polygon's rectangle does NOT define its + // point_type (but uses it...) + typedef boost::polygon::point_data type; +}; + + +template +struct indexed_access +< + boost::polygon::rectangle_data, + min_corner, 0 +> +{ + typedef boost::polygon::rectangle_data box_type; + + static inline CoordinateType get(box_type const& b) + { + return boost::polygon::xl(b); + } + + static inline void set(box_type& b, CoordinateType const& value) + { + boost::polygon::xl(b, value); + } +}; + + +template +struct indexed_access +< + boost::polygon::rectangle_data, + min_corner, 1 +> +{ + typedef boost::polygon::rectangle_data box_type; + + static inline CoordinateType get(box_type const& b) + { + return boost::polygon::yl(b); + } + + static inline void set(box_type& b, CoordinateType const& value) + { + boost::polygon::yl(b, value); + } +}; + + +template +struct indexed_access +< + boost::polygon::rectangle_data, + max_corner, 0 +> +{ + typedef boost::polygon::rectangle_data box_type; + + static inline CoordinateType get(box_type const& b) + { + return boost::polygon::xh(b); + } + + static inline void set(box_type& b, CoordinateType const& value) + { + boost::polygon::xh(b, value); + } +}; + + +template +struct indexed_access +< + boost::polygon::rectangle_data, + max_corner, 1 +> +{ + typedef boost::polygon::rectangle_data box_type; + + static inline CoordinateType get(box_type const& b) + { + return boost::polygon::yh(b); + } + + static inline void set(box_type& b, CoordinateType const& value) + { + boost::polygon::yh(b, value); + } +}; + + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP diff --git a/include/boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp b/include/boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp new file mode 100644 index 000000000..c5f05e0c5 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp @@ -0,0 +1,84 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP + +// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry +// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon +// hole_iterator -> returning ring_proxy's instead of normal polygon_data + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace adapt { namespace bp +{ + + +template +class hole_iterator + : public ::boost::iterator_facade + < + hole_iterator, + RingProxy, // value type + boost::forward_traversal_tag, + RingProxy // reference type + > +{ +public : + typedef typename boost::polygon::polygon_with_holes_traits + < + Polygon + >::iterator_holes_type ith_type; + + explicit inline hole_iterator(Polygon& polygon, ith_type const it) + : m_polygon(polygon) + , m_base(it) + { + } + + typedef std::ptrdiff_t difference_type; + +private: + friend class boost::iterator_core_access; + + inline RingProxy dereference() const + { + return RingProxy(m_polygon, this->m_base); + } + + inline void increment() { ++m_base; } + inline void decrement() { --m_base; } + inline void advance(difference_type n) + { + for (int i = 0; i < n; i++) + { + ++m_base; + } + } + + inline bool equal(hole_iterator const& other) const + { + return this->m_base == other.m_base; + } + + Polygon& m_polygon; + ith_type m_base; +}; + + +}}}} + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_polygon/holes_proxy.hpp b/include/boost/geometry/geometries/adapted/boost_polygon/holes_proxy.hpp new file mode 100644 index 000000000..bba0c272f --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon/holes_proxy.hpp @@ -0,0 +1,204 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLES_PROXY_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLES_PROXY_HPP + +// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry +// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon +// pair{begin_holes, begin_holes} -> interior_proxy + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace adapt { namespace bp +{ + + +// Polygon should implement the boost::polygon::polygon_with_holes_concept +// Specify constness in the template parameter if necessary +template +struct holes_proxy +{ + typedef ring_proxy + < + typename boost::mpl::if_ + < + typename boost::is_const, + Polygon const, + Polygon + >::type + > proxy_type; + typedef hole_iterator iterator_type; + + // The next line does not work probably because coordinate_type is part of the + // polygon_traits, but not of the polygon_with_holes_traits + // typedef typename boost::polygon::polygon_traits::coordinate_type coordinate_type; + + // So we use: + typedef typename Polygon::coordinate_type coordinate_type; + + inline holes_proxy(Polygon& p) + : polygon(p) + {} + + inline void clear() + { + Polygon empty; + // Clear the holes + polygon.set_holes + ( + boost::polygon::begin_holes(empty), + boost::polygon::end_holes(empty) + ); + } + + inline void resize(std::size_t new_size) + { + std::vector > temporary_copy + ( + boost::polygon::begin_holes(polygon), + boost::polygon::end_holes(polygon) + ); + temporary_copy.resize(new_size); + polygon.set_holes(temporary_copy.begin(), temporary_copy.end()); + } + + template + inline void push_back(Ring const& ring) + { + std::vector > temporary_copy + ( + boost::polygon::begin_holes(polygon), + boost::polygon::end_holes(polygon) + ); + boost::polygon::polygon_data added; + boost::polygon::set_points(added, ring.begin(), ring.end()); + temporary_copy.push_back(added); + polygon.set_holes(temporary_copy.begin(), temporary_copy.end()); + } + + + Polygon& polygon; +}; + + +// Support holes_proxy for Boost.Range ADP + +// Const versions +template +inline typename boost::geometry::adapt::bp::holes_proxy::iterator_type + range_begin(boost::geometry::adapt::bp::holes_proxy const& proxy) +{ + typename boost::geometry::adapt::bp::holes_proxy::iterator_type + begin(proxy.polygon, boost::polygon::begin_holes(proxy.polygon)); + return begin; +} + +template +inline typename boost::geometry::adapt::bp::holes_proxy::iterator_type + range_end(boost::geometry::adapt::bp::holes_proxy const& proxy) +{ + typename boost::geometry::adapt::bp::holes_proxy::iterator_type + end(proxy.polygon, boost::polygon::end_holes(proxy.polygon)); + return end; +} + +// Mutable versions +template +inline typename boost::geometry::adapt::bp::holes_proxy::iterator_type + range_begin(boost::geometry::adapt::bp::holes_proxy& proxy) +{ + typename boost::geometry::adapt::bp::holes_proxy::iterator_type + begin(proxy.polygon, boost::polygon::begin_holes(proxy.polygon)); + return begin; +} + +template +inline typename boost::geometry::adapt::bp::holes_proxy::iterator_type + range_end(boost::geometry::adapt::bp::holes_proxy& proxy) +{ + typename boost::geometry::adapt::bp::holes_proxy::iterator_type + end(proxy.polygon, boost::polygon::end_holes(proxy.polygon)); + return end; +} + + +}} + +namespace traits +{ + +template +struct rvalue_type > +{ + typedef adapt::bp::holes_proxy type; +}; + + +template +struct clear > +{ + static inline void apply(adapt::bp::holes_proxy proxy) + { + proxy.clear(); + } +}; + +template +struct resize > +{ + static inline void apply(adapt::bp::holes_proxy proxy, std::size_t new_size) + { + proxy.resize(new_size); + } +}; + +template +struct push_back > +{ + template + static inline void apply(adapt::bp::holes_proxy proxy, Ring const& ring) + { + proxy.push_back(ring); + } +}; + + + +} // namespace traits + + +}} + + +// Specialize holes_proxy for Boost.Range +namespace boost +{ + template + struct range_mutable_iterator > + { + typedef typename geometry::adapt::bp::holes_proxy::iterator_type type; + }; + + template + struct range_const_iterator > + { + typedef typename geometry::adapt::bp::holes_proxy::iterator_type type; + }; + +} // namespace boost + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLES_PROXY_HPP diff --git a/include/boost/geometry/geometries/adapted/boost_polygon/point.hpp b/include/boost/geometry/geometries/adapted/boost_polygon/point.hpp new file mode 100644 index 000000000..8f39c917d --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon/point.hpp @@ -0,0 +1,102 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP + +// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry +// boost::polygon::point_data -> boost::geometry::point + + +#include + +#include +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + + +template +struct tag > +{ + typedef point_tag type; +}; + + +template +struct coordinate_type > +{ + typedef CoordinateType type; +}; + + +template +struct coordinate_system > +{ + typedef cs::cartesian type; +}; + + +template +struct dimension > + : boost::mpl::int_<2> +{}; + + +template +struct access, 0> +{ + typedef boost::polygon::point_data point_type; + + static inline CoordinateType get(point_type const& p) + { + return p.x(); + } + + static inline void set(point_type& p, CoordinateType const& value) + { + p.x(value); + } +}; + + +template +struct access, 1> +{ + typedef boost::polygon::point_data point_type; + + static inline CoordinateType get(point_type const& p) + { + return p.y(); + } + + static inline void set(point_type& p, CoordinateType const& value) + { + p.y(value); + } +}; + + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP diff --git a/include/boost/geometry/geometries/adapted/boost_polygon/polygon.hpp b/include/boost/geometry/geometries/adapted/boost_polygon/polygon.hpp new file mode 100644 index 000000000..426608fd5 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon/polygon.hpp @@ -0,0 +1,111 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP + +// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry +// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon + +#include + +#include +#include +#include +#include + +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag > +{ + typedef polygon_tag type; +}; + +template +struct ring_const_type > +{ + typedef adapt::bp::ring_proxy const> type; +}; + +template +struct ring_mutable_type > +{ + typedef adapt::bp::ring_proxy > type; +}; + +template +struct interior_const_type > +{ + typedef adapt::bp::holes_proxy const> type; +}; + +template +struct interior_mutable_type > +{ + typedef adapt::bp::holes_proxy > type; +}; + + +template +struct exterior_ring > +{ + typedef boost::polygon::polygon_with_holes_data polygon_type; + typedef adapt::bp::ring_proxy proxy; + typedef adapt::bp::ring_proxy const_proxy; + + static inline proxy get(polygon_type& p) + { + return proxy(p); + } + + static inline const_proxy get(polygon_type const& p) + { + return const_proxy(p); + } +}; + +template +struct interior_rings > +{ + typedef boost::polygon::polygon_with_holes_data polygon_type; + typedef adapt::bp::holes_proxy proxy; + typedef adapt::bp::holes_proxy const_proxy; + + static inline proxy get(polygon_type& p) + { + return proxy(p); + } + + static inline const_proxy get(polygon_type const& p) + { + return const_proxy(p); + } +}; + + + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_polygon/ring.hpp b/include/boost/geometry/geometries/adapted/boost_polygon/ring.hpp new file mode 100644 index 000000000..a8aabfb71 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon/ring.hpp @@ -0,0 +1,163 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP + +// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry +// boost::polygon::polygon_data -> boost::geometry::ring + +#include +#include + +#include +#include +#include +#include +#include +#include + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +namespace boost { namespace geometry +{ + +namespace traits +{ + +template +struct tag > +{ + typedef ring_tag type; +}; + +template +struct clear > +{ + static inline void apply(boost::polygon::polygon_data& data) + { + // There is no "clear" function but we can assign + // a newly (and therefore empty) constructed polygon + boost::polygon::assign(data, boost::polygon::polygon_data()); + } +}; + +template +struct push_back > +{ + typedef boost::polygon::point_data point_type; + + static inline void apply(boost::polygon::polygon_data& data, + point_type const& point) + { + // Boost.Polygon's polygons are not appendable. So create a temporary vector, + // add a record and set it to the original. Of course: this is not efficient. + // But there seems no other way (without using a wrapper) + std::vector temporary_vector + ( + boost::polygon::begin_points(data), + boost::polygon::end_points(data) + ); + temporary_vector.push_back(point); + data.set(temporary_vector.begin(), temporary_vector.end()); + } +}; + + + + +} // namespace traits + +}} // namespace boost::geometry + + +// Adapt Boost.Polygon's polygon_data to Boost.Range +// This just translates to +// polygon_data.begin() and polygon_data.end() +namespace boost +{ + template + struct range_mutable_iterator > + { + typedef typename boost::polygon::polygon_traits + < + boost::polygon::polygon_data + >::iterator_type type; + }; + + template + struct range_const_iterator > + { + typedef typename boost::polygon::polygon_traits + < + boost::polygon::polygon_data + >::iterator_type type; + }; + + template + struct range_size > + { + typedef std::size_t type; + }; + +} // namespace boost + + +// Support Boost.Polygon's polygon_data for Boost.Range ADP +namespace boost { namespace polygon +{ + +template +inline typename polygon_traits + < + polygon_data + >::iterator_type range_begin(polygon_data& polygon) +{ + return polygon.begin(); +} + +template +inline typename polygon_traits + < + polygon_data + >::iterator_type range_begin(polygon_data const& polygon) +{ + return polygon.begin(); +} + +template +inline typename polygon_traits + < + polygon_data + >::iterator_type range_end(polygon_data& polygon) +{ + return polygon.end(); +} + +template +inline typename polygon_traits + < + polygon_data + >::iterator_type range_end(polygon_data const& polygon) +{ + return polygon.end(); +} + +template +inline std::size_t range_calculate_size(polygon_data const& polygon) +{ + return polygon.size(); +} + +}} + +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP diff --git a/include/boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp b/include/boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp new file mode 100644 index 000000000..df1ee1d46 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp @@ -0,0 +1,301 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_PROXY_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_PROXY_HPP + +// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry +// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon +// pair{begin_points, end_points} -> ring_proxy + +#include +#include + + + +namespace boost { namespace geometry +{ + +namespace adapt { namespace bp +{ + +namespace detail +{ + +template +struct modify +{}; + +template <> +struct modify +{ + template + static inline void push_back(Ring& ring, Point const& point) + { + // Boost.Polygon's polygons are not appendable. So create a temporary vector, + // add a record and set it to the original. Of course: this is not efficient. + // But there seems no other way (without using a wrapper) + std::vector temporary_vector + ( + boost::polygon::begin_points(ring), + boost::polygon::end_points(ring) + ); + temporary_vector.push_back(point); + boost::polygon::set_points(ring, temporary_vector.begin(), temporary_vector.end()); + } + +}; + +template <> +struct modify +{ + template + static inline void push_back(Ring& ring, Point const& point) + { + } + +}; + + +} + + +// Polygon should implement the boost::polygon::polygon_with_holes_concept +// Specify constness in the template parameter if necessary +template +class ring_proxy +{ +public : + typedef typename boost::polygon::polygon_traits + < + typename boost::remove_const::type + >::iterator_type iterator_type; + + typedef typename boost::polygon::polygon_with_holes_traits + < + typename boost::remove_const::type + >::iterator_holes_type hole_iterator_type; + + static const bool is_mutable = !boost::is_const::type::value; + + inline ring_proxy(Polygon& p) + : m_polygon_pointer(&p) + , m_do_hole(false) + {} + + // Constructor used from hole_iterator + inline ring_proxy(Polygon& p, hole_iterator_type hole_it) + : m_polygon_pointer(&p) + , m_do_hole(true) + , m_hole_it(hole_it) + {} + + // Default constructor, for mutable polygons / appending (interior) rings + inline ring_proxy() + : m_polygon_pointer(&m_polygon_for_default_constructor) + , m_do_hole(false) + {} + + + iterator_type begin() const + { + return m_do_hole + ? boost::polygon::begin_points(*m_hole_it) + : boost::polygon::begin_points(*m_polygon_pointer) + ; + } + + iterator_type begin() + { + return m_do_hole + ? boost::polygon::begin_points(*m_hole_it) + : boost::polygon::begin_points(*m_polygon_pointer) + ; + } + + iterator_type end() const + { + return m_do_hole + ? boost::polygon::end_points(*m_hole_it) + : boost::polygon::end_points(*m_polygon_pointer) + ; + } + + iterator_type end() + { + return m_do_hole + ? boost::polygon::end_points(*m_hole_it) + : boost::polygon::end_points(*m_polygon_pointer) + ; + } + + // Mutable + void clear() + { + Polygon p; + if (m_do_hole) + { + // Does NOT work see comment above + } + else + { + boost::polygon::set_points(*m_polygon_pointer, + boost::polygon::begin_points(p), + boost::polygon::end_points(p)); + } + } + + void resize(std::size_t new_size) + { + if (m_do_hole) + { + // Does NOT work see comment above + } + else + { + // TODO: implement this by resizing the container + } + } + + + + template + void push_back(Point const& point) + { + if (m_do_hole) + { + //detail::modify::push_back(*m_hole_it, point); + //std::cout << "HOLE: " << typeid(*m_hole_it).name() << std::endl; + //std::cout << "HOLE: " << typeid(m_hole_it).name() << std::endl; + //std::cout << "HOLE: " << typeid(hole_iterator_type).name() << std::endl; + + // Note, ths does NOT work because hole_iterator_type is defined + // as a const_iterator by Boost.Polygon + + } + else + { + detail::modify::push_back(*m_polygon_pointer, point); + } + } + +private : + Polygon* m_polygon_pointer; + bool m_do_hole; + hole_iterator_type m_hole_it; + + Polygon m_polygon_for_default_constructor; +}; + + + + +// Support geometry::adapt::bp::ring_proxy for Boost.Range ADP +template +inline typename boost::geometry::adapt::bp::ring_proxy::iterator_type + range_begin(boost::geometry::adapt::bp::ring_proxy& proxy) +{ + return proxy.begin(); +} + +template +inline typename boost::geometry::adapt::bp::ring_proxy::iterator_type + range_begin(boost::geometry::adapt::bp::ring_proxy const& proxy) +{ + return proxy.begin(); +} + +template +inline typename boost::geometry::adapt::bp::ring_proxy::iterator_type + range_end(boost::geometry::adapt::bp::ring_proxy& proxy) +{ + return proxy.end(); +} + +template +inline typename boost::geometry::adapt::bp::ring_proxy::iterator_type + range_end(boost::geometry::adapt::bp::ring_proxy const& proxy) +{ + return proxy.end(); +} + + + + +}} // namespace adapt::bp + + +namespace traits +{ + +template +struct tag > +{ + typedef ring_tag type; +}; + + +template +struct rvalue_type > +{ + typedef adapt::bp::ring_proxy type; +}; + +template +struct clear > +{ + static inline void apply(adapt::bp::ring_proxy proxy) + { + proxy.clear(); + } +}; + + +template +struct resize > +{ + static inline void apply(adapt::bp::ring_proxy proxy, std::size_t new_size) + { + proxy.resize(new_size); + } +}; + +template +struct push_back > +{ + static inline void apply(adapt::bp::ring_proxy proxy, + typename boost::polygon::polygon_traits::point_type const& point) + { + proxy.push_back(point); + } +}; + + +} // namespace traits + +}} // namespace boost::geometry + +// Specialize ring_proxy for Boost.Range +namespace boost +{ + template + struct range_mutable_iterator > + { + typedef typename geometry::adapt::bp::ring_proxy::iterator_type type; + }; + + template + struct range_const_iterator > + { + typedef typename geometry::adapt::bp::ring_proxy::iterator_type type; + }; + +} // namespace boost + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_PROXY_HPP diff --git a/include/boost/geometry/geometries/adapted/boost_range/adjacent_filtered.hpp b/include/boost/geometry/geometries/adapted/boost_range/adjacent_filtered.hpp new file mode 100644 index 000000000..4bc628cc4 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_range/adjacent_filtered.hpp @@ -0,0 +1,40 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_ADJACENT_FILTERED_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_ADJACENT_FILTERED_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +template +#if BOOST_VERSION > 104500 +struct tag > +#else +struct tag > +#endif +{ + typedef typename geometry::tag::type type; +}; + +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_ADJACENT_FILTERED_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_range/filtered.hpp b/include/boost/geometry/geometries/adapted/boost_range/filtered.hpp new file mode 100644 index 000000000..72cd57f99 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_range/filtered.hpp @@ -0,0 +1,40 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_FILTERED_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_FILTERED_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +template +#if BOOST_VERSION > 104500 +struct tag > +#else +struct tag > +#endif +{ + typedef typename geometry::tag::type type; +}; + +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_FILTERED_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_range/reversed.hpp b/include/boost/geometry/geometries/adapted/boost_range/reversed.hpp new file mode 100644 index 000000000..d80f50f70 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_range/reversed.hpp @@ -0,0 +1,40 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_REVERSED_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_REVERSED_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +template +#if BOOST_VERSION > 104500 +struct tag > +#else +struct tag > +#endif +{ + typedef typename geometry::tag::type type; +}; + +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_REVERSED_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_range/sliced.hpp b/include/boost/geometry/geometries/adapted/boost_range/sliced.hpp new file mode 100644 index 000000000..c1d7792e1 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_range/sliced.hpp @@ -0,0 +1,36 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_SLICED_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_SLICED_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +template +struct tag > +{ + typedef typename geometry::tag::type type; +}; + +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_SLICED_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_range/strided.hpp b/include/boost/geometry/geometries/adapted/boost_range/strided.hpp new file mode 100644 index 000000000..28803eef3 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_range/strided.hpp @@ -0,0 +1,36 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_STRIDED_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_STRIDED_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +template +struct tag > +{ + typedef typename geometry::tag::type type; +}; + +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_STRIDED_HPP + diff --git a/include/boost/geometry/geometries/adapted/boost_range/uniqued.hpp b/include/boost/geometry/geometries/adapted/boost_range/uniqued.hpp new file mode 100644 index 000000000..d163f6bb3 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/boost_range/uniqued.hpp @@ -0,0 +1,40 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2010-2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_UNIQUED_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_UNIQUED_HPP + + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace traits +{ + +template +#if BOOST_VERSION > 104500 +struct tag > +#else +struct tag > +#endif +{ + typedef typename geometry::tag::type type; +}; + +} + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_UNIQUED_HPP + diff --git a/include/boost/geometry/geometries/adapted/c_array.hpp b/include/boost/geometry/geometries/adapted/c_array.hpp new file mode 100644 index 000000000..0e2209b43 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/c_array.hpp @@ -0,0 +1,103 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP + +#include + +#include + +#include +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + + +// Create class and specialization to indicate the tag +// for normal cases and the case that the type of the c-array is arithmetic +template +struct c_array_tag +{ + typedef geometry_not_recognized_tag type; +}; + + +template <> +struct c_array_tag +{ + typedef point_tag type; +}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +// Assign the point-tag, preventing arrays of points getting a point-tag +template +struct tag + : detail::c_array_tag::value> {}; + + +template +struct coordinate_type +{ + typedef CoordinateType type; +}; + + +template +struct dimension: boost::mpl::int_ {}; + + +template +struct access +{ + static inline CoordinateType get(CoordinateType const p[DimensionCount]) + { + return p[Dimension]; + } + + static inline void set(CoordinateType p[DimensionCount], + CoordinateType const& value) + { + p[Dimension] = value; + } +}; + +// The library user has +// 1) either to specify the coordinate system +// 2) or include where @=cartesian,geographic,... + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP diff --git a/include/boost/geometry/geometries/adapted/c_array_as_linestring.hpp b/include/boost/geometry/geometries/adapted/c_array_as_linestring.hpp new file mode 100644 index 000000000..41b4319c6 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/c_array_as_linestring.hpp @@ -0,0 +1,51 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_AS_LINESTRING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_AS_LINESTRING_HPP + + +#ifdef BOOST_GEOMETRY_ADAPTED_C_ARRAY_AS_POINT_COLLECTION_TAG_DEFINED +#error Include either "c_array_as_linestring" or "c_array_as_ring" \ + or "c_array_as_multi_point" to adapt a c array +#endif + +#define BOOST_GEOMETRY_ADAPTED_C_ARRAY_AS_POINT_COLLECTION_TAG_DEFINED + + +#include + +#include +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + + template + struct tag< T[PointCount][DimensionCount] > + { + typedef linestring_tag type; + }; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_AS_LINESTRING_HPP diff --git a/include/boost/geometry/geometries/adapted/c_array_as_ring.hpp b/include/boost/geometry/geometries/adapted/c_array_as_ring.hpp new file mode 100644 index 000000000..604da8e39 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/c_array_as_ring.hpp @@ -0,0 +1,51 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_AS_RING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_AS_RING_HPP + + +#ifdef BOOST_GEOMETRY_ADAPTED_C_ARRAY_AS_POINT_COLLECTION_TAG_DEFINED +#error Include either "c_array_as_linestring" or "c_array_as_ring" \ + or "c_array_as_multi_point" to adapt a c array +#endif + +#define BOOST_GEOMETRY_ADAPTED_C_ARRAY_AS_POINT_COLLECTION_TAG_DEFINED + + +#include + +#include +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + + template + struct tag< T[PointCount][DimensionCount] > + { + typedef ring_tag type; + }; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_AS_RING_HPP diff --git a/include/boost/geometry/geometries/adapted/c_array_cartesian.hpp b/include/boost/geometry/geometries/adapted/c_array_cartesian.hpp new file mode 100644 index 000000000..dc1efcaca --- /dev/null +++ b/include/boost/geometry/geometries/adapted/c_array_cartesian.hpp @@ -0,0 +1,45 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_CARTESIAN_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_CARTESIAN_HPP + +#ifdef BOOST_GEOMETRY_ADAPTED_C_ARRAY_COORDINATE_SYSTEM_DEFINED +#error Include only one headerfile to register coordinate coordinate_system for adapted c array +#endif + +#define BOOST_GEOMETRY_ADAPTED_C_ARRAY_COORDINATE_SYSTEM_DEFINED + + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + template + struct coordinate_system + { typedef cs::cartesian type; }; + +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_CARTESIAN_HPP diff --git a/include/boost/geometry/geometries/adapted/c_array_geographic.hpp b/include/boost/geometry/geometries/adapted/c_array_geographic.hpp new file mode 100644 index 000000000..f9003acf3 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/c_array_geographic.hpp @@ -0,0 +1,43 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_GEOGRAPHIC_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_GEOGRAPHIC_HPP + +#ifdef BOOST_GEOMETRY_ADAPTED_C_ARRAY_COORDINATE_SYSTEM_DEFINED +#error Include only one headerfile to register coordinate coordinate_system for adapted c array +#endif + +#define BOOST_GEOMETRY_ADAPTED_C_ARRAY_COORDINATE_SYSTEM_DEFINED + +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + template + struct coordinate_system + { typedef cs::geographic type; }; + +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_GEOGRAPHIC_HPP diff --git a/include/boost/geometry/geometries/adapted/fusion.hpp b/include/boost/geometry/geometries/adapted/fusion.hpp new file mode 100644 index 000000000..81d89230a --- /dev/null +++ b/include/boost/geometry/geometries/adapted/fusion.hpp @@ -0,0 +1,159 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2011 Akira Takahashi +// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_HPP + + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + +namespace fusion_adapt_detail +{ + +template +struct all_same : + boost::mpl::bool_< + boost::mpl::count_if< + Sequence, + boost::is_same< + typename boost::mpl::front::type, + boost::mpl::_ + > + >::value == boost::mpl::size::value + > +{}; + +template +struct is_coordinate_size : boost::mpl::bool_< + boost::fusion::result_of::size::value == 2 || + boost::fusion::result_of::size::value == 3> {}; + +template +struct is_fusion_sequence + : mpl::and_, + fusion_adapt_detail::is_coordinate_size, + fusion_adapt_detail::all_same > +{}; + + +} // namespace fusion_adapt_detail + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +// Boost Fusion Sequence, 2D or 3D +template +struct coordinate_type + < + Sequence, + typename boost::enable_if + < + fusion_adapt_detail::is_fusion_sequence + >::type + > +{ + typedef typename boost::mpl::front::type type; +}; + + +template +struct dimension + < + Sequence, + typename boost::enable_if + < + fusion_adapt_detail::is_fusion_sequence + >::type + > : boost::mpl::size +{}; + + +template +struct access + < + Sequence, + Dimension, + typename boost::enable_if + < + fusion_adapt_detail::is_fusion_sequence + >::type + > +{ + typedef typename coordinate_type::type ctype; + + static inline ctype get(Sequence const& point) + { + return boost::fusion::at_c(point); + } + + template + static inline void set(Sequence& point, CoordinateType const& value) + { + boost::fusion::at_c(point) = value; + } +}; + +// The library user has +// 1) either to specify the coordinate system using a traits class +// 2) or include +// where @=cartesian,geographic,... + +template +struct tag + < + Sequence, + typename boost::enable_if + < + fusion_adapt_detail::is_fusion_sequence + >::type + > +{ + typedef point_tag type; +}; + +} // namespace traits + +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_HPP + diff --git a/include/boost/geometry/geometries/adapted/fusion_cartesian.hpp b/include/boost/geometry/geometries/adapted/fusion_cartesian.hpp new file mode 100644 index 000000000..2aa17a712 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/fusion_cartesian.hpp @@ -0,0 +1,44 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2011 Akira Takahashi +// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_CARTESIAN_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_CARTESIAN_HPP + +#ifdef BOOST_GEOMETRY_ADAPTED_FUSION_COORDINATE_SYSTEM_DEFINED +#error Include only one headerfile to register coordinate coordinate_system for adapted fusion +#endif + +#define BOOST_GEOMETRY_ADAPTED_FUSION_COORDINATE_SYSTEM_DEFINED + + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + template + struct coordinate_system< + Sequence, + typename boost::enable_if< + fusion_adapt_detail::is_fusion_sequence >::type> + { typedef cs::cartesian type; }; + +} // namespace traits +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_CARTESIAN_HPP diff --git a/include/boost/geometry/geometries/adapted/fusion_geographic.hpp b/include/boost/geometry/geometries/adapted/fusion_geographic.hpp new file mode 100644 index 000000000..4e693af4e --- /dev/null +++ b/include/boost/geometry/geometries/adapted/fusion_geographic.hpp @@ -0,0 +1,44 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2011 Akira Takahashi +// Copyright (c) 2011 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_GEOGRAPHIC_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_GEOGRAPHIC_HPP + +#ifdef BOOST_GEOMETRY_ADAPTED_FUSION_COORDINATE_SYSTEM_DEFINED +#error Include only one headerfile to register coordinate coordinate_system for adapted fusion +#endif + +#define BOOST_GEOMETRY_ADAPTED_FUSION_COORDINATE_SYSTEM_DEFINED + + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + template + struct coordinate_system< + Sequence, + typename boost::enable_if< + fusion_adapt_detail::is_fusion_sequence >::type> + { typedef cs::geographic type; }; + +} // namespace traits +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_GEOGRAPHIC_HPP diff --git a/include/boost/geometry/geometries/adapted/std_as_linestring.hpp b/include/boost/geometry/geometries/adapted/std_as_linestring.hpp new file mode 100644 index 000000000..8abf0a8bd --- /dev/null +++ b/include/boost/geometry/geometries/adapted/std_as_linestring.hpp @@ -0,0 +1,72 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_AS_LINESTRING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_AS_LINESTRING_HPP + + +#ifdef BOOST_GEOMETRY_ADAPTED_STD_AS_POINT_COLLECTION_TAG_DEFINED +#error Include either "std_as_linestring" or "std_as_ring" \ + or "std_as_multi_point" to adapt the std:: containers +#endif + +#define BOOST_GEOMETRY_ADAPTED_STD_AS_POINT_COLLECTION_TAG_DEFINED + + +#include +#include +#include +#include + + +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace util +{ + struct std_as_linestring + { + typedef linestring_tag type; + }; + +} +#endif + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + // specialization for an iterator pair (read only) + template struct tag< std::pair > : util::std_as_linestring {}; + + // specializations for the std:: containers: vector, deque, list + template struct tag< std::vector

> : util::std_as_linestring {}; + template struct tag< std::deque

> : util::std_as_linestring {}; + template struct tag< std::list

> : util::std_as_linestring {}; + +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_AS_LINESTRING_HPP diff --git a/include/boost/geometry/geometries/adapted/std_as_ring.hpp b/include/boost/geometry/geometries/adapted/std_as_ring.hpp new file mode 100644 index 000000000..30b802430 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/std_as_ring.hpp @@ -0,0 +1,54 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_AS_RING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_AS_RING_HPP + + +#ifdef BOOST_GEOMETRY_ADAPTED_STD_AS_POINT_COLLECTION_TAG_DEFINED +#error Include either "std_as_linestring" or "std_as_ring" \ + or "std_as_multi_point" to adapt the std:: containers +#endif + +#define BOOST_GEOMETRY_ADAPTED_STD_AS_POINT_COLLECTION_TAG_DEFINED + + +#include +#include +#include +#include + +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + // specialization for an iterator pair + template struct tag< std::pair > { typedef ring_tag type; }; + + // specialization for the std:: containers: vector, deque, list + template struct tag< std::vector > { typedef ring_tag type; }; + template struct tag< std::deque > { typedef ring_tag type; }; + template struct tag< std::list > { typedef ring_tag type; }; +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_AS_RING_HPP diff --git a/include/boost/geometry/geometries/adapted/std_pair_as_segment.hpp b/include/boost/geometry/geometries/adapted/std_pair_as_segment.hpp new file mode 100644 index 000000000..636770df8 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/std_pair_as_segment.hpp @@ -0,0 +1,98 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP + +// Only possible if the std::pair is not used for iterator/pair +// (maybe it is possible to avoid that by detecting in the other file +// if an iterator was used in the pair) + +#ifdef BOOST_GEOMETRY_ADAPTED_STD_RANGE_TAG_DEFINED +#error Include only one headerfile to register tag for adapted std:: containers or iterator pair +#endif + +#define BOOST_GEOMETRY_ADAPTED_STD_RANGE_TAG_DEFINED + + +#include + + +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + + +template +struct tag > +{ + typedef segment_tag type; +}; + +template +struct point_type > +{ + typedef Point type; +}; + +template +struct indexed_access, 0, Dimension> +{ + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(std::pair const& s) + { + return geometry::get(s.first); + } + + static inline void set(std::pair& s, coordinate_type const& value) + { + geometry::set(s.first, value); + } +}; + + +template +struct indexed_access, 1, Dimension> +{ + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(std::pair const& s) + { + return geometry::get(s.second); + } + + static inline void set(std::pair& s, coordinate_type const& value) + { + geometry::set(s.second, value); + } +}; + + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP diff --git a/include/boost/geometry/geometries/adapted/tuple.hpp b/include/boost/geometry/geometries/adapted/tuple.hpp new file mode 100644 index 000000000..f26b8e08b --- /dev/null +++ b/include/boost/geometry/geometries/adapted/tuple.hpp @@ -0,0 +1,136 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_HPP + + +#include + +#include + +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +// boost::tuple, 2D +template +struct coordinate_type > +{ + typedef CoordinateType type; +}; + + +template +struct dimension > + : boost::mpl::int_<2> +{}; + + +template +struct access + < + boost::tuple, + Dimension + > +{ + static inline CoordinateType get( + boost::tuple const& point) + { + return point.template get(); + } + + static inline void set(boost::tuple& point, + CoordinateType const& value) + { + point.template get() = value; + } +}; + + +template +struct tag > +{ + typedef point_tag type; +}; + + +// boost::tuple, 3D +template +struct coordinate_type + < + boost::tuple + > +{ + typedef CoordinateType type; +}; + +template +struct dimension > + : boost::mpl::int_<3> +{}; + + +template +struct access + < + boost::tuple, + Dimension + > +{ + static inline CoordinateType get( + boost::tuple + < + CoordinateType, CoordinateType, CoordinateType + > const& point) + { + return point.template get(); + } + + static inline void set( + boost::tuple& point, + CoordinateType const& value) + { + point.template get() = value; + } +}; + + +template +struct tag > +{ + typedef point_tag type; +}; + +// The library user has +// 1) either to specify the coordinate system using a traits class +// 2) or include +// where @=cartesian,geographic,... + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_HPP + diff --git a/include/boost/geometry/geometries/adapted/tuple_cartesian.hpp b/include/boost/geometry/geometries/adapted/tuple_cartesian.hpp new file mode 100644 index 000000000..b6e9cd682 --- /dev/null +++ b/include/boost/geometry/geometries/adapted/tuple_cartesian.hpp @@ -0,0 +1,49 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_CARTESIAN_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_CARTESIAN_HPP + +#ifdef BOOST_GEOMETRY_ADAPTED_TUPLE_COORDINATE_SYSTEM_DEFINED +#error Include only one headerfile to register coordinate coordinate_system for adapted tuple +#endif + +#define BOOST_GEOMETRY_ADAPTED_TUPLE_COORDINATE_SYSTEM_DEFINED + + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + template + struct coordinate_system > + { typedef cs::cartesian type; }; + + template + struct coordinate_system > + { typedef cs::cartesian type; }; + +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_CARTESIAN_HPP diff --git a/include/boost/geometry/geometries/adapted/tuple_geographic.hpp b/include/boost/geometry/geometries/adapted/tuple_geographic.hpp new file mode 100644 index 000000000..da0c702ee --- /dev/null +++ b/include/boost/geometry/geometries/adapted/tuple_geographic.hpp @@ -0,0 +1,49 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_GEOGRAPHIC_HPP +#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_GEOGRAPHIC_HPP + +#ifdef BOOST_GEOMETRY_ADAPTED_TUPLE_COORDINATE_SYSTEM_DEFINED +#error Include only one headerfile to register coordinate coordinate_system for adapted tuple +#endif + +#define BOOST_GEOMETRY_ADAPTED_TUPLE_COORDINATE_SYSTEM_DEFINED + + +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + template + struct coordinate_system > + { typedef cs::geographic type; }; + + template + struct coordinate_system > + { typedef cs::geographic type; }; + +} +#endif + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_GEOGRAPHIC_HPP diff --git a/include/boost/geometry/geometries/box.hpp b/include/boost/geometry/geometries/box.hpp new file mode 100644 index 000000000..a42e72c91 --- /dev/null +++ b/include/boost/geometry/geometries/box.hpp @@ -0,0 +1,134 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_BOX_HPP +#define BOOST_GEOMETRY_GEOMETRIES_BOX_HPP + +#include + +#include + +#include +#include + + + +namespace boost { namespace geometry +{ + +namespace model +{ + + +/*! + \brief Class box: defines a box made of two describing points + \ingroup geometries + \details Box is always described by a min_corner() and a max_corner() point. If another + rectangle is used, use linear_ring or polygon. + \note Boxes are for selections and for calculating the envelope of geometries. Not all algorithms + are implemented for box. Boxes are also used in Spatial Indexes. + \tparam Point point type. The box takes a point type as template parameter. + The point type can be any point type. + It can be 2D but can also be 3D or more dimensional. + The box can also take a latlong point type as template parameter. + */ + +template +class box +{ + BOOST_CONCEPT_ASSERT( (concept::Point) ); + +public: + + inline box() {} + + /*! + \brief Constructor taking the minimum corner point and the maximum corner point + */ + inline box(Point const& min_corner, Point const& max_corner) + { + geometry::convert(min_corner, m_min_corner); + geometry::convert(max_corner, m_max_corner); + } + + inline Point const& min_corner() const { return m_min_corner; } + inline Point const& max_corner() const { return m_max_corner; } + + inline Point& min_corner() { return m_min_corner; } + inline Point& max_corner() { return m_max_corner; } + +private: + + Point m_min_corner; + Point m_max_corner; +}; + + +} // namespace model + + +// Traits specializations for box above +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag > +{ + typedef box_tag type; +}; + +template +struct point_type > +{ + typedef Point type; +}; + +template +struct indexed_access, min_corner, Dimension> +{ + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(model::box const& b) + { + return geometry::get(b.min_corner()); + } + + static inline void set(model::box& b, coordinate_type const& value) + { + geometry::set(b.min_corner(), value); + } +}; + +template +struct indexed_access, max_corner, Dimension> +{ + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(model::box const& b) + { + return geometry::get(b.max_corner()); + } + + static inline void set(model::box& b, coordinate_type const& value) + { + geometry::set(b.max_corner(), value); + } +}; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_BOX_HPP diff --git a/include/boost/geometry/geometries/concepts/box_concept.hpp b/include/boost/geometry/geometries/concepts/box_concept.hpp new file mode 100644 index 000000000..e0eb80798 --- /dev/null +++ b/include/boost/geometry/geometries/concepts/box_concept.hpp @@ -0,0 +1,136 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP + + +#include + +#include + + +#include +#include +#include + + +namespace boost { namespace geometry { namespace concept +{ + + +/*! +\brief Box concept +\ingroup concepts +\par Formal definition: +The box concept is defined as following: +- there must be a specialization of traits::tag defining box_tag as type +- there must be a specialization of traits::point_type to define the + underlying point type (even if it does not consist of points, it should define + this type, to indicate the points it can work with) +- there must be a specialization of traits::indexed_access, per index + (min_corner, max_corner) and per dimension, with two functions: + - get to get a coordinate value + - set to set a coordinate value (this one is not checked for ConstBox) +*/ +template +class Box +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + typedef typename point_type::type point_type; + + + template + < + std::size_t Index, + std::size_t Dimension, + std::size_t DimensionCount + > + struct dimension_checker + { + static void apply() + { + Geometry* b = 0; + geometry::set(*b, geometry::get(*b)); + dimension_checker::apply(); + } + }; + + template + struct dimension_checker + { + static void apply() {} + }; + +public : + BOOST_CONCEPT_USAGE(Box) + { + static const std::size_t n = dimension::type::value; + dimension_checker::apply(); + dimension_checker::apply(); + } +#endif +}; + + +/*! +\brief Box concept (const version) +\ingroup const_concepts +\details The ConstBox concept apply the same as the Box concept, +but does not apply write access. +*/ +template +class ConstBox +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + typedef typename point_type::type point_type; + typedef typename coordinate_type::type coordinate_type; + + 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(geometry::get(*b)); + boost::ignore_unused_variable_warning(coord); + dimension_checker::apply(); + } + }; + + template + struct dimension_checker + { + static void apply() {} + }; + +public : + BOOST_CONCEPT_USAGE(ConstBox) + { + static const std::size_t n = dimension::type::value; + dimension_checker::apply(); + dimension_checker::apply(); + } +#endif +}; + +}}} // namespace boost::geometry::concept + + +#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_BOX_CONCEPT_HPP diff --git a/include/boost/geometry/geometries/concepts/check.hpp b/include/boost/geometry/geometries/concepts/check.hpp new file mode 100644 index 000000000..cd913e48b --- /dev/null +++ b/include/boost/geometry/geometries/concepts/check.hpp @@ -0,0 +1,171 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP +#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP + + +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace concept_check +{ + +template +class check +{ + BOOST_CONCEPT_ASSERT((Concept )); +}; + +}} // namespace detail::check +#endif // DOXYGEN_NO_DETAIL + + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + +template +struct check +{}; + + +template +struct check + : detail::concept_check::check > +{}; + + +template +struct check + : detail::concept_check::check > +{}; + + +template +struct check + : detail::concept_check::check > +{}; + + +template +struct check + : detail::concept_check::check > +{}; + + +template +struct check + : detail::concept_check::check > +{}; + + +template +struct check + : detail::concept_check::check > +{}; + + +template +struct check + : detail::concept_check::check > +{}; + + +template +struct check + : detail::concept_check::check > +{}; + + + +} // namespace dispatch +#endif + + + + +namespace concept +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + + +template +struct checker : dispatch::check + < + typename tag::type, + Geometry, + IsConst + > +{}; + + +} +#endif // DOXYGEN_NO_DETAIL + + +/*! + \brief Checks, in compile-time, the concept of any geometry + \ingroup concepts +*/ +template +inline void check() +{ + detail::checker::type::value> c; + boost::ignore_unused_variable_warning(c); +} + + +/*! + \brief Checks, in compile-time, the concept of two geometries, and if they + have equal dimensions + \ingroup concepts +*/ +template +inline void check_concepts_and_equal_dimensions() +{ + check(); + check(); + assert_dimension_equal(); +} + + +} // namespace concept + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_CHECK_HPP diff --git a/include/boost/geometry/geometries/concepts/linestring_concept.hpp b/include/boost/geometry/geometries/concepts/linestring_concept.hpp new file mode 100644 index 000000000..1a538cd4d --- /dev/null +++ b/include/boost/geometry/geometries/concepts/linestring_concept.hpp @@ -0,0 +1,125 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP + + +#include +#include +#include + +#include +#include +#include + +#include + + + +namespace boost { namespace geometry { namespace concept +{ + + +/*! +\brief Linestring concept +\ingroup concepts +\par Formal definition: +The linestring concept is defined as following: +- there must be a specialization of traits::tag defining linestring_tag as type +- it must behave like a Boost.Range +- it must implement a std::back_insert_iterator + - either by implementing push_back + - or by specializing std::back_insert_iterator + +\note to fulfill the concepts, no traits class has to be specialized to +define the point type. + +\par Example: + +A custom linestring, defining the necessary specializations to fulfill to the concept. + +Suppose that the following linestring is defined: +\dontinclude doxygen_5.cpp +\skip custom_linestring1 +\until }; + +It can then be adapted to the concept as following: +\dontinclude doxygen_5.cpp +\skip adapt custom_linestring1 +\until }} + +\note +- There is also the registration macro BOOST_GEOMETRY_REGISTER_LINESTRING +- For registration of std::vector

(and deque, and list) it is enough to +include the header-file geometries/adapted/std_as_linestring.hpp. That registers +a vector as a linestring (so it cannot be registered as a linear ring then, +in the same source code). + + +*/ + +template +class Linestring +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + typedef typename point_type::type point_type; + + BOOST_CONCEPT_ASSERT( (concept::Point) ); + BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept) ); + +public : + + BOOST_CONCEPT_USAGE(Linestring) + { + Geometry* ls = 0; + traits::clear::apply(*ls); + traits::resize::apply(*ls, 0); + point_type* point = 0; + traits::push_back::apply(*ls, *point); + } +#endif +}; + + +/*! +\brief Linestring concept (const version) +\ingroup const_concepts +\details The ConstLinestring concept check the same as the Linestring concept, +but does not check write access. +*/ +template +class ConstLinestring +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + typedef typename point_type::type point_type; + + BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); + //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept) ); + // Relaxed the concept. + BOOST_CONCEPT_ASSERT( (boost::ForwardRangeConcept) ); + + +public : + + BOOST_CONCEPT_USAGE(ConstLinestring) + { + } +#endif +}; + +}}} // namespace boost::geometry::concept + + +#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_LINESTRING_CONCEPT_HPP diff --git a/include/boost/geometry/geometries/concepts/point_concept.hpp b/include/boost/geometry/geometries/concepts/point_concept.hpp new file mode 100644 index 000000000..bcf59de98 --- /dev/null +++ b/include/boost/geometry/geometries/concepts/point_concept.hpp @@ -0,0 +1,176 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP + +#include + +#include + +#include +#include +#include + + + + +namespace boost { namespace geometry { namespace concept +{ + +/*! +\brief Point concept. +\ingroup concepts + +\par Formal definition: +The point concept is defined as following: +- there must be a specialization of traits::tag defining point_tag as type +- there must be a specialization of traits::coordinate_type defining the type + of its coordinates +- there must be a specialization of traits::coordinate_system defining its + coordinate system (cartesian, spherical, etc) +- there must be a specialization of traits::dimension defining its number + of dimensions (2, 3, ...) (derive it conveniently + from boost::mpl::int_<X> for X-D) +- there must be a specialization of traits::access, per dimension, + with two functions: + - \b get to get a coordinate value + - \b set to set a coordinate value (this one is not checked for ConstPoint) + +\par Example: + +A legacy point, defining the necessary specializations to fulfil to the concept. + +Suppose that the following point is defined: +\dontinclude doxygen_5.cpp +\skip legacy_point1 +\until }; + +It can then be adapted to the concept as following: +\dontinclude doxygen_5.cpp +\skip adapt legacy_point1 +\until }} + +Note that it is done like above to show the system. Users will normally use the registration macro. + +\par Example: + +A read-only legacy point, using a macro to fulfil to the ConstPoint concept. +It cannot be modified by the library but can be used in all algorithms where +points are not modified. + +The point looks like the following: + +\dontinclude doxygen_5.cpp +\skip legacy_point2 +\until }; + +It uses the macro as following: +\dontinclude doxygen_5.cpp +\skip adapt legacy_point2 +\until end adaptation + +*/ + +template +class Point +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + + typedef typename coordinate_type::type ctype; + typedef typename coordinate_system::type csystem; + + enum { ccount = dimension::value }; + + + template + struct dimension_checker + { + static void apply() + { + P* p = 0; + geometry::set(*p, geometry::get(*p)); + dimension_checker::apply(); + } + }; + + + template + struct dimension_checker + { + static void apply() {} + }; + +public: + + /// BCCL macro to apply the Point concept + BOOST_CONCEPT_USAGE(Point) + { + dimension_checker::apply(); + } +#endif +}; + + +/*! +\brief point concept (const version). + +\ingroup const_concepts + +\details The ConstPoint concept apply the same as the Point concept, +but does not apply write access. + +*/ +template +class ConstPoint +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + + typedef typename coordinate_type::type ctype; + typedef typename coordinate_system::type csystem; + + enum { ccount = dimension::value }; + + + template + struct dimension_checker + { + static void apply() + { + const P* p = 0; + ctype coord(geometry::get(*p)); + boost::ignore_unused_variable_warning(coord); + dimension_checker::apply(); + } + }; + + + template + struct dimension_checker + { + static void apply() {} + }; + +public: + + /// BCCL macro to apply the ConstPoint concept + BOOST_CONCEPT_USAGE(ConstPoint) + { + dimension_checker::apply(); + } +#endif +}; + +}}} // namespace boost::geometry::concept + +#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP diff --git a/include/boost/geometry/geometries/concepts/polygon_concept.hpp b/include/boost/geometry/geometries/concepts/polygon_concept.hpp new file mode 100644 index 000000000..c7c45b9ec --- /dev/null +++ b/include/boost/geometry/geometries/concepts/polygon_concept.hpp @@ -0,0 +1,135 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + + +namespace boost { namespace geometry { namespace concept +{ + +/*! +\brief Checks polygon concept +\ingroup concepts +*/ +template +class Polygon +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + typedef typename boost::remove_const::type polygon_type; + + typedef typename traits::ring_const_type::type ring_const_type; + typedef typename traits::ring_mutable_type::type ring_mutable_type; + typedef typename traits::interior_const_type::type interior_const_type; + typedef typename traits::interior_mutable_type::type interior_mutable_type; + + typedef typename point_type::type point_type; + typedef typename ring_type::type ring_type; + + BOOST_CONCEPT_ASSERT( (concept::Point) ); + BOOST_CONCEPT_ASSERT( (concept::Ring) ); + + //BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept) ); + + struct checker + { + static inline void apply() + { + polygon_type* poly = 0; + polygon_type const* cpoly = poly; + + ring_mutable_type e = traits::exterior_ring::get(*poly); + interior_mutable_type i = traits::interior_rings::get(*poly); + ring_const_type ce = traits::exterior_ring::get(*cpoly); + interior_const_type ci = traits::interior_rings::get(*cpoly); + + boost::ignore_unused_variable_warning(e); + boost::ignore_unused_variable_warning(i); + boost::ignore_unused_variable_warning(ce); + boost::ignore_unused_variable_warning(ci); + boost::ignore_unused_variable_warning(poly); + boost::ignore_unused_variable_warning(cpoly); + } + }; + +public: + + BOOST_CONCEPT_USAGE(Polygon) + { + checker::apply(); + } +#endif +}; + + +/*! +\brief Checks polygon concept (const version) +\ingroup const_concepts +*/ +template +class ConstPolygon +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + + typedef typename boost::remove_const::type const_polygon_type; + + typedef typename traits::ring_const_type::type ring_const_type; + typedef typename traits::interior_const_type::type interior_const_type; + + typedef typename point_type::type point_type; + typedef typename ring_type::type ring_type; + + BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); + BOOST_CONCEPT_ASSERT( (concept::ConstRing) ); + + ////BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept) ); + + struct checker + { + static inline void apply() + { + const_polygon_type const* cpoly = 0; + + ring_const_type ce = traits::exterior_ring::get(*cpoly); + interior_const_type ci = traits::interior_rings::get(*cpoly); + + boost::ignore_unused_variable_warning(ce); + boost::ignore_unused_variable_warning(ci); + boost::ignore_unused_variable_warning(cpoly); + } + }; + +public: + + BOOST_CONCEPT_USAGE(ConstPolygon) + { + checker::apply(); + } +#endif +}; + +}}} // namespace boost::geometry::concept + +#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POLYGON_CONCEPT_HPP diff --git a/include/boost/geometry/geometries/concepts/ring_concept.hpp b/include/boost/geometry/geometries/concepts/ring_concept.hpp new file mode 100644 index 000000000..4fb37f515 --- /dev/null +++ b/include/boost/geometry/geometries/concepts/ring_concept.hpp @@ -0,0 +1,99 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP + + +#include +#include +#include + +#include +#include +#include + +#include + + +namespace boost { namespace geometry { namespace concept +{ + + +/*! +\brief ring concept +\ingroup concepts +\par Formal definition: +The ring concept is defined as following: +- there must be a specialization of traits::tag defining ring_tag as type +- it must behave like a Boost.Range +- there can optionally be a specialization of traits::point_order defining the + order or orientation of its points, clockwise or counterclockwise. +- it must implement a std::back_insert_iterator + (This is the same as the for the concept Linestring, and described there) + +\note to fulfill the concepts, no traits class has to be specialized to +define the point type. +*/ +template +class Ring +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + typedef typename point_type::type point_type; + + BOOST_CONCEPT_ASSERT( (concept::Point) ); + BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept) ); + +public : + + BOOST_CONCEPT_USAGE(Ring) + { + Geometry* ring = 0; + traits::clear::apply(*ring); + traits::resize::apply(*ring, 0); + point_type* point = 0; + traits::push_back::apply(*ring, *point); + } +#endif +}; + + +/*! +\brief (linear) ring concept (const version) +\ingroup const_concepts +\details The ConstLinearRing concept check the same as the Geometry concept, +but does not check write access. +*/ +template +class ConstRing +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + typedef typename point_type::type point_type; + + BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); + BOOST_CONCEPT_ASSERT( (boost::RandomAccessRangeConcept) ); + + +public : + + BOOST_CONCEPT_USAGE(ConstRing) + { + } +#endif +}; + +}}} // namespace boost::geometry::concept + + +#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_RING_CONCEPT_HPP diff --git a/include/boost/geometry/geometries/concepts/segment_concept.hpp b/include/boost/geometry/geometries/concepts/segment_concept.hpp new file mode 100644 index 000000000..2616d8c3f --- /dev/null +++ b/include/boost/geometry/geometries/concepts/segment_concept.hpp @@ -0,0 +1,135 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2008-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP + + +#include + +#include + +#include +#include + + +namespace boost { namespace geometry { namespace concept +{ + + +/*! +\brief Segment concept. +\ingroup concepts +\details Formal definition: +The segment concept is defined as following: +- there must be a specialization of traits::tag defining segment_tag as type +- there must be a specialization of traits::point_type to define the + underlying point type (even if it does not consist of points, it should define + this type, to indicate the points it can work with) +- there must be a specialization of traits::indexed_access, per index + and per dimension, with two functions: + - get to get a coordinate value + - set to set a coordinate value (this one is not checked for ConstSegment) + +\note The segment concept is similar to the box concept, defining another tag. +However, the box concept assumes the index as min_corner, max_corner, while +for the segment concept there is no assumption. +*/ +template +class Segment +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + typedef typename point_type::type point_type; + + BOOST_CONCEPT_ASSERT( (concept::Point) ); + + + template + struct dimension_checker + { + static void apply() + { + Geometry* s = 0; + geometry::set(*s, geometry::get(*s)); + dimension_checker::apply(); + } + }; + + template + struct dimension_checker + { + static void apply() {} + }; + +public : + + BOOST_CONCEPT_USAGE(Segment) + { + static const size_t n = dimension::type::value; + dimension_checker<0, 0, n>::apply(); + dimension_checker<1, 0, n>::apply(); + } +#endif +}; + + +/*! +\brief Segment concept (const version). +\ingroup const_concepts +\details The ConstSegment concept verifies the same as the Segment concept, +but does not verify write access. +*/ +template +class ConstSegment +{ +#ifndef DOXYGEN_NO_CONCEPT_MEMBERS + typedef typename point_type::type point_type; + typedef typename coordinate_type::type coordinate_type; + + BOOST_CONCEPT_ASSERT( (concept::ConstPoint) ); + + + template + struct dimension_checker + { + static void apply() + { + const Geometry* s = 0; + coordinate_type coord(geometry::get(*s)); + boost::ignore_unused_variable_warning(coord); + dimension_checker::apply(); + } + }; + + template + struct dimension_checker + { + static void apply() {} + }; + +public : + + BOOST_CONCEPT_USAGE(ConstSegment) + { + static const size_t n = dimension::type::value; + dimension_checker<0, 0, n>::apply(); + dimension_checker<1, 0, n>::apply(); + } +#endif +}; + + +}}} // namespace boost::geometry::concept + + +#endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_SEGMENT_CONCEPT_HPP diff --git a/include/boost/geometry/geometries/geometries.hpp b/include/boost/geometry/geometries/geometries.hpp new file mode 100644 index 000000000..cef9f6bf1 --- /dev/null +++ b/include/boost/geometry/geometries/geometries.hpp @@ -0,0 +1,29 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_HPP +#define BOOST_GEOMETRY_GEOMETRIES_HPP + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#endif // BOOST_GEOMETRY_GEOMETRIES_HPP diff --git a/include/boost/geometry/geometries/linestring.hpp b/include/boost/geometry/geometries/linestring.hpp new file mode 100644 index 000000000..177ddf68e --- /dev/null +++ b/include/boost/geometry/geometries/linestring.hpp @@ -0,0 +1,95 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_LINESTRING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_LINESTRING_HPP + +#include +#include + +#include +#include + +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace model +{ + +/*! +\brief A linestring (named so by OGC) is a collection (default a vector) of points. +\ingroup geometries +\tparam Point \tparam_point +\tparam Container \tparam_container +\tparam Allocator \tparam_allocator + +\qbk{before.synopsis, +[heading Model of] +[link geometry.reference.concepts.concept_linestring Linestring Concept] +} + +*/ +template +< + typename Point, + template class Container = std::vector, + template class Allocator = std::allocator +> +class linestring : public Container > +{ + BOOST_CONCEPT_ASSERT( (concept::Point) ); + + typedef Container > base_type; + +public : + /// \constructor_default{linestring} + inline linestring() + : base_type() + {} + + /// \constructor_begin_end{linestring} + template + inline linestring(Iterator begin, Iterator end) + : base_type(begin, end) + {} +}; + +} // namespace model + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +< + typename Point, + template class Container, + template class Allocator +> +struct tag > +{ + typedef linestring_tag type; +}; +} // namespace traits + +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_LINESTRING_HPP diff --git a/include/boost/geometry/geometries/point.hpp b/include/boost/geometry/geometries/point.hpp new file mode 100644 index 000000000..35786e6bf --- /dev/null +++ b/include/boost/geometry/geometries/point.hpp @@ -0,0 +1,178 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_POINT_HPP + +#include + +#include +#include + +#include +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + + +namespace model +{ + +/*! +\brief Basic point class, having coordinates defined in a neutral way +\details Defines a neutral point class, fulfilling the Point Concept. + Library users can use this point class, or use their own point classes. + This point class is used in most of the samples and tests of Boost.Geometry + This point class is used occasionally within the library, where a temporary + point class is necessary. +\ingroup geometries +\tparam CoordinateType \tparam_numeric +\tparam DimensionCount number of coordinates, usually 2 or 3 +\tparam CoordinateSystem coordinate system, for example cs::cartesian + +\qbk{[include reference/geometries/point.qbk]} +\qbk{before.synopsis, [heading Model of]} +\qbk{before.synopsis, [link geometry.reference.concepts.concept_point Point Concept]} + + +*/ +template +< + typename CoordinateType, + std::size_t DimensionCount, + typename CoordinateSystem +> +class point +{ +public: + + /// @brief Default constructor, no initialization + inline point() + {} + + /// @brief Constructor to set one, two or three values + inline point(CoordinateType const& v0, CoordinateType const& v1 = 0, CoordinateType const& v2 = 0) + { + if (DimensionCount >= 1) m_values[0] = v0; + if (DimensionCount >= 2) m_values[1] = v1; + if (DimensionCount >= 3) m_values[2] = v2; + } + + /// @brief Get a coordinate + /// @tparam K coordinate to get + /// @return the coordinate + template + inline CoordinateType const& get() const + { + BOOST_STATIC_ASSERT(K < DimensionCount); + return m_values[K]; + } + + /// @brief Set a coordinate + /// @tparam K coordinate to set + /// @param value value to set + template + inline void set(CoordinateType const& value) + { + BOOST_STATIC_ASSERT(K < DimensionCount); + m_values[K] = value; + } + +private: + + CoordinateType m_values[DimensionCount]; +}; + + +} // namespace model + +// Adapt the point to the concept +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ +template +< + typename CoordinateType, + std::size_t DimensionCount, + typename CoordinateSystem +> +struct tag > +{ + typedef point_tag type; +}; + +template +< + typename CoordinateType, + std::size_t DimensionCount, + typename CoordinateSystem +> +struct coordinate_type > +{ + typedef CoordinateType type; +}; + +template +< + typename CoordinateType, + std::size_t DimensionCount, + typename CoordinateSystem +> +struct coordinate_system > +{ + typedef CoordinateSystem type; +}; + +template +< + typename CoordinateType, + std::size_t DimensionCount, + typename CoordinateSystem +> +struct dimension > + : boost::mpl::int_ +{}; + +template +< + typename CoordinateType, + std::size_t DimensionCount, + typename CoordinateSystem, + std::size_t Dimension +> +struct access, Dimension> +{ + static inline CoordinateType get( + model::point const& p) + { + return p.template get(); + } + + static inline void set( + model::point& p, + CoordinateType const& value) + { + p.template set(value); + } +}; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_POINT_HPP diff --git a/include/boost/geometry/geometries/point_xy.hpp b/include/boost/geometry/geometries/point_xy.hpp new file mode 100644 index 000000000..e4185a332 --- /dev/null +++ b/include/boost/geometry/geometries/point_xy.hpp @@ -0,0 +1,125 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP +#define BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP + +#include + +#include + +#include +#include + +namespace boost { namespace geometry +{ + +namespace model { namespace d2 +{ + +/*! +\brief 2D point in Cartesian coordinate system +\tparam CoordinateType numeric type, for example, double, float, int +\tparam CoordinateSystem coordinate system, defaults to cs::cartesian + +\qbk{before.synopsis, +[heading Model of] +[link geometry.reference.concepts.concept_point Point Concept] +} +*/ +template +class point_xy : public model::point +{ +public: + + /// Default constructor, does not initialize anything + inline point_xy() + : model::point() + {} + + /// Constructor with x/y values + inline point_xy(CoordinateType const& x, CoordinateType const& y) + : model::point(x, y) + {} + + /// Get x-value + inline CoordinateType const& x() const + { return this->template get<0>(); } + + /// Get y-value + inline CoordinateType const& y() const + { return this->template get<1>(); } + + /// Set x-value + inline void x(CoordinateType const& v) + { this->template set<0>(v); } + + /// Set y-value + inline void y(CoordinateType const& v) + { this->template set<1>(v); } +}; + + +}} // namespace model::d2 + + +// Adapt the point_xy to the concept +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag > +{ + typedef point_tag type; +}; + +template +struct coordinate_type > +{ + typedef CoordinateType type; +}; + +template +struct coordinate_system > +{ + typedef CoordinateSystem type; +}; + +template +struct dimension > + : boost::mpl::int_<2> +{}; + +template +struct access, Dimension > +{ + static inline CoordinateType get( + model::d2::point_xy const& p) + { + return p.template get(); + } + + static inline void set(model::d2::point_xy& p, + CoordinateType const& value) + { + p.template set(value); + } +}; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP diff --git a/include/boost/geometry/geometries/polygon.hpp b/include/boost/geometry/geometries/polygon.hpp new file mode 100644 index 000000000..0186aaa59 --- /dev/null +++ b/include/boost/geometry/geometries/polygon.hpp @@ -0,0 +1,319 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP +#define BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + +namespace model +{ + +/*! +\brief The polygon contains an outer ring and zero or more inner rings. +\ingroup geometries +\tparam Point point type +\tparam ClockWise true for clockwise direction, + false for CounterClockWise direction +\tparam Closed true for closed polygons (last point == first point), + false open points +\tparam PointList container type for points, + for example std::vector, std::list, std::deque +\tparam RingList container type for inner rings, + for example std::vector, std::list, std::deque +\tparam PointAlloc container-allocator-type, for the points +\tparam RingAlloc container-allocator-type, for the rings +\note The container collecting the points in the rings can be different + from the container collecting the inner rings. They all default to vector. + +\qbk{before.synopsis, +[heading Model of] +[link geometry.reference.concepts.concept_polygon Polygon Concept] +} + + +*/ +template +< + typename Point, + bool ClockWise = true, + bool Closed = true, + template class PointList = std::vector, + template class RingList = std::vector, + template class PointAlloc = std::allocator, + template class RingAlloc = std::allocator +> +class polygon +{ + BOOST_CONCEPT_ASSERT( (concept::Point) ); + +public: + + // Member types + typedef Point point_type; + typedef ring ring_type; + typedef RingList > inner_container_type; + + inline ring_type const& outer() const { return m_outer; } + inline inner_container_type const& inners() const { return m_inners; } + + inline ring_type& outer() { return m_outer; } + inline inner_container_type & inners() { return m_inners; } + + /// Utility method, clears outer and inner rings + inline void clear() + { + m_outer.clear(); + m_inners.clear(); + } + +private: + + ring_type m_outer; + inner_container_type m_inners; +}; + + +} // namespace model + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +< + typename Point, + bool ClockWise, bool Closed, + template class PointList, + template class RingList, + template class PointAlloc, + template class RingAlloc +> +struct tag +< + model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, PointAlloc, RingAlloc + > +> +{ + typedef polygon_tag type; +}; + +template +< + typename Point, + bool ClockWise, bool Closed, + template class PointList, + template class RingList, + template class PointAlloc, + template class RingAlloc +> +struct ring_const_type +< + model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, PointAlloc, RingAlloc + > +> +{ + typedef typename model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc + >::ring_type const& type; +}; + + +template +< + typename Point, + bool ClockWise, bool Closed, + template class PointList, + template class RingList, + template class PointAlloc, + template class RingAlloc +> +struct ring_mutable_type +< + model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, PointAlloc, RingAlloc + > +> +{ + typedef typename model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc + >::ring_type& type; +}; + +template +< + typename Point, + bool ClockWise, bool Closed, + template class PointList, + template class RingList, + template class PointAlloc, + template class RingAlloc +> +struct interior_const_type +< + model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc + > +> +{ + typedef typename model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc + >::inner_container_type const& type; +}; + + +template +< + typename Point, + bool ClockWise, bool Closed, + template class PointList, + template class RingList, + template class PointAlloc, + template class RingAlloc +> +struct interior_mutable_type +< + model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc + > +> +{ + typedef typename model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc + >::inner_container_type& type; +}; + + +template +< + typename Point, + bool ClockWise, bool Closed, + template class PointList, + template class RingList, + template class PointAlloc, + template class RingAlloc +> +struct exterior_ring +< + model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, PointAlloc, RingAlloc + > +> +{ + typedef model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc + > polygon_type; + + static inline typename polygon_type::ring_type& get(polygon_type& p) + { + return p.outer(); + } + + static inline typename polygon_type::ring_type const& get( + polygon_type const& p) + { + return p.outer(); + } +}; + +template +< + typename Point, + bool ClockWise, bool Closed, + template class PointList, + template class RingList, + template class PointAlloc, + template class RingAlloc +> +struct interior_rings +< + model::polygon + < + Point, ClockWise, Closed, + PointList, RingList, + PointAlloc, RingAlloc + > +> +{ + typedef model::polygon + < + Point, ClockWise, Closed, PointList, RingList, + PointAlloc, RingAlloc + > polygon_type; + + static inline typename polygon_type::inner_container_type& get( + polygon_type& p) + { + return p.inners(); + } + + static inline typename polygon_type::inner_container_type const& get( + polygon_type const& p) + { + return p.inners(); + } +}; + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP diff --git a/include/boost/geometry/geometries/register/box.hpp b/include/boost/geometry/geometries/register/box.hpp new file mode 100644 index 000000000..4761384a9 --- /dev/null +++ b/include/boost/geometry/geometries/register/box.hpp @@ -0,0 +1,129 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_BOX_HPP +#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_BOX_HPP + + +#ifndef DOXYGEN_NO_SPECIALIZATIONS + + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS(Box, Point, MinCorner, MaxCorner) \ +template \ +struct indexed_access \ +{ \ + typedef typename coordinate_type::type ct; \ + static inline ct get(Box const& b) \ + { return geometry::get(b. MinCorner); } \ + static inline void set(Box& b, ct const& value) \ + { geometry::set(b. MinCorner, value); } \ +}; \ +template \ +struct indexed_access \ +{ \ + typedef typename coordinate_type::type ct; \ + static inline ct get(Box const& b) \ + { return geometry::get(b. MaxCorner); } \ + static inline void set(Box& b, ct const& value) \ + { geometry::set(b. MaxCorner, value); } \ +}; + + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_TEMPLATIZED(Box, MinCorner, MaxCorner) \ +template \ +struct indexed_access, min_corner, D> \ +{ \ + typedef typename coordinate_type

::type ct; \ + static inline ct get(Box

const& b) \ + { return geometry::get(b. MinCorner); } \ + static inline void set(Box

& b, ct const& value) \ + { geometry::set(b. MinCorner, value); } \ +}; \ +template \ +struct indexed_access, max_corner, D> \ +{ \ + typedef typename coordinate_type

::type ct; \ + static inline ct get(Box

const& b) \ + { return geometry::get(b. MaxCorner); } \ + static inline void set(Box

& b, ct const& value) \ + { geometry::set(b. MaxCorner, value); } \ +}; + + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_4VALUES(Box, Point, Left, Bottom, Right, Top) \ +template <> struct indexed_access \ +{ \ + typedef coordinate_type::type ct; \ + static inline ct get(Box const& b) { return b. Left; } \ + static inline void set(Box& b, ct const& value) { b. Left = value; } \ +}; \ +template <> struct indexed_access \ +{ \ + typedef coordinate_type::type ct; \ + static inline ct get(Box const& b) { return b. Bottom; } \ + static inline void set(Box& b, ct const& value) { b. Bottom = value; } \ +}; \ +template <> struct indexed_access \ +{ \ + typedef coordinate_type::type ct; \ + static inline ct get(Box const& b) { return b. Right; } \ + static inline void set(Box& b, ct const& value) { b. Right = value; } \ +}; \ +template <> struct indexed_access \ +{ \ + typedef coordinate_type::type ct; \ + static inline ct get(Box const& b) { return b. Top; } \ + static inline void set(Box& b, ct const& value) { b. Top = value; } \ +}; + + + + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(Box, PointType) \ + template<> struct tag { typedef box_tag type; }; \ + template<> struct point_type { typedef PointType type; }; + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS_TEMPLATIZED(Box) \ + template struct tag > { typedef box_tag type; }; \ + template struct point_type > { typedef P type; }; + +#endif // DOXYGEN_NO_SPECIALIZATIONS + + + +#define BOOST_GEOMETRY_REGISTER_BOX(Box, PointType, MinCorner, MaxCorner) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(Box, PointType) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS(Box, PointType, MinCorner, MaxCorner) \ +}}} + + +#define BOOST_GEOMETRY_REGISTER_BOX_TEMPLATIZED(Box, MinCorner, MaxCorner) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS_TEMPLATIZED(Box) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_TEMPLATIZED(Box, MinCorner, MaxCorner) \ +}}} + +#define BOOST_GEOMETRY_REGISTER_BOX_2D_4VALUES(Box, PointType, Left, Bottom, Right, Top) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_TRAITS(Box, PointType) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_BOX_ACCESS_4VALUES(Box, PointType, Left, Bottom, Right, Top) \ +}}} + + + +// CONST versions are for boxes probably not that common. Postponed. + + +#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_BOX_HPP diff --git a/include/boost/geometry/geometries/register/linestring.hpp b/include/boost/geometry/geometries/register/linestring.hpp new file mode 100644 index 000000000..c8d17195a --- /dev/null +++ b/include/boost/geometry/geometries/register/linestring.hpp @@ -0,0 +1,30 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_LINESTRING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_LINESTRING_HPP + + +#include +#include + + +#define BOOST_GEOMETRY_REGISTER_LINESTRING(Linestring) \ +namespace boost { namespace geometry { namespace traits { \ + template<> struct tag { typedef linestring_tag type; }; \ +}}} + + + +#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_LINESTRING_HPP diff --git a/include/boost/geometry/geometries/register/point.hpp b/include/boost/geometry/geometries/register/point.hpp new file mode 100644 index 000000000..518a88c15 --- /dev/null +++ b/include/boost/geometry/geometries/register/point.hpp @@ -0,0 +1,173 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_POINT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_POINT_HPP + + +#include + +#ifndef DOXYGEN_NO_SPECIALIZATIONS + +// Starting point, specialize basic traits necessary to register a point +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, Dim, CoordinateType, CoordinateSystem) \ + template<> struct tag { typedef point_tag type; }; \ + template<> struct dimension : boost::mpl::int_ {}; \ + template<> struct coordinate_type { typedef CoordinateType type; }; \ + template<> struct coordinate_system { typedef CoordinateSystem type; }; + +// Specialize access class per dimension +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, Dim, CoordinateType, Get, Set) \ + template<> struct access \ + { \ + static inline CoordinateType get(Point const& p) { return p. Get; } \ + static inline void set(Point& p, CoordinateType const& value) { p. Set = value; } \ + }; + +// Const version +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, Dim, CoordinateType, Get) \ + template<> struct access \ + { \ + static inline CoordinateType get(Point const& p) { return p. Get; } \ + }; + + +// Getter/setter version +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, Dim, CoordinateType, Get, Set) \ + template<> struct access \ + { \ + static inline CoordinateType get(Point const& p) \ + { return p. Get (); } \ + static inline void set(Point& p, CoordinateType const& value) \ + { p. Set ( value ); } \ + }; + +#endif // DOXYGEN_NO_SPECIALIZATIONS + + +/*! +\brief \brief_macro{2D point type} +\ingroup register +\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_2D, two-dimensional point type} +\param Point \param_macro_type{Point} +\param CoordinateType \param_macro_coortype{point} +\param CoordinateSystem \param_macro_coorsystem +\param Field0 \param_macro_member{\macro_x} +\param Field1 \param_macro_member{\macro_y} + +\qbk{[include reference/geometries/register/point.qbk]} +*/ +#define BOOST_GEOMETRY_REGISTER_POINT_2D(Point, CoordinateType, CoordinateSystem, Field0, Field1) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 2, CoordinateType, CoordinateSystem) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 0, CoordinateType, Field0, Field0) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 1, CoordinateType, Field1, Field1) \ +}}} + +/*! +\brief \brief_macro{3D point type} +\ingroup register +\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_3D, three-dimensional point type} +\param Point \param_macro_type{Point} +\param CoordinateType \param_macro_coortype{point} +\param CoordinateSystem \param_macro_coorsystem +\param Field0 \param_macro_member{\macro_x} +\param Field1 \param_macro_member{\macro_y} +\param Field2 \param_macro_member{\macro_z} +*/ +#define BOOST_GEOMETRY_REGISTER_POINT_3D(Point, CoordinateType, CoordinateSystem, Field0, Field1, Field2) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 3, CoordinateType, CoordinateSystem) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 0, CoordinateType, Field0, Field0) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 1, CoordinateType, Field1, Field1) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS(Point, 2, CoordinateType, Field2, Field2) \ +}}} + +/*! +\brief \brief_macro{2D point type} \brief_macro_const +\ingroup register +\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_2D_CONST, two-dimensional point type}. \details_macro_const +\param Point \param_macro_type{Point} +\param CoordinateType \param_macro_coortype{point} +\param CoordinateSystem \param_macro_coorsystem +\param Field0 \param_macro_member{\macro_x} +\param Field1 \param_macro_member{\macro_y} +*/ +#define BOOST_GEOMETRY_REGISTER_POINT_2D_CONST(Point, CoordinateType, CoordinateSystem, Field0, Field1) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 2, CoordinateType, CoordinateSystem) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 0, CoordinateType, Field0) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 1, CoordinateType, Field1) \ +}}} + +/*! +\brief \brief_macro{3D point type} \brief_macro_const +\ingroup register +\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_3D_CONST, three-dimensional point type}. \details_macro_const +\param Point \param_macro_type{Point} +\param CoordinateType \param_macro_coortype{point} +\param CoordinateSystem \param_macro_coorsystem +\param Field0 \param_macro_member{\macro_x} +\param Field1 \param_macro_member{\macro_y} +\param Field2 \param_macro_member{\macro_z} +*/ +#define BOOST_GEOMETRY_REGISTER_POINT_3D_CONST(Point, CoordinateType, CoordinateSystem, Field0, Field1, Field2) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 3, CoordinateType, CoordinateSystem) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 0, CoordinateType, Field0) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 1, CoordinateType, Field1) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_CONST(Point, 2, CoordinateType, Field2) \ +}}} + +/*! +\brief \brief_macro{2D point type} \brief_macro_getset +\ingroup register +\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET, two-dimensional point type}. \details_macro_getset +\param Point \param_macro_type{Point} +\param CoordinateType \param_macro_coortype{point} +\param CoordinateSystem \param_macro_coorsystem +\param Get0 \param_macro_getset{get, \macro_x} +\param Get1 \param_macro_getset{get, \macro_y} +\param Set0 \param_macro_getset{set, \macro_x} +\param Set1 \param_macro_getset{set, \macro_y} +*/ +#define BOOST_GEOMETRY_REGISTER_POINT_2D_GET_SET(Point, CoordinateType, CoordinateSystem, Get0, Get1, Set0, Set1) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 2, CoordinateType, CoordinateSystem) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 0, CoordinateType, Get0, Set0) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 1, CoordinateType, Get1, Set1) \ +}}} + +/*! +\brief \brief_macro{3D point type} \brief_macro_getset +\ingroup register +\details \details_macro{BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET, three-dimensional point type}. \details_macro_getset +\param Point \param_macro_type{Point} +\param CoordinateType \param_macro_coortype{point} +\param CoordinateSystem \param_macro_coorsystem +\param Get0 \param_macro_getset{get, \macro_x} +\param Get1 \param_macro_getset{get, \macro_y} +\param Get2 \param_macro_getset{get, \macro_z} +\param Set0 \param_macro_getset{set, \macro_x} +\param Set1 \param_macro_getset{set, \macro_y} +\param Set2 \param_macro_getset{set, \macro_z} +*/ +#define BOOST_GEOMETRY_REGISTER_POINT_3D_GET_SET(Point, CoordinateType, CoordinateSystem, Get0, Get1, Get2, Set0, Set1, Set2) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_TRAITS(Point, 3, CoordinateType, CoordinateSystem) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 0, CoordinateType, Get0, Set0) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 1, CoordinateType, Get1, Set1) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_POINT_ACCESS_GET_SET(Point, 2, CoordinateType, Get2, Set2) \ +}}} + +#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_POINT_HPP diff --git a/include/boost/geometry/geometries/register/ring.hpp b/include/boost/geometry/geometries/register/ring.hpp new file mode 100644 index 000000000..61f2e08d3 --- /dev/null +++ b/include/boost/geometry/geometries/register/ring.hpp @@ -0,0 +1,33 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_RING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_RING_HPP + +#include +#include + +#define BOOST_GEOMETRY_REGISTER_RING(Ring) \ +namespace boost { namespace geometry { namespace traits { \ + template<> struct tag { typedef ring_tag type; }; \ +}}} + + +#define BOOST_GEOMETRY_REGISTER_RING_TEMPLATIZED(Ring) \ +namespace boost { namespace geometry { namespace traits { \ + template struct tag< Ring

> { typedef ring_tag type; }; \ +}}} + + +#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_RING_HPP diff --git a/include/boost/geometry/geometries/register/segment.hpp b/include/boost/geometry/geometries/register/segment.hpp new file mode 100644 index 000000000..0db1d9ebb --- /dev/null +++ b/include/boost/geometry/geometries/register/segment.hpp @@ -0,0 +1,129 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#ifndef BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP + + +#ifndef DOXYGEN_NO_SPECIALIZATIONS + + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS(Segment, Point, Index0, Index1) \ +template \ +struct indexed_access \ +{ \ + typedef typename coordinate_type::type ct; \ + static inline ct get(Segment const& b) \ + { return geometry::get(b. Index0); } \ + static inline void set(Segment& b, ct const& value) \ + { geometry::set(b. Index0, value); } \ +}; \ +template \ +struct indexed_access \ +{ \ + typedef typename coordinate_type::type ct; \ + static inline ct get(Segment const& b) \ + { return geometry::get(b. Index1); } \ + static inline void set(Segment& b, ct const& value) \ + { geometry::set(b. Index1, value); } \ +}; + + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_TEMPLATIZED(Segment, Index0, Index1) \ +template \ +struct indexed_access, min_corner, D> \ +{ \ + typedef typename coordinate_type

::type ct; \ + static inline ct get(Segment

const& b) \ + { return geometry::get(b. Index0); } \ + static inline void set(Segment

& b, ct const& value) \ + { geometry::set(b. Index0, value); } \ +}; \ +template \ +struct indexed_access, max_corner, D> \ +{ \ + typedef typename coordinate_type

::type ct; \ + static inline ct get(Segment

const& b) \ + { return geometry::get(b. Index1); } \ + static inline void set(Segment

& b, ct const& value) \ + { geometry::set(b. Index1, value); } \ +}; + + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_4VALUES(Segment, Point, Left, Bottom, Right, Top) \ +template <> struct indexed_access \ +{ \ + typedef coordinate_type::type ct; \ + static inline ct get(Segment const& b) { return b. Left; } \ + static inline void set(Segment& b, ct const& value) { b. Left = value; } \ +}; \ +template <> struct indexed_access \ +{ \ + typedef coordinate_type::type ct; \ + static inline ct get(Segment const& b) { return b. Bottom; } \ + static inline void set(Segment& b, ct const& value) { b. Bottom = value; } \ +}; \ +template <> struct indexed_access \ +{ \ + typedef coordinate_type::type ct; \ + static inline ct get(Segment const& b) { return b. Right; } \ + static inline void set(Segment& b, ct const& value) { b. Right = value; } \ +}; \ +template <> struct indexed_access \ +{ \ + typedef coordinate_type::type ct; \ + static inline ct get(Segment const& b) { return b. Top; } \ + static inline void set(Segment& b, ct const& value) { b. Top = value; } \ +}; + + + + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \ + template<> struct tag { typedef segment_tag type; }; \ + template<> struct point_type { typedef PointType type; }; + +#define BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS_TEMPLATIZED(Segment) \ + template struct tag > { typedef segment_tag type; }; \ + template struct point_type > { typedef P type; }; + +#endif // DOXYGEN_NO_SPECIALIZATIONS + + + +#define BOOST_GEOMETRY_REGISTER_SEGMENT(Segment, PointType, Index0, Index1) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS(Segment, PointType, Index0, Index1) \ +}}} + + +#define BOOST_GEOMETRY_REGISTER_SEGMENT_TEMPLATIZED(Segment, Index0, Index1) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS_TEMPLATIZED(Segment) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_TEMPLATIZED(Segment, Index0, Index1) \ +}}} + +#define BOOST_GEOMETRY_REGISTER_SEGMENT_2D_4VALUES(Segment, PointType, Left, Bottom, Right, Top) \ +namespace boost { namespace geometry { namespace traits { \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_TRAITS(Segment, PointType) \ + BOOST_GEOMETRY_DETAIL_SPECIALIZE_SEGMENT_ACCESS_4VALUES(Segment, PointType, Left, Bottom, Right, Top) \ +}}} + + + +// CONST versions are for segments probably not that common. Postponed. + + +#endif // BOOST_GEOMETRY_GEOMETRIES_REGISTER_SEGMENT_HPP diff --git a/include/boost/geometry/geometries/ring.hpp b/include/boost/geometry/geometries/ring.hpp new file mode 100644 index 000000000..e577145c2 --- /dev/null +++ b/include/boost/geometry/geometries/ring.hpp @@ -0,0 +1,153 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_RING_HPP +#define BOOST_GEOMETRY_GEOMETRIES_RING_HPP + +#include +#include + +#include + +#include +#include +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +namespace model +{ +/*! +\brief A ring (aka linear ring) is a closed line which should not be selfintersecting +\ingroup geometries +\tparam Point point type +\tparam ClockWise true for clockwise direction, + false for CounterClockWise direction +\tparam Closed true for closed polygons (last point == first point), + false open points +\tparam Container container type, for example std::vector, std::deque +\tparam Allocator container-allocator-type + +\qbk{before.synopsis, +[heading Model of] +[link geometry.reference.concepts.concept_ring Ring Concept] +} +*/ +template +< + typename Point, + bool ClockWise = true, bool Closed = true, + template class Container = std::vector, + template class Allocator = std::allocator +> +class ring : public Container > +{ + BOOST_CONCEPT_ASSERT( (concept::Point) ); + + typedef Container > base_type; + +public : + /// \constructor_default{ring} + inline ring() + : base_type() + {} + + /// \constructor_begin_end{ring} + template + inline ring(Iterator begin, Iterator end) + : base_type(begin, end) + {} +}; + +} // namespace model + + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +< + typename Point, + bool ClockWise, bool Closed, + template class Container, + template class Allocator +> +struct tag > +{ + typedef ring_tag type; +}; + + +template +< + typename Point, + bool Closed, + template class Container, + template class Allocator +> +struct point_order > +{ + static const order_selector value = counterclockwise; +}; + + +template +< + typename Point, + bool Closed, + template class Container, + template class Allocator +> +struct point_order > +{ + static const order_selector value = clockwise; +}; + +template +< + typename Point, + bool PointOrder, + template class Container, + template class Allocator +> +struct closure > +{ + static const closure_selector value = closed; +}; + +template +< + typename Point, + bool PointOrder, + template class Container, + template class Allocator +> +struct closure > +{ + static const closure_selector value = open; +}; + + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_RING_HPP diff --git a/include/boost/geometry/geometries/segment.hpp b/include/boost/geometry/geometries/segment.hpp new file mode 100644 index 000000000..1a3a44085 --- /dev/null +++ b/include/boost/geometry/geometries/segment.hpp @@ -0,0 +1,203 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2011 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2011 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2011 Mateusz Loskot, London, UK. + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_GEOMETRIES_SEGMENT_HPP +#define BOOST_GEOMETRY_GEOMETRIES_SEGMENT_HPP + +#include + +#include +#include +#include + +#include + +namespace boost { namespace geometry +{ + +namespace model +{ + +/*! +\brief Class segment: small class containing two points +\ingroup geometries +\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 There is also a point-referring-segment, class referring_segment, + containing point references, where points are NOT copied +*/ +template +class segment : public std::pair +{ +public : + inline segment() + {} + + inline segment(Point const& p1, Point const& p2) + { + this->first = p1; + this->second = p2; + } +}; + + +/*! +\brief Class segment: small class containing two (templatized) point references +\ingroup geometries +\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. +\note type is const or non const, so geometry::segment

or geometry::segment

+\note We cannot derive from std::pair because of +reference assignments. +\tparam ConstOrNonConstPoint point type of the segment, maybe a point or a const point +*/ +template +class referring_segment +{ + BOOST_CONCEPT_ASSERT( ( + typename boost::mpl::if_ + < + boost::is_const, + concept::Point, + concept::ConstPoint + > + ) ); + + typedef ConstOrNonConstPoint point_type; + +public: + + point_type& first; + point_type& second; + + inline referring_segment(point_type& p1, point_type& p2) + : first(p1) + , second(p2) + {} +}; + + +} // namespace model + + +// Traits specializations for segment above +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS +namespace traits +{ + +template +struct tag > +{ + typedef segment_tag type; +}; + +template +struct point_type > +{ + typedef Point type; +}; + +template +struct indexed_access, 0, Dimension> +{ + typedef model::segment segment_type; + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(segment_type const& s) + { + return geometry::get(s.first); + } + + static inline void set(segment_type& s, coordinate_type const& value) + { + geometry::set(s.first, value); + } +}; + + +template +struct indexed_access, 1, Dimension> +{ + typedef model::segment segment_type; + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(segment_type const& s) + { + return geometry::get(s.second); + } + + static inline void set(segment_type& s, coordinate_type const& value) + { + geometry::set(s.second, value); + } +}; + + +template +struct tag > +{ + typedef segment_tag type; +}; + +template +struct point_type > +{ + typedef ConstOrNonConstPoint type; +}; + +template +struct indexed_access, 0, Dimension> +{ + typedef model::referring_segment segment_type; + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(segment_type const& s) + { + return geometry::get(s.first); + } + + static inline void set(segment_type& s, coordinate_type const& value) + { + geometry::set(s.first, value); + } +}; + + +template +struct indexed_access, 1, Dimension> +{ + typedef model::referring_segment segment_type; + typedef typename geometry::coordinate_type::type coordinate_type; + + static inline coordinate_type get(segment_type const& s) + { + return geometry::get(s.second); + } + + static inline void set(segment_type& s, coordinate_type const& value) + { + geometry::set(s.second, value); + } +}; + + + +} // namespace traits +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_GEOMETRIES_SEGMENT_HPP