A few questions?

I’d like to have some similar controls/functionalities as my
Openlayers map, but I don’t know if Cesium can do those or has plans to do those
or if you have some suggestions for things like :

Add a Map Scale or a Scale Bar;

Edit/update a Polygon: This would mean two kind
of updates:

2.1 Pure
code update, for example: If I add lots of geometry instances to a primitive,
from the Cesium API, now I can get a geometry
of a geometry instance from the primitive, but then I couldn’t get the vertices
(or the positions, holes of a polygon) from the geometry, and not able to update
them. Please see my sample code below:

function
addTest1000Polygons(primitives, ellipsoid){

    var

child = new Cesium.CompositePrimitive();

    primitives.add(child);

    child.show = true;           

    var x =-180;

    var y = -90;

    var delta = 1;        



    var polyInstances = [];  



    for (var i = 0; i < 1000; ++i) {

        if (y>90)

                    {

                                    return;

                    }

                    if (x > 180) {

                                    x = -180;

                                    y = y + 2*delta;

                    }             

                    var positions =

ellipsoid.cartographicArrayToCartesianArray([

                                    Cesium.Cartographic.fromDegrees(x,

y),

                                    Cesium.Cartographic.fromDegrees(x,

y + delta),

                                    Cesium.Cartographic.fromDegrees(x
  • delta, y + delta),

                                      Cesium.Cartographic.fromDegrees(x
    
  • delta, y),

                                      Cesium.Cartographic.fromDegrees(x,
    

y)

                    ]);          



                    var polyInstance = new

Cesium.GeometryInstance({

                                    geometry :

Cesium.PolygonGeometry.fromPositions({

                                                    positions :

positions,

                                                    vertexFormat

: Cesium.PerInstanceColorAppearance.VERTEX_FORMAT

                                    }),

                                    attributes: {

                                                    color:

Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.RED)

                                    }

                    });

                   

                    polyInstances.push(polyInstance);



                    x = x + 2*delta;                                

    }   

   

    // create a nested polygon with holes outline

    var polygonWithHole = new Cesium.PolygonGeometry({    polygonHierarchy : {       

    positions :

ellipsoid.cartographicArrayToCartesianArray([

                                    Cesium.Cartographic.fromDegrees(-109.0,

30.0),

                                    Cesium.Cartographic.fromDegrees(-95.0,

30.0),

                                    Cesium.Cartographic.fromDegrees(-95.0,

40.0),

                                    Cesium.Cartographic.fromDegrees(-109.0,

40.0) ]),

    holes : [{           

                    positions :

ellipsoid.cartographicArrayToCartesianArray([

                                    Cesium.Cartographic.fromDegrees(-107.0,

31.0),

                                    Cesium.Cartographic.fromDegrees(-107.0,

39.0),

                                    Cesium.Cartographic.fromDegrees(-97.0,

39.0),

                                    Cesium.Cartographic.fromDegrees(-97.0,

31.0) ]),

                    holes : [{               

                                    positions :

ellipsoid.cartographicArrayToCartesianArray([

                                                    Cesium.Cartographic.fromDegrees(-105.0,

33.0),

                                                    Cesium.Cartographic.fromDegrees(-99.0,

33.0),

                                                    Cesium.Cartographic.fromDegrees(-99.0,

37.0),

                                                    Cesium.Cartographic.fromDegrees(-105.0,

37.0) ]),

                                    holes : [{                   

                                                    positions :

ellipsoid.cartographicArrayToCartesianArray([

                                                                    Cesium.Cartographic.fromDegrees(-103.0,

34.0),

                                                                    Cesium.Cartographic.fromDegrees(-101.0,

34.0),

                                                                    Cesium.Cartographic.fromDegrees(-101.0,

36.0),

                                                                    Cesium.Cartographic.fromDegrees(-103.0,

36.0) ])

                                                    }]            

                                    }]      

                    }]   

    }});



    var holegeometry = Cesium.PolygonGeometry.createGeometry(polygonWithHole);     

    var holePolygonInstance = new Cesium.GeometryInstance({

                    geometry : holegeometry,

                    attributes: {

                                    color:

Cesium.ColorGeometryInstanceAttribute.fromColor(Cesium.Color.GREEN)

                    }

    });

   

    polyInstances.push(holePolygonInstance);



    child.add(new Cesium.Primitive({

                    geometryInstances : polyInstances,

                    appearance : new

Cesium.PerInstanceColorAppearance({

                                    closed : true,

                                    translucent : true

                    })

    }));         

                                                                   

    var allGeoInstances = child.get(0).geometryInstances;

   

    var len = allGeoInstances.length;

   

    //Just use the last one as an example

    var myLastGeoIns = allGeoInstances[len-1];

    console.log('myLastGeoIns:' + myLastGeoIns);

    var myLastGeo = myLastGeoIns.geometry;

    console.log('myLastGeo' + myLastGeo);

    //myLastGeo is an object of Geometry, ref. : http://cesiumjs.org/Cesium/Build/Documentation/Geometry.html?classFilter=Geometrry&show=all

    //how can I get my parts (exterior and holes) or coordinates

