-
Notifications
You must be signed in to change notification settings - Fork 5
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
User defined dataset bounds #596
Conversation
✅ Deploy Preview for veda-ui ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
As a note for later, we'll have to figure out what happens when we have multiple layers and more than one wants a bbox 😬
]; | ||
|
||
if (checkFitBoundsFromLayer(usableBounds, mapInstance)) { | ||
mapInstance.fitBounds(usableBounds, { padding: FIT_BOUNDS_PADDING }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is the same as what you added in vector-timeseries
.
Might be worth exploring running it at the map level (maybe in mapbox/index.tsx
), or as an alternative provide a hook to reduce repetition.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Abstracted the function to a hook. There should be less repetition now, but I had to get the stac bbox for the vector data as well.
For the record, the most prominent use case for these bounds is when the dataset does cover a larger area (e.g. global), but the Dashboard instance has a thematic / contextual focus on a specific region. For example, the U.S. GHG Center has a focus on the US, but instead of subsetting or limiting the larger/global datasets to that region, they just want to provide an initial / default view centered on the focus region (US / CONUS). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, one concern with the current behavior: Say a user opens the NO2 PT dataset, which is the global NO2 dataset but with bounds
set on Portugal. They then zoom to another region and want to share that view with another user by giving them the URL. The other users will not be able to see the same view - the link to the NO2 PT view will always zoom to Portugal after loading.
For the GHG Center, we will basically set the "initial bounds" to CONUS for all datasets on record (since it is the U.S. GHG Center), but the behavior that you cannot share links that point outside of that area (even if data exists) will probably surprise some users.
As I understand it, you implemented bounds
to really override the bounds coming from STAC in all aspects - also as the source of truth of what the dataset actually covers / should cover.
I think the configured initial/default bounds (initial_bounds
?) should still allow for users to zoom outside of that area and create URLs that point to it. I know we are doing this to prevent users from going to areas where there is no data - but perhaps we can do without these guardrails for the case where a particular area is requested via the URL parameters?
Co-authored-by: Erik Escoffier <[email protected]>
@j08lue That's a very valid point and one that merits some thought. Whenever the map moves the url gets updated with the position, which means that there will almost always be a value in the url. If, right now, we rely on the existence of that value to decide whether to fit the bounds or not, we'll never do it because there's always a value. Possible approachIt could be possible to only set the value on the url if the user moves the map, which means that if the value is there it was by user's intention and so that value should take precedence. Now we have to think about what happens when the user changes between dataset layers. Two options: Option 1:
Option 2:
If all the layers of a dataset have the same bounds, then option 2 gives the user more freedom, given that it is expected that the browsing that they'd be doing, is all in the same area - but I don't think we can assume this. Future (A&E)This is not going to be viable in the new A&E. Since arbitrary datasets can be added we have no control (nor should force) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question For my education, so we can not use the bounding box just to initialize the page? (when mapPosition
value is empty?)
We could, I guess. That would mean removing the other logic that is currently in place and simplifying the behavior - effectively removing the features that guide (force) the users towards the area defined by |
My apologies that my comment was not helpful. It sounds like the bound is not even a bound for the dataset; it is just for the display on the landing page. then, this aligns more with |
@hanbyul-here I agree that these Currently the dataset default bounds, only become available after the dataset has loaded info from STAC, at which point the mapPosition is no longer empty, making in tricky to know which to rely on. |
826db5a
to
d5cb803
Compare
@hanbyul-here @j08lue added an experimental commit with the "option 2" described above. I think this kind of solves for that situation where the map is centered somewhere when the users open the page, but the url can still be shared and datasets switched quickly without loosing context. Check it out in the preview url and let me know what your think |
I think this is a great solution that I would be happy for us to release. We can collect user feedback on the live application. |
Co-authored-by: Jonas <[email protected]>
This PR adds support for dataset layers to define initial bounds for the map. This is useful for datasets that are not global, and for which the STAC bounds are not appropriate.
Bounds are defined using a
bounds
property on the dataset layer. This property should be an array with 4 numbers, representing the minimum and maximum longitude and latitude values, in that order.Example (world bounds)
Note on bounds and dataset layer switching:
The exploration map will always prioritize the position set in the url. This is so that the user can share a link to a specific location. However, upon load the map will check if the position set in the url is within or overlapping the bounds of the dataset layer. If it is not, the map will switch to the dataset layer bounds. This is to avoid showing an empty map when the user shares a link to a location that is not within the dataset layer bounds.
If there are no bounds set in the dataset configuration, the bbox from the STAC catalog will be used if available, otherwise it will default to the world bounds.