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

Get Indexed Layers / Restrict Camera Visible Rect #592

Merged

Conversation

maurhofer-ubique
Copy link
Contributor

@maurhofer-ubique maurhofer-ubique commented Feb 8, 2024

Summary by CodeRabbit

  • New Features
    • Introduced an interface for managing indexed layers, allowing retrieval of layer interfaces and indices.
    • Enhanced map camera functionality with the ability to restrict the visible rectangle, improving map view control.
    • Added methods to retrieve indexed layers, enhancing layer management and accessibility.
  • Refactor
    • Improved position and zoom handling in the map camera, including adjustments based on bounds and zoom factors.
  • Documentation
    • Updated documentation to reflect new functionalities and methods related to indexed layers and map camera enhancements.

Copy link
Contributor

coderabbitai bot commented Feb 8, 2024

Walkthrough

The recent updates introduce new functionalities across the map and camera interfaces, focusing on indexed layers and bounds restrictions. These changes enhance the map's capabilities by allowing better layer management and control over the visible map area. The introduction of IndexedLayerInterface and enhancements in MapCamera2d for bounds restrictions signify a significant improvement in map interaction and layer indexing, making the map more flexible and user-friendly.

Changes

Files Change Summary
.../map/IndexedLayerInterface.kt, .../jni/map/NativeIndexedLayerInterface.cpp, .../jni/map/NativeIndexedLayerInterface.h, .../MCIndexedLayerInterface+Private.h, .../MCIndexedLayerInterface+Private.mm, .../MCIndexedLayerInterface.h, shared/public/IndexedLayerInterface.h, shared/src/map/layers/IndexedLayer.cpp, shared/src/map/layers/IndexedLayer.h Introduced IndexedLayerInterface and its implementations across Android, iOS, and shared codebases for managing indexed layers.
.../map/MapCamera2dInterface.kt, .../jni/map/NativeMapCamera2dInterface.cpp, .../MCMapCamera2dInterface+Private.mm, .../MCMapCamera2dInterface.h, shared/public/MapCamera2dInterface.h, shared/src/map/camera/MapCamera2d.cpp, shared/src/map/camera/MapCamera2d.h Added functionality to restrict bounds for the whole visible rectangle in MapCamera2dInterface and its implementations.
.../map/MapInterface.kt, .../jni/map/NativeMapInterface.cpp, .../MCMapInterface+Private.mm, .../MCMapInterface.h, shared/public/MapInterface.h, shared/src/map/MapScene.cpp, shared/src/map/MapScene.h Added methods to retrieve indexed layers in MapInterface and its implementations, enhancing layer management.
djinni/map/core.djinni Updated interface definitions to include new methods for indexed layers and bounds restrictions.

🐰🌟
In the land of code and map,
New layers indexed, a wondrous wrap.
Bounds restricted, a view so fine,
With every update, our maps align.
🌍🔍

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.

@maurhofer-ubique maurhofer-ubique force-pushed the feature/indexed-layers-restrictive-camera-bounds branch from 8586653 to 2f77f6c Compare February 8, 2024 07:21
@maurhofer-ubique maurhofer-ubique force-pushed the feature/indexed-layers-restrictive-camera-bounds branch from 2f77f6c to dbd0a9f Compare February 8, 2024 08:02
@maurhofer-ubique maurhofer-ubique marked this pull request as ready for review February 8, 2024 13:37
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 17a6435 and fbc4644.
Files ignored due to path filters (2)
  • djinni/yaml/indexed_layer.yaml is excluded by: !**/*.yaml
  • djinni/yaml/indexed_layer_interface.yaml is excluded by: !**/*.yaml
