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

Update mapbounds logic #175

Merged
merged 1 commit into from
Jan 10, 2023
Merged

Update mapbounds logic #175

merged 1 commit into from
Jan 10, 2023

Conversation

VijayanB
Copy link
Member

@VijayanB VijayanB commented Jan 7, 2023

Description

if more than one copies are visible, use max bounds else wrap bounds to cover international date line.

Signed-off-by: Vijayan Balasubramanian balasvij@amazon.com

Issues Resolved

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

// maps can render more than 1 copies of map at lower zoom level and displays
// one side from 1 copy and other side from other copy at higher zoom level if
// screen crosses internation dateline
function calculateBoundingBoxLngLimit(bounds: LngLatBounds) {
Copy link
Member

Choose a reason for hiding this comment

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

Nice improvement 👍

return lon;
// wrap bounds if only portion of globe is visible
return {
right: bounds.getSouthEast().wrap().lng,
Copy link
Member

Choose a reason for hiding this comment

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

I have a question here, suppose the current map lng bounding is [-170, 181], it is [-170, -179] after wrapping. It will return

{
  right: -179,
  left: -170,
}

The query would be

{
  bottom_right: {
        lon: -179,
        lat: ...,
      },
      top_left: {
        lon: -170,
        lat: ...,
      },
    };

Is this what OpenSearch expecting?

Copy link
Member Author

@VijayanB VijayanB Jan 9, 2023

Choose a reason for hiding this comment

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

@ruanyl Sorry, do you mean will OpenSearch accept similar to following query or not

{
  "DestLocation": {
    "bottom_right": {
      "lon": -176.8581559092076,
      "lat": -38.91257159667413
    },
    "top_left": {
      "lon": -173.24641047835382,
      "lat": 78.53889135857452
    }
  }
}

Copy link
Member

Choose a reason for hiding this comment

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

@VijayanB I mean will OpenSearch return the same results as expected in the bounding box [-170, 181] after the lng been wrapped in such case where bottom_right.lon < top_left .lon?

Copy link
Member Author

Choose a reason for hiding this comment

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

@ruanyl Yes.

junqiu-lei
junqiu-lei previously approved these changes Jan 9, 2023
martin-gaievski
martin-gaievski previously approved these changes Jan 9, 2023
const boundsMinLng = bounds.getNorthWest().lng;
const boundsMaxLng = bounds.getSouthEast().lng;
// if bounds expands more than 360 then, consider complete globe is visible
if (boundsMaxLng - boundsMinLng >= MAX_LONGITUDE - MIN_LONGITUDE) {
Copy link
Member Author

@VijayanB VijayanB Jan 9, 2023

Choose a reason for hiding this comment

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

Yeah. SouthEast will always be greater than NorthWest in Maplibre since we are not wrapping.

if more than one copies are visible, use max bounds
else wrap bounds.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
@codecov-commenter
Copy link

Codecov Report

Merging #175 (1ce75fe) into main (ea102a5) will increase coverage by 0.14%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #175      +/-   ##
==========================================
+ Coverage   87.50%   87.64%   +0.14%     
==========================================
  Files           6        6              
  Lines         176      178       +2     
  Branches       24       24              
==========================================
+ Hits          154      156       +2     
  Misses         16       16              
  Partials        6        6              
Impacted Files Coverage Δ
...Dashboards/plugins/dashboards-maps/common/index.ts 100.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@VijayanB VijayanB merged commit 7eb646e into opensearch-project:main Jan 10, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jan 10, 2023
if more than one copies are visible, use max bounds
else wrap bounds.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
(cherry picked from commit 7eb646e)
@opensearch-trigger-bot
Copy link

The backport to 2.5 failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.5 2.5
# Navigate to the new working tree
cd .worktrees/backport-2.5
# Create a new branch
git switch --create backport/backport-175-to-2.5
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 7eb646e381337fcc9151d0c881b5b0dbe9ca4f14
# Push it to GitHub
git push --set-upstream origin backport/backport-175-to-2.5
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.5

Then, create a pull request where the base branch is 2.5 and the compare/head branch is backport/backport-175-to-2.5.

VijayanB pushed a commit that referenced this pull request Jan 10, 2023
if more than one copies are visible, use max bounds
else wrap bounds.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
VijayanB added a commit to VijayanB/dashboards-maps that referenced this pull request Jan 10, 2023
if more than one copies are visible, use max bounds
else wrap bounds.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
(cherry picked from commit 7eb646e)
VijayanB added a commit that referenced this pull request Jan 10, 2023
if more than one copies are visible, use max bounds
else wrap bounds.

Signed-off-by: Vijayan Balasubramanian <balasvij@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants