diff options
Diffstat (limited to 'boost/geometry/core/cs.hpp')
-rw-r--r-- | boost/geometry/core/cs.hpp | 155 |
1 files changed, 114 insertions, 41 deletions
diff --git a/boost/geometry/core/cs.hpp b/boost/geometry/core/cs.hpp index 301fb6b76f..c39eec3d4d 100644 --- a/boost/geometry/core/cs.hpp +++ b/boost/geometry/core/cs.hpp @@ -4,10 +4,11 @@ // 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. +// This file was modified by Oracle on 2014, 2018. +// Modifications copyright (c) 2014-2018, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// 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. @@ -22,7 +23,6 @@ #include <cstddef> #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> @@ -56,7 +56,7 @@ namespace core_detail { template <typename DegreeOrRadian> -struct coordinate_system_units +struct define_angular_units { BOOST_MPL_ASSERT_MSG ((false), @@ -65,13 +65,13 @@ struct coordinate_system_units }; template <> -struct coordinate_system_units<geometry::degree> +struct define_angular_units<geometry::degree> { typedef geometry::degree units; }; template <> -struct coordinate_system_units<geometry::radian> +struct define_angular_units<geometry::radian> { typedef geometry::radian units; }; @@ -107,12 +107,8 @@ known as lat,long or lo,la or phi,lambda */ template<typename DegreeOrRadian> struct geographic -{ - typedef typename core_detail::coordinate_system_units - < - DegreeOrRadian - >::units units; -}; + : core_detail::define_angular_units<DegreeOrRadian> +{}; @@ -136,12 +132,8 @@ struct geographic */ template<typename DegreeOrRadian> struct spherical -{ - typedef typename core_detail::coordinate_system_units - < - DegreeOrRadian - >::units units; -}; + : core_detail::define_angular_units<DegreeOrRadian> +{}; /*! @@ -156,12 +148,8 @@ struct spherical */ template<typename DegreeOrRadian> struct spherical_equatorial -{ - typedef typename core_detail::coordinate_system_units - < - DegreeOrRadian - >::units units; -}; + : core_detail::define_angular_units<DegreeOrRadian> +{}; @@ -174,12 +162,15 @@ struct spherical_equatorial */ template<typename DegreeOrRadian> struct polar -{ - typedef typename core_detail::coordinate_system_units - < - DegreeOrRadian - >::units units; -}; + : core_detail::define_angular_units<DegreeOrRadian> +{}; + + +/*! +\brief Undefined coordinate system +\ingroup cs +*/ +struct undefined {}; } // namespace cs @@ -227,9 +218,18 @@ struct cs_tag<cs::cartesian> }; +template <> +struct cs_tag<cs::undefined> +{ + typedef cs_undefined_tag type; +}; + #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + + } // namespace traits + /*! \brief Meta-function returning coordinate system tag (cs family) of any geometry \tparam Geometry \tparam_geometry @@ -245,24 +245,97 @@ struct cs_tag }; -/*! -\brief Meta-function to verify if a coordinate system is radian -\tparam CoordinateSystem Any coordinate system. -\ingroup core -*/ +namespace traits +{ + +// cartesian or undefined template <typename CoordinateSystem> -struct is_radian : boost::true_type {}; +struct cs_angular_units +{ + typedef geometry::radian type; +}; + +#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +template<typename DegreeOrRadian> +struct cs_angular_units<cs::geographic<DegreeOrRadian> > +{ + typedef DegreeOrRadian type; +}; + +template<typename DegreeOrRadian> +struct cs_angular_units<cs::spherical<DegreeOrRadian> > +{ + typedef DegreeOrRadian type; +}; + +template<typename DegreeOrRadian> +struct cs_angular_units<cs::spherical_equatorial<DegreeOrRadian> > +{ + typedef DegreeOrRadian type; +}; + +#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS + +} // namespace traits -#ifndef DOXYGEN_NO_SPECIALIZATIONS -// Specialization for any degree coordinate systems -template <template<typename> class CoordinateSystem> -struct is_radian< CoordinateSystem<degree> > : boost::false_type +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + +template <typename Geometry> +struct cs_angular_units { + typedef typename traits::cs_angular_units + < + typename geometry::coordinate_system<Geometry>::type + >::type type; }; -#endif // DOXYGEN_NO_SPECIALIZATIONS + +template <typename Units, typename CsTag> +struct cs_tag_to_coordinate_system +{ + BOOST_MPL_ASSERT_MSG((false), + NOT_IMPLEMENTED_FOR_THIS_COORDINATE_SYSTEM, + (types<CsTag>)); +}; + +template <typename Units> +struct cs_tag_to_coordinate_system<Units, cs_undefined_tag> +{ + typedef cs::undefined type; +}; + +template <typename Units> +struct cs_tag_to_coordinate_system<Units, cartesian_tag> +{ + typedef cs::cartesian type; +}; + +template <typename Units> +struct cs_tag_to_coordinate_system<Units, spherical_equatorial_tag> +{ + typedef cs::spherical_equatorial<Units> type; +}; + +template <typename Units> +struct cs_tag_to_coordinate_system<Units, spherical_polar_tag> +{ + typedef cs::spherical<Units> type; +}; + +template <typename Units> +struct cs_tag_to_coordinate_system<Units, geographic_tag> +{ + typedef cs::geographic<Units> type; +}; + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + }} // namespace boost::geometry |