1#pragma once
2
3#include <mapbox/geometry/geometry.hpp>
4#include <mapbox/geometry/point_arithmetic.hpp>
5#include <mapbox/geometry/for_each_point.hpp>
6
7namespace mbgl {
8
9enum class FeatureType : uint8_t {
10 Unknown = 0,
11 Point = 1,
12 LineString = 2,
13 Polygon = 3
14};
15
16template <class T>
17using Point = mapbox::geometry::point<T>;
18
19template <class T>
20using LineString = mapbox::geometry::line_string<T>;
21
22template <class T>
23using Polygon = mapbox::geometry::polygon<T>;
24
25template <class T>
26using MultiPoint = mapbox::geometry::multi_point<T>;
27
28template <class T>
29using MultiLineString = mapbox::geometry::multi_line_string<T>;
30
31template <class T>
32using MultiPolygon = mapbox::geometry::multi_polygon<T>;
33
34template <class T>
35using LinearRing = mapbox::geometry::linear_ring<T>;
36
37template <class T>
38using Geometry = mapbox::geometry::geometry<T>;
39
40template <class S, class T>
41Point<S> convertPoint(const Point<T>& p) {
42 return Point<S>(p.x, p.y);
43}
44
45struct ToFeatureType {
46 template <class T>
47 FeatureType operator()(const Point<T> &) const { return FeatureType::Point; }
48 template <class T>
49 FeatureType operator()(const MultiPoint<T> &) const { return FeatureType::Point; }
50 template <class T>
51 FeatureType operator()(const LineString<T> &) const { return FeatureType::LineString; }
52 template <class T>
53 FeatureType operator()(const MultiLineString<T> &) const { return FeatureType::LineString; }
54 template <class T>
55 FeatureType operator()(const Polygon<T> &) const { return FeatureType::Polygon; }
56 template <class T>
57 FeatureType operator()(const MultiPolygon<T> &) const { return FeatureType::Polygon; }
58 template <class T>
59 FeatureType operator()(const mapbox::geometry::geometry_collection<T> &) const { return FeatureType::Unknown; }
60};
61
62template <class T, typename F>
63auto forEachPoint(const Geometry<T>& g, F f) {
64 mapbox::geometry::for_each_point(g, f);
65}
66
67} // namespace mbgl
68

source code of qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/util/geometry.hpp