Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions shared/public/VectorMapSourceDescription.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ class VectorMapDescription {
std::optional<std::string> spriteBaseUrl;
std::map<std::string, std::shared_ptr<GeoJSONVTInterface>> geoJsonSources;
bool persistingSymbolPlacement;
bool useCustomCrossTileIdentifier;

VectorMapDescription(std::string identifier,
std::vector<std::shared_ptr<VectorMapSourceDescription>> vectorSources,
std::vector<std::shared_ptr<VectorLayerDescription>> layers,
std::optional<std::string> spriteBaseUrl,
std::map<std::string, std::shared_ptr<GeoJSONVTInterface>> 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) {}
};
3 changes: 2 additions & 1 deletion shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,13 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ
std::optional<std::string> metadata;
std::shared_ptr<Value> 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;
Expand Down Expand Up @@ -549,6 +551,7 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ
layers,
sprite,
geojsonSources,
persistingSymbolPlacement);
persistingSymbolPlacement,
useCustomCrossTileIdentifier);
return Tiled2dMapVectorLayerParserResult(mapDesc, LoaderStatus::OK, "", metadata);
};
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ Tiled2dMapVectorSourceSymbolDataManager::Tiled2dMapVectorSourceSymbolDataManager
const Actor<Tiled2dMapVectorReadyManager> &readyManager,
const std::shared_ptr<Tiled2dMapVectorStateManager> &featureStateManager,
const std::shared_ptr<Tiled2dMapVectorLayerSymbolDelegateInterface> &symbolDelegate,
bool persistingSymbolPlacement)
bool persistingSymbolPlacement,
bool useCustomCrossTileIdentifier)
: Tiled2dMapVectorSourceDataManager(vectorLayer, mapDescription, layerConfig, source, readyManager, featureStateManager),
fontLoader(fontLoader), vectorSource(vectorSource),
animationCoordinatorMap(std::make_shared<SymbolAnimationCoordinatorMap>()),
symbolDelegate(symbolDelegate),
persistingSymbolPlacement(persistingSymbolPlacement) {
persistingSymbolPlacement(persistingSymbolPlacement),
useCustomCrossTileIdentifier(useCustomCrossTileIdentifier) {

for (const auto &layer: mapDescription->layers) {
if (layer->getType() == VectorLayerType::symbol && layer->source == source) {
Expand Down Expand Up @@ -455,7 +457,8 @@ std::vector<Actor<Tiled2dMapVectorSymbolGroup>> Tiled2dMapVectorSourceSymbolData
layerIdentifier),
featureStateManager,
symbolDelegate,
persistingSymbolPlacement);
persistingSymbolPlacement,
useCustomCrossTileIdentifier);
symbolGroupActor.message(MFN(&Tiled2dMapVectorSymbolGroup::initialize), features, featuresBase,
std::min(featuresBase + maxNumFeaturesPerGroup, numFeatures) - featuresBase,
animationCoordinatorMap, selfActor, alpha);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ class Tiled2dMapVectorSourceSymbolDataManager:
const Actor<Tiled2dMapVectorReadyManager> &readyManager,
const std::shared_ptr<Tiled2dMapVectorStateManager> &featureStateManager,
const std::shared_ptr<Tiled2dMapVectorLayerSymbolDelegateInterface> &symbolDelegate,
bool persistingSymbolPlacement);
bool persistingSymbolPlacement,
bool useCustomCrossTileIdentifier);

void onAdded(const std::weak_ptr<::MapInterface> &mapInterface) override;

Expand Down Expand Up @@ -149,6 +150,7 @@ class Tiled2dMapVectorSourceSymbolDataManager:
std::shared_ptr<Tiled2dMapVectorLayerSymbolDelegateInterface> symbolDelegate;

bool persistingSymbolPlacement = false;
bool useCustomCrossTileIdentifier = false;

#ifdef OPENMOBILEMAPS_GL
// Higher counts may cause issues for instanced text rendering
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Tiled2dMapVectorSymbolGroup::Tiled2dMapVectorSymbolGroup(uint32_t groupId,
const std::shared_ptr<SymbolVectorLayerDescription> &layerDescription,
const std::shared_ptr<Tiled2dMapVectorStateManager> &featureStateManager,
const std::shared_ptr<Tiled2dMapVectorLayerSymbolDelegateInterface> &symbolDelegate,
const bool persistingSymbolPlacement)
const bool persistingSymbolPlacement,
const bool useCustomCrossTileIdentifier)
: groupId(groupId),
mapInterface(mapInterface),
layerConfig(layerConfig),
Expand All @@ -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()) {
Expand Down Expand Up @@ -1010,7 +1012,7 @@ Tiled2dMapVectorSymbolGroup::createSymbolObject(const Tiled2dMapVersionedTileInf
auto symbolObject = std::make_shared<Tiled2dMapVectorSymbolObject>(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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class Tiled2dMapVectorSymbolGroup : public ActorObject, public std::enable_share
const std::shared_ptr<SymbolVectorLayerDescription> &layerDescription,
const std::shared_ptr<Tiled2dMapVectorStateManager> &featureStateManager,
const std::shared_ptr<Tiled2dMapVectorLayerSymbolDelegateInterface> &symbolDelegate,
const bool persistingSymbolPlacement);
const bool persistingSymbolPlacement,
const bool useCustomCrossTileIdentifier);

void initialize(std::weak_ptr<std::vector<Tiled2dMapVectorTileInfo::FeatureTuple>> weakFeatures,
int32_t featuresBase,
Expand Down Expand Up @@ -109,6 +110,7 @@ class Tiled2dMapVectorSymbolGroup : public ActorObject, public std::enable_share
std::shared_ptr<SymbolVectorLayerDescription> layerDescription;
const WeakActor<Tiled2dMapVectorFontProvider> fontProvider;
const bool persistingSymbolPlacement = false;
const bool useCustomCrossTileIdentifier = false;

std::shared_ptr<Quad2dInstancedInterface> iconInstancedObject;
std::shared_ptr<Quad2dStretchedInstancedInterface> stretchedInstancedObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Tiled2dMapVectorSymbolObject::Tiled2dMapVectorSymbolObject(const std::weak_ptr<M
const bool hasCustomTexture,
const double dpFactor,
const bool persistingSymbolPlacement,
const bool useCustomCrossTileIdentifier,
bool is3d,
const Vec3D &tileOrigin) :
description(description),
Expand Down Expand Up @@ -102,7 +103,12 @@ Tiled2dMapVectorSymbolObject::Tiled2dMapVectorSymbolObject(const std::weak_ptr<M
const bool hasText = !fullText.empty();
const size_t contentHash = usedKeys.getHash(evalContext);
Copy link
Contributor

@matzf matzf Mar 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This contentHash can be relatively expensive and can be moved into the if (useCustomCrossTileIdentifier ... branch.


crossTileIdentifier = std::hash<std::tuple<std::string, std::string, bool, size_t>>()(std::tuple<std::string, std::string, bool, size_t>(fullText, layerIdentifier, hasIcon, contentHash));
if (useCustomCrossTileIdentifier || featureContext->identifier == 0) {
crossTileIdentifier = std::hash<std::tuple<std::string, std::string, bool, size_t>>()(std::tuple<std::string, std::string, bool, size_t>(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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Tiled2dMapVectorSymbolObject {
const bool hasCustomTexture,
const double dpFactor,
const bool persistingSymbolPlacement,
const bool useCustomCrossTileIdentifier,
bool is3d,
const Vec3D &tileOrigin);

Expand Down