summaryrefslogtreecommitdiff
path: root/boost/geometry/core
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/core')
-rw-r--r--boost/geometry/core/cs.hpp63
-rw-r--r--boost/geometry/core/interior_type.hpp2
-rw-r--r--boost/geometry/core/radius.hpp250
-rw-r--r--boost/geometry/core/ring_type.hpp17
-rw-r--r--boost/geometry/core/srs.hpp195
-rw-r--r--boost/geometry/core/tags.hpp13
6 files changed, 525 insertions, 15 deletions
diff --git a/boost/geometry/core/cs.hpp b/boost/geometry/core/cs.hpp
index cf6c56b53c..301fb6b76f 100644
--- a/boost/geometry/core/cs.hpp
+++ b/boost/geometry/core/cs.hpp
@@ -1,8 +1,13 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
-// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
+
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -16,7 +21,8 @@
#include <cstddef>
-#include <boost/type_traits.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/integral_constant.hpp>
#include <boost/geometry/core/coordinate_system.hpp>
#include <boost/geometry/core/tags.hpp>
@@ -45,6 +51,35 @@ struct degree {};
struct radian {};
+#ifndef DOXYGEN_NO_DETAIL
+namespace core_detail
+{
+
+template <typename DegreeOrRadian>
+struct coordinate_system_units
+{
+ BOOST_MPL_ASSERT_MSG
+ ((false),
+ COORDINATE_SYSTEM_UNITS_MUST_BE_DEGREES_OR_RADIANS,
+ (types<DegreeOrRadian>));
+};
+
+template <>
+struct coordinate_system_units<geometry::degree>
+{
+ typedef geometry::degree units;
+};
+
+template <>
+struct coordinate_system_units<geometry::radian>
+{
+ typedef geometry::radian units;
+};
+
+} // namespace core_detail
+#endif // DOXYGEN_NO_DETAIL
+
+
namespace cs
{
@@ -73,7 +108,10 @@ known as lat,long or lo,la or phi,lambda
template<typename DegreeOrRadian>
struct geographic
{
- typedef DegreeOrRadian units;
+ typedef typename core_detail::coordinate_system_units
+ <
+ DegreeOrRadian
+ >::units units;
};
@@ -99,7 +137,10 @@ struct geographic
template<typename DegreeOrRadian>
struct spherical
{
- typedef DegreeOrRadian units;
+ typedef typename core_detail::coordinate_system_units
+ <
+ DegreeOrRadian
+ >::units units;
};
@@ -116,7 +157,10 @@ struct spherical
template<typename DegreeOrRadian>
struct spherical_equatorial
{
- typedef DegreeOrRadian units;
+ typedef typename core_detail::coordinate_system_units
+ <
+ DegreeOrRadian
+ >::units units;
};
@@ -131,7 +175,10 @@ struct spherical_equatorial
template<typename DegreeOrRadian>
struct polar
{
- typedef DegreeOrRadian units;
+ typedef typename core_detail::coordinate_system_units
+ <
+ DegreeOrRadian
+ >::units units;
};
diff --git a/boost/geometry/core/interior_type.hpp b/boost/geometry/core/interior_type.hpp
index 02328372f0..e6c4537e41 100644
--- a/boost/geometry/core/interior_type.hpp
+++ b/boost/geometry/core/interior_type.hpp
@@ -86,7 +86,7 @@ struct interior_return_type<polygon_tag, Polygon>
{
typedef typename boost::remove_const<Polygon>::type nc_polygon_type;
- typedef typename mpl::if_
+ typedef typename boost::mpl::if_
<
boost::is_const<Polygon>,
typename traits::interior_const_type<nc_polygon_type>::type,
diff --git a/boost/geometry/core/radius.hpp b/boost/geometry/core/radius.hpp
new file mode 100644
index 0000000000..ee6d5d246f
--- /dev/null
+++ b/boost/geometry/core/radius.hpp
@@ -0,0 +1,250 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014 Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+
+#ifndef BOOST_GEOMETRY_CORE_RADIUS_HPP
+#define BOOST_GEOMETRY_CORE_RADIUS_HPP
+
+
+#include <cstddef>
+
+#include <boost/static_assert.hpp>
+
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+#include <boost/geometry/util/bare_type.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace traits
+{
+
+/*!
+ \brief Traits class to get/set radius of a circle/sphere/(ellipse)
+ \details the radius access meta-functions give read/write access to the radius of a circle or a sphere,
+ or to the major/minor axis or an ellipse, or to one of the 3 equatorial radii of an ellipsoid.
+
+ It should be specialized per geometry, in namespace core_dispatch. Those specializations should
+ forward the call via traits to the geometry class, which could be specified by the user.
+
+ There is a corresponding generic radius_get and radius_set function
+ \par Geometries:
+ - n-sphere (circle,sphere)
+ - upcoming ellipse
+ \par Specializations should provide:
+ - inline static T get(Geometry const& geometry)
+ - inline static void set(Geometry& geometry, T const& radius)
+ \ingroup traits
+*/
+template <typename Geometry, std::size_t Dimension>
+struct radius_access {};
+
+
+/*!
+ \brief Traits class indicating the type (double,float,...) of the radius of a circle or a sphere
+ \par Geometries:
+ - n-sphere (circle,sphere)
+ - upcoming ellipse
+ \par Specializations should provide:
+ - typedef T type (double,float,int,etc)
+ \ingroup traits
+*/
+template <typename Geometry>
+struct radius_type {};
+
+} // namespace traits
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Tag, typename Geometry>
+struct radius_type
+{
+ //typedef core_dispatch_specialization_required type;
+};
+
+/*!
+ \brief radius access meta-functions, used by concept n-sphere and upcoming ellipse.
+*/
+template <typename Tag,
+ typename Geometry,
+ std::size_t Dimension,
+ typename IsPointer>
+struct radius_access
+{
+ //static inline CoordinateType get(Geometry const& ) {}
+ //static inline void set(Geometry& g, CoordinateType const& value) {}
+};
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+/*!
+ \brief Metafunction to get the type of radius of a circle / sphere / ellipse / etc.
+ \ingroup access
+ \tparam Geometry the type of geometry
+*/
+template <typename Geometry>
+struct radius_type
+{
+ typedef typename core_dispatch::radius_type
+ <
+ typename tag<Geometry>::type,
+ typename util::bare_type<Geometry>::type
+ >::type type;
+};
+
+/*!
+ \brief Function to get radius of a circle / sphere / ellipse / etc.
+ \return radius The radius for a given axis
+ \ingroup access
+ \param geometry the geometry to get the radius from
+ \tparam I index of the axis
+*/
+template <std::size_t I, typename Geometry>
+inline typename radius_type<Geometry>::type get_radius(Geometry const& geometry)
+{
+ return core_dispatch::radius_access
+ <
+ typename tag<Geometry>::type,
+ typename util::bare_type<Geometry>::type,
+ I,
+ typename boost::is_pointer<Geometry>::type
+ >::get(geometry);
+}
+
+/*!
+ \brief Function to set the radius of a circle / sphere / ellipse / etc.
+ \ingroup access
+ \tparam I index of the axis
+ \param geometry the geometry to change
+ \param radius the radius to set
+*/
+template <std::size_t I, typename Geometry>
+inline void set_radius(Geometry& geometry,
+ typename radius_type<Geometry>::type const& radius)
+{
+ core_dispatch::radius_access
+ <
+ typename tag<Geometry>::type,
+ typename util::bare_type<Geometry>::type,
+ I,
+ typename boost::is_pointer<Geometry>::type
+ >::set(geometry, radius);
+}
+
+
+
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+template <typename Tag, typename Geometry, std::size_t Dimension>
+struct radius_access
+{
+ static inline typename radius_type<Geometry>::type get(Geometry const& geometry)
+ {
+ return traits::radius_access<Geometry, Dimension>::get(geometry);
+ }
+ static inline void set(Geometry& geometry,
+ typename radius_type<Geometry>::type const& value)
+ {
+ traits::radius_access<Geometry, Dimension>::set(geometry, value);
+ }
+};
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+#ifndef DOXYGEN_NO_DISPATCH
+namespace core_dispatch
+{
+
+template <typename Tag,
+ typename Geometry,
+ std::size_t Dimension>
+struct radius_access<Tag, Geometry, Dimension, boost::true_type>
+{
+ typedef typename geometry::radius_type<Geometry>::type radius_type;
+
+ static inline radius_type get(const Geometry * geometry)
+ {
+ return radius_access
+ <
+ Tag,
+ Geometry,
+ Dimension,
+ typename boost::is_pointer<Geometry>::type
+ >::get(*geometry);
+ }
+
+ static inline void set(Geometry * geometry, radius_type const& value)
+ {
+ return radius_access
+ <
+ Tag,
+ Geometry,
+ Dimension,
+ typename boost::is_pointer<Geometry>::type
+ >::set(*geometry, value);
+ }
+};
+
+
+template <typename Geometry>
+struct radius_type<srs_sphere_tag, Geometry>
+{
+ typedef typename traits::radius_type<Geometry>::type type;
+};
+
+template <typename Geometry, std::size_t Dimension>
+struct radius_access<srs_sphere_tag, Geometry, Dimension, boost::false_type>
+ : detail::radius_access<srs_sphere_tag, Geometry, Dimension>
+{
+ BOOST_STATIC_ASSERT(Dimension == 0);
+ //BOOST_STATIC_ASSERT(Dimension < 3);
+};
+
+template <typename Geometry>
+struct radius_type<srs_spheroid_tag, Geometry>
+{
+ typedef typename traits::radius_type<Geometry>::type type;
+};
+
+template <typename Geometry, std::size_t Dimension>
+struct radius_access<srs_spheroid_tag, Geometry, Dimension, boost::false_type>
+ : detail::radius_access<srs_spheroid_tag, Geometry, Dimension>
+{
+ BOOST_STATIC_ASSERT(Dimension == 0 || Dimension == 2);
+ //BOOST_STATIC_ASSERT(Dimension < 3);
+};
+
+} // namespace core_dispatch
+#endif // DOXYGEN_NO_DISPATCH
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_RADIUS_HPP
diff --git a/boost/geometry/core/ring_type.hpp b/boost/geometry/core/ring_type.hpp
index fe551f060f..c007931126 100644
--- a/boost/geometry/core/ring_type.hpp
+++ b/boost/geometry/core/ring_type.hpp
@@ -1,8 +1,13 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
-// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
-// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
+
+// This file was modified by Oracle on 2015.
+// Modifications copyright (c) 2015, Oracle and/or its affiliates.
+
+// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -95,7 +100,7 @@ struct ring_return_type<polygon_tag, Polygon>
{
typedef typename boost::remove_const<Polygon>::type nc_polygon_type;
- typedef typename mpl::if_
+ typedef typename boost::mpl::if_
<
boost::is_const<Polygon>,
typename traits::ring_const_type<nc_polygon_type>::type,
@@ -110,7 +115,7 @@ struct ring_return_type<multi_linestring_tag, MultiLinestring>
typedef typename ring_return_type
<
linestring_tag,
- typename mpl::if_
+ typename boost::mpl::if_
<
boost::is_const<MultiLinestring>,
typename boost::range_value<MultiLinestring>::type const,
@@ -126,7 +131,7 @@ struct ring_return_type<multi_polygon_tag, MultiPolygon>
typedef typename ring_return_type
<
polygon_tag,
- typename mpl::if_
+ typename boost::mpl::if_
<
boost::is_const<MultiPolygon>,
typename boost::range_value<MultiPolygon>::type const,
diff --git a/boost/geometry/core/srs.hpp b/boost/geometry/core/srs.hpp
new file mode 100644
index 0000000000..bf1b4e28a5
--- /dev/null
+++ b/boost/geometry/core/srs.hpp
@@ -0,0 +1,195 @@
+// Boost.Geometry (aka GGL, Generic Geometry Library)
+
+// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
+// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
+// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014 Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
+// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
+// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
+
+// Use, modification and distribution is subject to the Boost Software License,
+// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_GEOMETRY_CORE_SRS_HPP
+#define BOOST_GEOMETRY_CORE_SRS_HPP
+
+
+#include <cstddef>
+
+#include <boost/static_assert.hpp>
+
+#include <boost/geometry/core/radius.hpp>
+#include <boost/geometry/core/tag.hpp>
+#include <boost/geometry/core/tags.hpp>
+
+
+namespace boost { namespace geometry
+{
+
+namespace srs
+{
+
+/*!
+ \brief Defines spheroid radius values for use in geographical CS calculations
+ \note See http://en.wikipedia.org/wiki/Figure_of_the_Earth
+ and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84
+*/
+template <typename RadiusType>
+class spheroid
+{
+public:
+ spheroid(RadiusType const& a, RadiusType const& b)
+ : m_a(a)
+ , m_b(b)
+ {}
+
+ spheroid()
+ : m_a(RadiusType(6378137.0))
+ , m_b(RadiusType(6356752.314245))
+ {}
+
+ template <std::size_t I>
+ RadiusType get_radius() const
+ {
+ BOOST_STATIC_ASSERT(I < 3);
+
+ return I < 2 ? m_a : m_b;
+ }
+
+ template <std::size_t I>
+ void set_radius(RadiusType const& radius)
+ {
+ BOOST_STATIC_ASSERT(I < 3);
+
+ (I < 2 ? m_a : m_b) = radius;
+ }
+
+private:
+ RadiusType m_a, m_b; // equatorial radius, polar radius
+};
+
+} // namespace srs
+
+// Traits specializations for spheroid
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename RadiusType>
+struct tag< srs::spheroid<RadiusType> >
+{
+ typedef srs_spheroid_tag type;
+};
+
+template <typename RadiusType>
+struct radius_type< srs::spheroid<RadiusType> >
+{
+ typedef RadiusType type;
+};
+
+template <typename RadiusType, std::size_t Dimension>
+struct radius_access<srs::spheroid<RadiusType>, Dimension>
+{
+ typedef srs::spheroid<RadiusType> spheroid_type;
+
+ static inline RadiusType get(spheroid_type const& s)
+ {
+ return s.template get_radius<Dimension>();
+ }
+
+ static inline void set(spheroid_type& s, RadiusType const& value)
+ {
+ s.template set_radius<Dimension>(value);
+ }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+namespace srs
+{
+
+/*!
+ \brief Defines sphere radius value for use in spherical CS calculations
+*/
+template <typename RadiusType>
+class sphere
+{
+public:
+ explicit sphere(RadiusType const& r)
+ : m_r(r)
+ {}
+ sphere()
+ : m_r(RadiusType((2.0 * 6378137.0 + 6356752.314245) / 3.0))
+ {}
+
+ template <std::size_t I>
+ RadiusType get_radius() const
+ {
+ BOOST_STATIC_ASSERT(I < 3);
+
+ return m_r;
+ }
+
+ template <std::size_t I>
+ void set_radius(RadiusType const& radius)
+ {
+ BOOST_STATIC_ASSERT(I < 3);
+
+ m_r = radius;
+ }
+
+private:
+ RadiusType m_r; // radius
+};
+
+} // namespace srs
+
+// Traits specializations for sphere
+#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+namespace traits
+{
+
+template <typename RadiusType>
+struct tag< srs::sphere<RadiusType> >
+{
+ typedef srs_sphere_tag type;
+};
+
+template <typename RadiusType>
+struct radius_type< srs::sphere<RadiusType> >
+{
+ typedef RadiusType type;
+};
+
+template <typename RadiusType, std::size_t Dimension>
+struct radius_access<srs::sphere<RadiusType>, Dimension>
+{
+ typedef srs::sphere<RadiusType> sphere_type;
+
+ static inline RadiusType get(sphere_type const& s)
+ {
+ return s.template get_radius<Dimension>();
+ }
+
+ static inline void set(sphere_type& s, RadiusType const& value)
+ {
+ s.template set_radius<Dimension>(value);
+ }
+};
+
+} // namespace traits
+#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
+
+
+}} // namespace boost::geometry
+
+
+#endif // BOOST_GEOMETRY_CORE_SRS_HPP
diff --git a/boost/geometry/core/tags.hpp b/boost/geometry/core/tags.hpp
index 160477b8c4..5d6acb1878 100644
--- a/boost/geometry/core/tags.hpp
+++ b/boost/geometry/core/tags.hpp
@@ -4,6 +4,11 @@
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
+// This file was modified by Oracle on 2014.
+// Modifications copyright (c) 2014 Oracle and/or its affiliates.
+
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
@@ -37,6 +42,14 @@ struct spherical_equatorial_tag : spherical_tag {};
struct geographic_tag : spherical_tag {};
+// Tags defining coordinate systems reference models
+
+/// For reference spheroid defining parameters of geographical coordinate system
+struct srs_spheroid_tag {};
+
+/// For reference sphere defining parameters of spherical coordinate system
+struct srs_sphere_tag : srs_spheroid_tag {};
+
// Tags defining tag hierarchy