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