1. A concise explanation of the problem you're experiencing.
I have a json file which I need to load using Cesium.GeoJsonDataSource.load, add the dataSource to viewer, and visualize features with custom styling.
I have managed to do this with simpler json files containing only one type of features e.g. only MultiLineStrings, only Polygons or only Points.
Now I have json which contains both Point and MultiLineStrings.
My question is, is it possible to load this kind of json file, and if it is then how to do it? Can I somwhow adjust the json file structure to fit the function requirements? Or there is no other way but to separate the file into multiple files according to feature type (which actually is not an option for me)?
See the code comments below.
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
json file (actually much larger than this):
[
{
"name":"Building",
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"geometry":{
"type":"Point",
"coordinates":[
15.947065173349179,
45.80343302400814
]
},
"properties":{
...
}
}
]
},
{
"name":"Floor",
"type":"FeatureCollection",
"features":[
{
"type":"Feature",
"geometry":{
"type":"MultiLineString",
"coordinates":[
[
[
15.947320004827413,
45.77868733628231,
0
],
[
15.990385463305135,
45.778893374452025,
0
]
],
[
[
15.990385463305135,
45.778893374452025,
0
],
[
15.990385463305135,
45.778893374452025,
5
]
],
[
[
15.947320004827413,
45.77868733628231,
5
],
[
15.990385463305135,
45.778893374452025,
5
]
]
]
},
"properties":{
...
}
},
{
"type":"Feature",
"geometry":{
"type":"MultiLineString",
"coordinates":[
[
[
15.947320303103405,
45.77868492920056,
-5
],
[
15.990385759730152,
45.77889096725009,
-5
]
],
[
[
15.990385759730152,
45.77889096725009,
-5
],
[
15.990385759730152,
45.77889096725009,
0
]
],
[
[
15.947320303103405,
45.77868492920056,
0
],
[
15.990385759730152,
45.77889096725009,
0
]
]
]
},
"properties":{
...
}
}
]
}
]
Code:
var promise = Cesium.GeoJsonDataSource.load('MY.json');
console.log('is this ok? ' + promise); // [object Object] *** Yes, it is.
promise.then(function(dataSource) { // I guess the error occurs here
console.log('does this work?'); // because this line doesn't print anything
viewer.dataSources.add(dataSource);
var entities = dataSource.entities.values;
It throws error:
t {name: "RuntimeError", message: "Unsupported GeoJSON object type: undefined", stack: "Error↵ at new t (http://127.0.0.1:50145/Cesium/…http://127.0.0.1:50145/Cesium/Cesium.js:484:28359"}
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I have building centroid georeferenced, floors inside the building, rooms and objects in rooms. I have to make 3D visualization by extruding the footprints.
I have experience with this kind of task, I've done it already (
http://www2.geof.unizg.hr/~pmalec/App_Zagreb3DGIS/index.html )
But now I have more complex json file which contains all kinds of feature types together.
The ultimate goal is to enable the user to import their json file, click on building centroid which triggers the 3D visualization of building and objects inside. That's why I need the features to be all in one file.
Also, I know this can be done with 3DTiles, but for now json is requested.
4. The Cesium version you're using, your operating system and browser.
Cesium 1.39
Win7 64bit
Chrome 64.0.3282.186