Files selected for processing (24)
  • bridging/android/java/io/openmobilemaps/mapscore/shared/map/IndexedLayerInterface.kt (1 hunks)
  • bridging/android/java/io/openmobilemaps/mapscore/shared/map/MapCamera2dInterface.kt (2 hunks)
  • bridging/android/java/io/openmobilemaps/mapscore/shared/map/MapInterface.kt (2 hunks)
  • bridging/android/jni/map/NativeIndexedLayerInterface.cpp (1 hunks)
  • bridging/android/jni/map/NativeIndexedLayerInterface.h (1 hunks)
  • bridging/android/jni/map/NativeMapCamera2dInterface.cpp (1 hunks)
  • bridging/android/jni/map/NativeMapInterface.cpp (2 hunks)
  • bridging/ios/MCIndexedLayerInterface+Private.h (1 hunks)
  • bridging/ios/MCIndexedLayerInterface+Private.mm (1 hunks)
  • bridging/ios/MCIndexedLayerInterface.h (1 hunks)
  • bridging/ios/MCMapCamera2dInterface+Private.mm (1 hunks)
  • bridging/ios/MCMapCamera2dInterface.h (1 hunks)
  • bridging/ios/MCMapInterface+Private.mm (2 hunks)
  • bridging/ios/MCMapInterface.h (2 hunks)
  • djinni/map/core.djinni (3 hunks)
  • shared/public/IndexedLayerInterface.h (1 hunks)
  • shared/public/MapCamera2dInterface.h (1 hunks)
  • shared/public/MapInterface.h (2 hunks)
  • shared/src/map/MapScene.cpp (3 hunks)
  • shared/src/map/MapScene.h (1 hunks)
  • shared/src/map/camera/MapCamera2d.cpp (11 hunks)
  • shared/src/map/camera/MapCamera2d.h (3 hunks)
  • shared/src/map/layers/IndexedLayer.cpp (1 hunks)
  • shared/src/map/layers/IndexedLayer.h (1 hunks)
Files skipped from review due to trivial changes (3)
  • bridging/ios/MCIndexedLayerInterface+Private.h
  • bridging/ios/MCIndexedLayerInterface.h
  • shared/public/IndexedLayerInterface.h
Additional comments: 37
shared/src/map/layers/IndexedLayer.h (1)
  • 1-26: LGTM!
shared/src/map/layers/IndexedLayer.cpp (1)
  • 1-22: LGTM!
bridging/android/java/io/openmobilemaps/mapscore/shared/map/IndexedLayerInterface.kt (1)
  • 1-41: LGTM!
bridging/android/jni/map/NativeIndexedLayerInterface.h (1)
  • 1-47: LGTM!
bridging/ios/MCMapCamera2dInterface.h (1)
  • 95-95: LGTM!
shared/public/MapCamera2dInterface.h (1)
  • 88-88: LGTM!
bridging/android/jni/map/NativeIndexedLayerInterface.cpp (1)
  • 1-59: LGTM!
bridging/ios/MCMapInterface.h (1)
  • 59-59: LGTM!
bridging/ios/MCIndexedLayerInterface+Private.mm (1)
  • 1-102: LGTM!
shared/src/map/MapScene.h (1)
  • 50-50: LGTM!
shared/public/MapInterface.h (1)
  • 59-59: LGTM!
bridging/ios/MCMapInterface+Private.mm (1)
  • 155-160: LGTM!
djinni/map/core.djinni (3)
  • 42-42: LGTM!
  • 71-74: LGTM!
  • 170-170: LGTM!
shared/src/map/camera/MapCamera2d.h (3)
  • 134-134: LGTM!
  • 183-183: LGTM!
  • 223-223: LGTM!
bridging/ios/MCMapCamera2dInterface+Private.mm (1)
  • 276-280: LGTM!
bridging/android/java/io/openmobilemaps/mapscore/shared/map/MapInterface.kt (2)
  • 43-44: LGTM!
  • 167-172: LGTM!
bridging/android/jni/map/NativeMapInterface.cpp (2)
  • 9-9: LGTM!
  • 163-171: LGTM!
shared/src/map/MapScene.cpp (1)
  • 98-105: LGTM!
