diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/annotation/annotation_manager.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/map/source.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/map/source.hpp | 3 | ||||
-rw-r--r-- | src/mbgl/map/source_info.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/style.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/style/style_parser.cpp | 6 |
6 files changed, 12 insertions, 13 deletions
diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 9a966827c9..41bebbbdea 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -112,8 +112,7 @@ std::unique_ptr<AnnotationTile> AnnotationManager::getTile(const TileID& tileID) void AnnotationManager::updateStyle(Style& style) { // Create annotation source, point layer, and point bucket if (!style.getSource(SourceID)) { - std::unique_ptr<Source> source = std::make_unique<Source>(SourceType::Annotations); - source->info.source_id = SourceID; + std::unique_ptr<Source> source = std::make_unique<Source>(SourceType::Annotations, SourceID); source->enabled = true; style.addSource(std::move(source)); diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index c456a97cc4..f4c3f877ed 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -117,7 +117,7 @@ void parse(const JSValue& value, std::array<float, N>& target, const char* name) } // end namespace -Source::Source(SourceType type_) : type(type_) {} +Source::Source(SourceType type_, const std::string& id_) : type(type_), id(id_) {} Source::~Source() = default; @@ -334,7 +334,7 @@ TileData::State Source::addTile(const TileID& tileID, const StyleUpdateParameter newTile->data = std::make_shared<VectorTileData>(normalizedID, std::move(monitor), - info.source_id, + id, parameters.style, parameters.mode, callback); @@ -591,7 +591,7 @@ void Source::tileLoadingCompleteCallback(const TileID& tileID, const TransformSt } void Source::dumpDebugLogs() const { - Log::Info(Event::General, "Source::id: %s", info.source_id.c_str()); + Log::Info(Event::General, "Source::id: %s", id.c_str()); Log::Info(Event::General, "Source::loaded: %d", loaded); for (const auto& tile : tiles) { diff --git a/src/mbgl/map/source.hpp b/src/mbgl/map/source.hpp index 9d27a09f7f..079ac5c2db 100644 --- a/src/mbgl/map/source.hpp +++ b/src/mbgl/map/source.hpp @@ -39,7 +39,7 @@ public: virtual void onTileError(Source&, const TileID&, std::exception_ptr) {}; }; - Source(SourceType); + Source(SourceType, const std::string& id); ~Source(); void parseTileJSON(const JSValue&); @@ -70,6 +70,7 @@ public: void dumpDebugLogs() const; const SourceType type; + const std::string id; SourceInfo info; bool enabled = false; diff --git a/src/mbgl/map/source_info.hpp b/src/mbgl/map/source_info.hpp index c279374399..1b8c7a40f9 100644 --- a/src/mbgl/map/source_info.hpp +++ b/src/mbgl/map/source_info.hpp @@ -23,7 +23,6 @@ public: std::string attribution; std::array<float, 3> center = { { 0, 0, 0 } }; std::array<float, 4> bounds = { { -180, -90, 180, 90 } }; - std::string source_id = ""; }; } // namespace mbgl diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 5c6869ac77..fbca01311b 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -194,7 +194,7 @@ void Style::recalculate(float z) { Source* Style::getSource(const std::string& id) const { const auto it = std::find_if(sources.begin(), sources.end(), [&](const auto& source) { - return source->info.source_id == id; + return source->id == id; }); return it != sources.end() ? it->get() : nullptr; @@ -331,7 +331,7 @@ void Style::onSourceLoaded(Source& source) { void Style::onSourceError(Source& source, std::exception_ptr error) { lastError = error; Log::Error(Event::Style, "Failed to load source %s: %s", - source.info.source_id.c_str(), util::toString(error).c_str()); + source.id.c_str(), util::toString(error).c_str()); observer->onSourceError(source, error); observer->onResourceError(error); } @@ -348,7 +348,7 @@ void Style::onTileLoaded(Source& source, const TileID& tileID, bool isNewTile) { void Style::onTileError(Source& source, const TileID& tileID, std::exception_ptr error) { lastError = error; Log::Error(Event::Style, "Failed to load tile %s for source %s: %s", - std::string(tileID).c_str(), source.info.source_id.c_str(), util::toString(error).c_str()); + std::string(tileID).c_str(), source.id.c_str(), util::toString(error).c_str()); observer->onTileError(source, tileID, error); observer->onResourceError(error); } diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index 4c3061dcb4..6878907cd1 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -68,8 +68,8 @@ void StyleParser::parseSources(const JSValue& value) { } const auto type = SourceTypeClass({ typeVal.GetString(), typeVal.GetStringLength() }); - std::unique_ptr<Source> source = std::make_unique<Source>(type); - source->info.source_id = { nameVal.GetString(), nameVal.GetStringLength() }; + const std::string id { nameVal.GetString(), nameVal.GetStringLength() }; + std::unique_ptr<Source> source = std::make_unique<Source>(type, id); switch (type) { case SourceType::Vector: @@ -91,7 +91,7 @@ void StyleParser::parseSources(const JSValue& value) { Log::Warning(Event::ParseStyle, "source type %s is not supported", type.c_str()); } - sourcesMap.emplace(source->info.source_id, source.get()); + sourcesMap.emplace(id, source.get()); sources.emplace_back(std::move(source)); } } |