from this object and change them?

    var att = myLastGeo.attributes;

    console.log('attributes:' + att);  

    var pos = att.position;

    console.log('position:' + pos);    

    //I couldn't go further from this point

}

2.2 Edit
a Polygon on the MAP directly, I would like I can edit any polygon in any
primitives displayed to the map by javascript,( for example using the above
code) (not only the ones drawn by the
DrawHelper plugin tool).

Select a polygon and export it to a shape file?

Import a shape file?

About the layer switcher which openlayers
provide, the thing is for Cesium, looks like it doesn’t have the kind of “overlay
layers” concept: the geometries added on
the fly by js to the map are hold into a primitive/composite instead of a “layer
in openlayers”. This is ok, but the Primitive/Composite API looks like
lack of operations support for users easy to manipulate them for things like
layer switcher, and operations depends on a layer. etc.

Map Context menu that openlayers supports? (right-click
and depends on where you click and what underneath – layer, geometry etc), you’ll
get a different context menu?

Sorry I through so many things once to you, but as I’m thinking about these things now and would like to know your suggestions.

Thanks a lot for help.

Cathy

Hi Cathy,

Comments below.

  1. Add a Map Scale or a Scale Bar

Is this for zooming in and out? If so, there was some progress made on a navigation widget, but it’s not ready for use yet.

  1. Edit/update a Polygon

It would be straightforward to add new geometry types to the DrawHelper plugin - and a welcomed contribution. As for modifying a geometry instance in code once it is added to a primitive, as the tutorial explains, Cesium does not keep a copy of the geometry in system memory (only in WebGL) to save memory and geometry is reorganized and batched together for performance for a large number of a static geometries. To implement edit/update, we can use multiple primitives and re-create the geometries as needed. This is surprisingly fast for many uses cases.

  1. Select a polygon and export it to a shape file?

js2shapefile should do the trick.

  1. Import a shape file?

This is planned. In the meantime, Cesium supports GeoJSON, so you could first convert the shapefile to GeoJSON using js-shapefile-to-geojson. Cesium also supports CZML, and there is a shapefile-to-CZML converter written in C#.

  1. the Primitive/Composite API looks like lack of operations support for users easy to manipulate them for things like layer switcher, and operations depends on a layer. etc.

Primitives in Cesium are not layers because they are not tied to the globe’s surface; Cesium supports aircrafts, satellites, etc. Each primitive has a show property to show or hide it if that is useful to you.

  1. Map Context menu that openlayers supports? (right-click and depends on where you click and what underneath – layer, geometry etc), you’ll get a different context menu?

I’m not sure what all you want in the context menu, but b26 is shipping today with a new info-box widget for displaying metadata and zooming to objects.

Patrick

Hi Patrick:

Thanks very much for your reply and information you provided are so valuable!

Please see my more questions/comments below:

Hi Cathy,

Comments below.

  1. Add a Map Scale or a Scale Bar

Is this for zooming in and out? If so, there was some progress made on a navigation widget, but it’s not ready for use yet.

