#include #include #include #include #include namespace mbgl { GeoJSONTile::GeoJSONTile(const OverscaledTileID& overscaledTileID, std::string sourceID_, const TileParameters& parameters, std::shared_ptr data_) : GeometryTile(overscaledTileID, sourceID_, parameters) { updateData(std::move(data_)); } void GeoJSONTile::updateData(std::shared_ptr data_, bool resetLayers) { assert(data_); data = std::move(data_); data->getTile(id.canonical, [this, self = weakFactory.makeWeakPtr(), capturedData = data.get(), resetLayers]( style::GeoJSONData::TileFeatures features) { if (!self) return; if (data.get() != capturedData) return; auto tileData = std::make_unique(std::move(features)); setData(std::move(tileData), resetLayers); }); } void GeoJSONTile::querySourceFeatures( std::vector& result, const SourceQueryOptions& options) { // Ignore the sourceLayer, there is only one if (auto tileData = getData()) { if (auto layer = tileData->getLayer({})) { auto featureCount = layer->featureCount(); for (std::size_t i = 0; i < featureCount; i++) { auto feature = layer->getFeature(i); // Apply filter, if any if (options.filter && !(*options.filter)(style::expression::EvaluationContext { static_cast(this->id.overscaledZ), feature.get() })) { continue; } result.push_back(convertFeature(*feature, id.canonical)); } } } } } // namespace mbgl