azavea / franklin

A STAC/OGC API Features Web Service
https://azavea.github.io/franklin/
Apache License 2.0
77 stars 19 forks source link

Item output is missing start_datetime and end_datetime #960

Open aripollak opened 3 years ago

aripollak commented 3 years ago

Describe the bug

If an input STAC item has start_datetime and end_datetime properties, like:

  "properties": {
    "datetime": "2011-01-01T00:00:00Z",
    "description": "BCSD surface water projections hydrologic data",
    "end_datetime": "2064-01-16T00:00:00",
    "start_datetime": "2064-01-16T00:00:00",
    "title": "sresb1.ukmo_hadcm3.1.monthly.swe.2064",
    "units": "mm"
  },

When requesting the item from Franklin, the start/end are missing:

{
  "properties": {
    "units": "mm",
    "datetime": "2011-01-01T00:00:00Z",
    "title": "sresb1.ukmo_hadcm3.1.monthly.swe.2064",
    "description": "BCSD surface water projections hydrologic data"
  }

Expected behavior I think start_datetime and end_datetime should be in the item STAC shown in Franklin.

jisantuc commented 3 years ago

!!!!

That's definitely a bug. We round trip test items with point-in-time datetimes and datetime ranges (generator is here), so this definitely seems like a Franklin problem. Thanks for the report!

jisantuc commented 3 years ago

Oh, nevermind, I see what happened here. The spec says:

Important: Using one of the fields REQUIRES inclusion of the other field as well to enable a user to search STAC records by the provided times. So if you use start_datetime you need to add end_datetime and vice-versa. Both fields are also REQUIRED if the datetime field is set to null. The datetime property in a STAC Item and these fields are not mutually exclusive.

But we decode the incoming JSON to either have a point-in-time datetime or to have a time range (we're using Either when we should be using something like These). I'll fix this upstream in stac4s

aripollak commented 3 years ago

Thanks! Is it now just a matter of updating to the latest stac4s?

jisantuc commented 3 years ago

Yup, I have a PR up to do that but I started failing a test because filtering isn't working quite as expected now 😨 and I haven't had a chance to dig in yet. It's covered as part of #930