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
7// This file was modified by Oracle on 2020-2021.
8// Modifications copyright (c) 2020-2021 Oracle and/or its affiliates.
9// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10
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_POINT_TYPE_HPP
19#define BOOST_GEOMETRY_CORE_POINT_TYPE_HPP
20
21
22#include <boost/range/value_type.hpp>
23
24#include <boost/geometry/core/geometry_types.hpp>
25#include <boost/geometry/core/ring_type.hpp>
26#include <boost/geometry/core/static_assert.hpp>
27#include <boost/geometry/core/tag.hpp>
28#include <boost/geometry/core/tags.hpp>
29#include <boost/geometry/util/sequence.hpp>
30#include <boost/geometry/util/type_traits_std.hpp>
31
32
33namespace boost { namespace geometry
34{
35
36namespace traits
37{
38
39/*!
40\brief Traits class indicating the type of contained points
41\ingroup traits
42\par Geometries:
43 - all geometries except point
44\par Specializations should provide:
45 - typedef P type (where P should fulfil the Point concept)
46\tparam Geometry geometry
47*/
48template <typename Geometry>
49struct point_type
50{
51 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
52 "Not implemented for this Geometry type.",
53 Geometry);
54};
55
56
57} // namespace traits
58
59
60#ifndef DOXYGEN_NO_DISPATCH
61namespace core_dispatch
62{
63
64template <typename Tag, typename Geometry>
65struct point_type
66{
67 // Default: call traits to get point type
68 typedef typename std::remove_const
69 <
70 typename traits::point_type<Geometry>::type
71 >::type type;
72};
73
74
75// Specialization for point: the point itself
76template <typename Point>
77struct point_type<point_tag, Point>
78{
79 typedef Point type;
80};
81
82
83// Specializations for linestring/ring, via boost::range
84template <typename Linestring>
85struct point_type<linestring_tag, Linestring>
86{
87 typedef typename boost::range_value<Linestring>::type type;
88};
89
90
91template <typename Ring>
92struct point_type<ring_tag, Ring>
93{
94 typedef typename boost::range_value<Ring>::type type;
95};
96
97
98// Specialization for polygon: the point-type is the point-type of its rings
99template <typename Polygon>
100struct point_type<polygon_tag, Polygon>
101{
102 typedef typename point_type
103 <
104 ring_tag,
105 typename ring_type<polygon_tag, Polygon>::type
106 >::type type;
107};
108
109
110template <typename MultiPoint>
111struct point_type<multi_point_tag, MultiPoint>
112{
113 typedef typename boost::range_value
114 <
115 MultiPoint
116 >::type type;
117};
118
119
120template <typename MultiLinestring>
121struct point_type<multi_linestring_tag, MultiLinestring>
122{
123 typedef typename point_type
124 <
125 linestring_tag,
126 typename boost::range_value<MultiLinestring>::type
127 >::type type;
128};
129
130
131template <typename MultiPolygon>
132struct point_type<multi_polygon_tag, MultiPolygon>
133{
134 typedef typename point_type
135 <
136 polygon_tag,
137 typename boost::range_value<MultiPolygon>::type
138 >::type type;
139};
140
141
142template <typename DynamicGeometry>
143struct point_type<dynamic_geometry_tag, DynamicGeometry>
144{
145 using geometry_t = typename util::sequence_front
146 <
147 typename traits::geometry_types<DynamicGeometry>::type
148 >::type;
149 using type = typename point_type
150 <
151 typename tag<geometry_t>::type,
152 typename util::remove_cptrref<geometry_t>::type
153 >::type;
154};
155
156
157template <typename GeometryCollection>
158struct point_type<geometry_collection_tag, GeometryCollection>
159{
160 using geometry_t = typename util::sequence_front
161 <
162 typename traits::geometry_types<GeometryCollection>::type
163 >::type;
164 using type = typename point_type
165 <
166 typename tag<geometry_t>::type,
167 typename util::remove_cptrref<geometry_t>::type
168 >::type;
169};
170
171
172} // namespace core_dispatch
173#endif // DOXYGEN_NO_DISPATCH
174
175
176/*!
177\brief \brief_meta{type, point_type, \meta_geometry_type}
178\tparam Geometry \tparam_geometry
179\ingroup core
180
181\qbk{[include reference/core/point_type.qbk]}
182*/
183template <typename Geometry>
184struct point_type
185{
186 typedef typename core_dispatch::point_type
187 <
188 typename tag<Geometry>::type,
189 typename util::remove_cptrref<Geometry>::type
190 >::type type;
191};
192
193
194}} // namespace boost::geometry
195
196
197#endif // BOOST_GEOMETRY_CORE_POINT_TYPE_HPP
198

source code of boost/libs/geometry/include/boost/geometry/core/point_type.hpp