The form that I see in your documentation can query the database for more data when writing CEL, but is it possible to call an external API? It is also possible to update a dimension to fill in a missing value.
For example, if I want to update a dimension by adding the "alt" value of the "c8y_Position" segment, calling the specific API: https://maps.googleapis.com/maps/api/elevation/json?locations=40.714728,-73.998672
Is it possible to write such a statement:
expression string js:getElevation(lng, lat) [
function request(lng, lat, callback) {
var xobj = new XMLHttpRequest();
xobj.open('GET', 'https://maps.googleapis.com/maps/api/elevation/json?locations=' + lat + ', ' + lng + ', true);
xobj.onreadystatechange = function () {
if (xobj.readyState == 4 && xobj.status == "200") {
callback(xobj.responseText);
}
};
xobj.send(null);
}
request(lng, lat, function (data) {
return data.results.elevation;
});
]
insert into UpdateMeasurement
select
e.id as id,
getElevation(
getNumber(e, "c8y_Position.lng.value"),
getNumber(e, "c8y_Position.lat.value")
) as c8y_Position.alt
from MeasurementCreated e
Is it possible to perform such processing. Do you have more samples or documentation on CEL?
source
share