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

feat: query with geo bounding box #148

Merged

Conversation

ruanyl
Copy link
Member

@ruanyl ruanyl commented Dec 29, 2022

What's changed:

  1. When the map application is opened(initial load), it will query data with the current map bounds
  2. When user zoom in/out, move the map, resize the window, etc. New queries will be fired with the updated bounding box and then update the map accordingly.

Bug fixes:

  • fixed wrong maplibre instance passed to addTooltip() function which results in a runtime error
  • fixed empty onHover popup rendered on layer which has tooltip disabled

Signed-off-by: Yulong Ruan [email protected]

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.

@ruanyl ruanyl requested a review from a team December 29, 2022 08:17
@VijayanB
Copy link
Member

VijayanB commented Dec 29, 2022

@ruanyl Looking really good. Thanks for making the changes. Two comments.

Can we add check box (instead of switch) inside Filters section like below to decide whether to apply this filter or not?
We also enable this checkbox only if selected field type is geo_point. WDYT?
Screen Shot 2022-12-29 at 3 48 57 PM

I still see tooltip hover when it is disabled.
Screen Shot 2022-12-29 at 3 37 29 PM

@ruanyl
Copy link
Member Author

ruanyl commented Dec 30, 2022

Hi @VijayanB, thanks for the comments!

  1. For adding the a checkbox to let user control how the map data should be loaded seems to me that we're exposing to many implementation details to the end user.

From the end user's point of view, when they are viewing the map, they may not interested in how the data is loaded and adding this checkbox may confuse the user. But of course, this is just my two cents.

  1. For the empty popup, nice catch! Now I'm able to reproduce it when I disabled the tooltip but not refresh the page. And I investigated the issue, I think the reason is mouseenter event listener added by addTooltip function is not unsubscribed(map.off()) when layer config changed(tooltip config). The empty popup is actually from the old mouseenter event listener.

To fix the issue, we would need to unsubscribe the previous event listener whenever adding the new event listener when layer config changed, we do this for click popup in map_container.tsx.

It seems it's not a trivial task to refactor this part, I'd suggest to fix it in a separate task.

@VijayanB
Copy link
Member

Hi @VijayanB, thanks for the comments!

  1. For adding the a checkbox to let user control how the map data should be loaded seems to me that we're exposing to many implementation details to the end user.

From the end user's point of view, when they are viewing the map, they may not interested in how the data is loaded and adding this checkbox may confuse the user. But of course, this is just my two cents.

Totally understand. However, adding filter implicitly (without an option to disable ) might confuse users too. This option was already available in Coordinate map, so i assume our users are aware of that.
One use case i could think of is, let's say if i want to view top 100 documents ( in an index irrespective of which part of map i am looking at ) i won't be able to do it unless i am at higher zoom level.

  1. For the empty popup, nice catch! Now I'm able to reproduce it when I disabled the tooltip but not refresh the page. And I investigated the issue, I think the reason is mouseenter event listener added by addTooltip function is not unsubscribed(map.off()) when layer config changed(tooltip config). The empty popup is actually from the old mouseenter event listener.

To fix the issue, we would need to unsubscribe the previous event listener whenever adding the new event listener when layer config changed, we do this for click popup in map_container.tsx.

It seems it's not a trivial task to refactor this part, I'd suggest to fix it in a separate task.

Agree. Let's do it in separate task like your suggestion.

@ruanyl
Copy link
Member Author

ruanyl commented Dec 30, 2022

@VijayanB Aha, you're right, thanks for the context, that makes sense to me 👍

@VijayanB
Copy link
Member

@ruanyl Even when i haven't enable the option to use geo filters, i see requests are triggered in network tab and these requests for some reason have old time filter ex: i updated my time filter to 15 weeks, but, i see these requests uses old time filter vale ( 15 m) .

@ruanyl
Copy link
Member Author

ruanyl commented Jan 1, 2023

@VijayanB Do you mean the global time filter is not applied? Is it a regression due to this PR?

@VijayanB
Copy link
Member

VijayanB commented Jan 2, 2023

lobal time filter is not

  1. Ideally no new request should be triggered since useGeofilter is false.
  2. When geofilter is true, time filter is not reflected.

Screen Shot 2023-01-01 at 9 45 46 PM

@ruanyl
Copy link
Member Author

