1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
4 // Copyright (c) 2008-2014 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
7 // This file was modified by Oracle on 2014.
8 // Modifications copyright (c) 2014, Oracle and/or its affiliates.
10 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
13 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
15 // Use, modification and distribution is subject to the Boost Software License,
16 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
19 #ifndef BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
20 #define BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP
24 #include <boost/concept_check.hpp>
25 #include <boost/core/ignore_unused.hpp>
27 #include <boost/geometry/core/access.hpp>
28 #include <boost/geometry/core/coordinate_dimension.hpp>
29 #include <boost/geometry/core/coordinate_system.hpp>
33 namespace boost { namespace geometry { namespace concepts
40 \par Formal definition:
41 The point concept is defined as following:
42 - there must be a specialization of traits::tag defining point_tag as type
43 - there must be a specialization of traits::coordinate_type defining the type
45 - there must be a specialization of traits::coordinate_system defining its
46 coordinate system (cartesian, spherical, etc)
47 - there must be a specialization of traits::dimension defining its number
48 of dimensions (2, 3, ...) (derive it conveniently
49 from boost::mpl::int_<X> for X-D)
50 - there must be a specialization of traits::access, per dimension,
52 - \b get to get a coordinate value
53 - \b set to set a coordinate value (this one is not checked for ConstPoint)
54 - for non-Cartesian coordinate systems, the coordinate system's units
55 must either be boost::geometry::degree or boost::geometry::radian
60 A legacy point, defining the necessary specializations to fulfil to the concept.
62 Suppose that the following point is defined:
63 \dontinclude doxygen_5.cpp
67 It can then be adapted to the concept as following:
68 \dontinclude doxygen_5.cpp
69 \skip adapt legacy_point1
72 Note that it is done like above to show the system. Users will normally use the registration macro.
76 A read-only legacy point, using a macro to fulfil to the ConstPoint concept.
77 It cannot be modified by the library but can be used in all algorithms where
78 points are not modified.
80 The point looks like the following:
82 \dontinclude doxygen_5.cpp
86 It uses the macro as following:
87 \dontinclude doxygen_5.cpp
88 \skip adapt legacy_point2
93 template <typename Geometry>
96 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
98 typedef typename coordinate_type<Geometry>::type ctype;
99 typedef typename coordinate_system<Geometry>::type csystem;
101 // The following enum is used to fully instantiate the coordinate
102 // system class; this is needed in order to check the units passed
103 // to it for non-Cartesian coordinate systems.
104 enum { cs_check = sizeof(csystem) };
106 enum { ccount = dimension<Geometry>::value };
108 template <typename P, std::size_t Dimension, std::size_t DimensionCount>
109 struct dimension_checker
114 geometry::set<Dimension>(*p, geometry::get<Dimension>(*p));
115 dimension_checker<P, Dimension+1, DimensionCount>::apply();
120 template <typename P, std::size_t DimensionCount>
121 struct dimension_checker<P, DimensionCount, DimensionCount>
123 static void apply() {}
128 /// BCCL macro to apply the Point concept
129 BOOST_CONCEPT_USAGE(Point)
131 dimension_checker<Geometry, 0, ccount>::apply();
138 \brief point concept (const version).
140 \ingroup const_concepts
142 \details The ConstPoint concept apply the same as the Point concept,
143 but does not apply write access.
146 template <typename Geometry>
149 #ifndef DOXYGEN_NO_CONCEPT_MEMBERS
151 typedef typename coordinate_type<Geometry>::type ctype;
152 typedef typename coordinate_system<Geometry>::type csystem;
154 // The following enum is used to fully instantiate the coordinate
155 // system class; this is needed in order to check the units passed
156 // to it for non-Cartesian coordinate systems.
157 enum { cs_check = sizeof(csystem) };
159 enum { ccount = dimension<Geometry>::value };
161 template <typename P, std::size_t Dimension, std::size_t DimensionCount>
162 struct dimension_checker
167 ctype coord(geometry::get<Dimension>(*p));
168 boost::ignore_unused(p, coord);
169 dimension_checker<P, Dimension+1, DimensionCount>::apply();
174 template <typename P, std::size_t DimensionCount>
175 struct dimension_checker<P, DimensionCount, DimensionCount>
177 static void apply() {}
182 /// BCCL macro to apply the ConstPoint concept
183 BOOST_CONCEPT_USAGE(ConstPoint)
185 dimension_checker<Geometry, 0, ccount>::apply();
190 }}} // namespace boost::geometry::concepts
192 #endif // BOOST_GEOMETRY_GEOMETRIES_CONCEPTS_POINT_CONCEPT_HPP