Using the Java czml-writer to Develop a Toolbox for MatLab

Over the last few weeks I’ve been working on getting some solid integration between MatLab and Cesium. I’ve been successful in getting sockets opened up with java and between Cesium’s javascripts, so now I can send just a matrix of positions in MatLab and have it appear in Cesium and move around according to the provided data. To accomplish this I had to use a text file as a make-shift configuration for the czml that just had the positions appended to the end of the byte array being sent over a socket.

Moving forward I’d like to begin making use of the czml-writer project to allow for much finer tuned control over the properties of each object. The end goal for my project is to create a toolbox for MatLab that can be used to dynamically show positions recorded from a radar. This is why I need to migrate away from having a static text file because it doesn’t allow any control by a user without them manually manipulating the file, which also requiring them to have knowledge of czml formatting.

I understand in theory how the java part of the czml-writer works, where it isn’t an executable but a package of classes to be called to write parts of a czml file. I think this will be perfect for making simple functions to call the various classes in MatLab because there is such nice integration between java and MatLab. I am just having a hard time understanding the correct way to call everything, and what the outputs will be because the documentation for this library is pretty lacking, and there isn’t much on the forums either. If anyone has some example code or advice from their work I would really appreciate the help, as well as trying to possibly getting some unofficial documentation going on the forums for the java half of the writer.

Best,
Chris

W dniu wtorek, 30 września 2014 14:51:18 UTC+2 użytkownik Chris M. napisał:

Over the last few weeks I've been working on getting some solid integration between MatLab and Cesium. I've been successful in getting sockets opened up with java and between Cesium's javascripts, so now I can send just a matrix of positions in MatLab and have it appear in Cesium and move around according to the provided data. To accomplish this I had to use a text file as a make-shift configuration for the czml that just had the positions appended to the end of the byte array being sent over a socket.

Moving forward I'd like to begin making use of the czml-writer project to allow for much finer tuned control over the properties of each object. The end goal for my project is to create a toolbox for MatLab that can be used to dynamically show positions recorded from a radar. This is why I need to migrate away from having a static text file because it doesn't allow any control by a user without them manually manipulating the file, which also requiring them to have knowledge of czml formatting.

I understand in theory how the java part of the czml-writer works, where it isn't an executable but a package of classes to be called to write parts of a czml file. I think this will be perfect for making simple functions to call the various classes in MatLab because there is such nice integration between java and MatLab. I am just having a hard time understanding the correct way to call everything, and what the outputs will be because the documentation for this library is pretty lacking, and there isn't much on the forums either. If anyone has some example code or advice from their work I would really appreciate the help, as well as trying to possibly getting some unofficial documentation going on the forums for the java half of the writer.

Best,
Chris

Generally API is straight-forward, so you should be able to discover it only by using intelli-sense.
But here is a quick glimpse how it works:

StringWriter w = new StringWriter();
CesiumOutputStream cos = new CesiumOutputStream(w);
cos.setPrettyFormatting(true);
cos.writeStartSequence();
CesiumStreamWriter writer = new CesiumStreamWriter();
// now you start writing your actual objects
PacketCesiumWriter packet = writer.openPacket(cos);
packet.writeId(next.getID());
PositionListCesiumWriter plWriter = packet.openVertexPositionsProperty();
plWriter.writeCartographicDegrees(clist); // write list of cartographic coords
plWriter.close(); // remember to close all open packets
PolylineCesiumWriter polylineWriter = packet.openPolylineProperty();
polylineWriter.writeColorProperty(new Color(255,255,255));
polylineWriter.writeOutlineWidthProperty(1);
polylineWriter.writeWidthProperty(2);
polylineWriter.writeShowProperty(true);
polylineWriter.close();
packet.close();
//repeat

cos.writeEndSequence();

Search for other objects thru packet.openXXXProperty().

W dniu środa, 31 grudnia 2014 09:07:35 UTC+1 użytkownik stepien...@gmail.com napisał:

W dniu wtorek, 30 września 2014 14:51:18 UTC+2 użytkownik Chris M. napisał:
> Over the last few weeks I've been working on getting some solid integration between MatLab and Cesium. I've been successful in getting sockets opened up with java and between Cesium's javascripts, so now I can send just a matrix of positions in MatLab and have it appear in Cesium and move around according to the provided data. To accomplish this I had to use a text file as a make-shift configuration for the czml that just had the positions appended to the end of the byte array being sent over a socket.
>
> Moving forward I'd like to begin making use of the czml-writer project to allow for much finer tuned control over the properties of each object. The end goal for my project is to create a toolbox for MatLab that can be used to dynamically show positions recorded from a radar. This is why I need to migrate away from having a static text file because it doesn't allow any control by a user without them manually manipulating the file, which also requiring them to have knowledge of czml formatting.
>
> I understand in theory how the java part of the czml-writer works, where it isn't an executable but a package of classes to be called to write parts of a czml file. I think this will be perfect for making simple functions to call the various classes in MatLab because there is such nice integration between java and MatLab. I am just having a hard time understanding the correct way to call everything, and what the outputs will be because the documentation for this library is pretty lacking, and there isn't much on the forums either. If anyone has some example code or advice from their work I would really appreciate the help, as well as trying to possibly getting some unofficial documentation going on the forums for the java half of the writer.
>
> Best,
> Chris
Generally API is straight-forward, so you should be able to discover it only by using intelli-sense.
But here is a quick glimpse how it works:

StringWriter w = new StringWriter();
CesiumOutputStream cos = new CesiumOutputStream(w);
cos.setPrettyFormatting(true);
cos.writeStartSequence();
CesiumStreamWriter writer = new CesiumStreamWriter();
// now you start writing your actual objects
PacketCesiumWriter packet = writer.openPacket(cos);
packet.writeId(next.getID());
PositionListCesiumWriter plWriter = packet.openVertexPositionsProperty();
plWriter.writeCartographicDegrees(clist); // write list of cartographic coords
plWriter.close(); // remember to close all open packets
PolylineCesiumWriter polylineWriter = packet.openPolylineProperty();
polylineWriter.writeColorProperty(new Color(255,255,255));
polylineWriter.writeOutlineWidthProperty(1);
polylineWriter.writeWidthProperty(2);
polylineWriter.writeShowProperty(true);
polylineWriter.close();
packet.close();
//repeat

cos.writeEndSequence();

Search for other objects thru packet.openXXXProperty().

Also please take a note its from b26 , so the API might have changed a little bit.

Can you please explain how you used MATLAB to have objects appear on Cesium? I am trying really hard right now to do that, but am completely new to MATLAB and am having trouble getting things like highlighted areas and boxes appear on my offline running Cesium map. If you could please help that would be appreciated

Hi there,

We unfortunately don’t have any example code for doing this since no one on the Cesium team uses Matlab regularly. However perhaps someone else in the community can provide an example. I suspect the best way to do this is to make use of Matlab’s Java or c# interop layers to write out some CZML then load objects into Cesium.

Hope that helps,

  • Rachel