From d446ed0ac81f44079ef86b8e5e8a50e066598218 Mon Sep 17 00:00:00 2001 From: Christoph Maurhofer Date: Fri, 19 Jan 2024 11:17:46 +0100 Subject: [PATCH] Add multiselect flag for geometry layers (fill, line) --- ...apVectorLayerSelectionCallbackInterface.kt | 8 +++++++ ...pVectorLayerSelectionCallbackInterface.cpp | 22 +++++++++++++++++++ ...MapVectorLayerSelectionCallbackInterface.h | 2 ++ ...LayerSelectionCallbackInterface+Private.mm | 20 +++++++++++++++++ ...MapVectorLayerSelectionCallbackInterface.h | 4 ++++ .../tiled/vector/tiled_vector_layer.djinni | 1 + .../public/BackgroundVectorLayerDescription.h | 2 +- shared/public/LineVectorLayerDescription.h | 7 +++--- shared/public/PolygonVectorLayerDescription.h | 7 +++--- shared/public/RasterVectorLayerDescription.h | 2 +- shared/public/SymbolVectorLayerDescription.h | 2 +- ...MapVectorLayerSelectionCallbackInterface.h | 3 +++ shared/public/Tiled2dMapVectorTile.h | 1 + shared/public/VectorLayerDescription.h | 7 ++++-- .../Tiled2dMapVectorLayerParserHelper.cpp | 12 +++++++--- .../vector/tiles/Tiled2dMapVectorTile.cpp | 2 ++ .../tiles/line/Tiled2dMapVectorLineTile.cpp | 8 ++++++- .../Tiled2dMapVectorPolygonPatternTile.cpp | 11 ++++++++-- .../polygon/Tiled2dMapVectorPolygonTile.cpp | 11 ++++++++-- 19 files changed, 113 insertions(+), 19 deletions(-) diff --git a/bridging/android/java/io/openmobilemaps/mapscore/shared/map/layers/tiled/vector/Tiled2dMapVectorLayerSelectionCallbackInterface.kt b/bridging/android/java/io/openmobilemaps/mapscore/shared/map/layers/tiled/vector/Tiled2dMapVectorLayerSelectionCallbackInterface.kt index 89ff834f9..f91f2d491 100644 --- a/bridging/android/java/io/openmobilemaps/mapscore/shared/map/layers/tiled/vector/Tiled2dMapVectorLayerSelectionCallbackInterface.kt +++ b/bridging/android/java/io/openmobilemaps/mapscore/shared/map/layers/tiled/vector/Tiled2dMapVectorLayerSelectionCallbackInterface.kt @@ -10,6 +10,8 @@ abstract class Tiled2dMapVectorLayerSelectionCallbackInterface { abstract fun didSelectFeature(featureInfo: VectorLayerFeatureInfo, layerIdentifier: String, coord: io.openmobilemaps.mapscore.shared.map.coordinates.Coord): Boolean + abstract fun didMultiSelectLayerFeatures(featureInfos: ArrayList, layerIdentifier: String, coord: io.openmobilemaps.mapscore.shared.map.coordinates.Coord): Boolean + abstract fun didClickBackgroundConfirmed(coord: io.openmobilemaps.mapscore.shared.map.coordinates.Coord): Boolean private class CppProxy : Tiled2dMapVectorLayerSelectionCallbackInterface { @@ -33,6 +35,12 @@ abstract class Tiled2dMapVectorLayerSelectionCallbackInterface { } private external fun native_didSelectFeature(_nativeRef: Long, featureInfo: VectorLayerFeatureInfo, layerIdentifier: String, coord: io.openmobilemaps.mapscore.shared.map.coordinates.Coord): Boolean + override fun didMultiSelectLayerFeatures(featureInfos: ArrayList, layerIdentifier: String, coord: io.openmobilemaps.mapscore.shared.map.coordinates.Coord): Boolean { + assert(!this.destroyed.get()) { error("trying to use a destroyed object") } + return native_didMultiSelectLayerFeatures(this.nativeRef, featureInfos, layerIdentifier, coord) + } + private external fun native_didMultiSelectLayerFeatures(_nativeRef: Long, featureInfos: ArrayList, layerIdentifier: String, coord: io.openmobilemaps.mapscore.shared.map.coordinates.Coord): Boolean + override fun didClickBackgroundConfirmed(coord: io.openmobilemaps.mapscore.shared.map.coordinates.Coord): Boolean { assert(!this.destroyed.get()) { error("trying to use a destroyed object") } return native_didClickBackgroundConfirmed(this.nativeRef, coord) diff --git a/bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.cpp b/bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.cpp index 6238c5bff..b3e2b141d 100644 --- a/bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.cpp +++ b/bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.cpp @@ -27,6 +27,17 @@ bool NativeTiled2dMapVectorLayerSelectionCallbackInterface::JavaProxy::didSelect ::djinni::jniExceptionCheck(jniEnv); return ::djinni::Bool::toCpp(jniEnv, jret); } +bool NativeTiled2dMapVectorLayerSelectionCallbackInterface::JavaProxy::didMultiSelectLayerFeatures(const std::vector<::VectorLayerFeatureInfo> & c_featureInfos, const std::string & c_layerIdentifier, const ::Coord & c_coord) { + auto jniEnv = ::djinni::jniGetThreadEnv(); + ::djinni::JniLocalScope jscope(jniEnv, 10); + const auto& data = ::djinni::JniClass<::djinni_generated::NativeTiled2dMapVectorLayerSelectionCallbackInterface>::get(); + auto jret = jniEnv->CallBooleanMethod(Handle::get().get(), data.method_didMultiSelectLayerFeatures, + ::djinni::get(::djinni::List<::djinni_generated::NativeVectorLayerFeatureInfo>::fromCpp(jniEnv, c_featureInfos)), + ::djinni::get(::djinni::String::fromCpp(jniEnv, c_layerIdentifier)), + ::djinni::get(::djinni_generated::NativeCoord::fromCpp(jniEnv, c_coord))); + ::djinni::jniExceptionCheck(jniEnv); + return ::djinni::Bool::toCpp(jniEnv, jret); +} bool NativeTiled2dMapVectorLayerSelectionCallbackInterface::JavaProxy::didClickBackgroundConfirmed(const ::Coord & c_coord) { auto jniEnv = ::djinni::jniGetThreadEnv(); ::djinni::JniLocalScope jscope(jniEnv, 10); @@ -55,6 +66,17 @@ CJNIEXPORT jboolean JNICALL Java_io_openmobilemaps_mapscore_shared_map_layers_ti } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) } +CJNIEXPORT jboolean JNICALL Java_io_openmobilemaps_mapscore_shared_map_layers_tiled_vector_Tiled2dMapVectorLayerSelectionCallbackInterface_00024CppProxy_native_1didMultiSelectLayerFeatures(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_featureInfos, jstring j_layerIdentifier, ::djinni_generated::NativeCoord::JniType j_coord) +{ + try { + const auto& ref = ::djinni::objectFromHandleAddress<::Tiled2dMapVectorLayerSelectionCallbackInterface>(nativeRef); + auto r = ref->didMultiSelectLayerFeatures(::djinni::List<::djinni_generated::NativeVectorLayerFeatureInfo>::toCpp(jniEnv, j_featureInfos), + ::djinni::String::toCpp(jniEnv, j_layerIdentifier), + ::djinni_generated::NativeCoord::toCpp(jniEnv, j_coord)); + return ::djinni::release(::djinni::Bool::fromCpp(jniEnv, r)); + } JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */) +} + CJNIEXPORT jboolean JNICALL Java_io_openmobilemaps_mapscore_shared_map_layers_tiled_vector_Tiled2dMapVectorLayerSelectionCallbackInterface_00024CppProxy_native_1didClickBackgroundConfirmed(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, ::djinni_generated::NativeCoord::JniType j_coord) { try { diff --git a/bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.h b/bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.h index db136770d..5a9dc8b7c 100644 --- a/bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.h +++ b/bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.h @@ -34,6 +34,7 @@ class NativeTiled2dMapVectorLayerSelectionCallbackInterface final : ::djinni::Jn ~JavaProxy(); bool didSelectFeature(const ::VectorLayerFeatureInfo & featureInfo, const std::string & layerIdentifier, const ::Coord & coord) override; + bool didMultiSelectLayerFeatures(const std::vector<::VectorLayerFeatureInfo> & featureInfos, const std::string & layerIdentifier, const ::Coord & coord) override; bool didClickBackgroundConfirmed(const ::Coord & coord) override; private: @@ -42,6 +43,7 @@ class NativeTiled2dMapVectorLayerSelectionCallbackInterface final : ::djinni::Jn const ::djinni::GlobalRef clazz { ::djinni::jniFindClass("io/openmobilemaps/mapscore/shared/map/layers/tiled/vector/Tiled2dMapVectorLayerSelectionCallbackInterface") }; const jmethodID method_didSelectFeature { ::djinni::jniGetMethodID(clazz.get(), "didSelectFeature", "(Lio/openmobilemaps/mapscore/shared/map/layers/tiled/vector/VectorLayerFeatureInfo;Ljava/lang/String;Lio/openmobilemaps/mapscore/shared/map/coordinates/Coord;)Z") }; + const jmethodID method_didMultiSelectLayerFeatures { ::djinni::jniGetMethodID(clazz.get(), "didMultiSelectLayerFeatures", "(Ljava/util/ArrayList;Ljava/lang/String;Lio/openmobilemaps/mapscore/shared/map/coordinates/Coord;)Z") }; const jmethodID method_didClickBackgroundConfirmed { ::djinni::jniGetMethodID(clazz.get(), "didClickBackgroundConfirmed", "(Lio/openmobilemaps/mapscore/shared/map/coordinates/Coord;)Z") }; }; diff --git a/bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface+Private.mm b/bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface+Private.mm index 0487e16e6..df865002e 100644 --- a/bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface+Private.mm +++ b/bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface+Private.mm @@ -44,6 +44,17 @@ - (BOOL)didSelectFeature:(nonnull MCVectorLayerFeatureInfo *)featureInfo } DJINNI_TRANSLATE_EXCEPTIONS() } +- (BOOL)didMultiSelectLayerFeatures:(nonnull NSArray *)featureInfos + layerIdentifier:(nonnull NSString *)layerIdentifier + coord:(nonnull MCCoord *)coord { + try { + auto objcpp_result_ = _cppRefHandle.get()->didMultiSelectLayerFeatures(::djinni::List<::djinni_generated::VectorLayerFeatureInfo>::toCpp(featureInfos), + ::djinni::String::toCpp(layerIdentifier), + ::djinni_generated::Coord::toCpp(coord)); + return ::djinni::Bool::fromCpp(objcpp_result_); + } DJINNI_TRANSLATE_EXCEPTIONS() +} + - (BOOL)didClickBackgroundConfirmed:(nonnull MCCoord *)coord { try { auto objcpp_result_ = _cppRefHandle.get()->didClickBackgroundConfirmed(::djinni_generated::Coord::toCpp(coord)); @@ -69,6 +80,15 @@ bool didSelectFeature(const ::VectorLayerFeatureInfo & c_featureInfo, const std: return ::djinni::Bool::toCpp(objcpp_result_); } } + bool didMultiSelectLayerFeatures(const std::vector<::VectorLayerFeatureInfo> & c_featureInfos, const std::string & c_layerIdentifier, const ::Coord & c_coord) override + { + @autoreleasepool { + auto objcpp_result_ = [djinni_private_get_proxied_objc_object() didMultiSelectLayerFeatures:(::djinni::List<::djinni_generated::VectorLayerFeatureInfo>::fromCpp(c_featureInfos)) + layerIdentifier:(::djinni::String::fromCpp(c_layerIdentifier)) + coord:(::djinni_generated::Coord::fromCpp(c_coord))]; + return ::djinni::Bool::toCpp(objcpp_result_); + } + } bool didClickBackgroundConfirmed(const ::Coord & c_coord) override { @autoreleasepool { diff --git a/bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface.h b/bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface.h index a7483a5d7..32e722373 100644 --- a/bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface.h +++ b/bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface.h @@ -12,6 +12,10 @@ layerIdentifier:(nonnull NSString *)layerIdentifier coord:(nonnull MCCoord *)coord; +- (BOOL)didMultiSelectLayerFeatures:(nonnull NSArray *)featureInfos + layerIdentifier:(nonnull NSString *)layerIdentifier + coord:(nonnull MCCoord *)coord; + - (BOOL)didClickBackgroundConfirmed:(nonnull MCCoord *)coord; @end diff --git a/djinni/map/layers/tiled/vector/tiled_vector_layer.djinni b/djinni/map/layers/tiled/vector/tiled_vector_layer.djinni index 6530829be..699db07d6 100644 --- a/djinni/map/layers/tiled/vector/tiled_vector_layer.djinni +++ b/djinni/map/layers/tiled/vector/tiled_vector_layer.djinni @@ -92,6 +92,7 @@ vector_layer_feature_info = record { tiled_2d_map_vector_layer_selection_callback_interface = interface +c +j +o { did_select_feature(feature_info: vector_layer_feature_info, layer_identifier: string, coord: coord): bool; + did_multi_select_layer_features(feature_infos: list, layer_identifier: string, coord: coord): bool; did_click_background_confirmed(coord: coord) : bool; } diff --git a/shared/public/BackgroundVectorLayerDescription.h b/shared/public/BackgroundVectorLayerDescription.h index 26217c3d1..de72b789b 100644 --- a/shared/public/BackgroundVectorLayerDescription.h +++ b/shared/public/BackgroundVectorLayerDescription.h @@ -65,7 +65,7 @@ class BackgroundVectorLayerDescription: public VectorLayerDescription { BackgroundVectorStyle style, std::optional renderPassIndex, std::shared_ptr interactable): - VectorLayerDescription(identifier, "", "", 0, 0, nullptr, renderPassIndex, interactable), + VectorLayerDescription(identifier, "", "", 0, 0, nullptr, renderPassIndex, interactable, false), style(style) {}; std::unique_ptr clone() override { diff --git a/shared/public/LineVectorLayerDescription.h b/shared/public/LineVectorLayerDescription.h index f51d19332..cef864260 100644 --- a/shared/public/LineVectorLayerDescription.h +++ b/shared/public/LineVectorLayerDescription.h @@ -133,14 +133,15 @@ class LineVectorLayerDescription: public VectorLayerDescription { std::shared_ptr filter, LineVectorStyle style, std::optional renderPassIndex, - std::shared_ptr interactable): - VectorLayerDescription(identifier, source, sourceId, minZoom, maxZoom, filter, renderPassIndex, interactable), + std::shared_ptr interactable, + bool multiselect): + VectorLayerDescription(identifier, source, sourceId, minZoom, maxZoom, filter, renderPassIndex, interactable, multiselect), style(style) {}; std::unique_ptr clone() override { return std::make_unique(identifier, source, sourceLayer, minZoom, maxZoom, filter ? filter->clone() : nullptr, style, renderPassIndex, - interactable ? interactable->clone() : nullptr); + interactable ? interactable->clone() : nullptr, multiselect); } virtual UsedKeysCollection getUsedKeys() const override { diff --git a/shared/public/PolygonVectorLayerDescription.h b/shared/public/PolygonVectorLayerDescription.h index 7feca6dc9..f082d3ab7 100644 --- a/shared/public/PolygonVectorLayerDescription.h +++ b/shared/public/PolygonVectorLayerDescription.h @@ -98,14 +98,15 @@ class PolygonVectorLayerDescription: public VectorLayerDescription { std::shared_ptr filter, PolygonVectorStyle style, std::optional renderPassIndex, - std::shared_ptr interactable): - VectorLayerDescription(identifier, source, sourceId, minZoom, maxZoom, filter, renderPassIndex, interactable), + std::shared_ptr interactable, + bool multiselect): + VectorLayerDescription(identifier, source, sourceId, minZoom, maxZoom, filter, renderPassIndex, interactable, multiselect), style(style) {}; std::unique_ptr clone() override { return std::make_unique(identifier, source, sourceLayer, minZoom, maxZoom, filter ? filter->clone() : nullptr, style, renderPassIndex, - interactable ? interactable->clone() : nullptr); + interactable ? interactable->clone() : nullptr, multiselect); } virtual UsedKeysCollection getUsedKeys() const override { diff --git a/shared/public/RasterVectorLayerDescription.h b/shared/public/RasterVectorLayerDescription.h index 37af30755..949ab93e1 100644 --- a/shared/public/RasterVectorLayerDescription.h +++ b/shared/public/RasterVectorLayerDescription.h @@ -144,7 +144,7 @@ class RasterVectorLayerDescription: public VectorLayerDescription { bool underzoom, bool overzoom, std::optional<::RectCoord> bounds): - VectorLayerDescription(identifier, source, "", minZoom, maxZoom, nullptr, renderPassIndex, interactable), + VectorLayerDescription(identifier, source, "", minZoom, maxZoom, nullptr, renderPassIndex, interactable, false), style(style), url(url), underzoom(underzoom), overzoom(overzoom), adaptScaleToScreen(adaptScaleToScreen), numDrawPreviousLayers(numDrawPreviousLayers), maskTiles(maskTiles), zoomLevelScaleFactor(zoomLevelScaleFactor), bounds(bounds) {}; diff --git a/shared/public/SymbolVectorLayerDescription.h b/shared/public/SymbolVectorLayerDescription.h index 1086f0d75..4dcc6c58c 100644 --- a/shared/public/SymbolVectorLayerDescription.h +++ b/shared/public/SymbolVectorLayerDescription.h @@ -510,7 +510,7 @@ class SymbolVectorLayerDescription: public VectorLayerDescription { SymbolVectorStyle style, std::optional renderPassIndex, std::shared_ptr interactable): - VectorLayerDescription(identifier, source, sourceId, minZoom, maxZoom, filter, renderPassIndex, interactable), + VectorLayerDescription(identifier, source, sourceId, minZoom, maxZoom, filter, renderPassIndex, interactable, false), style(style) {}; std::unique_ptr clone() override { diff --git a/shared/public/Tiled2dMapVectorLayerSelectionCallbackInterface.h b/shared/public/Tiled2dMapVectorLayerSelectionCallbackInterface.h index 6bbda34c7..33ea471aa 100644 --- a/shared/public/Tiled2dMapVectorLayerSelectionCallbackInterface.h +++ b/shared/public/Tiled2dMapVectorLayerSelectionCallbackInterface.h @@ -5,6 +5,7 @@ #include "Coord.h" #include +#include struct VectorLayerFeatureInfo; @@ -14,5 +15,7 @@ class Tiled2dMapVectorLayerSelectionCallbackInterface { virtual bool didSelectFeature(const VectorLayerFeatureInfo & featureInfo, const std::string & layerIdentifier, const ::Coord & coord) = 0; + virtual bool didMultiSelectLayerFeatures(const std::vector & featureInfos, const std::string & layerIdentifier, const ::Coord & coord) = 0; + virtual bool didClickBackgroundConfirmed(const ::Coord & coord) = 0; }; diff --git a/shared/public/Tiled2dMapVectorTile.h b/shared/public/Tiled2dMapVectorTile.h index cf61656fd..ce12ec9b0 100644 --- a/shared/public/Tiled2dMapVectorTile.h +++ b/shared/public/Tiled2dMapVectorTile.h @@ -77,6 +77,7 @@ class Tiled2dMapVectorTile : public ActorObject, double dpFactor = 1.0; std::weak_ptr selectionDelegate; + bool multiselect = false; const std::shared_ptr featureStateManager; }; diff --git a/shared/public/VectorLayerDescription.h b/shared/public/VectorLayerDescription.h index 79f67fcfd..e683b5ab4 100644 --- a/shared/public/VectorLayerDescription.h +++ b/shared/public/VectorLayerDescription.h @@ -26,6 +26,7 @@ class VectorLayerDescription { int maxZoom; std::shared_ptr filter; std::optional renderPassIndex; + bool multiselect; virtual VectorLayerType getType() = 0; @@ -58,7 +59,8 @@ class VectorLayerDescription { int maxZoom, std::shared_ptr filter, std::optional renderPassIndex, - std::shared_ptr interactable): + std::shared_ptr interactable, + bool multiselect): identifier(identifier), source(source), sourceLayer(sourceId), @@ -66,7 +68,8 @@ class VectorLayerDescription { maxZoom(maxZoom), filter(filter), renderPassIndex(renderPassIndex), - interactable(interactable) {} + interactable(interactable), + multiselect(multiselect) {} virtual ~VectorLayerDescription() = default; diff --git a/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp b/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp index 7d8ef518a..099a4da51 100644 --- a/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp +++ b/shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp @@ -223,6 +223,7 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ std::optional renderPassIndex; std::shared_ptr interactable = globalIsInteractable; + bool layerMultiselect = false; std::shared_ptr blendMode; if (val["metadata"].is_object()) { @@ -232,6 +233,9 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ if (!val["metadata"]["interactable"].is_null()) { interactable = parser.parseValue(val["metadata"]["interactable"]); } + if (!val["metadata"]["multiselect"].is_null()) { + layerMultiselect = val["metadata"].value("multiselect", false); + } if (!val["metadata"]["blend-mode"].is_null()) { blendMode = parser.parseValue(val["metadata"]["blend-mode"]); } @@ -301,7 +305,8 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ filter, style, renderPassIndex, - interactable); + interactable, + layerMultiselect); layers.push_back(layerDesc); @@ -360,7 +365,7 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ filter, style, renderPassIndex, - interactable); + interactable); // in-layer layerMultiselect not yet supported layers.push_back(layerDesc); } else if (val["type"] == "fill") { @@ -379,7 +384,8 @@ Tiled2dMapVectorLayerParserResult Tiled2dMapVectorLayerParserHelper::parseStyleJ filter, style, renderPassIndex, - interactable); + interactable, + layerMultiselect); layers.push_back(layerDesc); } diff --git a/shared/src/map/layers/tiled/vector/tiles/Tiled2dMapVectorTile.cpp b/shared/src/map/layers/tiled/vector/tiles/Tiled2dMapVectorTile.cpp index 9da6f4fb7..8ce4ad9f2 100644 --- a/shared/src/map/layers/tiled/vector/tiles/Tiled2dMapVectorTile.cpp +++ b/shared/src/map/layers/tiled/vector/tiles/Tiled2dMapVectorTile.cpp @@ -26,6 +26,8 @@ Tiled2dMapVectorTile::Tiled2dMapVectorTile(const std::weak_ptr &ma if (auto strongMapInterface = mapInterface.lock()) { dpFactor = strongMapInterface->getCamera()->getScreenDensityPpi() / 160.0; } + + multiselect = description->multiselect; } void Tiled2dMapVectorTile::updateVectorLayerDescription(const std::shared_ptr &description, diff --git a/shared/src/map/layers/tiled/vector/tiles/line/Tiled2dMapVectorLineTile.cpp b/shared/src/map/layers/tiled/vector/tiles/line/Tiled2dMapVectorLineTile.cpp index 86957d00b..106c92cfb 100644 --- a/shared/src/map/layers/tiled/vector/tiles/line/Tiled2dMapVectorLineTile.cpp +++ b/shared/src/map/layers/tiled/vector/tiles/line/Tiled2dMapVectorLineTile.cpp @@ -409,17 +409,23 @@ bool Tiled2dMapVectorLineTile::onClickConfirmed(const Vec2F &posScreen) { auto lineDescription = std::static_pointer_cast(description); + std::vector featureInfos; for (auto const &[lineCoordinateVector, featureContext]: hitDetection) { for (auto const &coordinates: lineCoordinateVector) { auto lineWidth = lineDescription->style.getLineWidth(EvaluationContext(zoomIdentifier, dpFactor, featureContext, featureStateManager)); if (LineHelper::pointWithin(coordinates, point, lineWidth, coordinateConverter)) { - if (strongSelectionDelegate->didSelectFeature(featureContext->getFeatureInfo(), description->identifier, point)) { + if (multiselect) { + featureInfos.push_back(featureContext->getFeatureInfo()); + } else if (strongSelectionDelegate->didSelectFeature(featureContext->getFeatureInfo(), description->identifier, point)) { return true; } } } } + if (multiselect && !featureInfos.empty()) { + return strongSelectionDelegate->didMultiSelectLayerFeatures(featureInfos, description->identifier, point); + } return false; } diff --git a/shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonPatternTile.cpp b/shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonPatternTile.cpp index ce79db2da..9d32cd4d6 100644 --- a/shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonPatternTile.cpp +++ b/shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonPatternTile.cpp @@ -410,14 +410,21 @@ bool Tiled2dMapVectorPolygonPatternTile::onClickConfirmed(const Vec2F &posScreen } auto point = camera->coordFromScreenPosition(posScreen); + std::vector featureInfos; for (auto const &[polygon, featureContext]: hitDetectionPolygons) { if (VectorTileGeometryHandler::isPointInTriangulatedPolygon(point, polygon, converter)) { - if (strongSelectionDelegate->didSelectFeature(featureContext->getFeatureInfo(), description->identifier, - converter->convert(CoordinateSystemIdentifiers::EPSG4326(), point))) { + if (multiselect) { + featureInfos.push_back(featureContext->getFeatureInfo()); + } else if (strongSelectionDelegate->didSelectFeature(featureContext->getFeatureInfo(), description->identifier, + converter->convert(CoordinateSystemIdentifiers::EPSG4326(),point))) { return true; } } } + if (multiselect && !featureInfos.empty()) { + return strongSelectionDelegate->didMultiSelectLayerFeatures(featureInfos, description->identifier, converter->convert(CoordinateSystemIdentifiers::EPSG4326(), point)); + } + return false; } diff --git a/shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonTile.cpp b/shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonTile.cpp index 62f2d635f..ddb73e25f 100644 --- a/shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonTile.cpp +++ b/shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonTile.cpp @@ -327,14 +327,21 @@ bool Tiled2dMapVectorPolygonTile::onClickConfirmed(const Vec2F &posScreen) { } auto point = camera->coordFromScreenPosition(posScreen); + std::vector featureInfos; for (auto const &[polygon, featureContext]: hitDetectionPolygons) { if (VectorTileGeometryHandler::isPointInTriangulatedPolygon(point, polygon, converter)) { - if (strongSelectionDelegate->didSelectFeature(featureContext->getFeatureInfo(), description->identifier, - converter->convert(CoordinateSystemIdentifiers::EPSG4326(), point))) { + if (multiselect) { + featureInfos.push_back(featureContext->getFeatureInfo()); + } else if (strongSelectionDelegate->didSelectFeature(featureContext->getFeatureInfo(), description->identifier, + converter->convert(CoordinateSystemIdentifiers::EPSG4326(),point))) { return true; } } } + if (multiselect && !featureInfos.empty()) { + return strongSelectionDelegate->didMultiSelectLayerFeatures(featureInfos, description->identifier, converter->convert(CoordinateSystemIdentifiers::EPSG4326(), point)); + } + return false; }