FROST-Server icon indicating copy to clipboard operation
FROST-Server copied to clipboard

concatenate observations from multiple datastreams in one query

Open borg1310 opened this issue 1 year ago • 1 comments

hi,

i have a question about querying data from a frost server: Is it possible to concatenate the observations of several data streams based on an attribute? In our database there are derived time series, that are composed of several data streams. The data stream sources of the combined data stream are assigned by a list of IDs or names in the properties. Here is an example:

{
  "@iot.selfLink": "http://localhost:8080/FROST-Server//v1.1/Datastreams(4)",
  "@iot.id": 4,
  "name": "SAK254-Concat",
  "description": "Concatenation of multiple datastreams from different SAK254 sensors at the Rappbode",
  "observationType": "OM_Observation",
  "unitOfMeasurement": {
    "name": "specific absorption coeeficient",
    "symbol": "1/m",
    "definition": "TBD"
  },
  "properties": {
    "sourceRelatedDatastreams": [
      1,
      2,
      3
    ]
  },
  "[email protected]": "http://localhost:8080/FROST-Server//v1.1/Datastreams(4)/ObservedProperty",
  "[email protected]": "http://localhost:8080/FROST-Server//v1.1/Datastreams(4)/Sensor",
  "[email protected]": "http://localhost:8080/FROST-Server//v1.1/Datastreams(4)/Thing",
  "[email protected]": "http://localhost:8080/FROST-Server//v1.1/Datastreams(4)/Observations"
}

Is it possible to create a single query to concatenate and output all observations from the datastream sources contained in the derived datastream? Only the derived datastream should be known.

thanks in advance

best regards,

juergen

borg1310 avatar Sep 04 '24 13:09 borg1310

@borg1310 one option you may use is EntityLinking but it is not available yet for one-to-many relationship. If sourceRelatedDatastreams has always a fixed amount of elements (e.g. always 3 datastreams), a workaround for that would be create one specialized property for each of them.

A more dynamic alternative, that for the time being I would recommend, is to use different HTTP requests:

  • Datastreams(4)?$select=properties/sourceRelatedDatastreams to retrieve the ids.
  • Observations?$filter=Datastream/id in (x,y,z)&$orderBy=phenomenonTime asc where x,y and z are the ids you extracted from the previous query (1,2,3 from your example)

DanielBertocci avatar Oct 01 '24 08:10 DanielBertocci