Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show labels only if they are not hidden later #566

Closed
wants to merge 7 commits into from

Conversation

friedrich-ubique
Copy link
Contributor

@friedrich-ubique friedrich-ubique commented Jan 8, 2024

Summary by CodeRabbit

  • Bug Fixes
    • Improved collision detection logic to ensure more accurate and reliable collision outcomes.
    • Refined symbol comparison operations to enhance map layer rendering consistency.
    • Updated symbol group collision detection to streamline map data management and improve performance.

Copy link
Contributor

coderabbitai bot commented Jan 8, 2024

Warning

Rate Limit Exceeded

@maurhofer-ubique has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 20 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.

Commits Files that changed from the base of the PR and between a8154db and ea3db50.

Walkthrough

The recent updates involve refining the collision detection system and modifying comparison logic in symbol management. The CollisionGrid now uses a boolean to track and return collision status, while the symbol comparison and group collision logic in the map vector source data manager have been simplified by removing certain conditional checks.

Changes

File Path Change Summary
shared/public/CollisionGrid.h,
shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp,
shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h
Refactored collision tracking and symbol comparison logic.
android/src/main/cpp/graphics/objects/*.cpp,
bridging/android/java/io/openmobilemaps/mapscore/shared/graphics/RenderPassConfig.kt,
bridging/android/java/io/openmobilemaps/mapscore/shared/map/layers/tiled/vector/Tiled2dMapVectorLayerSelectionCallbackInterface.kt,
bridging/android/jni/graphics/NativeRenderPassConfig.*,
bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.*,
bridging/ios/MCRenderPassConfig.*,
bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface.*,
djinni/graphics/core.djinni,
djinni/map/layers/tiled/vector/tiled_vector_layer.djinni,
shared/public/*.h,
shared/public/RenderPassConfig.h,
shared/public/Tiled2dMapVectorLayer.h,
shared/public/Tiled2dMapVectorLayerSelectionCallbackInterface.h,
shared/public/Tiled2dMapVectorStyleParser.h,
shared/public/Tiled2dMapVectorTile.h,
shared/public/Value.h
Added or modified properties, methods, and classes related to rendering and map layers.
shared/src/map/layers/icon/IconLayer.cpp,
shared/src/map/layers/line/LineLayer.cpp,
shared/src/map/layers/polygon/PolygonLayer.cpp,
shared/src/map/layers/text/TextLayer.cpp,
shared/src/map/layers/tiled/raster/Tiled2dMapRasterLayer.cpp,
shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayer.cpp,
shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp,
shared/src/map/layers/tiled/vector/Tiled2dMapVectorStyleParser.cpp,
shared/src/map/layers/tiled/vector/sourcemanagers/*.cpp,
shared/src/map/layers/tiled/vector/sublayers/background/Tiled2dMapVectorBackgroundSubLayer.cpp,
shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolCollisionManager.*,
shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp,
shared/src/map/layers/tiled/vector/tiles/*.cpp
Updated various classes related to map rendering and symbol management.

Poem

🐇💻 CodeRabbit hops with glee, 🎉
As changes bloom on map and tree.
Symbols sort and layers render,
A digital world, oh so tender! 🗺️✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8ebf024 and 2d214f5.
Files selected for processing (3)
  • shared/public/CollisionGrid.h (1 hunks)
  • shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h (1 hunks)
  • shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp (1 hunks)
Additional comments: 2
shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h (1)
  • 42-47: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [37-47]

The changes to the operator< method remove the checks for isColliding and smallestVisibleZoom. This simplification could impact the sorting and rendering priority of symbols. Ensure that this change aligns with the intended behavior and that all dependent sorting logic has been updated accordingly.

shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp (1)
  • 629-632: The changes in the collisionDetection method involve the collection of symbol objects for collision detection. The use of reserve and insert with make_move_iterator is efficient for combining vectors without unnecessary copying. However, ensure that the objects being moved are not used elsewhere after this operation to avoid access to moved-from objects.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 73ca61d and 8eadb85.
Files selected for processing (3)
  • shared/public/CollisionGrid.h (1 hunks)
  • shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h (1 hunks)
  • shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp (1 hunks)
Additional comments: 2
shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h (1)
  • 42-47: > Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [58-63]

The comparison logic in operator< has been simplified to only use symbolSortKey and symbolTileIndex. Ensure that this change aligns with the intended sorting behavior, as it no longer considers isColliding and smallestVisibleZoom, which could affect the rendering order of symbols.

shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp (1)
  • 629-632: The collisionDetection method has been modified to remove conditional logic related to persistingPlacement. Objects are now directly concatenated to allObjects without conditional branching. Verify that this change does not affect the intended behavior of symbol placement and collision detection.

Comment on lines 102 to 123
bool collision = false;
for (int16_t y = indexRange.yMin; y <= indexRange.yMax; y++) {
for (int16_t x = indexRange.xMin; x <= indexRange.xMax; x++) {
if (!collision) {
for (const auto &rect : gridRects[y][x]) {
if (CollisionUtil::checkRectCollision(projectedRectangle, rect)) {
return 1;
collision = true;
}
}
for (const auto &circle : gridCircles[y][x]) {
if (CollisionUtil::checkRectCircleCollision(projectedRectangle, circle)) {
return 1;
collision = true;
}
}

}
}

// Only insert, when not colliding
for (int16_t y = indexRange.yMin; y <= indexRange.yMax; y++) {
for (int16_t x = indexRange.xMin; x <= indexRange.xMax; x++) {
}
gridRects[y][x].push_back(projectedRectangle);
}
}

if (rectangle.contentHash != 0 && rectangle.symbolSpacing > 0) {
spacedRects[rectangle.contentHash].push_back(projectedRectangle);
}
if (collision) return 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

The logic in addAndCheckCollisionAlignedRect now uses a boolean flag collision to track if a collision has occurred, with conditional insertion of rectangles into the grid. Ensure that this change does not introduce any regressions, especially since the insertion is now inside the loop and may be executed multiple times for the same rectangle, which could be incorrect.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 633e5cf and 5790949.
Files selected for processing (3)
  • shared/public/CollisionGrid.h (1 hunks)
  • shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h (1 hunks)
  • shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • shared/public/CollisionGrid.h
  • shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h
  • shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 9

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c185fae and a8154db.
Files selected for processing (56)
  • android/src/main/cpp/graphics/objects/LineGroup2dOpenGl.cpp (1 hunks)
  • android/src/main/cpp/graphics/objects/Polygon2dOpenGl.cpp (1 hunks)
  • android/src/main/cpp/graphics/objects/PolygonGroup2dOpenGl.cpp (1 hunks)
  • android/src/main/cpp/graphics/objects/PolygonPatternGroup2dOpenGl.cpp (1 hunks)
  • android/src/main/cpp/graphics/objects/Quad2dInstancedOpenGl.cpp (1 hunks)
  • android/src/main/cpp/graphics/objects/Quad2dOpenGl.cpp (1 hunks)
  • android/src/main/cpp/graphics/objects/Quad2dStretchedInstancedOpenGl.cpp (1 hunks)
  • android/src/main/cpp/graphics/objects/Text2dInstancedOpenGl.cpp (1 hunks)
  • android/src/main/cpp/graphics/objects/Text2dOpenGl.cpp (1 hunks)
  • bridging/android/java/io/openmobilemaps/mapscore/shared/graphics/RenderPassConfig.kt (1 hunks)
  • bridging/android/java/io/openmobilemaps/mapscore/shared/map/layers/tiled/vector/Tiled2dMapVectorLayerSelectionCallbackInterface.kt (2 hunks)
  • bridging/android/jni/graphics/NativeRenderPassConfig.cpp (1 hunks)
  • bridging/android/jni/graphics/NativeRenderPassConfig.h (1 hunks)
  • bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.cpp (2 hunks)
  • bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.h (2 hunks)
  • bridging/ios/MCRenderPassConfig+Private.mm (1 hunks)
  • bridging/ios/MCRenderPassConfig.h (1 hunks)
  • bridging/ios/MCRenderPassConfig.mm (1 hunks)
  • bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface+Private.mm (2 hunks)
  • bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface.h (1 hunks)
  • djinni/graphics/core.djinni (1 hunks)
  • djinni/map/layers/tiled/vector/tiled_vector_layer.djinni (1 hunks)
  • shared/public/BackgroundVectorLayerDescription.h (1 hunks)
  • shared/public/CollisionGrid.h (8 hunks)
  • shared/public/LineVectorLayerDescription.h (1 hunks)
  • shared/public/PolygonVectorLayerDescription.h (1 hunks)
  • shared/public/RasterVectorLayerDescription.h (1 hunks)
  • shared/public/RenderPassConfig.h (1 hunks)
  • shared/public/SymbolVectorLayerDescription.h (1 hunks)
  • shared/public/Tiled2dMapVectorLayer.h (1 hunks)
  • shared/public/Tiled2dMapVectorLayerSelectionCallbackInterface.h (2 hunks)
  • shared/public/Tiled2dMapVectorStyleParser.h (3 hunks)
  • shared/public/Tiled2dMapVectorTile.h (1 hunks)
  • shared/public/Value.h (2 hunks)
  • shared/public/VectorLayerDescription.h (2 hunks)
  • shared/src/map/layers/icon/IconLayer.cpp (1 hunks)
  • shared/src/map/layers/line/LineLayer.cpp (1 hunks)
  • shared/src/map/layers/polygon/PolygonLayer.cpp (1 hunks)
  • shared/src/map/layers/text/TextLayer.cpp (1 hunks)
  • shared/src/map/layers/tiled/raster/Tiled2dMapRasterLayer.cpp (1 hunks)
  • shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayer.cpp (2 hunks)
  • shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp (5 hunks)
  • shared/src/map/layers/tiled/vector/Tiled2dMapVectorStyleParser.cpp (1 hunks)
  • shared/src/map/layers/tiled/vector/sourcemanagers/Tiled2dMapVectorSourceDataManager.cpp (1 hunks)
  • shared/src/map/layers/tiled/vector/sourcemanagers/Tiled2dMapVectorSourceDataManager.h (1 hunks)
  • shared/src/map/layers/tiled/vector/sourcemanagers/Tiled2dMapVectorSourceTileDataManager.cpp (1 hunks)
  • shared/src/map/layers/tiled/vector/sublayers/background/Tiled2dMapVectorBackgroundSubLayer.cpp (1 hunks)
  • shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h (1 hunks)
  • shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolCollisionManager.cpp (2 hunks)
  • shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolCollisionManager.h (1 hunks)
  • shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp (3 hunks)
  • shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp (2 hunks)
  • shared/src/map/layers/tiled/vector/tiles/Tiled2dMapVectorTile.cpp (1 hunks)
  • shared/src/map/layers/tiled/vector/tiles/line/Tiled2dMapVectorLineTile.cpp (1 hunks)
  • shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonPatternTile.cpp (1 hunks)
  • shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonTile.cpp (1 hunks)
Files skipped from review due to trivial changes (1)
  • android/src/main/cpp/graphics/objects/LineGroup2dOpenGl.cpp
Files skipped from review as they are similar to previous changes (3)
  • shared/public/CollisionGrid.h
  • shared/src/map/layers/tiled/vector/symbol/SymbolObjectCollisionWrapper.h
  • shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolDataManager.cpp
Additional comments: 71
bridging/android/java/io/openmobilemaps/mapscore/shared/graphics/RenderPassConfig.kt (1)
  • 8-8: The addition of the isPassMasked property to the RenderPassConfig data class in Kotlin is consistent with the changes across other parts of the codebase. This property is likely used to determine if a render pass should be masked, which could be part of the rendering optimization mentioned in the PR objectives.
shared/public/RenderPassConfig.h (1)
  • 11-11: The addition of the isPassMasked boolean member to the RenderPassConfig struct in C++ is consistent with the changes in the Kotlin counterpart. This change is necessary for the new functionality to be available across the different parts of the application that use this configuration.
bridging/ios/MCRenderPassConfig.h (2)
  • 9-10: The Objective-C interface MCRenderPassConfig has been updated to include the new initializer with the isPassMasked parameter. This change aligns with the updates in other parts of the codebase and ensures that the new property is available in the iOS bridging layer.
  • 16-16: The property isPassMasked has been added correctly to the MCRenderPassConfig interface. It's marked as readonly, which is appropriate since it should be set at initialization time and not changed afterward.
bridging/ios/MCRenderPassConfig+Private.mm (2)
  • 13-14: The toCpp method in the MCRenderPassConfig+Private.mm file has been updated to handle the isPassMasked property correctly. This ensures that the Objective-C representation is correctly converted to the C++ representation.
  • 19-20: The fromCpp method has been updated to include the isPassMasked property when creating an Objective-C MCRenderPassConfig object from a C++ RenderPassConfig object. This change is necessary for the new functionality to be reflected in the Objective-C layer.
shared/public/Tiled2dMapVectorLayerSelectionCallbackInterface.h (1)
  • 18-18: The addition of the didMultiSelectLayerFeatures virtual function to the Tiled2dMapVectorLayerSelectionCallbackInterface is consistent with the PR objectives to support multi-selection of layer features. This change extends the interface to handle multi-selection events.
bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface.h (1)
  • 15-17: The new method didMultiSelectLayerFeatures has been added to the MCTiled2dMapVectorLayerSelectionCallbackInterface protocol in Objective-C. This method is intended to handle multi-selection of layer features, aligning with the changes in the corresponding C++ interface.
bridging/ios/MCRenderPassConfig.mm (3)
  • 10-14: The initializer in the MCRenderPassConfig.mm file has been updated to set the _isPassMasked property. This change is consistent with the addition of the isPassMasked property in the class interface.
  • 20-23: The factory method renderPassConfigWithRenderPassIndex has been updated to include the isPassMasked parameter. This ensures that the new property can be set when creating an instance of MCRenderPassConfig using this convenience method.
  • 29-29: The description method has been updated to include the isPassMasked property in the description string of MCRenderPassConfig. This is useful for debugging purposes to quickly see the state of an object.
bridging/android/jni/graphics/NativeRenderPassConfig.h (1)
  • 28-30: The JNI constructor signature in NativeRenderPassConfig.h has been updated to include the new isPassMasked parameter. Additionally, the field ID for isPassMasked has been retrieved correctly. These changes are necessary for JNI to work with the updated RenderPassConfig class.
shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolCollisionManager.h (1)
  • 21-21: The collisionDetection method in the Tiled2dMapVectorSourceSymbolCollisionManager class has been updated to include an additional boolean parameter persistingPlacement. This change is likely related to the PR objectives of refining label visibility logic.
bridging/android/jni/graphics/NativeRenderPassConfig.cpp (2)
  • 16-17: The fromCpp method in NativeRenderPassConfig.cpp has been updated to handle the isPassMasked property correctly when creating a JNI object. This ensures that the C++ representation is correctly converted to the JNI representation.
  • 26-27: The toCpp method has been updated to retrieve and assign the isPassMasked field from a JNI object. This change is necessary for the new functionality to be reflected in the C++ layer when converting from JNI.
shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSourceSymbolCollisionManager.cpp (1)
  • 11-17: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [14-24]

The collisionDetection method now takes an additional bool parameter persistingPlacement. The CollisionGrid constructor is also modified to accept this new parameter. These changes are consistent with the PR objectives to refine the logic for label visibility.

shared/public/VectorLayerDescription.h (2)
  • 29-30: The VectorLayerDescription class has been updated to include two new boolean properties, multiselect and selfMasked. These properties are initialized in the constructor's initializer list, which introduces new functionality related to multiselect and self-masking behavior for vector layers.
  • 63-75: The constructor of VectorLayerDescription has been updated to include the new boolean parameters multiselect and selfMasked. This change is consistent with the PR objectives to support multi-selection functionality and self-masking behavior.
shared/src/map/layers/tiled/vector/tiles/Tiled2dMapVectorTile.cpp (1)
  • 29-30: The Tiled2dMapVectorTile constructor now initializes the multiselect member variable from the provided description. This change introduces a new control flow to the constructor, affecting the initialization logic and is consistent with the PR objectives.
shared/src/map/layers/tiled/vector/Tiled2dMapVectorStyleParser.cpp (1)
  • 26-26: The Tiled2dMapVectorStyleParser class has been updated to include the toBooleanExpression constant. This addition is likely used in the style parsing logic to support new expression types in the map styling functionality.
djinni/graphics/core.djinni (1)
  • 61-61: The render_pass_config record has been updated to include a new field is_pass_masked of type bool. This change is consistent with the updates in other parts of the codebase and is necessary for the new functionality to be available in the Djinni interface definition.
shared/src/map/layers/tiled/vector/sourcemanagers/Tiled2dMapVectorSourceDataManager.cpp (1)
  • 37-39: The Tiled2dMapVectorSourceDataManager constructor now includes a conditional check for layerDescription->selfMasked, which results in the insertion of index into the selfMaskedLayers set. This change is consistent with the PR objectives and the updates to the VectorLayerDescription class.
bridging/android/java/io/openmobilemaps/mapscore/shared/map/layers/tiled/vector/Tiled2dMapVectorLayerSelectionCallbackInterface.kt (2)
  • 13-14: The Tiled2dMapVectorLayerSelectionCallbackInterface in Kotlin has been updated to include the new abstract function didMultiSelectLayerFeatures. This change is consistent with the updates to the corresponding C++ and Objective-C interfaces.
  • 38-43: The private class CppProxy within the Tiled2dMapVectorLayerSelectionCallbackInterface has been updated to handle the new didMultiSelectLayerFeatures function. This ensures that the Kotlin interface can interact with the native C++ code correctly.
shared/public/BackgroundVectorLayerDescription.h (1)
  • 68-68: The BackgroundVectorLayerDescription class constructor has been modified to include two additional boolean parameters in the call to the VectorLayerDescription constructor. This change is consistent with the updates to the VectorLayerDescription class and is necessary for the new functionality related to multiselect and self-masking behavior.
bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.h (2)
  • 37-37: The NativeTiled2dMapVectorLayerSelectionCallbackInterface class has been updated to include the new method didMultiSelectLayerFeatures. This method is consistent with the changes in the Kotlin interface and ensures that the JNI layer can handle multi-selection events.
  • 46-46: The JNI method ID for didMultiSelectLayerFeatures has been added correctly. This is necessary for the JNI layer to invoke the correct method in the Kotlin interface when multi-selection events occur.
shared/public/Tiled2dMapVectorTile.h (1)
  • 80-80: The Tiled2dMapVectorTile class has been updated to include a new boolean member variable multiselect. This change is consistent with the updates to the VectorLayerDescription class and is necessary for the new functionality related to multiselect behavior.
shared/src/map/layers/tiled/vector/sourcemanagers/Tiled2dMapVectorSourceDataManager.h (1)
  • 87-87: The declaration for std::unordered_set<int32_t> selfMaskedLayers has been added to the Tiled2dMapVectorSourceDataManager class. This is consistent with the changes in the corresponding implementation file and is necessary for the new functionality related to layer masking.
shared/public/PolygonVectorLayerDescription.h (2)
  • 101-103: The constructor of PolygonVectorLayerDescription has been updated to include two new boolean parameters, multiselect and selfMasked. Ensure that all instantiations of this class are updated to pass these new arguments.
Verification successful

The contents of shared/public/PolygonVectorLayerDescription.h confirm that the constructor for PolygonVectorLayerDescription has indeed been updated to include the two new boolean parameters multiselect and selfMasked. The constructor now takes these parameters in addition to the existing ones.

The contents of shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp show an instantiation of PolygonVectorLayerDescription where the new parameters are being passed correctly (layerMultiselect and layerSelfMasked).

Based on the provided outputs, it appears that the constructor definition has been updated with the new parameters and at least one instantiation in Tiled2dMapVectorLayerParserHelper.cpp has been updated to pass these new arguments. However, without checking every instantiation in the codebase, we cannot be completely certain that all instantiations have been updated accordingly.

Given the evidence from the outputs, the review comment seems to be verified for the provided instantiation, but a full verification would require checking all instantiations.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for instantiations of PolygonVectorLayerDescription without the new parameters.
ast-grep --lang cpp --pattern $'PolygonVectorLayerDescription($_, $_, $_, $_, $_, $_, $_, $_, $_, $_)'

Length of output: 103



Script:

#!/bin/bash
# Search for the constructor definition of PolygonVectorLayerDescription to confirm the number of parameters before and after the change.
ast-grep --lang cpp --pattern $'class PolygonVectorLayerDescription { $$$ PolygonVectorLayerDescription($$$) { $$$ } $$$ }'

Length of output: 469



Script:

#!/bin/bash
# Search for the constructor definition of PolygonVectorLayerDescription with a simplified pattern.
ast-grep --lang cpp --pattern $'PolygonVectorLayerDescription($$$)'

Length of output: 68



Script:

#!/bin/bash
# Use ripgrep to search for occurrences of "PolygonVectorLayerDescription" to find the constructor definition and calls.
rg 'PolygonVectorLayerDescription'

Length of output: 3025



Script:

#!/bin/bash
# Display the contents of PolygonVectorLayerDescription.h to confirm the constructor parameters.
cat shared/public/PolygonVectorLayerDescription.h

# Display the instantiation in Tiled2dMapVectorLayerParserHelper.cpp to inspect the constructor call.
cat shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp

Length of output: 29921

* 110-110: The `clone` method has been updated to include the new parameters `multiselect` and `selfMasked`. Verify that the cloned object's state is consistent with the original object's state regarding these new parameters.
android/src/main/cpp/graphics/objects/PolygonGroup2dOpenGl.cpp (1)
  • 101-111: The render method now includes logic to handle stencilMask, validTarget, and zpass based on isMasked and renderPass.isPassMasked. Ensure that the new logic does not interfere with existing rendering behavior and that the stencil operations are correctly configured.
android/src/main/cpp/graphics/objects/Polygon2dOpenGl.cpp (1)
  • 107-117: Similar to the previous file, the render method in Polygon2dOpenGl.cpp has been modified to handle stencil operations differently. Verify that these changes are consistent with the intended rendering behavior and do not introduce any regressions.
Verification successful

The render method in Polygon2dOpenGl.cpp has been successfully located, and the changes to handle stencil operations as described in the review comment have been confirmed. There are no indications of regressions or inconsistencies with the intended rendering behavior based on the output provided.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of the render method to ensure the new stencil logic is compatible with existing rendering behavior.
ast-grep --lang cpp --pattern $'$_->render($_, $_, $_, $_, $_)'

Length of output: 64



Script:

#!/bin/bash
# Search for usages of the render method within the Polygon2dOpenGl class to ensure the new stencil logic is compatible with existing rendering behavior.
ast-grep --lang cpp --pattern $'class Polygon2dOpenGl { $$$ render($$$) { $$$ } $$$ }'

Length of output: 432



Script:

#!/bin/bash
# Use ripgrep to search for the render method within the Polygon2dOpenGl class.
rg --cpp 'void Polygon2dOpenGl::render' -A 10 -B 10

Length of output: 461



Script:

#!/bin/bash
# Use ripgrep to search for the render method within the Polygon2dOpenGl class without specifying the language.
rg 'void Polygon2dOpenGl::render' -A 10 -B 10

Length of output: 4024

djinni/map/layers/tiled/vector/tiled_vector_layer.djinni (1)
  • 95-95: The did_multi_select_layer_features method has been added to the tiled_2d_map_vector_layer_selection_callback_interface. Ensure that all implementations of this interface are updated to include this new method.
bridging/ios/MCTiled2dMapVectorLayerSelectionCallbackInterface+Private.mm (1)
  • 47-56: The Objective-C++ interface MCTiled2dMapVectorLayerSelectionCallbackInterface now includes the didMultiSelectLayerFeatures method. Verify that this method is correctly bridged to the corresponding C++ implementation and that it is invoked where necessary.
shared/public/LineVectorLayerDescription.h (2)
  • 136-138: The constructor of LineVectorLayerDescription now includes multiselect and selfMasked parameters. Verify that all instantiations of this class are updated to pass these new arguments.
  • 145-145: The clone method has been updated to include the new parameters multiselect and selfMasked. Verify that the cloned object's state is consistent with the original object's state regarding these new parameters.
Verification successful

The clone method has been identified in several instances within the codebase, including in LineVectorLayerDescription.h and PolygonVectorLayerDescription.h, where it is called with the multiselect and selfMasked parameters. This suggests that the cloned object's state is consistent with the original object's state regarding these new parameters.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of the clone method to ensure the new parameters are handled correctly.
ast-grep --lang cpp --pattern $'$_->clone()'

Length of output: 45



Script:

#!/bin/bash
# Search for usages of the clone method with a more inclusive pattern that accounts for different argument counts.
ast-grep --lang cpp --pattern $'$_->clone($$$)'

Length of output: 48



Script:

#!/bin/bash
# Use ripgrep to search for the string 'clone' to find any potential method calls.
rg '->clone\('

Length of output: 421



Script:

#!/bin/bash
# Correctly escape the search pattern to prevent shell interpretation and use ripgrep to find 'clone' method calls.
rg -- '->clone\('

Length of output: 3697

bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.cpp (2)
  • 30-40: The JNI implementation now includes the didMultiSelectLayerFeatures method. Verify that this method is correctly bridged to the corresponding Java method and that it is invoked where necessary.
  • 69-78: The JNI method native_1didMultiSelectLayerFeatures has been added. Verify that this method is correctly implemented and that it properly handles the conversion between JNI types and C++ types.
Verification successful

The output from the shell script provides the body of the JNI method Java_io_openmobilemaps_mapscore_shared_map_layers_tiled_vector_Tiled2dMapVectorLayerSelectionCallbackInterface_00024CppProxy_native_1didMultiSelectLayerFeatures. The method implementation includes the following conversions:

  • ::djinni::List<::djinni_generated::NativeVectorLayerFeatureInfo>::toCpp(jniEnv, j_featureInfos) converts a JNI jobject to a C++ List of NativeVectorLayerFeatureInfo.
  • ::djinni::String::toCpp(jniEnv, j_layerIdentifier) converts a JNI jstring to a C++ String.
  • ::djinni_generated::NativeCoord::toCpp(jniEnv, j_coord) converts a JNI NativeCoord::JniType to a C++ NativeCoord.

The method then calls ref->didMultiSelectLayerFeatures with the converted C++ types and returns the result as a JNI boolean after converting it with ::djinni::Bool::fromCpp(jniEnv, r).

Based on the provided output, the JNI method native_1didMultiSelectLayerFeatures appears to be correctly implemented with proper handling of the conversion between JNI types and C++ types.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for the JNI method implementation to ensure proper type conversion.
ast-grep --lang cpp --pattern $'Java_io_openmobilemaps_mapscore_shared_map_layers_tiled_vector_Tiled2dMapVectorLayerSelectionCallbackInterface_00024CppProxy_native_1didMultiSelectLayerFeatures($_, $_, $_, $_)'

Length of output: 210



Script:

#!/bin/bash
# Use ripgrep to search for the JNI method by name to find its implementation.
rg 'Java_io_openmobilemaps_mapscore_shared_map_layers_tiled_vector_Tiled2dMapVectorLayerSelectionCallbackInterface_00024CppProxy_native_1didMultiSelectLayerFeatures'

Length of output: 609



Script:

#!/bin/bash
# Output the lines around the found method signature to review the method's body.
rg --context 10 'Java_io_openmobilemaps_mapscore_shared_map_layers_tiled_vector_Tiled2dMapVectorLayerSelectionCallbackInterface_00024CppProxy_native_1didMultiSelectLayerFeatures' bridging/android/jni/map/layers/tiled/vector/NativeTiled2dMapVectorLayerSelectionCallbackInterface.cpp

Length of output: 1854

shared/public/RasterVectorLayerDescription.h (1)
  • 147-147: The constructor of RasterVectorLayerDescription has been updated to include default values for multiselect and selfMasked. Ensure that this change does not affect any existing behavior where these parameters were not previously considered.
shared/src/map/layers/text/TextLayer.cpp (1)
  • 193-193: The generateRenderPasses method in TextLayer.cpp has been modified to include a default value for a new parameter in the RenderPassConfig constructor. Verify that this change is consistent with the intended behavior of the RenderPass instances.
Verification successful

---

<!--Monologue:
The new script has successfully found multiple usages of the RenderPassConfig constructor across various files in the codebase. All instances found have the second parameter explicitly set to 'false', which suggests that the default value being added to the constructor should be 'false' to maintain consistency with the current explicit usage. The change in the `TextLayer.cpp` file is consistent with these findings, as the second parameter is set to 'false' there as well. This indicates that the review comment is correct and the change is consistent with the intended behavior of the RenderPass instances.
-->

The `RenderPassConfig` constructor is consistently used with the second parameter set to `false` across various files in the codebase. The change in the `TextLayer.cpp` file aligns with this pattern, confirming that the modification is consistent with the intended behavior of the `RenderPass` instances.



</details>

<details>
<summary>Scripts Executed</summary>

The following scripts were executed for the analysis:



---

Script:
```shell
#!/bin/bash
# Search for usages of the RenderPassConfig constructor to ensure the new default value is consistent with intended behavior.
ast-grep --lang cpp --pattern $'RenderPassConfig($_, $_)'

Length of output: 58



Script:

#!/bin/bash
# Search for all usages of the RenderPassConfig constructor, regardless of the number of arguments.
ast-grep --lang cpp --pattern $'RenderPassConfig($$$)'

Length of output: 2265

android/src/main/cpp/graphics/objects/Quad2dOpenGl.cpp (1)
  • 196-210: The code changes introduce new logic for handling stencil masking based on the isMasked and renderPass.isPassMasked conditions. The use of += for stencilMask suggests that the values 128 and 127 are being combined in some cases, which could lead to a value of 255. This is likely intentional, but it's important to ensure that the resulting stencilMask value is within the expected range for the glStencilFunc and glStencilOp functions. The use of GL_INCR for zpass when renderPass.isPassMasked is true indicates that the stencil buffer will be incremented, which is a common operation when building up stencil values. However, it's crucial to verify that the rest of the rendering pipeline is consistent with these changes, especially if other parts of the code rely on specific stencil values.
Verification successful

The verification process has confirmed that the stencil operations in Quad2dOpenGl.cpp are consistent with similar operations throughout the rendering pipeline. The use of stencil values and operations in the provided snippet aligns with the patterns observed in other parts of the codebase, suggesting that the changes are appropriate and within the expected range for the rendering context.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the stencil values used here are consistent with other stencil operations in the rendering pipeline.
rg --type cpp "glStencilFunc" "glStencilOp"

Length of output: 93



Script:

#!/bin/bash
# Correcting the previous script to properly search for occurrences of "glStencilFunc" and "glStencilOp" within C++ files.
rg --type cpp "glStencilFunc|glStencilOp"

Length of output: 2403

android/src/main/cpp/graphics/objects/PolygonPatternGroup2dOpenGl.cpp (1)
  • 144-158: The changes in the render method of PolygonPatternGroup2dOpenGl are similar to those in Quad2dOpenGl.cpp, with the introduction of stencil masking logic. The same considerations apply here regarding the combined value of stencilMask and the use of GL_INCR for zpass. It's important to ensure that these changes are compatible with the rest of the rendering pipeline and that the stencil operations are being used correctly.
Verification successful

The verification process has confirmed that the stencil operations in PolygonPatternGroup2dOpenGl.cpp are consistent with those used in other parts of the rendering pipeline. The use of GL_EQUAL and GL_KEEP, as well as the variable zpass, align with similar operations across different OpenGL objects within the codebase. Therefore, the review comment is consistent with the codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the stencil values used here are consistent with other stencil operations in the rendering pipeline.
rg --type cpp "glStencilFunc" "glStencilOp"

Length of output: 93



Script:

#!/bin/bash
# Correcting the script to properly search for occurrences of glStencilFunc and glStencilOp within C++ files.
rg "glStencilFunc" -t cpp
rg "glStencilOp" -t cpp

Length of output: 2409

shared/src/map/layers/tiled/vector/sublayers/background/Tiled2dMapVectorBackgroundSubLayer.cpp (1)
  • 79-79: The change in the RenderPass constructor call from RenderPassConfig(0) to RenderPassConfig(0, false) introduces a new boolean parameter. This change affects the configuration of the render pass, and it's important to verify that the new parameter aligns with the intended behavior of the render pass throughout the application.
Verification successful

The RenderPassConfig structure has been reviewed, and it includes a boolean parameter named isPassMasked. This parameter is likely used to indicate whether the render pass should consider masking. The usage of RenderPassConfig(0, false) in Tiled2dMapVectorBackgroundSubLayer.cpp sets this parameter to false, which is consistent with other usages throughout the application where masking is not required. There are no comments indicating a different intended behavior for this parameter.

Based on the information provided, the change in the RenderPass constructor call from RenderPassConfig(0) to RenderPassConfig(0, false) in Tiled2dMapVectorBackgroundSubLayer.cpp is verified to be consistent with the intended behavior of the render pass configuration throughout the application.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new boolean parameter in the RenderPass constructor is being used correctly elsewhere in the application.
rg --type cpp "RenderPassConfig" | grep -v "Tiled2dMapVectorBackgroundSubLayer.cpp"

Length of output: 18338



Script:

#!/bin/bash
# Check the definition and any comments for RenderPassConfig to understand the purpose of the new boolean parameter.
rg "struct RenderPassConfig" --type cpp

Length of output: 233



Script:

#!/bin/bash
# Extract the contents of RenderPassConfig.h to review the structure definition and comments.
cat shared/public/RenderPassConfig.h

Length of output: 464

android/src/main/cpp/graphics/objects/Text2dOpenGl.cpp (1)
  • 212-226: The changes in the render method of Text2dOpenGl introduce stencil masking logic that is consistent with the changes observed in the other OpenGL-related files. The same considerations about the stencil mask values and operations apply. It's important to ensure that these stencil operations are consistent with the rest of the rendering pipeline.
Verification successful

The stencil operations in Text2dOpenGl.cpp are consistent with the rest of the rendering pipeline, using GL_EQUAL for the stencil function and GL_KEEP for the stencil operation, with context-specific reference and mask values. The usage of stencil values across different files follows a logical pattern that aligns with the changes observed in Text2dOpenGl.cpp.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the stencil values used here are consistent with other stencil operations in the rendering pipeline.
rg --type cpp "glStencilFunc" "glStencilOp"

Length of output: 93



Script:

#!/bin/bash
# Correcting the previous script to properly search for occurrences of "glStencilFunc" and "glStencilOp" in C++ files.
rg --type cpp "glStencilFunc|glStencilOp"

Length of output: 2403

shared/src/map/layers/line/LineLayer.cpp (1)
  • 188-188: The modification in the generateRenderPasses method to pass an additional argument false to the RenderPassConfig constructor is consistent with the changes observed in Tiled2dMapVectorBackgroundSubLayer.cpp. This change affects the creation of RenderPass objects, and it's important to verify that the new boolean parameter is being used correctly throughout the application.
Verification successful
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new boolean parameter in the RenderPass constructor is being used correctly elsewhere in the application.
rg --type cpp "RenderPassConfig" | grep -v "LineLayer.cpp"

Length of output: 18355



Script:

#!/bin/bash
# Check the RenderPassConfig constructor definition and the struct definition to understand the boolean parameter's purpose.
cat shared/public/RenderPassConfig.h

Length of output: 464



Script:

#!/bin/bash
# Verify that the 'selfMasked' property is being set correctly in the context where it is used.
rg --type cpp "selfMasked"

Length of output: 3729

android/src/main/cpp/graphics/objects/Quad2dInstancedOpenGl.cpp (1)
  • 209-223: The stencil buffer configuration logic has been added to the render method. This logic sets the stencil mask, valid target, and z-pass operation based on the isMasked and renderPass.isPassMasked conditions. Ensure that the values used for stencilMask and validTarget are consistent with the rest of the application's stencil usage to avoid conflicts or unintended behavior.
android/src/main/cpp/graphics/objects/Text2dInstancedOpenGl.cpp (1)
  • 203-217: Similar to the previous file, the stencil buffer configuration logic has been added to the render method. Verify that the stencil mask values and operations are consistent with the application's rendering logic and that there are no conflicts with other parts of the code that use the stencil buffer.
shared/src/map/layers/polygon/PolygonLayer.cpp (1)
  • 253-253: The constructor call for RenderPass within the generateRenderPasses method now includes an additional argument false. This change seems to be related to the handling of the stencil buffer. Confirm that this new argument aligns with the intended behavior of the RenderPass and that it does not inadvertently disable a feature or change behavior elsewhere in the rendering pipeline.
android/src/main/cpp/graphics/objects/Quad2dStretchedInstancedOpenGl.cpp (1)
  • 208-222: The stencil buffer configuration logic has been added to the render method. As with the other files, ensure that the stencil mask values and operations are consistent with the application's rendering logic and that there are no conflicts with other parts of the code that use the stencil buffer.
shared/src/map/layers/tiled/vector/sourcemanagers/Tiled2dMapVectorSourceTileDataManager.cpp (1)
  • 70-73: The pregenerateRenderPasses method now includes a new boolean variable selfMasked in the TileRenderDescription constructor call. This change is consistent with the description provided in the AI-generated summary. The code correctly checks if the layer index is found within selfMaskedLayers to determine the value of selfMasked.

No issues are found with this change, and it appears to be correctly implemented.

shared/src/map/layers/icon/IconLayer.cpp (1)
  • 342-342: The addition of a boolean parameter to the RenderPassConfig constructor call in buildRenderPasses method should be verified to ensure it aligns with the intended use of RenderPassConfig. If this boolean parameter controls a specific behavior, it's important to confirm that the default value of false is appropriate in all cases where buildRenderPasses is called.
shared/src/map/layers/tiled/vector/tiles/polygon/Tiled2dMapVectorPolygonPatternTile.cpp (1)
  • 413-427: The changes to onClickConfirmed method to support multi-select functionality appear to be correct. However, ensure that the multiselect variable is properly defined and accessible within this scope, as it is used to determine the behavior of the feature selection.
shared/public/Tiled2dMapVectorStyleParser.h (3)
  • 39-39: The addition of toBooleanExpression constant string is consistent with the pattern of defining expression types. Ensure that this new expression is integrated and handled correctly throughout the codebase.
  • 213-220: The implementation of toNumberExpression and toBooleanExpression parsing seems correct. It's important to ensure that the ToNumberValue and ToBooleanValue classes are properly defined and handle the conversion as expected.
  • 341-341: The change from ToBoolValue to BooleanValue in the coalesce expression handling should be verified to ensure that the BooleanValue class exists and is intended to replace ToBoolValue in this context.
shared/public/SymbolVectorLayerDescription.h (2)
  • 512-514: The constructor of SymbolVectorLayerDescription now includes a new boolean parameter selfMasked. Ensure that all instantiations of this class throughout the codebase are updated to pass this new parameter.
  • 520-520: The clone method has been updated to include the selfMasked parameter when creating a new instance. Verify that the cloned instances are correctly utilizing this parameter where needed.
Verification successful

The verification process has successfully identified the usage of the clone method in the SymbolVectorLayerDescription.h, PolygonVectorLayerDescription.h, and LineVectorLayerDescription.h files. In each instance, the selfMasked parameter is being passed to the clone method as part of the constructor call for creating a new instance. This confirms that the cloned instances are correctly utilizing the selfMasked parameter where needed.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of the clone method to ensure the new parameter is correctly handled.
ast-grep --lang cpp --pattern $'$_ = $_->clone()'

Length of output: 50



Script:

#!/bin/bash
# Use ripgrep to search for usages of the clone method in the codebase.
rg "->clone\(\)"

Length of output: 423



Script:

#!/bin/bash
# Correct the ripgrep command to properly escape special characters and search for usages of the clone method.
rg "\->clone\(\)"

Length of output: 3697



Script:

#!/bin/bash
# Extract the relevant lines around the clone method calls in the specific files to verify the handling of the selfMasked parameter.
rg -C 3 "\->clone\(\)" shared/public/SymbolVectorLayerDescription.h
rg -C 3 "\->clone\(\)" shared/public/PolygonVectorLayerDescription.h
rg -C 3 "\->clone\(\)" shared/public/LineVectorLayerDescription.h

Length of output: 1633

shared/src/map/layers/tiled/raster/Tiled2dMapRasterLayer.cpp (3)
  • 419-419: The RenderPassConfig constructor now includes a new boolean argument. Confirm that this change is consistent with the intended use of the RenderPassConfig throughout the codebase.
Verification successful

---

The ast-grep search has found multiple instances of `RenderPassConfig` being used with two arguments across various files in the codebase. In all instances, the second argument is a boolean value, which aligns with the change observed in the `Tiled2dMapRasterLayer.cpp` file. This consistency suggests that the new boolean argument is correctly applied throughout the codebase.



</details>

<details>
<summary>Scripts Executed</summary>

The following scripts were executed for the analysis:



---

Script:
```shell
#!/bin/bash
# Search for other usages of RenderPassConfig to ensure the new boolean argument is correctly applied.
ast-grep --lang cpp --pattern $'RenderPassConfig($_, $_)'

Length of output: 58



Script:

#!/bin/bash
# Search for usages of RenderPassConfig with any number of arguments to ensure the new boolean argument is correctly applied.
ast-grep --lang cpp --pattern $'RenderPassConfig($$$)'

Length of output: 2265

* 426-426: Repeat the verification for the `RenderPassConfig` constructor call within the `std::make_shared` to ensure consistency.
Verification successful

The RenderPassConfig constructor is consistently called with two arguments within the std::make_shared<RenderPass> in the Tiled2dMapRasterLayer.cpp file, as confirmed by the search results. The verification is successful.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Duplicate of the previous script, as the same verification applies here.
ast-grep --lang cpp --pattern $'RenderPassConfig($_, $_)'

Length of output: 58



Script:

#!/bin/bash
# Using rg to search for the string 'RenderPassConfig' to find all instances in the codebase.
rg 'RenderPassConfig'

Length of output: 27164

* 431-431: And again, verify the `RenderPassConfig` constructor call within the `std::make_shared` for consistency.
Verification successful

The RenderPassConfig constructor is consistently called with two arguments within the std::make_shared<RenderPass> across the codebase, including in the Tiled2dMapRasterLayer.cpp file. The verification process confirms that the constructor call is consistent.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Duplicate of the previous script, as the same verification applies here.
ast-grep --lang cpp --pattern $'RenderPassConfig($_, $_)'

Length of output: 58



Script:

#!/bin/bash
# Attempting a different approach to find the RenderPassConfig constructor usage.
# This time, we will use ripgrep to search for "RenderPassConfig" within the codebase.
rg 'RenderPassConfig\('

Length of output: 5393

shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp (4)
  • 234-245: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [226-242]

The parseStyleJsonFromString method now includes handling for multiselect and selfMasked metadata properties. Ensure that the handling of these properties is consistent with their intended use throughout the codebase.

  • 312-314: Verify that the layerMultiselect property is being correctly used when creating instances of LineVectorLayerDescription.
Verification successful

The extended context provided by the latest shell script output shows the full constructor call for LineVectorLayerDescription in Tiled2dMapVectorLayerParserHelper.cpp. The last parameter in the constructor call is layerMultiselect, which confirms that the layerMultiselect property is indeed being used when creating instances of LineVectorLayerDescription.

Based on this information, the review comment asking to verify that the layerMultiselect property is being correctly used when creating instances of LineVectorLayerDescription can be considered as verified.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for instantiations of LineVectorLayerDescription to ensure the new property is correctly applied.
ast-grep --lang cpp --pattern $'LineVectorLayerDescription($_, $_, $_, $_, $_, $_, $_, $_, $_, $_)'

Length of output: 100



Script:

#!/bin/bash
# Search for any instantiations of LineVectorLayerDescription to ensure the new property is correctly applied.
ast-grep --lang cpp --pattern $'LineVectorLayerDescription($$$)'

Length of output: 65



Script:

#!/bin/bash
# Use ripgrep to search for the string "LineVectorLayerDescription" to find any usage within the codebase.
rg 'LineVectorLayerDescription'

Length of output: 1988



Script:

#!/bin/bash
# Extract the lines around the instantiation of LineVectorLayerDescription in Tiled2dMapVectorLayerParserHelper.cpp
rg -C 5 'std::make_shared<LineVectorLayerDescription>' shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp

Length of output: 657



Script:

#!/bin/bash
# Extract more lines around the instantiation of LineVectorLayerDescription to see the full constructor call
rg -C 10 'std::make_shared<LineVectorLayerDescription>' shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp

Length of output: 1149

* 373-374: Verify that the `layerSelfMasked` property is being correctly used when creating instances of `SymbolVectorLayerDescription`.
Verification successful

The constructor signature for SymbolVectorLayerDescription has been successfully extracted and includes the selfMasked parameter as the last argument. This matches the context provided in the review comment, which suggests that the layerSelfMasked property should be used in the creation of instances of SymbolVectorLayerDescription.

Given the output from the script, we can confirm that the selfMasked parameter is indeed part of the constructor and should be correctly applied when creating instances of SymbolVectorLayerDescription.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for instantiations of SymbolVectorLayerDescription to ensure the new property is correctly applied.
ast-grep --lang cpp --pattern $'SymbolVectorLayerDescription($_, $_, $_, $_, $_, $_, $_, $_, $_)'

Length of output: 98



Script:

#!/bin/bash
# Search for the SymbolVectorLayerDescription class definition to find the correct constructor signature.
ast-grep --lang cpp --pattern $'class SymbolVectorLayerDescription { $$$ }'

Length of output: 421



Script:

#!/bin/bash
# Broaden the search to find any constructors for SymbolVectorLayerDescription.
ast-grep --lang cpp --pattern $'SymbolVectorLayerDescription($$$)'

Length of output: 67



Script:

#!/bin/bash
# Use ripgrep to search for the SymbolVectorLayerDescription constructor usage.
rg 'SymbolVectorLayerDescription' --cpp

Length of output: 447



Script:

#!/bin/bash
# Correct the ripgrep command to search for the SymbolVectorLayerDescription constructor usage without language-specific flags.
rg 'SymbolVectorLayerDescription'

Length of output: 5400



Script:

#!/bin/bash
# Extract the constructor signature from the SymbolVectorLayerDescription header file.
rg 'SymbolVectorLayerDescription\(.*\)' shared/public/SymbolVectorLayerDescription.h

Length of output: 86



Script:

#!/bin/bash
# Attempt to extract the lines from the SymbolVectorLayerDescription header file that define the constructor.
rg -A 3 'SymbolVectorLayerDescription\(' shared/public/SymbolVectorLayerDescription.h

Length of output: 296



Script:

#!/bin/bash
# Attempt to extract more lines from the SymbolVectorLayerDescription header file to get the full constructor signature.
rg -A 10 'SymbolVectorLayerDescription\(' shared/public/SymbolVectorLayerDescription.h

Length of output: 789

* 393-395: Verify that the `layerMultiselect` and `layerSelfMasked` properties are being correctly used when creating instances of `PolygonVectorLayerDescription`.
Verification successful

The contents of PolygonVectorLayerDescription.h and Tiled2dMapVectorLayerParserHelper.cpp have been successfully retrieved. From the output, we can see the constructor of PolygonVectorLayerDescription in the header file, which includes the parameters multiselect and selfMasked:

PolygonVectorLayerDescription(std::string identifier,
                              std::string source,
                              std::string sourceId,
                              int minZoom,
                              int maxZoom,
                              std::shared_ptr<Value> filter,
                              PolygonVectorStyle style,
                              std::optional<int32_t> renderPassIndex,
                              std::shared_ptr<Value> interactable,
                              bool multiselect,
                              bool selfMasked):
VectorLayerDescription(identifier, source, sourceId, minZoom, maxZoom, filter, renderPassIndex, interactable, multiselect, selfMasked),
style(style) {};

In the Tiled2dMapVectorLayerParserHelper.cpp file, we can see the instantiation of PolygonVectorLayerDescription where the layerMultiselect and layerSelfMasked properties are passed to the constructor:

auto layerDesc = std::make_shared<PolygonVectorLayerDescription>(val["id"],
                                                                 val["source"],
                                                                 val.value("source-layer", ""),
                                                                 val.value("minzoom", 0),
                                                                 val.value("maxzoom", 24),
                                                                 filter,
                                                                 style,
                                                                 renderPassIndex,
                                                                 interactable,
                                                                 layerMultiselect,
                                                                 layerSelfMasked);

This confirms that the layerMultiselect and layerSelfMasked properties are being correctly used when creating instances of PolygonVectorLayerDescription. The review comment has been verified with the actual codebase.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for instantiations of PolygonVectorLayerDescription to ensure the new properties are correctly applied.
ast-grep --lang cpp --pattern $'PolygonVectorLayerDescription($_, $_, $_, $_, $_, $_, $_, $_, $_, $_)'

Length of output: 103



Script:

#!/bin/bash
# Search for any usage of PolygonVectorLayerDescription to ensure we catch all instances, regardless of the number of arguments.
ast-grep --lang cpp --pattern $'PolygonVectorLayerDescription($$$)'

Length of output: 68



Script:

#!/bin/bash
# Use ripgrep to search for the string "PolygonVectorLayerDescription" in the codebase.
rg 'PolygonVectorLayerDescription'

Length of output: 3025



Script:

#!/bin/bash
# Extract the constructor definition from PolygonVectorLayerDescription.h
rg 'PolygonVectorLayerDescription\(.*\)' shared/public/PolygonVectorLayerDescription.h -A 2

# Extract the instantiation line from Tiled2dMapVectorLayerParserHelper.cpp
rg 'std::make_shared<PolygonVectorLayerDescription>\(.*\)' shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp

Length of output: 227



Script:

#!/bin/bash
# Output the contents of PolygonVectorLayerDescription.h
cat shared/public/PolygonVectorLayerDescription.h

# Output the contents of Tiled2dMapVectorLayerParserHelper.cpp
cat shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayerParserHelper.cpp

Length of output: 29921

shared/src/map/layers/tiled/vector/symbol/Tiled2dMapVectorSymbolObject.cpp (1)
  • 886-888: The logic to set hideFromCollision based on the outside flag is correctly implemented. However, it's important to ensure that the setHideFromCollision method handles the state change appropriately and that there are no side effects or race conditions when this state is read or modified elsewhere in the code.
shared/src/map/layers/tiled/vector/Tiled2dMapVectorLayer.cpp (5)
  • 562-567: The collisionManager.syncAccess function call has been updated to include a new parameter persistingPlacement. This parameter is obtained from mapDescription->persistingSymbolPlacement and passed to the collisionDetection method. Ensure that the collisionDetection method is correctly handling this new parameter and that all calls to syncAccess have been updated accordingly.
Verification successful

The collisionDetection method has been updated to include the new persistingPlacement parameter, and the syncAccess function calls have been updated accordingly in the codebase. The verification process is successful.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the collisionDetection method has been updated to handle the new parameter.
ast-grep --lang cpp --pattern $'collisionDetection($_, $_, $_, $_, $_)'
# Verify that all calls to syncAccess have been updated to include the new parameter.
ast-grep --lang cpp --pattern $'syncAccess($$$)'

Length of output: 122



Script:

#!/bin/bash
# Verify that the collisionDetection method exists and has been updated to handle the new parameter.
ast-grep --lang cpp --pattern $'collisionDetection($$$)'

# Verify that the syncAccess function exists and check for calls with the updated parameter list.
ast-grep --lang cpp --pattern $'syncAccess($$$)'

Length of output: 107



Script:

#!/bin/bash
# Use ripgrep to search for the string "collisionDetection" to confirm its existence and usage.
rg 'collisionDetection'

# Use ripgrep to search for the string "syncAccess" to confirm its existence and usage.
rg 'syncAccess'

Length of output: 8490

* 622-622: The `RenderPass` constructor call has been modified to include a new boolean argument `false`. This change is consistent across multiple calls to the `RenderPass` constructor. Ensure that the `RenderPass` class constructor and any other relevant methods are updated to handle this new argument correctly.
Verification successful

---



---

<!--Monologue:
The output from the ripgrep command has provided us with multiple instances where the `RenderPass` constructor is called. Specifically, it shows calls to the constructor with the new boolean argument, as well as the definition of the constructor itself in `shared/src/graphics/RenderPass.cpp`. This confirms that the `RenderPass` constructor has been updated to handle the new boolean argument and that it is being used in the codebase.

Given this information, I can conclude that the review comment has been verified successfully. The `RenderPass` constructor and its calls have been updated to include the new boolean argument as intended.
-->

The `RenderPass` constructor has been successfully updated to include the new boolean argument, and the calls to this constructor throughout the codebase have been adjusted accordingly.



</details>

<details>
<summary>Scripts Executed</summary>

The following scripts were executed for the analysis:



---

Script:
```shell
#!/bin/bash
# Verify that the RenderPass constructor has been updated to handle the new boolean argument.
ast-grep --lang cpp --pattern $'RenderPass($_, $_, $_)'

Length of output: 56



Script:

#!/bin/bash
# Search for any instances of the RenderPass constructor to verify the new argument.
ast-grep --lang cpp --pattern $'RenderPass($$$)'

Length of output: 49



Script:

#!/bin/bash
# Use ripgrep to search for the string "RenderPass" to find the constructor and its usage.
rg 'RenderPass' --cpp

Length of output: 429



Script:

#!/bin/bash
# Correct the ripgrep command to search for the string "RenderPass" in C++ files.
rg 'RenderPass' -tcpp

Length of output: 46195

* 627-629: Another instance of the `RenderPass` constructor call has been modified to include a new boolean argument `false`. This change is consistent with the previous comment and should be verified in the same manner. * 633-633: The `RenderPass` constructor call has been modified to include a new boolean argument `description->selfMasked`. This change is consistent with the previous comments and should be verified in the same manner. * 641-641: Yet another instance of the `RenderPass` constructor call has been modified to include a new boolean argument `false`. This change is consistent with the previous comments and should be verified in the same manner.

Comment on lines +869 to +871
auto check = collisionGrid->addAndCheckCollisionCircles(*boundingCircles);
willCollide = check == 1;
outside = check == 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

The introduction of the check variable to store the result of collisionGrid->addAndCheckCollisionCircles(*boundingCircles) is a good practice as it avoids calling the function multiple times. However, the magic numbers 1 and 2 used to determine the willCollide and outside flags are not self-explanatory. It would be better to use named constants or an enum to improve readability and maintainability.

// Suggested improvement using enum for clarity
enum CollisionResult {
    NoCollision = 0,
    WillCollide = 1,
    Outside = 2
};

// Then use the enum instead of magic numbers
willCollide = check == CollisionResult::WillCollide;
outside = check == CollisionResult::Outside;

Comment on lines +330 to +345
std::vector<VectorLayerFeatureInfo> 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));
}

Copy link
Contributor

Choose a reason for hiding this comment

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

The method onClickConfirmed has been updated to support multi-select functionality. The logic now includes a condition to check if multi-select is enabled and, if so, collects feature information into a vector. If multi-select is not enabled, it falls back to the previous behavior of single feature selection. The method also correctly returns the result of the delegate method didMultiSelectLayerFeatures when multi-select is enabled and features are selected.

However, the multiselect parameter is not declared in the method signature provided in the code snippet. This will cause a compilation error as the variable is undeclared in the scope of the function.

- bool Tiled2dMapVectorPolygonTile::onClickConfirmed(const Vec2F &posScreen) {
+ bool Tiled2dMapVectorPolygonTile::onClickConfirmed(const Vec2F &posScreen, bool multiselect) {

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
std::vector<VectorLayerFeatureInfo> 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));
}
bool Tiled2dMapVectorPolygonTile::onClickConfirmed(const Vec2F &posScreen, bool multiselect) {
std::vector<VectorLayerFeatureInfo> featureInfos;
for (auto const &[polygon, featureContext]: hitDetectionPolygons) {
if (VectorTileGeometryHandler::isPointInTriangulatedPolygon(point, polygon, converter)) {
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));
}
}

Comment on lines +1528 to +1584
class ToBooleanValue: public Value {
const std::shared_ptr<Value> value;

public:
ToBooleanValue(const std::shared_ptr<Value> value): value(value) {}

std::unique_ptr<Value> clone() override {
return std::make_unique<ToBooleanValue>(value->clone());
}

UsedKeysCollection getUsedKeys() const override {
return value->getUsedKeys();
}

ValueVariant evaluate(const EvaluationContext &context) const override {
return std::visit(overloaded {
[](const std::string &val){
return !val.empty();
},
[](double val){
return val != 0.0 && !isnan(val);
},
[](int64_t val){
return val != 0 && !isnan(val);
},
[](bool val){
return val;
},
[](const Color &val){
return true;
},
[](const std::vector<float> &val){
return true;
},
[](const std::vector<std::string> &val){
return true;
},
[](const std::vector<FormattedStringEntry> &val){
return true;
},
[](const std::monostate &val) {
return false;
}
}, value->evaluate(context));
};

bool isEqual(const std::shared_ptr<Value>& other) const override {
if (auto casted = std::dynamic_pointer_cast<ToBooleanValue>(other)) {
// Compare the value member
if (value && casted->value && !value->isEqual(casted->value)) {
return false;
}
return true; // All members are equal
}
return false; // Not the same type or nullptr
}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

The ToBooleanValue class has been added, which includes a method to evaluate a Value object and return a boolean result based on the type of the value. This is a common pattern for type conversion and the implementation seems correct. However, there is a potential issue with the isnan check for integer types on lines 1550-1551, as isnan is not defined for integer types.

- return val != 0 && !isnan(val);
+ return val != 0;

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
class ToBooleanValue: public Value {
const std::shared_ptr<Value> value;
public:
ToBooleanValue(const std::shared_ptr<Value> value): value(value) {}
std::unique_ptr<Value> clone() override {
return std::make_unique<ToBooleanValue>(value->clone());
}
UsedKeysCollection getUsedKeys() const override {
return value->getUsedKeys();
}
ValueVariant evaluate(const EvaluationContext &context) const override {
return std::visit(overloaded {
[](const std::string &val){
return !val.empty();
},
[](double val){
return val != 0.0 && !isnan(val);
},
[](int64_t val){
return val != 0 && !isnan(val);
},
[](bool val){
return val;
},
[](const Color &val){
return true;
},
[](const std::vector<float> &val){
return true;
},
[](const std::vector<std::string> &val){
return true;
},
[](const std::vector<FormattedStringEntry> &val){
return true;
},
[](const std::monostate &val) {
return false;
}
}, value->evaluate(context));
};
bool isEqual(const std::shared_ptr<Value>& other) const override {
if (auto casted = std::dynamic_pointer_cast<ToBooleanValue>(other)) {
// Compare the value member
if (value && casted->value && !value->isEqual(casted->value)) {
return false;
}
return true; // All members are equal
}
return false; // Not the same type or nullptr
}
};
class ToBooleanValue: public Value {
const std::shared_ptr<Value> value;
public:
ToBooleanValue(const std::shared_ptr<Value> value): value(value) {}
std::unique_ptr<Value> clone() override {
return std::make_unique<ToBooleanValue>(value->clone());
}
UsedKeysCollection getUsedKeys() const override {
return value->getUsedKeys();
}
ValueVariant evaluate(const EvaluationContext &context) const override {
return std::visit(overloaded {
[](const std::string &val){
return !val.empty();
},
[](double val){
return val != 0.0 && !isnan(val);
},
[](int64_t val){
return val != 0;
},
[](bool val){
return val;
},
[](const Color &val){
return true;
},
[](const std::vector<float> &val){
return true;
},
[](const std::vector<std::string> &val){
return true;
},
[](const std::vector<FormattedStringEntry> &val){
return true;
},
[](const std::monostate &val) {
return false;
}
}, value->evaluate(context));
};
bool isEqual(const std::shared_ptr<Value>& other) const override {
if (auto casted = std::dynamic_pointer_cast<ToBooleanValue>(other)) {
// Compare the value member
if (value && casted->value && !value->isEqual(casted->value)) {
return false;
}
return true; // All members are equal
}
return false; // Not the same type or nullptr
}
};

The ToBooleanValue class has been added, which includes a method to evaluate a Value object and return a boolean result based on the type of the value. This is a common pattern for type conversion and the implementation seems correct. However, there is a potential issue with the isnan check for integer types on lines 1550-1551, as isnan is not defined for integer types.

- return val != 0 && !isnan(val);
+ return val != 0;

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
class ToBooleanValue: public Value {
const std::shared_ptr<Value> value;
public:
ToBooleanValue(const std::shared_ptr<Value> value): value(value) {}
std::unique_ptr<Value> clone() override {
return std::make_unique<ToBooleanValue>(value->clone());
}
UsedKeysCollection getUsedKeys() const override {
return value->getUsedKeys();
}
ValueVariant evaluate(const EvaluationContext &context) const override {
return std::visit(overloaded {
[](const std::string &val){
return !val.empty();
},
[](double val){
return val != 0.0 && !isnan(val);
},
[](int64_t val){
return val != 0 && !isnan(val);
},
[](bool val){
return val;
},
[](const Color &val){
return true;
},
[](const std::vector<float> &val){
return true;
},
[](const std::vector<std::string> &val){
return true;
},
[](const std::vector<FormattedStringEntry> &val){
return true;
},
[](const std::monostate &val) {
return false;
}
}, value->evaluate(context));
};
bool isEqual(const std::shared_ptr<Value>& other) const override {
if (auto casted = std::dynamic_pointer_cast<ToBooleanValue>(other)) {
// Compare the value member
if (value && casted->value && !value->isEqual(casted->value)) {
return false;
}
return true; // All members are equal
}
return false; // Not the same type or nullptr
}
};
class ToBooleanValue: public Value {
const std::shared_ptr<Value> value;
public:
ToBooleanValue(const std::shared_ptr<Value> value): value(value) {}
std::unique_ptr<Value> clone() override {
return std::make_unique<ToBooleanValue>(value->clone());
}
UsedKeysCollection getUsedKeys() const override {
return value->getUsedKeys();
}
ValueVariant evaluate(const EvaluationContext &context) const override {
return std::visit(overloaded {
[](const std::string &val){
return !val.empty();
},
[](double val){
return val != 0.0 && !isnan(val);
},
[](int64_t val){
return val != 0;
},
[](bool val){
return val;
},
[](const Color &val){
return true;
},
[](const std::vector<float> &val){
return true;
},
[](const std::vector<std::string> &val){
return true;
},
[](const std::vector<FormattedStringEntry> &val){
return true;
},
[](const std::monostate &val) {
return false;
}
}, value->evaluate(context));
};
bool isEqual(const std::shared_ptr<Value>& other) const override {
if (auto casted = std::dynamic_pointer_cast<ToBooleanValue>(other)) {
// Compare the value member
if (value && casted->value && !value->isEqual(casted->value)) {
return false;
}
return true; // All members are equal
}
return false; // Not the same type or nullptr
}
};

Comment on lines +412 to +428
std::vector<VectorLayerFeatureInfo> 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);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The method onClickConfirmed has been updated to support multi-select functionality. The logic now includes a condition to check if multi-select is enabled and, if so, collects feature information into a vector. If multi-select is not enabled, it falls back to the previous behavior of single feature selection. The method also correctly returns the result of the delegate method didMultiSelectLayerFeatures when multi-select is enabled and features are selected.

However, the multiselect parameter is not declared in the method signature provided in the code snippet. This will cause a compilation error as the variable is undeclared in the scope of the function.

- bool Tiled2dMapVectorLineTile::onClickConfirmed(const Vec2F &posScreen) {
+ bool Tiled2dMapVectorLineTile::onClickConfirmed(const Vec2F &posScreen, bool multiselect) {

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
std::vector<VectorLayerFeatureInfo> 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);
}
bool Tiled2dMapVectorLineTile::onClickConfirmed(const Vec2F &posScreen, bool multiselect) {
std::vector<VectorLayerFeatureInfo> 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 (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);
}
}

Comment on lines 1525 to 1602
}
};

class ToBoolValue: public Value {
class ToBooleanValue: public Value {
const std::shared_ptr<Value> value;

public:
ToBooleanValue(const std::shared_ptr<Value> value): value(value) {}

std::unique_ptr<Value> clone() override {
return std::make_unique<ToBooleanValue>(value->clone());
}

UsedKeysCollection getUsedKeys() const override {
return value->getUsedKeys();
}

ValueVariant evaluate(const EvaluationContext &context) const override {
return std::visit(overloaded {
[](const std::string &val){
return !val.empty();
},
[](double val){
return val != 0.0 && !isnan(val);
},
[](int64_t val){
return val != 0 && !isnan(val);
},
[](bool val){
return val;
},
[](const Color &val){
return true;
},
[](const std::vector<float> &val){
return true;
},
[](const std::vector<std::string> &val){
return true;
},
[](const std::vector<FormattedStringEntry> &val){
return true;
},
[](const std::monostate &val) {
return false;
}
}, value->evaluate(context));
};

bool isEqual(const std::shared_ptr<Value>& other) const override {
if (auto casted = std::dynamic_pointer_cast<ToBooleanValue>(other)) {
// Compare the value member
if (value && casted->value && !value->isEqual(casted->value)) {
return false;
}
return true; // All members are equal
}
return false; // Not the same type or nullptr
}
};

class BooleanValue: public Value {
const std::vector<std::shared_ptr<Value>> values;

public:
ToBoolValue(const std::shared_ptr<Value> value): values({ value }) {}
BooleanValue(const std::shared_ptr<Value> value): values({value }) {}

ToBoolValue(const std::vector<std::shared_ptr<Value>> values): values(values) {}
BooleanValue(const std::vector<std::shared_ptr<Value>> values): values(values) {}

std::unique_ptr<Value> clone() override {
std::vector<std::shared_ptr<Value>> clonedValues;
for (const auto &value: values) {
clonedValues.push_back(value->clone());
}
return std::make_unique<ToBoolValue>(clonedValues);
return std::make_unique<BooleanValue>(clonedValues);
}

UsedKeysCollection getUsedKeys() const override {
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1586-1622]

The BooleanValue class has been added, which seems to be designed to evaluate a list of Value objects and return a boolean result. However, the implementation on lines 1590-1622 is incorrect as it always returns false regardless of the evaluated values. This is likely not the intended behavior, and it should be fixed to correctly evaluate the boolean logic based on the values.

- return false;
+ // Correct implementation needed here based on the intended boolean logic

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1586-1622]

The BooleanValue class has been added, which seems to be designed to evaluate a list of Value objects and return a boolean result. However, the implementation on lines 1590-1622 is incorrect as it always returns false regardless of the evaluated values. This is likely not the intended behavior, and it should be fixed to correctly evaluate the boolean logic based on the values.

- return false;
+ // Correct implementation needed here based on the intended boolean logic

Comment on lines +13 to +16
RenderPassConfig(int32_t renderPassIndex_,
bool isPassMasked_)
: renderPassIndex(std::move(renderPassIndex_))
, isPassMasked(std::move(isPassMasked_))
Copy link
Contributor

Choose a reason for hiding this comment

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

The constructor of RenderPassConfig has been updated to initialize the new isPassMasked member. However, using std::move on primitive data types like bool and int32_t is unnecessary and does not provide any performance benefit. It's only useful for objects that manage resources, where moving can avoid expensive deep copies.

- : renderPassIndex(std::move(renderPassIndex_)),
-   isPassMasked(std::move(isPassMasked_))
+ : renderPassIndex(renderPassIndex_),
+   isPassMasked(isPassMasked_)

@@ -105,6 +105,7 @@ class Tiled2dMapVectorLayer
std::vector<std::shared_ptr<::RenderObjectInterface>> renderObjects;
std::shared_ptr<MaskingObjectInterface> maskingObject;
bool isModifyingMask;
bool selfMasked;
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The verification process has identified that the selfMasked variable is indeed used throughout the application. However, there is a lack of both documentation and automated tests concerning this variable, which is a significant concern for ensuring the correctness and maintainability of the feature it represents. It is recommended that documentation and tests be added to address these issues.

Analysis chain

The addition of the selfMasked boolean member variable to the Tiled2dMapVectorLayer class suggests a new feature or behavior related to masking. It's important to ensure that this new variable is integrated correctly into the layer's logic and that any new masking behavior is documented and tested.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the new selfMasked variable is being used correctly throughout the application.
rg --type cpp "selfMasked"

Length of output: 3729



Script:

#!/bin/bash
# Search for comments or documentation updates related to selfMasked
rg --type cpp -C 3 "selfMasked"

# Search for test files that might contain references to selfMasked
rg --type cpp "selfMasked" --glob "*Test.cpp" --glob "*test.cpp"

Length of output: 15055



Script:

#!/bin/bash
# Search for test files without relying on the naming convention to ensure all tests are included
rg --type cpp "selfMasked" --glob "*.*pp"

Length of output: 1971

@maurhofer-ubique maurhofer-ubique deleted the label-optimization branch January 24, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants