From ee761abf82ed86be790f51ffda476c8b257a37b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Ma=CC=88rki?= Date: Thu, 6 Mar 2025 18:08:59 +0100 Subject: [PATCH] MAP-28: Only use custom identifier if configured for map --- shared/public/VectorMapSourceDescription.h | 6 ++++-- .../map/layers/tiled/vector/Tiled2dMapVectorLayer.cpp | 3 ++- .../tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp | 5 ++++- .../symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp | 9 ++++++--- .../symbol/Tiled2dMapVectorSourceSymbolDataManager.h | 4 +++- .../tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.cpp | 6 ++++-- .../tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.h | 4 +++- .../tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp | 8 +++++++- .../tiled/vector/symbol/Tiled2dMapVectorSymbolObject.h | 1 + 9 files changed, 34 insertions(+), 12 deletions(-) diff --git a/shared/public/VectorMapSourceDescription.h b/shared/public/VectorMapSourceDescription.h index 2974f2f3f..53efbeb8e 100644 --- a/shared/public/VectorMapSourceDescription.h +++ b/shared/public/VectorMapSourceDescription.h @@ -53,13 +53,15 @@ class VectorMapDescription { std::optional spriteBaseUrl; std::map> geoJsonSources; bool persistingSymbolPlacement; + bool useCustomCrossTileIdentifier; VectorMapDescription(std::string identifier, std::vector> vectorSources, std::vector> layers, std::optional spriteBaseUrl, std::map> geoJsonSources, - bool persistingSymbolPlacement): + bool persistingSymbolPlacement, + bool useCustomCrossTileIdentifier): identifier(identifier), vectorSources(vectorSources), layers(layers), spriteBaseUrl(spriteBaseUrl), - geoJsonSources(geoJsonSources), persistingSymbolPlacement(persistingSymbolPlacement) {} + geoJsonSources(geoJsonSources), persistingSymbolPlacement(persistingSymbolPlacement), useCustomCrossTileIdentifier(useCustomCrossTileIdentifier) {} }; diff --git a/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayer.cpp b/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayer.cpp index a32524c17..8db0072db 100644 --- a/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayer.cpp +++ b/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayer.cpp @@ -451,7 +451,8 @@ void Tiled2dMapVectorLayer::initializeVectorLayer() { readyManager, featureStateManager, symbolDelegate, - mapDescription->persistingSymbolPlacement); + mapDescription->persistingSymbolPlacement, + mapDescription->useCustomCrossTileIdentifier); actor.unsafe()->setAlpha(alpha); actor.unsafe()->enableAnimations(animationsEnabled); symbolSourceDataManagers[source] = actor; diff --git a/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp b/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp index 4b126b41f..cfd05ec38 100644 --- a/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp +++ b/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp @@ -287,11 +287,13 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ std::optional metadata; std::shared_ptr globalIsInteractable; bool persistingSymbolPlacement = false; + bool useCustomCrossTileIdentifier = false; if(json["metadata"].is_object()) { metadata = json["metadata"].dump(); globalIsInteractable = parser.parseValue(json["metadata"]["interactable"]); persistingSymbolPlacement = json["metadata"].value("persistingSymbolPlacement", false); + useCustomCrossTileIdentifier = json["metadata"].value("useCustomCrossTileIdentifier", false); } int64_t globalTransitionDuration = 300; @@ -549,6 +551,7 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ layers, sprite, geojsonSources, - persistingSymbolPlacement); + persistingSymbolPlacement, + useCustomCrossTileIdentifier); return Tiled2dMapVectorLayerParserResult(mapDesc, LoaderStatus::OK, "", metadata); }; diff --git a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp index a0ccffdb2..323f57f34 100644 --- a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp +++ b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp @@ -26,12 +26,14 @@ Tiled2dMapVectorSourceSymbolDataManager::Tiled2dMapVectorSourceSymbolDataManager const Actor &readyManager, const std::shared_ptr &featureStateManager, const std::shared_ptr &symbolDelegate, - bool persistingSymbolPlacement) + bool persistingSymbolPlacement, + bool useCustomCrossTileIdentifier) : Tiled2dMapVectorSourceDataManager(vectorLayer, mapDescription, layerConfig, source, readyManager, featureStateManager), fontLoader(fontLoader), vectorSource(vectorSource), animationCoordinatorMap(std::make_shared()), symbolDelegate(symbolDelegate), - persistingSymbolPlacement(persistingSymbolPlacement) { + persistingSymbolPlacement(persistingSymbolPlacement), + useCustomCrossTileIdentifier(useCustomCrossTileIdentifier) { for (const auto &layer: mapDescription->layers) { if (layer->getType() == VectorLayerType::symbol && layer->source == source) { @@ -455,7 +457,8 @@ std::vector> Tiled2dMapVectorSourceSymbolData layerIdentifier), featureStateManager, symbolDelegate, - persistingSymbolPlacement); + persistingSymbolPlacement, + useCustomCrossTileIdentifier); symbolGroupActor.message(MFN(&Tiled2dMapVectorSymbolGroup::initialize), features, featuresBase, std::min(featuresBase + maxNumFeaturesPerGroup, numFeatures) - featuresBase, animationCoordinatorMap, selfActor, alpha); diff --git a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.h b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.h index 356fc1ace..7b3287c6a 100644 --- a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.h +++ b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.h @@ -60,7 +60,8 @@ class Tiled2dMapVectorSourceSymbolDataManager: const Actor &readyManager, const std::shared_ptr &featureStateManager, const std::shared_ptr &symbolDelegate, - bool persistingSymbolPlacement); + bool persistingSymbolPlacement, + bool useCustomCrossTileIdentifier); void onAdded(const std::weak_ptr<::MapInterface> &mapInterface) override; @@ -149,6 +150,7 @@ class Tiled2dMapVectorSourceSymbolDataManager: std::shared_ptr symbolDelegate; bool persistingSymbolPlacement = false; + bool useCustomCrossTileIdentifier = false; #ifdef OPENMOBILEMAPS_GL // Higher counts may cause issues for instanced text rendering diff --git a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.cpp b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.cpp index 01ea27bd7..8eadc9acc 100644 --- a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.cpp +++ b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.cpp @@ -29,7 +29,8 @@ Tiled2dMapVectorSymbolGroup::Tiled2dMapVectorSymbolGroup(uint32_t groupId, const std::shared_ptr &layerDescription, const std::shared_ptr &featureStateManager, const std::shared_ptr &symbolDelegate, - const bool persistingSymbolPlacement) + const bool persistingSymbolPlacement, + const bool useCustomCrossTileIdentifier) : groupId(groupId), mapInterface(mapInterface), layerConfig(layerConfig), @@ -41,6 +42,7 @@ featureStateManager(featureStateManager), symbolDelegate(symbolDelegate), usedKeys(layerDescription->getUsedKeys()), persistingSymbolPlacement(persistingSymbolPlacement), +useCustomCrossTileIdentifier(useCustomCrossTileIdentifier), tileOrigin(0, 0, 0), is3d(mapInterface.lock()->is3d()){ if (auto strongMapInterface = mapInterface.lock()) { @@ -1010,7 +1012,7 @@ Tiled2dMapVectorSymbolGroup::createSymbolObject(const Tiled2dMapVersionedTileInf auto symbolObject = std::make_shared(mapInterface, layerConfig, fontProvider, tileInfo, layerIdentifier, description, featureContext, text, fullText, coordinate, lineCoordinates, fontList, textAnchor, angle, textJustify, textSymbolPlacement, hideIcon, animationCoordinatorMap, - featureStateManager, usedKeys, symbolTileIndex, hasCustomTexture, dpFactor, persistingSymbolPlacement, is3d, tileOrigin); + featureStateManager, usedKeys, symbolTileIndex, hasCustomTexture, dpFactor, persistingSymbolPlacement, useCustomCrossTileIdentifier, is3d, tileOrigin); symbolObject->setAlpha(alpha); const auto counts = symbolObject->getInstanceCounts(); if (counts.icons + counts.stretchedIcons + counts.textCharacters == 0) { diff --git a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.h b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.h index 872d155e1..d41643358 100644 --- a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.h +++ b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolGroup.h @@ -45,7 +45,8 @@ class Tiled2dMapVectorSymbolGroup : public ActorObject, public std::enable_share const std::shared_ptr &layerDescription, const std::shared_ptr &featureStateManager, const std::shared_ptr &symbolDelegate, - const bool persistingSymbolPlacement); + const bool persistingSymbolPlacement, + const bool useCustomCrossTileIdentifier); void initialize(std::weak_ptr> weakFeatures, int32_t featuresBase, @@ -109,6 +110,7 @@ class Tiled2dMapVectorSymbolGroup : public ActorObject, public std::enable_share std::shared_ptr layerDescription; const WeakActor fontProvider; const bool persistingSymbolPlacement = false; + const bool useCustomCrossTileIdentifier = false; std::shared_ptr iconInstancedObject; std::shared_ptr stretchedInstancedObject; diff --git a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp index 608688c05..8acdd0df7 100644 --- a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp +++ b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp @@ -46,6 +46,7 @@ Tiled2dMapVectorSymbolObject::Tiled2dMapVectorSymbolObject(const std::weak_ptr>()(std::tuple(fullText, layerIdentifier, hasIcon, contentHash)); + if (useCustomCrossTileIdentifier || featureContext->identifier == 0) { + crossTileIdentifier = std::hash>()(std::tuple(fullText, layerIdentifier, hasIcon, contentHash)); + } + else { + crossTileIdentifier = featureContext->identifier; + } double xTolerance = std::ceil(std::abs(tileInfo.tileInfo.bounds.bottomRight.x - tileInfo.tileInfo.bounds.topLeft.x) / 4096.0); double yTolerance = std::ceil(std::abs(tileInfo.tileInfo.bounds.bottomRight.y - tileInfo.tileInfo.bounds.topLeft.y) / 4096.0); diff --git a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.h b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.h index 862ee36d6..25ad5a896 100644 --- a/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.h +++ b/shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.h @@ -53,6 +53,7 @@ class Tiled2dMapVectorSymbolObject { const bool hasCustomTexture, const double dpFactor, const bool persistingSymbolPlacement, + const bool useCustomCrossTileIdentifier, bool is3d, const Vec3D &tileOrigin);