-
Notifications
You must be signed in to change notification settings - Fork 40
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
collection_temporal_extent produces invalid datetime #275
Comments
We have at least two options that would get extents that are compliant with the STAC spec:
SELECT to_jsonb(array[array[
to_char(min(datetime) AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"'),
to_char(max(datetime) AT TIME ZONE 'UTC', 'YYYY-MM-DD"T"HH24:MI:SS"Z"')
]])
FROM items WHERE collection='pgstac-test-collection'
;
to_jsonb
════════════════════════════════════════════════════
[["2011-07-31T00:00:00Z", "2011-08-25T00:00:00Z"]]
(1 row)
select to_jsonb(array[array[min(datetime), max(datetime)]])
from items where collection='pgstac-test-collection';
to_jsonb
══════════════════════════════════════════════════════════════
[["2011-07-31T00:00:00+00:00", "2011-08-25T00:00:00+00:00"]]
(1 row)
@bitner what do you think? |
yeah, if the to_jsonb casting is giving us the expected format, let's just use that. |
select jsonb_pretty(collection_extent('pgstac-test-collection'));
jsonb_pretty
══════════════════════════════════════════════
{ ↵
"spatial": { ↵
"bbox": [ ↵
[ ↵
-88.00382995605469, ↵
30.496826171875, ↵
-85.24566650390625, ↵
31.003585815429688 ↵
] ↵
] ↵
}, ↵
"temporal": { ↵
"interval": [ ↵
[ ↵
"2011-07-31T00:00:00+00:00",↵
"2011-08-25T00:00:00+00:00" ↵
] ↵
] ↵
} ↵
}
(1 row)
select jsonb_pretty(collection_temporal_extent('pgstac-test-collection'));
jsonb_pretty
═══════════════════════════════════
[ ↵
[ ↵
"2011-07-31 00:00:00+00",↵
"2011-08-25 00:00:00+00" ↵
] ↵
]
(1 row) I don't think the issue here has much (if any) impact, but we can easily make sure that |
The function
collection_temporal_extent
(e.g., used inupdate_collection_extents
) produces datetimes invalid to the STAC specification:pgstac/src/pgstac/sql/003a_items.sql
Lines 337 to 341 in 0c88741
The current function results the following temporal interval:
However, the STAC Collection json schema requires the following pattern:
(\\+00:00|Z)$
https://github.com/radiantearth/stac-spec/blob/master/collection-spec/json-schema/collection.json#L169
A valid timestamp in STAC should be like this:
In my case it works to just remove the timestamp conversion to text (
::text
) from the function above.The text was updated successfully, but these errors were encountered: