To encapsulate the differences, this introduces an abstract GeometryTileMonitor class, with concrete VectorTileMonitor and AnnotationTileMonitor implementations, and makes pbf parsing for VectorTile data happen lazily in getLayer, since we want that to happen on the worker thread, rather than when VectorTile is created. Fixes #2792
56 lines
1.6 KiB
C++
56 lines
1.6 KiB
C++
#ifndef MBGL_ANNOTATION_TILE
|
|
#define MBGL_ANNOTATION_TILE
|
|
|
|
#include <mbgl/map/geometry_tile.hpp>
|
|
#include <mbgl/map/tile_id.hpp>
|
|
|
|
#include <map>
|
|
#include <unordered_map>
|
|
|
|
namespace mbgl {
|
|
|
|
class AnnotationTileFeature : public GeometryTileFeature {
|
|
public:
|
|
AnnotationTileFeature(FeatureType, GeometryCollection,
|
|
std::unordered_map<std::string, std::string> properties = {{}});
|
|
|
|
FeatureType getType() const override { return type; }
|
|
mapbox::util::optional<Value> getValue(const std::string&) const override;
|
|
GeometryCollection getGeometries() const override { return geometries; }
|
|
|
|
const FeatureType type;
|
|
const std::unordered_map<std::string, std::string> properties;
|
|
const GeometryCollection geometries;
|
|
};
|
|
|
|
class AnnotationTileLayer : public GeometryTileLayer {
|
|
public:
|
|
std::size_t featureCount() const override { return features.size(); }
|
|
util::ptr<const GeometryTileFeature> getFeature(std::size_t i) const override { return features[i]; }
|
|
|
|
std::vector<util::ptr<const AnnotationTileFeature>> features;
|
|
};
|
|
|
|
class AnnotationTile : public GeometryTile {
|
|
public:
|
|
util::ptr<GeometryTileLayer> getLayer(const std::string&) const override;
|
|
|
|
std::map<std::string, util::ptr<AnnotationTileLayer>> layers;
|
|
};
|
|
|
|
class MapData;
|
|
|
|
class AnnotationTileMonitor : public GeometryTileMonitor {
|
|
public:
|
|
AnnotationTileMonitor(const TileID&, MapData&);
|
|
|
|
Request* monitorTile(std::function<void (std::exception_ptr, std::unique_ptr<GeometryTile>)>) override;
|
|
|
|
private:
|
|
std::unique_ptr<AnnotationTile> tile;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|