1 #pragma once
2
3 #include <mbgl/annotation/annotation.hpp>
4 #include <mbgl/util/geo.hpp>
5
6 #include <string>
7
8 #pragma GCC diagnostic push
9 #pragma GCC diagnostic ignored "-Wunused-function"
10 #pragma GCC diagnostic ignored "-Wunused-parameter"
11 #pragma GCC diagnostic ignored "-Wunused-variable"
12 #pragma GCC diagnostic ignored "-Wshadow"
13 #ifdef __clang__
14 #pragma GCC diagnostic ignored "-Wunknown-pragmas"
15 #endif
16 #pragma GCC diagnostic ignored "-Wpragmas"
17 #pragma GCC diagnostic ignored "-Wdeprecated-register"
18 #pragma GCC diagnostic ignored "-Wshorten-64-to-32"
19 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
20 #ifndef __clang__
21 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
22 #pragma GCC diagnostic ignored "-Wmisleading-indentation"
23 #endif
24 #include <boost/geometry.hpp>
25 #include <boost/geometry/geometries/point.hpp>
26 #include <boost/geometry/geometries/box.hpp>
27 #include <boost/geometry/geometries/register/point.hpp>
28 #include <boost/geometry/geometries/register/box.hpp>
29 #include <boost/geometry/index/rtree.hpp>
30 #pragma GCC diagnostic pop
31
32 namespace mbgl {
33
34 class AnnotationTileLayer;
35 class CanonicalTileID;
36
37 class SymbolAnnotationImpl {
38 public:
39 SymbolAnnotationImpl(AnnotationID, SymbolAnnotation);
40
41 void updateLayer(const CanonicalTileID&, AnnotationTileLayer&) const;
42
43 const AnnotationID id;
44 const SymbolAnnotation annotation;
45 };
46
47 } // namespace mbgl
48
49 namespace boost {
50 namespace geometry {
51
52 // Make Boost Geometry aware of our LatLng type
53 namespace traits {
54
55 template<> struct tag<mbgl::LatLng> { using type = point_tag; };
56 template<> struct dimension<mbgl::LatLng> : boost::mpl::int_<2> {};
57 template<> struct coordinate_type<mbgl::LatLng> { using type = double; };
58 template<> struct coordinate_system<mbgl::LatLng> { using type = boost::geometry::cs::cartesian; };
59
getboost::geometry::traits::access60 template<> struct access<mbgl::LatLng, 0> { static inline double get(mbgl::LatLng const& p) { return p.longitude(); } };
getboost::geometry::traits::access61 template<> struct access<mbgl::LatLng, 1> { static inline double get(mbgl::LatLng const& p) { return p.latitude(); } };
62
63 template<> struct tag<mbgl::LatLngBounds> { using type = box_tag; };
64 template<> struct point_type<mbgl::LatLngBounds> { using type = mbgl::LatLng; };
65
66 template <size_t D>
67 struct indexed_access<mbgl::LatLngBounds, min_corner, D>
68 {
69 using ct = coordinate_type<mbgl::LatLng>::type;
getboost::geometry::traits::indexed_access70 static inline ct get(mbgl::LatLngBounds const& b) { return geometry::get<D>(b.southwest()); }
setboost::geometry::traits::indexed_access71 static inline void set(mbgl::LatLngBounds& b, ct const& value) { geometry::set<D>(b.southwest(), value); }
72 };
73
74 template <size_t D>
75 struct indexed_access<mbgl::LatLngBounds, max_corner, D>
76 {
77 using ct = coordinate_type<mbgl::LatLng>::type;
getboost::geometry::traits::indexed_access78 static inline ct get(mbgl::LatLngBounds const& b) { return geometry::get<D>(b.northeast()); }
setboost::geometry::traits::indexed_access79 static inline void set(mbgl::LatLngBounds& b, ct const& value) { geometry::set<D>(b.northeast(), value); }
80 };
81
82 } // namespace traits
83
84 // Tell Boost Geometry how to access a std::shared_ptr<mbgl::SymbolAnnotation> object.
85 namespace index {
86
87 template <>
88 struct indexable<std::shared_ptr<const mbgl::SymbolAnnotationImpl>> {
89 using result_type = mbgl::LatLng;
operator ()boost::geometry::index::indexable90 mbgl::LatLng operator()(const std::shared_ptr<const mbgl::SymbolAnnotationImpl>& v) const {
91 const mbgl::Point<double>& p = v->annotation.geometry;
92 return mbgl::LatLng(p.y, p.x);
93 }
94 };
95
96 } // namespace index
97
98 } // namespace geometry
99 } // namespace boost
100