Hi everybody,
I am quite new to developing web maps with HTML/Javascript and Cesium ION, so sorry if what I ask sounds too easy.
I am trying to define a function that would take an attribute of my CityGML 3D data and color my buildings according to classes defined based on this attribute.
The problem is not all my buildings have this attribute, some of them are missing it. As a result, when I check the type of this attribute I get “number” for those buildings that have the attribute and “object” for those that do not have it (value is “null” in this case). The function that I defined is not working I think exactly because of this, so my thinking was to include a condition to exclude the objects with no attribute. How could I do this?
I have tried a compound condition, but it also does not do anything.
This is what the console returns for the attribute that I am using:
That is what I initially tried:
> function styleByStromBedarf() {
> tileset.style = new Cesium.Cesium3DTileStyle ({
> color: {
> conditions: [
> ["${Strom Gesamtbedarf} >= 200000", "color('purple')"],
> ["${Strom Gesamtbedarf} >= 100000", "color('red')"],
> ["${Strom Gesamtbedarf} >= 50000", "color('cyan')"],
> ["${Strom Gesamtbedarf} < 10000", "color('yellow')"]
> ]}
> });
> }
That would be with the compound condition that also does not work, nothing happens:
function styleByStromBedarf() { tilesetCityGMLPfaff.style = new Cesium.Cesium3DTileStyle ({ show : "${Strom Gesamtbedarf} !== null", color: { conditions: [ ["(${Strom Gesamtbedarf} !== null) && (${Strom Gesamtbedarf} >= 200000)", "color('purple')"], ["(${Strom Gesamtbedarf} !== null) && (${Strom Gesamtbedarf} >= 100000)", "color('red')"], ["(${Strom Gesamtbedarf} !== null) && (${Strom Gesamtbedarf} >= 50000)", "color('cyan')"], ["(${Strom Gesamtbedarf} !== null) && (${Strom Gesamtbedarf} < 10000)", "color('yellow')"] ]} }); }
Many thanks for your ideas.
Regards,