1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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.
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
14 #ifndef BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP
15 #define BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP
19 #include <boost/config.hpp>
20 #include <boost/mpl/int.hpp>
22 #include <boost/geometry/core/cs.hpp>
23 #include <boost/geometry/geometries/point.hpp>
25 namespace boost { namespace geometry
28 namespace model { namespace d2
32 \brief 2D point in Cartesian coordinate system
33 \tparam CoordinateType numeric type, for example, double, float, int
34 \tparam CoordinateSystem coordinate system, defaults to cs::cartesian
36 \qbk{[include reference/geometries/point_xy.qbk]}
39 [link geometry.reference.concepts.concept_point Point Concept]
42 \qbk{[include reference/geometries/point_assign_warning.qbk]}
45 template<typename CoordinateType, typename CoordinateSystem = cs::cartesian>
46 class point_xy : public model::point<CoordinateType, 2, CoordinateSystem>
50 #ifndef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
51 /// \constructor_default_no_init
54 /// \constructor_default_no_init
59 /// Constructor with x/y values
60 inline point_xy(CoordinateType const& x, CoordinateType const& y)
61 : model::point<CoordinateType, 2, CoordinateSystem>(x, y)
65 inline CoordinateType const& x() const
66 { return this->template get<0>(); }
69 inline CoordinateType const& y() const
70 { return this->template get<1>(); }
73 inline void x(CoordinateType const& v)
74 { this->template set<0>(v); }
77 inline void y(CoordinateType const& v)
78 { this->template set<1>(v); }
82 }} // namespace model::d2
85 // Adapt the point_xy to the concept
86 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
90 template <typename CoordinateType, typename CoordinateSystem>
91 struct tag<model::d2::point_xy<CoordinateType, CoordinateSystem> >
93 typedef point_tag type;
96 template<typename CoordinateType, typename CoordinateSystem>
97 struct coordinate_type<model::d2::point_xy<CoordinateType, CoordinateSystem> >
99 typedef CoordinateType type;
102 template<typename CoordinateType, typename CoordinateSystem>
103 struct coordinate_system<model::d2::point_xy<CoordinateType, CoordinateSystem> >
105 typedef CoordinateSystem type;
108 template<typename CoordinateType, typename CoordinateSystem>
109 struct dimension<model::d2::point_xy<CoordinateType, CoordinateSystem> >
110 : boost::mpl::int_<2>
113 template<typename CoordinateType, typename CoordinateSystem, std::size_t Dimension>
114 struct access<model::d2::point_xy<CoordinateType, CoordinateSystem>, Dimension >
116 static inline CoordinateType get(
117 model::d2::point_xy<CoordinateType, CoordinateSystem> const& p)
119 return p.template get<Dimension>();
122 static inline void set(model::d2::point_xy<CoordinateType, CoordinateSystem>& p,
123 CoordinateType const& value)
125 p.template set<Dimension>(value);
129 } // namespace traits
130 #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
132 }} // namespace boost::geometry
134 #endif // BOOST_GEOMETRY_GEOMETRIES_POINT_XY_HPP