]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry (aka GGL, Generic Geometry Library) |
2 | ||
3 | // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. | |
4 | // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. | |
6 | ||
20effc67 TL |
7 | // This file was modified by Oracle on 2020. |
8 | // Modifications copyright (c) 2020, Oracle and/or its affiliates. | |
9 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle | |
10 | ||
7c673cae FG |
11 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library |
12 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
13 | ||
14 | // Use, modification and distribution is subject to the Boost Software License, | |
15 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
16 | // http://www.boost.org/LICENSE_1_0.txt) | |
17 | ||
18 | #ifndef BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP | |
19 | #define BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP | |
20 | ||
21 | ||
7c673cae | 22 | #include <boost/geometry/core/point_type.hpp> |
20effc67 | 23 | #include <boost/geometry/core/static_assert.hpp> |
7c673cae | 24 | #include <boost/geometry/core/tag.hpp> |
20effc67 | 25 | #include <boost/geometry/util/type_traits_std.hpp> |
7c673cae FG |
26 | |
27 | ||
28 | namespace boost { namespace geometry | |
29 | { | |
30 | ||
31 | namespace traits | |
32 | { | |
33 | ||
34 | /*! | |
35 | \brief Traits class which indicate the coordinate type (double,float,...) of a point | |
36 | \ingroup traits | |
37 | \par Geometries: | |
38 | - point | |
39 | \par Specializations should provide: | |
40 | - typedef T type; (double,float,int,etc) | |
41 | */ | |
42 | template <typename Point, typename Enable = void> | |
43 | struct coordinate_type | |
44 | { | |
20effc67 TL |
45 | BOOST_GEOMETRY_STATIC_ASSERT_FALSE( |
46 | "Not implemented for this Point type.", | |
47 | Point); | |
7c673cae FG |
48 | }; |
49 | ||
50 | } // namespace traits | |
51 | ||
52 | #ifndef DOXYGEN_NO_DISPATCH | |
53 | namespace core_dispatch | |
54 | { | |
55 | ||
56 | template <typename GeometryTag, typename Geometry> | |
57 | struct coordinate_type | |
58 | { | |
59 | typedef typename point_type<GeometryTag, Geometry>::type point_type; | |
60 | ||
61 | // Call its own specialization on point-tag | |
62 | typedef typename coordinate_type<point_tag, point_type>::type type; | |
63 | }; | |
64 | ||
65 | template <typename Point> | |
66 | struct coordinate_type<point_tag, Point> | |
67 | { | |
68 | typedef typename traits::coordinate_type | |
69 | < | |
20effc67 | 70 | typename util::remove_cptrref<Point>::type |
7c673cae FG |
71 | >::type type; |
72 | }; | |
73 | ||
74 | ||
75 | } // namespace core_dispatch | |
76 | #endif // DOXYGEN_NO_DISPATCH | |
77 | ||
78 | ||
79 | /*! | |
80 | \brief \brief_meta{type, coordinate type (int\, float\, double\, etc), \meta_point_type} | |
81 | \tparam Geometry \tparam_geometry | |
82 | \ingroup core | |
83 | ||
84 | \qbk{[include reference/core/coordinate_type.qbk]} | |
85 | */ | |
86 | template <typename Geometry> | |
87 | struct coordinate_type | |
88 | { | |
89 | typedef typename core_dispatch::coordinate_type | |
20effc67 TL |
90 | < |
91 | typename tag<Geometry>::type, | |
92 | typename util::remove_cptrref<Geometry>::type | |
93 | >::type type; | |
7c673cae FG |
94 | }; |
95 | ||
20effc67 TL |
96 | /*! |
97 | \brief assert_coordinate_type_equal, a compile-time check for equality of two coordinate types | |
98 | \ingroup utility | |
99 | */ | |
100 | template <typename Geometry1, typename Geometry2> | |
101 | constexpr inline void assert_coordinate_type_equal(Geometry1 const& , Geometry2 const& ) | |
102 | { | |
103 | static_assert(std::is_same | |
104 | < | |
105 | typename coordinate_type<Geometry1>::type, | |
106 | typename coordinate_type<Geometry2>::type | |
107 | >::value, "Coordinate types in geometries should be the same"); | |
108 | } | |
7c673cae FG |
109 | |
110 | }} // namespace boost::geometry | |
111 | ||
112 | ||
113 | #endif // BOOST_GEOMETRY_CORE_COORDINATE_TYPE_HPP |