bridging/android/java/io/openmobilemaps/mapscore/shared/map/MapCamera2dInterface.kt (2)
  • 81-82: The addition of setBoundsRestrictWholeVisibleRect aligns with the PR objectives to enhance camera control functionalities by allowing the restriction of the camera's visible rectangle. Ensure corresponding implementations handle this new abstract method appropriately.
  • 300-305: The implementation of setBoundsRestrictWholeVisibleRect in the CppProxy class correctly asserts object validity before calling the native method. This ensures the method is not called on a destroyed object, aligning with the error handling pattern used throughout the class.
bridging/android/jni/map/NativeMapCamera2dInterface.cpp (1)
  • 317-323: The addition of native_setBoundsRestrictWholeVisibleRect correctly implements the JNI bridge for the newly added setBoundsRestrictWholeVisibleRect method in the Kotlin interface. The use of ::djinni::Bool::toCpp for converting the JNI boolean parameter to C++ is consistent with the rest of the file.
shared/src/map/camera/MapCamera2d.cpp (10)
  • 76-82: > 📝 NOTE

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

The use of structured bindings for positionMapSystem and adjustedZoom from getBoundsCorrectedCoords is a good practice for readability and maintainability. However, ensure that all calls to setZoom within the class now correctly use adjustedZoom to maintain consistency.

  • 111-117: > 📝 NOTE

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

Similar to the previous comment, the structured bindings usage here is consistent and improves code clarity. It's important to verify that the animation logic correctly handles the adjusted position and zoom, especially in the completion handlers where the final state is set.

  • 263-269: The adjustment of coordAnimation and zoomAnimation end values based on padding corrections is a critical update for ensuring animations reflect the actual visible area considering padding. This change enhances the responsiveness and accuracy of camera movements. Ensure that similar logic is applied consistently wherever animations are used.
  • 279-285: This segment mirrors the adjustments made for setPaddingLeft, applied to setPaddingRight. Consistency in handling padding adjustments for all sides is crucial for maintaining a uniform user experience. Verify that padding values are validated to prevent negative or excessively large values that could distort the camera view.
  • 295-301: The adjustments for setPaddingTop follow the same pattern as for other padding setters, ensuring that the camera's view is correctly adjusted for padding at the top. Consistency in handling across different padding directions is maintained. Again, validate padding inputs.
  • 311-317: Adjustments in setPaddingBottom are consistent with the handling of other padding directions. This ensures that the camera's view accounts for bottom padding correctly. It's important to maintain this consistency across all padding setters for a coherent user experience.
  • 821-823: The call to getBoundsCorrectedCoords within setBounds ensures that when the map bounds are updated, the camera's center position and zoom are also adjusted accordingly to remain within the new bounds. This is crucial for preventing the camera from displaying areas outside the defined map bounds.
  • 843-893: The getBoundsCorrectedCoords method's implementation to handle both scenarios of config.boundsRestrictWholeVisibleRect being true or false is comprehensive. However, ensure that the calculations for targetScaleDiffFactorX and targetScaleDiffFactorY correctly account for the visible area's aspect ratio to prevent distortion. Additionally, verify that the adjustments made to newPosition and newZoom are accurate and maintain the intended view within bounds.
  • 927-929: The call to getBoundsCorrectedCoords within clampCenterToPaddingCorrectedBounds ensures that any adjustments to the camera's position or zoom factor due to changes in padding or bounds are correctly applied. This method's invocation in various setters helps maintain the camera's view within the desired constraints.
  • 937-940: The addition of setBoundsRestrictWholeVisibleRect allows for dynamic toggling of how bounds restrictions are applied to the visible rectangle. This flexibility is beneficial for different mapping scenarios. Ensure that this setting is correctly applied across all relevant camera adjustments to maintain consistent behavior.

@zimmermannubique zimmermannubique self-requested a review February 8, 2024 13:44
@zimmermannubique zimmermannubique merged commit 5ef6af7 into develop Feb 8, 2024
1 of 2 checks passed
@zimmermannubique zimmermannubique deleted the feature/indexed-layers-restrictive-camera-bounds branch February 8, 2024 13:45
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.

2 participants