#include #include #include #include #include #include namespace mbgl { AnnotationTile::AnnotationTile(const OverscaledTileID& overscaledTileID, const TileParameters& parameters) : GeometryTile(overscaledTileID, AnnotationManager::SourceID, parameters), annotationManager(parameters.annotationManager) { annotationManager.addTile(*this); } AnnotationTile::~AnnotationTile() { annotationManager.removeTile(*this); } void AnnotationTile::setNecessity(Necessity) { } class AnnotationTileFeatureData { public: AnnotationTileFeatureData(const AnnotationID id_, FeatureType type_, GeometryCollection&& geometries_, std::unordered_map&& properties_) : id(id_), type(type_), geometries(std::move(geometries_)), properties(std::move(properties_)) { } AnnotationID id; FeatureType type; GeometryCollection geometries; std::unordered_map properties; }; AnnotationTileFeature::AnnotationTileFeature(std::shared_ptr data_) : data(std::move(data_)) { } AnnotationTileFeature::~AnnotationTileFeature() = default; FeatureType AnnotationTileFeature::getType() const { return data->type; } optional AnnotationTileFeature::getValue(const std::string& key) const { auto it = data->properties.find(key); if (it != data->properties.end()) { return optional(it->second); } return optional(); } optional AnnotationTileFeature::getID() const { return { static_cast(data->id) }; } GeometryCollection AnnotationTileFeature::getGeometries() const { return data->geometries; } class AnnotationTileLayerData { public: AnnotationTileLayerData(const std::string& name_) : name(name_) { } const std::string name; std::vector> features; }; AnnotationTileLayer::AnnotationTileLayer(std::shared_ptr layer_) : layer(std::move(layer_)) { } std::size_t AnnotationTileLayer::featureCount() const { return layer->features.size(); } std::unique_ptr AnnotationTileLayer::getFeature(std::size_t i) const { return std::make_unique(layer->features.at(i)); } std::string AnnotationTileLayer::getName() const { return layer->name; } void AnnotationTileLayer::addFeature(const AnnotationID id, FeatureType type, GeometryCollection geometries, std::unordered_map properties) { layer->features.emplace_back(std::make_shared( id, type, std::move(geometries), std::move(properties))); } std::unique_ptr AnnotationTileData::clone() const { return std::make_unique(*this); } std::unique_ptr AnnotationTileData::getLayer(const std::string& name) const { auto it = layers.find(name); if (it != layers.end()) { return std::make_unique(it->second); } return nullptr; } std::unique_ptr AnnotationTileData::addLayer(const std::string& name) { // Only constructs a new layer if it doesn't yet exist, otherwise, we'll use the existing one. auto it = layers.find(name); if (it == layers.end()) { it = layers.emplace(name, std::make_shared(name)).first; } return std::make_unique(it->second); } } // namespace mbgl