-
Notifications
You must be signed in to change notification settings - Fork 110
How to tell if search is for single datetime? (Should str_to_interval
return a single value for that?)
#688
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
Comments
According to this, searching with a single datetime should be allowed. |
Yes, a single value is allowed, and then I assume that implies one wants to search for an exact match, right? Then I will create a PR to make On a related note, I noticed that a POST to The POST payload I get from STAC Browser is
So, what if a PR would include:
|
Oh, I now see that the Guess that makes changing POST a bit tedious. Even more: the behavior for a single value ( @property
def start_date(self) -> Optional[dt]:
values = (self.datetime or "").split("/")
if len(values) == 1:
return None
if values[0] == ".." or values[0] == "":
return None
return parse_rfc3339(values[0])
@property
def end_date(self) -> Optional[dt]:
values = (self.datetime or "").split("/")
if len(values) == 1:
return parse_rfc3339(values[0])
if values[1] == ".." or values[1] == "":
return None
return parse_rfc3339(values[1]) |
It can be hard to get an exact match on a datetime I guess. |
So basically querying a single datetime gives you everything before that datetime? I wonder if this is documented in the spec anywhere? |
For POST: yes, if the user's implementation of the abstract For GET, the user's implementation of the abstract For future readers, I'm doing this now in my own code for POST: def post_search(
self, search_request: BaseSearchPostRequest, **kwargs
) -> ItemCollection:
# A `{"datetime": "2012-07-02T01:30:00Z/2012-07-02T13:30:00Z"}`
# will make stac-pydantic leave `datetime` at its original
# string value, and add a `start_date` and `end_date` to
# `search_request`. For `{"datetime": "2012-07-02T01:30:00Z"}`
# the value goes into `end_date`, leaving `start_date` at None.
# So, we need to parse the string value ourselves here.
# See https://github.com/stac-utils/stac-fastapi/issues/688
if search_request.datetime:
search_request.datetime = str_to_interval(search_request.datetime)
return self.get_search(**search_request.model_dump()) That will work for me, if I fix I'll create another issue in stac-pydantic to discuss its handling of |
looking at https://docs.ogc.org/is/17-069r4/17-069r4.html#_parameter_datetime it seem that if |
I'd guess this is a bug, but maybe not, so a question first:
The STAC API - Item Search specs define:
If only a single date+time is provided, I'd guess this implies one searches for an exact match?
Indeed,
DateTimeType
allows for a single value too:All good so far. However, today's
str_to_interval
always returns a tuple. And that function is used as the converter for the search request:So when implementing get_search how would one know if a single date+time was requested, or a range with an open end?
The tests only check intervals, so are not giving me the definitive answer. But I'm guessing this is an oversight?
(Of course I can provide a PR if this is indeed a bug.)
The text was updated successfully, but these errors were encountered: