/** * Create CSV Download links from STA * @param {*} e STA Thing * @param Date Date onject of latest observation * @param {*} timespan Timespan backwards from now in hours * @returns CSV download STA URL */ function csvDownloadLink(e, dateFrom, timespan) { let csv; if (e.Datastreams[0]) { let h = dateFrom - timespan * 3600000; let filter = "/Observations" + "?$resultFormat=CSV" + "&$filter=during(phenomenonTime," + new Date(h).toISOString() + "/" + dateFrom.toISOString() + ")" + "&$orderBy=phenomenonTime desc" + "&$select=id,resultTime,phenomenonTime,result" + "&$top=10000"; csv = e.Datastreams[0]["@iot.selfLink"] + filter; } return csv; } /** * Create STA URL for last n Observations of Datastream[0] of Thing e * @param {*} STA Thing * @param int Number of last n Observations * @returns URL */ function lastNObs(e, n) { let uri; if (e.Datastreams[0]) { uri = e.Datastreams[0]["@iot.selfLink"] + "/Observations" + "?$orderBy=phenomenonTime desc" + "&$top=" + n; } return uri; } /** * Ceate appended HTML tags for URLs in array. * @param [] dashboards_array * @returns html */ function dashboardURLs(dashboards_array) { let html = ""; dashboards_array.forEach((url, index) => { html += '#' + index + " "; }); return html; } /** * * @param {*} e STA Thing * @param {*} m Leaflet Marker */ function addPopup(e, m) { // Name and @iot.ids let title = e.name; // let thing_iot_id = e["@iot.id"]; let datastream_iot_id = e.Datastreams[0]["@iot.id"]; // let location_iot_id = e.Locations[0]["@iot.id"]; // lsa_id, type, frequency let lsa_id = !!e.properties.lsa_id ? e.properties.lsa_id : "-"; let det_id = !!e.properties.det_id ? e.properties.det_id : "-"; let lsa_type = !!e.properties.aggregation_type ? e.properties.aggregation_type : ""; if (lsa_type === "single_detector") { lsa_type = "Zählschleife"; } else if (lsa_type === "whole_intersection") { lsa_type = "Summe aller Zählschleifen der Lichtsignalanlage " + lsa_id + "."; } let frequency = !!e.properties.frequency ? e.properties.frequency : ""; // Popup html let html = `
ID Lichtsignalanlage | ${lsa_id} |
ID Detektor | ${det_id} |
Detektortype | ${lsa_type} |
Datenfrequenz | ${frequency} |