52North / helgoland-toolbox

Collection of tools for a sensor observation based client
https://52north.github.io/helgoland-toolbox/
Other
13 stars 16 forks source link

Incorrect detection of time #157

Closed SpeckiJ closed 1 year ago

SpeckiJ commented 1 year ago

When trying to add an STA datastream with only a single observation helgoland sends the malformed request

<STA>/v1.1/Datastreams(<ID>)Observations?%24filter=phenomenonTime%20eq%20undefined

when querying for first/last value.

This is caused by: https://github.com/52North/helgoland-toolbox/blob/389e5c0be93f16315d158d3d7b6e4ad14af4daad/projects/helgoland/core/src/lib/api-communication/connectors/sta-api-v1-connector/sta-api-v1-connector.ts#L258

This check is designed to check if the timestamp is a duration (two timestamps seperated by slash), but it simply does not do that because of javascript magic.

Example illustrating the issue (we should take the else-branch because we have no slash):

ds = {
    "phenomenonTime": "2099-03-11T17:55:09.000Z"
};

if (ds.phenomenonTime && ds.phenomenonTime.indexOf('/')) {
    console.log("split timestring by slash");
} else {
    console.log("timestring has no slash")
}