Not getting the coordinates value of entity geometry

I have GeoJson file with structure like this:

{
  "name" : "Ceste",
  "type" : "FeatureCollection",
  "features" : [
    {
      "type" : "Feature",
      "geometry" : {
        "type" : "LineString",
        "coordinates" : [
          [ 14.784126954837147, 44.751569774747963, 22.852624448807024 ],
          [ 14.784144357046641, 44.751555297588091, 22.802581355622205 ],
          [ 14.78423523289271, 44.751479696440853, 22.073970366184071 ],
          [ 14.784243682367348, 44.75147266716661, 22.044607577579942 ],
          [ 14.784250616330484, 44.751466898672639, 22.010225830034699 ],
          [ 14.784251598317018, 44.751466081739494, 22.003502991291107 ]
        ]
      },
      "properties" : {
        "OBJECTID" : 1,
        "Entity" : "LWPolyline",
        "Layer" : "CESTA",
        "Color" : 2,
        "Linetype" : "CONTINUOUS",
        "Elevation" : 0,
        "LineWt" : 25,
        "RefName" : "",
        "Shape_Leng" : 106.946785933
      }
    }, ...

I can access properties, but can't access geometry values.
I need to get coordinates in order to make polylineVolume to visualize pipeline on terrain.

If I can get entity.properties.Color, why can't I get entity.geometry.coordinates? How can I access coordinates and make polylineVolume from them?

var entities1 = dataSource1.entities.values;
        
        var colorHash = {};
        for (var i = 0; i < entities1.length; i++) {
            var entity = entities1[i];
            entity.name=entity.properties.Layer;
            var name = entity.name;
            var color = colorHash[name];
            if (!color) {
                color = Cesium.Color.fromRandom({
                    alpha : 1.0
                });
                colorHash[name] = color;
            }
            
            console.log("coordinates: " + entity.geometry.coordinates);
            entity.corridor.material = color;
            entity.corridor.outline = false;
        }

* in this code above I'm just trying to print coordinates in console to see if the entity.geometry.coordinates works. When running it shows TypeError: entity.geometry is undefined

Hi Paula,

For a GeoJson linestring, you should be getting either a polyline or a corridor as your output entity (depending on whether or not your entity is clamped to ground). So to read coordinates out, you can access entity.polyline.positions, which will give you an array of Cartesian3 positions. You can then convert those into lat/long using Cartographic.fromCartesian().

See http://cesiumjs.org/Cesium/Build/Documentation/Cartographic.html?classFilter=carto#.fromCartesian

Hope that helps

  • Rachel