-
Notifications
You must be signed in to change notification settings - Fork 0
Date filter #60
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
base: main
Are you sure you want to change the base?
Date filter #60
Conversation
- Add DateRange interface for start/end dates and times - Add DateFilterPreset interface for quick filter options - Update StacSearch interface to include datetime field - Add date filter properties to StacMapContextType interface
- Add date filter utility functions for item filtering and STAC search formatting - Add date range validation and preset configurations - Add URL persistence utilities for date range serialization/deserialization - Support for date/time parsing and ISO 8601 formatting
- Add dateRange state and setDateRange function - Add clearDateRange and isDateFilterActive computed property - Integrate date filter state with existing context - Add URL persistence for date range state
- Add useFilteredSearchItems hook for client-side item filtering - Add useFilteredCollections hook for collection temporal filtering - Implement memoized filtering logic for performance - Support filtering based on item datetime and collection temporal extent
- Update stac-search hook to include datetime in STAC API requests - Add date range to query keys for proper cache invalidation - Update stac-geoparquet hook to filter DuckDB queries by datetime - Support server-side filtering for improved performance
- Add DateFilter component with preset options and custom date inputs - Integrate DateFilter into panel search tab - Add visual indicators for active date filters in search results - Support for quick presets and custom date range selection
- Update map to use filtered search items and collections - Add visual indicators for active date filters - Support for filtered GeoJSON layer generation - Maintain map performance with filtered datasets
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.
Awesome, thanks for this! #4 isn't well written (apologies), but there's actually two different types of "date time filtering" we support and that you implement in this PR:
- Filtering of already-loaded items, whether those items are loaded into
searchItems
orvalue
(via an item collection) - Setting the datetime interval on a
search
I think we should separate the two, putting the "filter items already loaded" stuff in a new tab with the standard <LuFilter />
icon. That lets us access the filtering even if the value
doesn't support search, e.g. with item collections.
src/types/stac.ts
Outdated
export interface DateFilterPreset { | ||
id: string; | ||
label: string; | ||
getDateRange: () => DateRange; | ||
} |
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.
Nit: this file has been (so far) just for "stac-y" values ... this feels like it should live in the date-filter component?
Please push back if that's not standard practice for react apps.
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.
agreed, was being lazy. changed
src/utils/date-filter.ts
Outdated
item.properties?.datetime || | ||
item.properties?.start_datetime || | ||
item.properties?.end_datetime; |
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 isn't quite right because we're loosing the "range" part of an item's datetime. I think we'll need something like (pseudocode): ((item.datetime || item.start_datetime) >= effectiveStartDate) || ((item.datetime || item.end_datetime) <= effectiveEndDate)
src/provider/stac-map.tsx
Outdated
// Date filtering properties | ||
dateRange, | ||
setDateRange, | ||
clearDateRange, | ||
isDateFilterActive, |
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.
Curious (not sure one way or the other) if we want to pull this all the way up to the app's state, or keep it in panel
. My instinct is to keep it in panel
, because we'll want to re-set the date range whenever we change value
, because the date range will be bound by (e.g.) a collection's temporal extents or the temporal extents of an item collection's items
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.
unless i'm misunderstanding, this makes me think that dateRange
should be in the app state since it's tied with value
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.
It can be derived from value, but might be different for searching (find me all items in 2025) and filtering (now that I have a search result from the server API, narrow the items in that search result down to June 2025).
i split out client side temporal filtering and added a separate ui for it. not tested across all the various types of inputs fwiw but seems to function decently well. will respect the server-side search temporal boundaries and the collection-level boundaries if those exist scrubber.mov |
Yoooo this is it. I'll take a look at the code tomorrow but the functionality is dank |
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.
Thanks! This is looking good. Some notes as I monkey'd around.
Functionality change requests
When there's no temporal data available, let's disable the tab (since that's what we've been doing w/ the other tabs):
The default state when there's no filter looks a little funny -- not sure the right way to show the sliders, maybe just for the full collection temporal extent?
I think it'd be nice to have the slider on the search page too?
Bugs
- I slid the date slider around a bunch and got a crash with
Too many calls to Location or History APIs within a short timeframe.
- On a reload of http://localhost:5173/stac-map/?href=https%3A%2F%2Fstac.eoapi.dev%2Fcollections%2FMAXAR_yellowstone_flooding22&dateRange=startDate%3D2022-06-15T18%253A27%253A58.000Z%26endDate%3D2022-06-18T18%253A18%253A32.000Z&clientFilter=clientStartDate%3D2022-06-16T06%253A45%253A04.414Z%26clientEndDate%3D2022-06-18T18%253A18%253A32.000Z, I got
In HTML, <button> cannot be a descendant of <button>.
- When searching against http://localhost:5173/stac-map/?href=https%3A%2F%2Fstac.eoapi.dev%2Fcollections%2FMAXAR_yellowstone_flooding22&dateRange=startDate%3D2022-06-15T18%253A27%253A58.000Z%26endDate%3D2022-06-18T18%253A18%253A32.000Z&clientFilter=clientStartDate%3D2022-06-16T06%253A45%253A04.414Z%26clientEndDate%3D2022-06-18T18%253A18%253A32.000Z, I clicked "this year" and got
Uncaught Error: [zag-js/slider] The configured
min,
max,
stepor
minStepsBetweenThumbsvalues are invalid
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.
Looking sharp, just a couple more things 🙇🏼
- Since we only have one element on the search pane, we can remove the accordion:
- Still get a
Uncaught Error: [zag-js/slider] The configured
min,
max,
stepor
minStepsBetweenThumbsvalues are invalid
when I click "this year" for a collection that doesn't have data for this year. - I'm finding the
buttons to be a little buggy if I just spam click them, so maybe just remove for now? IMO the slider gets us a MVP.
- Can we get the temporal scrubber (filter pane) working for http://localhost:5173/stac-map/?href=https%3A%2F%2Fraw.githubusercontent.com%2Fdevelopmentseed%2Flabs-375-stac-geoparquet-backend%2Frefs%2Fheads%2Fmain%2Fdata%2Fnaip.parquet? I think filtering stac-geoparquet could a cool use-case.
|
Reprod for crash (with |
Available PR templates