Adding Point geometry

Hi All!

I am new to Cesium. I am trying to add a point on the ellipsoid. But, could not trace out the method for Adding it as line polygon/ellipse/circle etc. Is it only the Billboard way.

Thanks in advance

N. Ram kumar

I create a point with the following code:

function pointCesium (position, color) {

var _canvas = document.createElement(‘canvas’);

_canvas.width = 3;

_canvas.height = 3;

var context2D = _canvas.getContext(‘2d’);

context2D.beginPath();

context2D.arc(1.5, 1.5, 1.5, 0, Cesium.Math.TWO_PI, true);

context2D.closePath();

context2D.fillStyle = ‘rgb(255, 255, 255)’;

context2D.fill();

var billboards = new Cesium.BillboardCollection();

var textureAtlas = scene.getContext().createTextureAtlas({

image : _canvas

});

billboards.setTextureAtlas(textureAtlas);

var point = billboards.add({

position : position,

color : color,

imageIndex : 0

});

primitives.add(billboards);

}

It is a billboard, but the circle stays on the surface.

Dear Tamy,

Thank you for the code snippet. Just to gain more understanding I would like to list few queries regarding the same.

1) Why is it that 2D context of the canvas was taken ? What if we were supposed to put points over ellipsoid (globe)?
2) How is the 'position' object defined? can we create with lat/long and height values?
3) In case we would like to put a collection of points as a single feature, how can it be done?

Awaiting your reply.

N. Ram Kumar

Hi Kumar!

You can find some information here: http://www.w3schools.com/tags/ref_canvas.asp and https://developer.mozilla.org/en-US/docs/HTML/Canvas

I changed the code:

function PointsCesium (color) {

var _canvas = document.createElement(‘canvas’);

_canvas.width = 3;

_canvas.height = 3;

var context2D = _canvas.getContext(‘2d’);

context2D.beginPath();

context2D.arc(1.5, 1.5, 1.5, 0, Cesium.Math.TWO_PI, true);

context2D.closePath();

context2D.fillStyle = ‘rgb(255, 255, 255)’;

context2D.fill();

var billboards = new Cesium.BillboardCollection();

var textureAtlas = scene.getContext().createTextureAtlas({

image : _canvas

});

billboards.setTextureAtlas(textureAtlas);

primitives.add(billboards);

Dear Tammy,

Thanks to you once again. I have tested the code snippet placing exactly as you suggested, in sandcastle. Yes i have seen the points placed on globe. Very nice to see them. I request you to excuse me as my queries were with in complete understanding. I found that Cesium really, to me, is a wonderful app. No such other app at least to my knowledge. Great work by all those developers involved and thanks to all of them to make it open source.

In fact I wanted to experiment and play with it, but really I have not found a topic based help. I am just trying out the following (to share with you) and request for your help/advice.

I would like to place certain points/polygons on the globe. Select a satellite of my interest and try to observe the orbits it takes and try to estimate when would those points/polys would be covered by the selected sat (what time, pass etc). I saw one of the demo 'isat' but could not get what i wanted. Also, i have seen in one of the examples showing rectangular pyramid for sensor. But how to get the area it grazed on ground (intersection of the pyramid on ground). I have noticed in several examples that though the satellite is shown orbiting, but the Earth underneath does not rotate simultaneously. Please correct me if i am wrong.

Awaiting your reply.

N. Ram kumar