Ok… for refresh interval my map crashes over time.
Has anyone experienced this?
All examples I see with things moving are the CZML file has all the coordinates built into the czml file.
Ex… Vehicle.czml.
Are there any examples that update the coordinates periodically and displayed on the map ?
I am also display a track history file which can be large (has all the points of a track from the beginning of the start scenario) and
The performance on the map is not very good.
Any help with this would greatly be appreciated.
Thank you
Hi there,
The Cesium Entity system is designed to handle problems just like this, where you want to specify how a property changes over time. I don’t know exactly what your situation is, but you might consider reading in your CZML files using the CZML DataSource: https://cesiumjs.org/Cesium/Build/Documentation/CzmlDataSource.html
This will allow you to access all your CZML objects as entities. Entities provide a robust way of specifying an object’s properties at specific times. Here are some Sandcastle examples you might find useful.
Hope that helps!
Hi Rachel,
Thanks for your response… I understand about the Entity … but… I am looking using CZML streaming now….
In a nut shell… I have a separate application that is updating a file in a director
On the same machine from a web browser that is has a Cesium map plugged in… a java script reads this file and displays
The lat/long of multiple tracks. The position gets updated over time. I used google map network links I am trying to port over.
I have used the browser interval to read the file and display but technique has major performance issues and will eventuall
Crash the Cesium Map.
I have looked at the Sandcastle examples but none of them show anything moving over time based on and updated CZML file.
In other works for example the CZML file will one have on position entry for each track… I may have 1-50 tracks in this file that need to be displayed
On the map… This position entry will get updated over time for each track and displayed again on the map.
So need something that periodically reads this CZML file and displays all the tracks without cause performance issues and crashes.
Does this make sense ?
Thanks,
Carlo
On Behalf Of Rachel Hwang
Hi Carlo,
Reloading your CZML should work fine – can you provide a code example of how you’re reloading? Maybe we can spot a bug.
Best,
Hi Rachel,
Here is a basic code snippet.
I will find out if I can give you a copy of the .kml files in question.
Let me know if this is not clear
Thanks,
Carlo
var nIntervId;
var ge;
var viewer;
nIntervId = setInterval(updateTracks,5000); **** This is the autorefresh that will eventually crash the map.
viewer = new Cesium.Viewer(‘geContainer’,
{ timeline: false,
animation: false
});
ge = new Cesium.KmlDataSource();
function updateTracks()
{
var options = {
camera : viewer.scene.camera,
canvas : viewer.scene.canvas
};
kmlUrl = 'google_earth/active/' + "localTracks" + '.kml';
**** THIS IS A DIRECTORY ON THE LINUX MACHINE>>> THIS FILE GETS UPDATED PERIODICALLY WITH NEW LOCATIONS>
viewer.dataSources.add(ge.load(kmlUrl,options))
.then( function (dataSource) {
viewer.flyTo(dataSource.entities);
}
In your code snippet, you are adding the same KmlDataSource instance to viewer.dataSources over and over every time updateTracks is called. You should only add the data source once.
Ok… how would I change this code then so I read the file and display on the map at each interval with the new lat/long ?
Thanks,
C.
On Behalf Of Scott Hunter
I have an if around fly to view so it only flys to view at startup
On Behalf Of Scott Hunter
I add the instance once now and then read the new file and load the new kml file.
That seems to work now.
The question I have can I keep the old point when the load is done. So if the position changes I want to
Have the old position still shown on the map so it shows a track history with KML ??
It appears I can do it with CZML…
Is there an way to do this with KML… The KmlDataSource does not have a process function according to the docs.
Thanks,
Carlo
load(czml, options) → Promise.<CzmlDataSource>
DataSources/CzmlDataSource.js
2139
Loads the provided url or CZML object, replacing any existing data.
process(czml, options) → Promise.<CzmlDataSource>
DataSources/CzmlDataSource.js
2127
Processes the provided url or CZML object without clearing any existing data.
viewer = new Cesium.Viewer(‘geContainer’,
{ timeline: false,
animation: false
});
ge = new Cesium.KmlDataSource();
kmlUrl = ‘google_earth/active/’ + “localTracks” + ‘.kml’;
if (firstTimeFlyToView){
viewer.dataSources.add(ge.load(kmlUrl,options))
.then( function (dataSource) {
viewer.flyTo(dataSource.entities);
});
firstTimeFlyToView = 0;
}
else {
ge.load(kmlUrl,options);
}
On Behalf Of Scott Hunter
Hi Carlo,
Unfortunately, KML wasn’t really designed to work this way – the specification doesn’t allow for it. However, you can keep the old data around just by creating a new KMLDataSource instance each time you load.
Hope that helps,
Thanks Rachel,
That works fine… is there a way after a few minutes to start removing the old sources ?
We only want to keep the last two minutes’ worth of data on the map.
Thank you.
Hi Carlo,
Some of this thread (on implementing entity timeout), is applicable for DataSources too: https://groups.google.com/d/msg/cesium-dev/PzqinNJ51cM/olsNLmSQAAAJ
In short, we don’t have native support for a dataSource timeout right now, however you can use the show property of a DataSource, set it to an TimeIntervalCollection (computed at time of load, setting show to false after 2 minutes), then check periodically to see whether show’s value has changed, then remove a timed out data source when appropriate.
Here’s the docs for DataSource: http://cesiumjs.org/Cesium/Build/Documentation/DataSource.html?classFilter=data
And a TimeIntervalCollectionProperty: http://cesiumjs.org/Cesium/Build/Documentation/TimeIntervalCollectionProperty.html
Hope that helps!
Hi Rachel,
One other thing… not sure if you have any insight on this but after a while browser will crash
Saying ran out of memory when I add datasources for a while. I am updating the map display every second.
If you have any insight on this I would appreciate. I will try your suggestions as well.
Thank you
Carlo
Hi Rachel,
Ok I built a parser that reads in a .kml file and stores it to a .czml file.
I am now running with .czml files…
I have a Chrome browser running and and a IE browser running.
I eventually get a crash on the IE browser but the chrome one is still running for now… (both crash in time with .kml processing for some reason)
Can anyone tell me the cause of this error on IE ? I will try firefox next… Any suggestions or recommended settings on the browsers ?
Thank You
Carlo
Hi Rachel,
Al browsers over time will crash and run out of memory.
Not sure if there is a bug or what is going on. But I can not keep it up that long with the examples I sent you.
Carlo
Hi Carlo,
Can you share your loading code? That will make it easier for us to help you.
Best,
Hi Rachel,
Same code in this discussion. Same happens for both kml and czml.
This code run every second to read in a new file with updated tracks and position.
Browsers will crash within an hour or less. I even tried loading overtime as well.
I tried to create the instance once add…then load the subsequent call…or created the instance every call.
Does not matter … will crash over time.
Let me know what you think. You can tell over time that the browsers seems to slow down as well.
Thanks,
Carlo
ge = new Cesium.KmlDataSource();
kmlUrl = 'google_earth/active/' + "localTracks" + '.kml';
if (firstTimeFlyToView){
viewer.dataSources.add(ge.load(kmlUrl,options))
.then( function (dataSource) {
viewer.flyTo(dataSource.entities);
});
firstTimeFlyToView = 0;
}
else {
ge.load(kmlUrl,options);
}
Hi Carlo,
Our apologies, but w’re having some trouble reproducing your issue. Can you provide a complete code example, perhaps as a Sandcastle example? (You can paste in your code, then save it as a gist by clicking the “Share” button at the top. Just paste the link here.) http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Hello%20World.html&label=Showcases
We’d love to help, but we have to reproduce your problem first.
Best,
Hi Rachel,
Yes… That is what i was planning on doing. I will try to have a simple example to reproduce the problem
in the next day or so.
Will let you know if I can reproduce it with a sandcastle or something similar.
Thank You
Carlo