]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/geometry/geometries/point_xy.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / geometries / point_xy.hpp
CommitLineData
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
27namespace boost { namespace geometry
28{
29
30namespace 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*/
47template<typename CoordinateType, typename CoordinateSystem = cs::cartesian>
48class point_xy : public model::point<CoordinateType, 2, CoordinateSystem>
49{
50public:
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
82namespace traits
83{
84
85template <typename CoordinateType, typename CoordinateSystem>
86struct tag<model::d2::point_xy<CoordinateType, CoordinateSystem> >
87{
88 typedef point_tag type;
89};
90
91template<typename CoordinateType, typename CoordinateSystem>
92struct coordinate_type<model::d2::point_xy<CoordinateType, CoordinateSystem> >
93{
94 typedef CoordinateType type;
95};
96
97template<typename CoordinateType, typename CoordinateSystem>
98struct coordinate_system<model::d2::point_xy<CoordinateType, CoordinateSystem> >
99{
100 typedef CoordinateSystem type;
101};
102
103template<typename CoordinateType, typename CoordinateSystem>
104struct dimension<model::d2::point_xy<CoordinateType, CoordinateSystem> >
20effc67 105 : std::integral_constant<std::size_t, 2>
7c673cae
FG
106{};
107
108template<typename CoordinateType, typename CoordinateSystem, std::size_t Dimension>
109struct 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
124template<typename CoordinateType, typename CoordinateSystem>
125struct 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