]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 | ||
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_GEOMETRIES_POINT_XY_HPP | |
19 | #define BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP | |
20 | ||
21 | #include <cstddef> | |
20effc67 | 22 | #include <type_traits> |
7c673cae FG |
23 | |
24 | #include <boost/geometry/core/cs.hpp> | |
25 | #include <boost/geometry/geometries/point.hpp> | |
26 | ||
27 | namespace boost { namespace geometry | |
28 | { | |
29 | ||
30 | namespace model { namespace d2 | |
31 | { | |
32 | ||
33 | /*! | |
34 | \brief 2D point in Cartesian coordinate system | |
35 | \tparam CoordinateType numeric type, for example, double, float, int | |
36 | \tparam CoordinateSystem coordinate system, defaults to cs::cartesian | |
37 | ||
38 | \qbk{[include reference/geometries/point_xy.qbk]} | |
39 | \qbk{before.synopsis, | |
40 | [heading Model of] | |
41 | [link geometry.reference.concepts.concept_point Point Concept] | |
42 | } | |
43 | ||
44 | \qbk{[include reference/geometries/point_assign_warning.qbk]} | |
45 | ||
46 | */ | |
47 | template<typename CoordinateType, typename CoordinateSystem = cs::cartesian> | |
48 | class point_xy : public model::point<CoordinateType, 2, CoordinateSystem> | |
49 | { | |
50 | public: | |
7c673cae | 51 | /// \constructor_default_no_init |
20effc67 | 52 | constexpr point_xy() = default; |
7c673cae FG |
53 | |
54 | /// Constructor with x/y values | |
20effc67 | 55 | constexpr point_xy(CoordinateType const& x, CoordinateType const& y) |
7c673cae FG |
56 | : model::point<CoordinateType, 2, CoordinateSystem>(x, y) |
57 | {} | |
58 | ||
59 | /// Get x-value | |
20effc67 | 60 | constexpr CoordinateType const& x() const |
7c673cae FG |
61 | { return this->template get<0>(); } |
62 | ||
63 | /// Get y-value | |
20effc67 | 64 | constexpr CoordinateType const& y() const |
7c673cae FG |
65 | { return this->template get<1>(); } |
66 | ||
67 | /// Set x-value | |
20effc67 | 68 | void x(CoordinateType const& v) |
7c673cae FG |
69 | { this->template set<0>(v); } |
70 | ||
71 | /// Set y-value | |
20effc67 | 72 | void y(CoordinateType const& v) |
7c673cae FG |
73 | { this->template set<1>(v); } |
74 | }; | |
75 | ||
76 | ||
77 | }} // namespace model::d2 | |
78 | ||
79 | ||
80 | // Adapt the point_xy to the concept | |
81 | #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS | |
82 | namespace traits | |
83 | { | |
84 | ||
85 | template <typename CoordinateType, typename CoordinateSystem> | |
86 | struct tag<model::d2::point_xy<CoordinateType, CoordinateSystem> > | |
87 | { | |
88 | typedef point_tag type; | |
89 | }; | |
90 | ||
91 | template<typename CoordinateType, typename CoordinateSystem> | |
92 | struct coordinate_type<model::d2::point_xy<CoordinateType, CoordinateSystem> > | |
93 | { | |
94 | typedef CoordinateType type; | |
95 | }; | |
96 | ||
97 | template<typename CoordinateType, typename CoordinateSystem> | |
98 | struct coordinate_system<model::d2::point_xy<CoordinateType, CoordinateSystem> > | |
99 | { | |
100 | typedef CoordinateSystem type; | |
101 | }; | |
102 | ||
103 | template<typename CoordinateType, typename CoordinateSystem> | |
104 | struct dimension<model::d2::point_xy<CoordinateType, CoordinateSystem> > | |
20effc67 | 105 | : std::integral_constant<std::size_t, 2> |
7c673cae FG |
106 | {}; |
107 | ||
108 | template<typename CoordinateType, typename CoordinateSystem, std::size_t Dimension> | |
109 | struct access<model::d2::point_xy<CoordinateType, CoordinateSystem>, Dimension > | |
110 | { | |
20effc67 | 111 | static constexpr CoordinateType get( |
7c673cae FG |
112 | model::d2::point_xy<CoordinateType, CoordinateSystem> const& p) |
113 | { | |
114 | return p.template get<Dimension>(); | |
115 | } | |
116 | ||
20effc67 | 117 | static void set(model::d2::point_xy<CoordinateType, CoordinateSystem>& p, |
7c673cae FG |
118 | CoordinateType const& value) |
119 | { | |
120 | p.template set<Dimension>(value); | |
121 | } | |
122 | }; | |
123 | ||
20effc67 TL |
124 | template<typename CoordinateType, typename CoordinateSystem> |
125 | struct make<model::d2::point_xy<CoordinateType, CoordinateSystem> > | |
126 | { | |
127 | typedef model::d2::point_xy<CoordinateType, CoordinateSystem> point_type; | |
128 | ||
129 | static const bool is_specialized = true; | |
130 | ||
131 | static constexpr point_type apply(CoordinateType const& x, | |
132 | CoordinateType const& y) | |
133 | { | |
134 | return point_type(x, y); | |
135 | } | |
136 | }; | |
137 | ||
138 | ||
7c673cae FG |
139 | } // namespace traits |
140 | #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS | |
141 | ||
142 | }} // namespace boost::geometry | |
143 | ||
144 | #endif // BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP |