1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
7 // This file was modified by Oracle on 2014.
8 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
19 #ifndef BOOST_GEOMETRY_CORE_CS_HPP
20 #define BOOST_GEOMETRY_CORE_CS_HPP
24 #include <boost/mpl/assert.hpp>
25 #include <boost/type_traits/integral_constant.hpp>
27 #include <boost/geometry/core/coordinate_system.hpp>
28 #include <boost/geometry/core/tags.hpp>
31 namespace boost { namespace geometry
35 \brief Unit of plane angle: Degrees
36 \details Tag defining the unit of plane angle for spherical coordinate systems.
37 This tag specifies that coordinates are defined in degrees (-180 .. 180).
38 It has to be specified for some coordinate systems.
39 \qbk{[include reference/core/degree_radian.qbk]}
45 \brief Unit of plane angle: Radians
46 \details Tag defining the unit of plane angle for spherical coordinate systems.
47 This tag specifies that coordinates are defined in radians (-PI .. PI).
48 It has to be specified for some coordinate systems.
49 \qbk{[include reference/core/degree_radian.qbk]}
54 #ifndef DOXYGEN_NO_DETAIL
58 template <typename DegreeOrRadian>
59 struct coordinate_system_units
63 COORDINATE_SYSTEM_UNITS_MUST_BE_DEGREES_OR_RADIANS,
64 (types<DegreeOrRadian>));
68 struct coordinate_system_units<geometry::degree>
70 typedef geometry::degree units;
74 struct coordinate_system_units<geometry::radian>
76 typedef geometry::radian units;
79 } // namespace core_detail
80 #endif // DOXYGEN_NO_DETAIL
87 \brief Cartesian coordinate system
88 \details Defines the Cartesian or rectangular coordinate system
89 where points are defined in 2 or 3 (or more)
90 dimensions and usually (but not always) known as x,y,z
91 \see http://en.wikipedia.org/wiki/Cartesian_coordinate_system
100 \brief Geographic coordinate system, in degree or in radian
101 \details Defines the geographic coordinate system where points
102 are defined in two angles and usually
103 known as lat,long or lo,la or phi,lambda
104 \see http://en.wikipedia.org/wiki/Geographic_coordinate_system
106 \note might be moved to extensions/gis/geographic
108 template<typename DegreeOrRadian>
111 typedef typename core_detail::coordinate_system_units
120 \brief Spherical (polar) coordinate system, in degree or in radian
121 \details Defines the spherical coordinate system where points are
122 defined in two angles
123 and an optional radius usually known as r, theta, phi
126 0 <= phi < 2pi is the angle between the positive x-axis and the
127 line from the origin to the P projected onto the xy-plane.
129 0 <= theta <= pi is the angle between the positive z-axis and the
130 line formed between the origin and P.
131 - coordinate 2 (if specified):
132 r >= 0 is the distance from the origin to a given point P.
134 \see http://en.wikipedia.org/wiki/Spherical_coordinates
137 template<typename DegreeOrRadian>
140 typedef typename core_detail::coordinate_system_units
148 \brief Spherical equatorial coordinate system, in degree or in radian
149 \details This one resembles the geographic coordinate system, and has latitude
150 up from zero at the equator, to 90 at the pole
151 (opposite to the spherical(polar) coordinate system).
152 Used in astronomy and in GIS (but there is also the geographic)
154 \see http://en.wikipedia.org/wiki/Spherical_coordinates
157 template<typename DegreeOrRadian>
158 struct spherical_equatorial
160 typedef typename core_detail::coordinate_system_units
169 \brief Polar coordinate system
170 \details Defines the polar coordinate system "in which each point
171 on a plane is determined by an angle and a distance"
172 \see http://en.wikipedia.org/wiki/Polar_coordinates
175 template<typename DegreeOrRadian>
178 typedef typename core_detail::coordinate_system_units
192 \brief Traits class defining coordinate system tag, bound to coordinate system
194 \tparam CoordinateSystem coordinate system
196 template <typename CoordinateSystem>
202 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
204 template<typename DegreeOrRadian>
205 struct cs_tag<cs::geographic<DegreeOrRadian> >
207 typedef geographic_tag type;
210 template<typename DegreeOrRadian>
211 struct cs_tag<cs::spherical<DegreeOrRadian> >
213 typedef spherical_polar_tag type;
216 template<typename DegreeOrRadian>
217 struct cs_tag<cs::spherical_equatorial<DegreeOrRadian> >
219 typedef spherical_equatorial_tag type;
224 struct cs_tag<cs::cartesian>
226 typedef cartesian_tag type;
230 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
231 } // namespace traits
234 \brief Meta-function returning coordinate system tag (cs family) of any geometry
235 \tparam Geometry \tparam_geometry
238 template <typename Geometry>
241 typedef typename traits::cs_tag
243 typename geometry::coordinate_system<Geometry>::type
249 \brief Meta-function to verify if a coordinate system is radian
250 \tparam CoordinateSystem Any coordinate system.
253 template <typename CoordinateSystem>
254 struct is_radian : boost::true_type {};
257 #ifndef DOXYGEN_NO_SPECIALIZATIONS
259 // Specialization for any degree coordinate systems
260 template <template<typename> class CoordinateSystem>
261 struct is_radian< CoordinateSystem<degree> > : boost::false_type
265 #endif // DOXYGEN_NO_SPECIALIZATIONS
267 }} // namespace boost::geometry
269 #endif // BOOST_GEOMETRY_CORE_CS_HPP