Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@101: // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. Chris@101: // Copyright (c) 2008-2014 Bruno Lalande, Paris, France. Chris@101: // Copyright (c) 2009-2014 Mateusz Loskot, London, UK. Chris@101: Chris@101: // This file was modified by Oracle on 2014. Chris@101: // Modifications copyright (c) 2014, Oracle and/or its affiliates. Chris@101: Chris@101: // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle Chris@16: Chris@16: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@16: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GEOMETRY_CORE_CS_HPP Chris@16: #define BOOST_GEOMETRY_CORE_CS_HPP Chris@16: Chris@16: #include Chris@16: Chris@101: #include Chris@101: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: Chris@16: Chris@16: namespace boost { namespace geometry Chris@16: { Chris@16: Chris@16: /*! Chris@16: \brief Unit of plane angle: Degrees Chris@16: \details Tag defining the unit of plane angle for spherical coordinate systems. Chris@101: This tag specifies that coordinates are defined in degrees (-180 .. 180). Chris@16: It has to be specified for some coordinate systems. Chris@16: \qbk{[include reference/core/degree_radian.qbk]} Chris@16: */ Chris@16: struct degree {}; Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Unit of plane angle: Radians Chris@16: \details Tag defining the unit of plane angle for spherical coordinate systems. Chris@101: This tag specifies that coordinates are defined in radians (-PI .. PI). Chris@16: It has to be specified for some coordinate systems. Chris@16: \qbk{[include reference/core/degree_radian.qbk]} Chris@16: */ Chris@16: struct radian {}; Chris@16: Chris@16: Chris@101: #ifndef DOXYGEN_NO_DETAIL Chris@101: namespace core_detail Chris@101: { Chris@101: Chris@101: template Chris@101: struct coordinate_system_units Chris@101: { Chris@101: BOOST_MPL_ASSERT_MSG Chris@101: ((false), Chris@101: COORDINATE_SYSTEM_UNITS_MUST_BE_DEGREES_OR_RADIANS, Chris@101: (types)); Chris@101: }; Chris@101: Chris@101: template <> Chris@101: struct coordinate_system_units Chris@101: { Chris@101: typedef geometry::degree units; Chris@101: }; Chris@101: Chris@101: template <> Chris@101: struct coordinate_system_units Chris@101: { Chris@101: typedef geometry::radian units; Chris@101: }; Chris@101: Chris@101: } // namespace core_detail Chris@101: #endif // DOXYGEN_NO_DETAIL Chris@101: Chris@101: Chris@16: namespace cs Chris@16: { Chris@16: Chris@16: /*! Chris@16: \brief Cartesian coordinate system Chris@16: \details Defines the Cartesian or rectangular coordinate system Chris@16: where points are defined in 2 or 3 (or more) Chris@16: dimensions and usually (but not always) known as x,y,z Chris@16: \see http://en.wikipedia.org/wiki/Cartesian_coordinate_system Chris@16: \ingroup cs Chris@16: */ Chris@16: struct cartesian {}; Chris@16: Chris@16: Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Geographic coordinate system, in degree or in radian Chris@16: \details Defines the geographic coordinate system where points Chris@16: are defined in two angles and usually Chris@16: known as lat,long or lo,la or phi,lambda Chris@16: \see http://en.wikipedia.org/wiki/Geographic_coordinate_system Chris@16: \ingroup cs Chris@16: \note might be moved to extensions/gis/geographic Chris@16: */ Chris@16: template Chris@16: struct geographic Chris@16: { Chris@101: typedef typename core_detail::coordinate_system_units Chris@101: < Chris@101: DegreeOrRadian Chris@101: >::units units; Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Spherical (polar) coordinate system, in degree or in radian Chris@16: \details Defines the spherical coordinate system where points are Chris@16: defined in two angles Chris@16: and an optional radius usually known as r, theta, phi Chris@16: \par Coordinates: Chris@16: - coordinate 0: Chris@16: 0 <= phi < 2pi is the angle between the positive x-axis and the Chris@16: line from the origin to the P projected onto the xy-plane. Chris@16: - coordinate 1: Chris@16: 0 <= theta <= pi is the angle between the positive z-axis and the Chris@16: line formed between the origin and P. Chris@16: - coordinate 2 (if specified): Chris@16: r >= 0 is the distance from the origin to a given point P. Chris@16: Chris@16: \see http://en.wikipedia.org/wiki/Spherical_coordinates Chris@16: \ingroup cs Chris@16: */ Chris@16: template Chris@16: struct spherical Chris@16: { Chris@101: typedef typename core_detail::coordinate_system_units Chris@101: < Chris@101: DegreeOrRadian Chris@101: >::units units; Chris@16: }; Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Spherical equatorial coordinate system, in degree or in radian Chris@16: \details This one resembles the geographic coordinate system, and has latitude Chris@101: up from zero at the equator, to 90 at the pole Chris@16: (opposite to the spherical(polar) coordinate system). Chris@16: Used in astronomy and in GIS (but there is also the geographic) Chris@16: Chris@16: \see http://en.wikipedia.org/wiki/Spherical_coordinates Chris@16: \ingroup cs Chris@16: */ Chris@16: template Chris@16: struct spherical_equatorial Chris@16: { Chris@101: typedef typename core_detail::coordinate_system_units Chris@101: < Chris@101: DegreeOrRadian Chris@101: >::units units; Chris@16: }; Chris@16: Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Polar coordinate system Chris@16: \details Defines the polar coordinate system "in which each point Chris@16: on a plane is determined by an angle and a distance" Chris@16: \see http://en.wikipedia.org/wiki/Polar_coordinates Chris@16: \ingroup cs Chris@16: */ Chris@16: template Chris@16: struct polar Chris@16: { Chris@101: typedef typename core_detail::coordinate_system_units Chris@101: < Chris@101: DegreeOrRadian Chris@101: >::units units; Chris@16: }; Chris@16: Chris@16: Chris@16: } // namespace cs Chris@16: Chris@16: Chris@16: namespace traits Chris@16: { Chris@16: Chris@16: /*! Chris@16: \brief Traits class defining coordinate system tag, bound to coordinate system Chris@16: \ingroup traits Chris@16: \tparam CoordinateSystem coordinate system Chris@16: */ Chris@16: template Chris@16: struct cs_tag Chris@16: { Chris@16: }; Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@16: Chris@16: template Chris@16: struct cs_tag > Chris@16: { Chris@16: typedef geographic_tag type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct cs_tag > Chris@16: { Chris@16: typedef spherical_polar_tag type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct cs_tag > Chris@16: { Chris@16: typedef spherical_equatorial_tag type; Chris@16: }; Chris@16: Chris@16: Chris@16: template<> Chris@16: struct cs_tag Chris@16: { Chris@16: typedef cartesian_tag type; Chris@16: }; Chris@16: Chris@16: Chris@16: #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS Chris@16: } // namespace traits Chris@16: Chris@16: /*! Chris@16: \brief Meta-function returning coordinate system tag (cs family) of any geometry Chris@101: \tparam Geometry \tparam_geometry Chris@16: \ingroup core Chris@16: */ Chris@101: template Chris@16: struct cs_tag Chris@16: { Chris@16: typedef typename traits::cs_tag Chris@16: < Chris@101: typename geometry::coordinate_system::type Chris@16: >::type type; Chris@16: }; Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Meta-function to verify if a coordinate system is radian Chris@101: \tparam CoordinateSystem Any coordinate system. Chris@16: \ingroup core Chris@16: */ Chris@16: template Chris@16: struct is_radian : boost::true_type {}; Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_NO_SPECIALIZATIONS Chris@16: Chris@16: // Specialization for any degree coordinate systems Chris@16: template class CoordinateSystem> Chris@16: struct is_radian< CoordinateSystem > : boost::false_type Chris@16: { Chris@16: }; Chris@16: Chris@16: #endif // DOXYGEN_NO_SPECIALIZATIONS Chris@16: Chris@16: }} // namespace boost::geometry Chris@16: Chris@16: #endif // BOOST_GEOMETRY_CORE_CS_HPP