ruanyl commented Jan 3, 2023

  1. Ideally no new request should be triggered since useGeofilter is false.
  2. When geofilter is true, time filter is not reflected.

@VijayanB the above issue should have been fixed now

@@ -303,6 +309,16 @@ export const DocumentLayerSource = ({
filters={selectedLayerConfig.source.filters ?? []}
onFiltersUpdated={onFiltersUpdated}
/>
<EuiSpacer />
<EuiFormRow>
<EuiSwitch
Copy link
Member

Choose a reason for hiding this comment

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

I found out that switch is preferred if an action is performed immediately. In this case, the update happens after user update layer config. Shall we change this control to checkbox?

Copy link
Member Author

Choose a reason for hiding this comment

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

In the screenshot you shared, it's a switch component, shall we make it consistent?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah. I shared screenshot from existing component ( i thought i mentioned in text), but i received this feedback from UX designer for tooltip. We also changed to checkbox for tooltip too.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's clear, I will update.

@VijayanB
Copy link
Member

VijayanB commented Jan 3, 2023

@ruanyl can you rebase with latest changes? Thanks

@ruanyl ruanyl force-pushed the feat-geo-bounding-box branch 2 times, most recently from 98e942e to 53a48ee Compare January 3, 2023 09:28
const mapBounds = maplibreRef.current.getBounds();
const filterBoundingBox = {
bottom_right: {
lon: adjustLongitudeForSearch(mapBounds.getSouthEast().lng),
Copy link
Member

Choose a reason for hiding this comment

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

Will calling mapBounds.getSouthEast().wrap() solves this problem?

Copy link
Member Author

Choose a reason for hiding this comment

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

@VijayanB that won't work out of the box, calling wrap() will wrap the longitude to range (-180, 180]. In the screenshot, after wrapping, the longitude of left bounding is great than the right bounding, the consequence is OpenSearch won't return results from the expected bounding box. What do people usually do to tackle this issue in a map application?

image

image

Copy link
Member

Choose a reason for hiding this comment

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

i got your point, let's keep your existing solution for bounds crossing date line. I can ask around, but on top of my head i might consider break it into two polygon and add or filter :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

For this did we break the query? I hope no because geobounding box query takes care of these things in the code.

Copy link
Member

@VijayanB VijayanB Jan 7, 2023

Choose a reason for hiding this comment

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

@navneet1v i raised new PR to support corner cases here: #175 . Here, i didn't break it into multiple query, instead wrapped the bounds. However, i had put ceiling to MIN/MAX if at least one complete map is visible. ( hybrid approach ) Let me know whether you see any problem with that approach.

@ruanyl
Copy link
Member Author

ruanyl commented Jan 6, 2023

@junqiu-lei @VijayanB Could you check the PR again?

@VijayanB
Copy link
Member

VijayanB commented Jan 6, 2023

@junqiu-lei @VijayanB Could you check the PR again?

Sure. Since there is a conflict, can you rebase? Sorry for keeping this PR unmerged

- allow user to turn on/off geo bounding box query
  display a switch in map filter config panel to allow user to switch
  on/off geo bounding box query
- search requests will only be sent for layers which have geo
  bounding query enabled
- geo bounding box query will applied global filters

Bug fixes:
- fixed wrong maplibre instance passed to addTooltip() function which
  results in a runtime error
- fixed empty onHover popup rendered on layer which has tooltip disabled

Signed-off-by: Yulong Ruan <[email protected]>
@ruanyl ruanyl force-pushed the feat-geo-bounding-box branch from 687a8bb to 17a3316 Compare January 6, 2023 02:25
@ruanyl
Copy link
Member Author

ruanyl commented Jan 6, 2023

@VijayanB No worry, the PR is updated now :)

junqiu-lei
junqiu-lei previously approved these changes Jan 6, 2023
Copy link
Member

@junqiu-lei junqiu-lei left a comment

Choose a reason for hiding this comment

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

Thanks! The PR Looks good to me.

Signed-off-by: Yulong Ruan <[email protected]>
VijayanB
VijayanB previously approved these changes Jan 6, 2023
@junqiu-lei junqiu-lei merged commit 05b863d into opensearch-project:feature/new-maps Jan 7, 2023
@junqiu-lei junqiu-lei added feature v2.5.0 'Issues and PRs related to version v2.5.0' labels Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature v2.5.0 'Issues and PRs related to version v2.5.0'
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants