Hello,
my goal is to animate real time drone’s path with live stream data (data send every 2s, API REST, to get JSON packet). For now i just able to make points every X seconds on the map (like chain) when i reach coordinates from API request and that point not even have altitude (somehow using only longitude and latitude).
I tried to search examples, but most of them are using completed long CZML file with all coordantes and just simply using load function. I know that each telemetry update can be turned into a CZML packet containing the time and the new sample value for properties like position or orientation. And in that situation need using function process instead load (also cant understand how to use properly). I misunderstand so many small but important things like:
- Do i need append every new packet to old one or its fine to load every CZML file as new one
- How to make my drone drag several seconds that i could get coordinates from API request and then drone can move smoothly from one point to another (use Callback function, ExtrapolationType.HOLD?). I know some things, but i am not able to combine into one code.
- why in Sandcastle $AJAX not working
Essentially i just need some example, which shows where i need to put my live streaming gps coordinates every X seconds from my API request and how to get smoothly moving path from one point to another. Like this: Time-tagged properties for a 3D model
Any suggestion or recommendations are appreciated
I know that my code is garbage, but maybe there will be possible to add something to change situation:
var viewer = new Cesium.Viewer("cesiumContainer");
const api_url = 'https://api.wheretheiss.at/v1/satellites/25544';
const data_type = 'json';
const request_type = 'GET';
let lon;
let lat;
let height;
let czmlnow;
function getData(){
$.ajax({
async: false,
type: request_type,
url: api_url,
datatype: data_type,
success: function(data){
lon = data.longitude;
lat = data.latitude;
height = data.altitude;
}
});
czmlnow = [
{
"id" : "document",
"name" : "CZML Point - Time Dynamic",
"version" : "1.0"
},
{
"id" : "point",
//"availability" : "2012-08-04T16:00:00Z/2012-08-04T16:05:00Z",
"position" : {
"epoch" : "2012-08-04T16:00:00Z",
"cartographicDegrees" : [lon,lat,height]
},
"point" : {
"color" : {
"rgba" : [255, 255, 255, 128]
},
"outlineColor" : {
"rgba" : [255, 0, 0, 128]
},
"outlineWidth" : 2,
"pixelSize" : 10
}
}
];
var dataSourcePromise = Cesium.CzmlDataSource.load(czmlnow); //process not working
viewer.dataSources.add(dataSourcePromise);
//console.log(lat,lon,height)
}
setInterval(getData, 1000);