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, 2018.
8 // Modifications copyright (c) 2014-2018, Oracle and/or its affiliates.
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
13 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
14 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16 // Use, modification and distribution is subject to the Boost Software License,
17 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
18 // http://www.boost.org/LICENSE_1_0.txt)
20 #ifndef BOOST_GEOMETRY_CORE_CS_HPP
21 #define BOOST_GEOMETRY_CORE_CS_HPP
25 #include <boost/mpl/assert.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 define_angular_units
63 COORDINATE_SYSTEM_UNITS_MUST_BE_DEGREES_OR_RADIANS,
64 (types<DegreeOrRadian>));
68 struct define_angular_units<geometry::degree>
70 typedef geometry::degree units;
74 struct define_angular_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>
110 : core_detail::define_angular_units<DegreeOrRadian>
116 \brief Spherical (polar) coordinate system, in degree or in radian
117 \details Defines the spherical coordinate system where points are
118 defined in two angles
119 and an optional radius usually known as r, theta, phi
122 0 <= phi < 2pi is the angle between the positive x-axis and the
123 line from the origin to the P projected onto the xy-plane.
125 0 <= theta <= pi is the angle between the positive z-axis and the
126 line formed between the origin and P.
127 - coordinate 2 (if specified):
128 r >= 0 is the distance from the origin to a given point P.
130 \see http://en.wikipedia.org/wiki/Spherical_coordinates
133 template<typename DegreeOrRadian>
135 : core_detail::define_angular_units<DegreeOrRadian>
140 \brief Spherical equatorial coordinate system, in degree or in radian
141 \details This one resembles the geographic coordinate system, and has latitude
142 up from zero at the equator, to 90 at the pole
143 (opposite to the spherical(polar) coordinate system).
144 Used in astronomy and in GIS (but there is also the geographic)
146 \see http://en.wikipedia.org/wiki/Spherical_coordinates
149 template<typename DegreeOrRadian>
150 struct spherical_equatorial
151 : core_detail::define_angular_units<DegreeOrRadian>
157 \brief Polar coordinate system
158 \details Defines the polar coordinate system "in which each point
159 on a plane is determined by an angle and a distance"
160 \see http://en.wikipedia.org/wiki/Polar_coordinates
163 template<typename DegreeOrRadian>
165 : core_detail::define_angular_units<DegreeOrRadian>
170 \brief Undefined coordinate system
183 \brief Traits class defining coordinate system tag, bound to coordinate system
185 \tparam CoordinateSystem coordinate system
187 template <typename CoordinateSystem>
193 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
195 template<typename DegreeOrRadian>
196 struct cs_tag<cs::geographic<DegreeOrRadian> >
198 typedef geographic_tag type;
201 template<typename DegreeOrRadian>
202 struct cs_tag<cs::spherical<DegreeOrRadian> >
204 typedef spherical_polar_tag type;
207 template<typename DegreeOrRadian>
208 struct cs_tag<cs::spherical_equatorial<DegreeOrRadian> >
210 typedef spherical_equatorial_tag type;
215 struct cs_tag<cs::cartesian>
217 typedef cartesian_tag type;
222 struct cs_tag<cs::undefined>
224 typedef cs_undefined_tag type;
227 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
230 } // 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
251 // cartesian or undefined
252 template <typename CoordinateSystem>
253 struct cs_angular_units
255 typedef geometry::radian type;
258 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
260 template<typename DegreeOrRadian>
261 struct cs_angular_units<cs::geographic<DegreeOrRadian> >
263 typedef DegreeOrRadian type;
266 template<typename DegreeOrRadian>
267 struct cs_angular_units<cs::spherical<DegreeOrRadian> >
269 typedef DegreeOrRadian type;
272 template<typename DegreeOrRadian>
273 struct cs_angular_units<cs::spherical_equatorial<DegreeOrRadian> >
275 typedef DegreeOrRadian type;
278 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
281 } // namespace traits
284 #ifndef DOXYGEN_NO_DETAIL
288 template <typename Geometry>
289 struct cs_angular_units
291 typedef typename traits::cs_angular_units
293 typename geometry::coordinate_system<Geometry>::type
298 template <typename Units, typename CsTag>
299 struct cs_tag_to_coordinate_system
301 BOOST_MPL_ASSERT_MSG((false),
302 NOT_IMPLEMENTED_FOR_THIS_COORDINATE_SYSTEM,
306 template <typename Units>
307 struct cs_tag_to_coordinate_system<Units, cs_undefined_tag>
309 typedef cs::undefined type;
312 template <typename Units>
313 struct cs_tag_to_coordinate_system<Units, cartesian_tag>
315 typedef cs::cartesian type;
318 template <typename Units>
319 struct cs_tag_to_coordinate_system<Units, spherical_equatorial_tag>
321 typedef cs::spherical_equatorial<Units> type;
324 template <typename Units>
325 struct cs_tag_to_coordinate_system<Units, spherical_polar_tag>
327 typedef cs::spherical<Units> type;
330 template <typename Units>
331 struct cs_tag_to_coordinate_system<Units, geographic_tag>
333 typedef cs::geographic<Units> type;
336 } // namespace detail
337 #endif // DOXYGEN_NO_DETAIL
340 }} // namespace boost::geometry
342 #endif // BOOST_GEOMETRY_CORE_CS_HPP