feat(thing): expose phenomenonTime on Thing for STAC and DCAT-AP temporal extent#125
feat(thing): expose phenomenonTime on Thing for STAC and DCAT-AP temporal extent#125Vishmayraj wants to merge 1 commit into
Conversation
|
Hi @Vishmayraj I think this should go into a separate branch/PR, since it looks like a distinct feature ( |
Thanks for the feedback. Just to clarify - these are already separate PRs on independent branches ( |
What this does
Adds
phenomenonTimeas a computed derived field on theThingentity, returning the aggregated temporal extent across all of a Thing's Datastreams in a singleGET /Thingsresponse.{ "@iot.id": 1, "name": "thing_name_1", "observedArea": { "type": "Polygon", "coordinates": ["..."] }, "phenomenonTime": "2020-01-01T11:05:00Z/2020-01-08T11:00:00Z" }Spec note
phenomenonTimeis defined by OGC STA 1.1 onDatastreamandObservation, not onThing. This PR adds it as a deliberate extension at the Thing level, consistent with istSOS4's existing pattern of extending the standard entity model (seeCommitntity).Why this matters
In the STA to DCAT-AP 3.0 mapping,
Thingis best modelled as adcat:DatasetSeriesa device-level grouping container for all its Datastreams. Connectors and harvesters that build a device-level catalog index need the temporal extent of each Thing without having to expand into its Datastreams.Without this field, that requires N+1 requests:
With this field, a single
GET /Thingsgives the full device index including temporal extent in one call. Together with PR #124 (observedAreaon Thing), a connector can now retrieve complete spatial and temporal metadata for all Things in a single request with no follow-up calls.How it works
Unlike
observedArea, no PostgreSQL function existed forphenomenonTimeonThing. This PR adds it from scratch:istsos_schema.sql-> newphenomenonTime(sensorthings."Thing")function that computeststzrange(min(lower(d."phenomenonTime")), max(upper(d."phenomenonTime")), '[]')across all Datastreams of the Thing, returningNULLif none have a time range yetmodels/thing.py-> declaresphenomenon_time = Column("phenomenonTime", TSTZRANGE)on the Thing ORM modelsta2rest.py-> addsphenomenon_timeto Thing and ThingTravelTimeDEFAULT_SELECTThe existing
get_select_attrinvisitors.pyalready handlesTSTZRANGEcolumns by formatting them as ISO 8601 intervals (start/end), identical to how Datastream'sphenomenonTimeis serialized. No additional changes needed.Testing