Imported Upstream version 1.49.0
[platform/upstream/boost.git] / boost / geometry / core / cs.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
6
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
9
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13
14 #ifndef BOOST_GEOMETRY_CORE_CS_HPP
15 #define BOOST_GEOMETRY_CORE_CS_HPP
16
17 #include <cstddef>
18
19 #include <boost/type_traits.hpp>
20
21 #include <boost/geometry/core/coordinate_system.hpp>
22 #include <boost/geometry/core/tags.hpp>
23
24
25 namespace boost { namespace geometry
26 {
27
28 /*!
29 \brief Unit of plane angle: Degrees
30 \details Tag defining the unit of plane angle for spherical coordinate systems.
31     This tag specifies that coordinates are defined in degrees (-180 .. 180). 
32     It has to be specified for some coordinate systems.
33 \qbk{[include reference/core/degree_radian.qbk]}
34 */
35 struct degree {};
36
37
38 /*!
39 \brief Unit of plane angle: Radians
40 \details Tag defining the unit of plane angle for spherical coordinate systems.
41     This tag specifies that coordinates are defined in radians (-PI .. PI). 
42     It has to be specified for some coordinate systems.
43 \qbk{[include reference/core/degree_radian.qbk]}
44 */
45 struct radian {};
46
47
48 namespace cs
49 {
50
51 /*!
52 \brief Cartesian coordinate system
53 \details Defines the Cartesian or rectangular coordinate system
54     where points are defined in 2 or 3 (or more)
55 dimensions and usually (but not always) known as x,y,z
56 \see http://en.wikipedia.org/wiki/Cartesian_coordinate_system
57 \ingroup cs
58 */
59 struct cartesian {};
60
61
62
63
64 /*!
65 \brief Geographic coordinate system, in degree or in radian
66 \details Defines the geographic coordinate system where points
67     are defined in two angles and usually
68 known as lat,long or lo,la or phi,lambda
69 \see http://en.wikipedia.org/wiki/Geographic_coordinate_system
70 \ingroup cs
71 \note might be moved to extensions/gis/geographic
72 */
73 template<typename DegreeOrRadian>
74 struct geographic
75 {
76     typedef DegreeOrRadian units;
77 };
78
79
80
81 /*!
82 \brief Spherical (polar) coordinate system, in degree or in radian
83 \details Defines the spherical coordinate system where points are
84     defined in two angles
85     and an optional radius usually known as r, theta, phi
86 \par Coordinates:
87 - coordinate 0:
88     0 <= phi < 2pi is the angle between the positive x-axis and the
89         line from the origin to the P projected onto the xy-plane.
90 - coordinate 1:
91     0 <= theta <= pi is the angle between the positive z-axis and the
92         line formed between the origin and P.
93 - coordinate 2 (if specified):
94     r >= 0 is the distance from the origin to a given point P.
95
96 \see http://en.wikipedia.org/wiki/Spherical_coordinates
97 \ingroup cs
98 */
99 template<typename DegreeOrRadian>
100 struct spherical
101 {
102     typedef DegreeOrRadian units;
103 };
104
105
106 /*!
107 \brief Spherical equatorial coordinate system, in degree or in radian
108 \details This one resembles the geographic coordinate system, and has latitude
109     up from zero at the equator, to 90 at the pole 
110     (opposite to the spherical(polar) coordinate system).
111     Used in astronomy and in GIS (but there is also the geographic)
112
113 \see http://en.wikipedia.org/wiki/Spherical_coordinates
114 \ingroup cs
115 */
116 template<typename DegreeOrRadian>
117 struct spherical_equatorial
118 {
119     typedef DegreeOrRadian units;
120 };
121
122
123
124 /*!
125 \brief Polar coordinate system
126 \details Defines the polar coordinate system "in which each point
127     on a plane is determined by an angle and a distance"
128 \see http://en.wikipedia.org/wiki/Polar_coordinates
129 \ingroup cs
130 */
131 template<typename DegreeOrRadian>
132 struct polar
133 {
134     typedef DegreeOrRadian units;
135 };
136
137
138 } // namespace cs
139
140
141 namespace traits
142 {
143
144 /*!
145 \brief Traits class defining coordinate system tag, bound to coordinate system
146 \ingroup traits
147 \tparam CoordinateSystem coordinate system
148 */
149 template <typename CoordinateSystem>
150 struct cs_tag
151 {
152 };
153
154
155 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
156
157 template<typename DegreeOrRadian>
158 struct cs_tag<cs::geographic<DegreeOrRadian> >
159 {
160     typedef geographic_tag type;
161 };
162
163 template<typename DegreeOrRadian>
164 struct cs_tag<cs::spherical<DegreeOrRadian> >
165 {
166     typedef spherical_polar_tag type;
167 };
168
169 template<typename DegreeOrRadian>
170 struct cs_tag<cs::spherical_equatorial<DegreeOrRadian> >
171 {
172     typedef spherical_equatorial_tag type;
173 };
174
175
176 template<>
177 struct cs_tag<cs::cartesian>
178 {
179     typedef cartesian_tag type;
180 };
181
182
183 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
184 } // namespace traits
185
186 /*!
187 \brief Meta-function returning coordinate system tag (cs family) of any geometry
188 \ingroup core
189 */
190 template <typename G>
191 struct cs_tag
192 {
193     typedef typename traits::cs_tag
194         <
195             typename geometry::coordinate_system<G>::type
196         >::type type;
197 };
198
199
200 /*!
201 \brief Meta-function to verify if a coordinate system is radian
202 \ingroup core
203 */
204 template <typename CoordinateSystem>
205 struct is_radian : boost::true_type {};
206
207
208 #ifndef DOXYGEN_NO_SPECIALIZATIONS
209
210 // Specialization for any degree coordinate systems
211 template <template<typename> class CoordinateSystem>
212 struct is_radian< CoordinateSystem<degree> > : boost::false_type
213 {
214 };
215
216 #endif // DOXYGEN_NO_SPECIALIZATIONS
217
218 }} // namespace boost::geometry
219
220 #endif // BOOST_GEOMETRY_CORE_CS_HPP