[Cathy] Yes, when map zoom in/out, we’d like to show the current Map Scale on the map. This is pretty common thing on the map.

  1. Edit/update a Polygon

It would be straightforward to add new geometry types to the DrawHelper plugin - and a welcomed contribution. As for modifying a geometry instance in code once it is added to a primitive, as the tutorial explains, Cesium does not keep a copy of the geometry in system memory (only in WebGL) to save memory and geometry is reorganized and batched together for performance for a large number of a static geometries. To implement edit/update, we can use multiple primitives and re-create the geometries as needed. This is surprisingly fast for many uses cases.

[Cathy]: We’d like to have a “draw complex polygon (polygon with holes)” on the DrawHelper plugin. Hopefully this could be added soon if possible. If when we start the development there’s still don’t have one, we’d like to implement it and contribute it back to Cesium.

For the last two statements, do you happen to have some code samples? So it will help me to do some tests first for possiblity and performance evaluation.

Please reference following No.6, you’ll see that editing a polygon in any primitive/layer (draw on map using js on the fly) is quite important for us.

  1. Select a polygon and export it to a shape file?

js2shapefile should do the trick.

[Cathy] Good information. Thx

  1. Import a shape file?

This is planned. In the meantime, Cesium supports GeoJSON, so you could first convert the shapefile to GeoJSON using js-shapefile-to-geojson. Cesium also supports CZML, and there is a shapefile-to-CZML converter written in C#.

[Cathy] Good information. Thx

  1. the Primitive/Composite API looks like lack of operations support for users easy to manipulate them for things like layer switcher, and operations depends on a layer. etc.

Primitives in Cesium are not layers because they are not tied to the globe’s surface; Cesium supports aircrafts, satellites, etc. Each primitive has a show property to show or hide it if that is useful to you.

[Cathy] I think users might still want the Primitive is kind of layers, at least it’s true in our case. It would be helpful if the Primitives have id/name properies, and have methods to get the Primtive by its id/name properties (as the methods in openlayer layers). Currently, you can only get a primitive by index (you’ll need to loop).

  1. Map Context menu that openlayers supports? (right-click and depends on where you click and what underneath – layer, geometry etc), you’ll get a different context menu?

I’m not sure what all you want in the context menu, but b26 is shipping today with a new info-box widget for displaying metadata and zooming to objects.

[Cathy] I’ll play the new info-box later. Here’s a few descriptions as the map context operation menu:

6.1 If you right click on the map, and there’s nothing on the map except the baselayer, the context menu would show and with very general menu items, such as “zoom to full extend”, “center here”, “Import Shape file”, “Search…”, “Clear …” etc.

6.2. If you right click on the map, and underneath the mouse position is a search polygon (in search layer — search primitive in Cesium), the context menu would show and with menu items suitable to the search polygon, such as: “zoom to”, “calculate area”, “edit”, “delete”, “save as order polygon” etc

6.3. If you right click on the map, and underneath the mouse position is an order polygon (in order layer — order primitive in Cesium), the context menu would show and with menu items suitable to the order polygon, such as: “zoom to”, “calculate area”, “edit”, “delete”, “export to shape”, "Save as … etc; Those common polygon operations maybe repeated in the menuitems in different layers (Primities in Cesium) if the layer’s geometry type is polygon.

Comments below.

For the last two statements, do you happen to have some code samples? So it will help me to do some tests first for possiblity and performance evaluation.

I don’t, but it shouldn’t be hard to put something together from the tutorial.

It would be helpful if the Primitives have id/name properies, and have methods to get the Primtive by its id/name properties (as the methods in openlayer layers).

In JavaScript, we can just add properties to objects, so you could just add a name property to each primitive and then override primitive add and remove to also add/remove primitives from a separate object that maps name to primitive.

Patrick

Hi Patrick,

Any update on Navigation Widget improvements as you mentioned earlier.

Thanks,
Gowtham.

Gowtham,

There has not been any recent progress on the navigation widget. We are focused on the entity API and KML at the moment.

Patrick