diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-05-31 17:34:11 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-06-01 17:37:01 -0700 |
commit | 0fba70d5a8465499b0dce900e5aa74f7189e4594 (patch) | |
tree | 7902b9bd29d25de0de6d116fc3245b1b269477f4 /src/mbgl/annotation/symbol_annotation_impl.hpp | |
parent | cfd6757ecc9bd4d9b1f4c5266d19da48c529f58b (diff) | |
download | qtlocation-mapboxgl-0fba70d5a8465499b0dce900e5aa74f7189e4594.tar.gz |
[all] Rationalize annotation API
Diffstat (limited to 'src/mbgl/annotation/symbol_annotation_impl.hpp')
-rw-r--r-- | src/mbgl/annotation/symbol_annotation_impl.hpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/mbgl/annotation/symbol_annotation_impl.hpp b/src/mbgl/annotation/symbol_annotation_impl.hpp new file mode 100644 index 0000000000..43c490140d --- /dev/null +++ b/src/mbgl/annotation/symbol_annotation_impl.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include <mbgl/annotation/annotation.hpp> +#include <mbgl/util/geo.hpp> + +#include <string> + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wshadow" +#ifdef __clang__ +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#endif +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wdeprecated-register" +#pragma GCC diagnostic ignored "-Wshorten-64-to-32" +#pragma GCC diagnostic ignored "-Wunused-local-typedefs" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#include <boost/geometry.hpp> +#include <boost/geometry/geometries/point.hpp> +#include <boost/geometry/geometries/box.hpp> +#include <boost/geometry/geometries/register/point.hpp> +#include <boost/geometry/geometries/register/box.hpp> +#include <boost/geometry/index/rtree.hpp> +#pragma GCC diagnostic pop + +// Make Boost Geometry aware of our LatLng type +BOOST_GEOMETRY_REGISTER_POINT_2D(mbgl::LatLng, double, boost::geometry::cs::cartesian, longitude, latitude) +BOOST_GEOMETRY_REGISTER_BOX(mbgl::LatLngBounds, mbgl::LatLng, southwest(), northeast()) + +namespace mbgl { + +class AnnotationTileLayer; +class CanonicalTileID; + +class SymbolAnnotationImpl { +public: + SymbolAnnotationImpl(const AnnotationID, const SymbolAnnotation&); + + void updateLayer(const CanonicalTileID&, AnnotationTileLayer&) const; + + const AnnotationID id; + const SymbolAnnotation annotation; +}; + +} // namespace mbgl + +// Tell Boost Geometry how to access a std::shared_ptr<mbgl::SymbolAnnotation> object. +namespace boost { +namespace geometry { +namespace index { + +template <> +struct indexable<std::shared_ptr<const mbgl::SymbolAnnotationImpl>> { + using result_type = mbgl::LatLng; + inline mbgl::LatLng operator()(const std::shared_ptr<const mbgl::SymbolAnnotationImpl>& v) const { + const mbgl::Point<double>& p = v->annotation.geometry.get<mbgl::Point<double>>(); + return mbgl::LatLng(p.y, p.x); + } +}; + +} // end namespace index +} // end namespace geometry +} // end namespace boost |