I would like to create a heat map based on the following demo
https://github.com/autodesk-platform-services/aps-iot-extensions-demo
However, the heatmap is not showing up.enter image description here
The changes I made in the sample code are as follows
1.Change the following parameters in /public/config.js
APS_MODEL_URN = ‘URN obtained from Translate a Revit File, Generating Room and Space Information’
(Reference:https://github.com/autodesk-platform-services/ aps-tutorial-postman/tree/master/ModelDerivative_07)
APS_MODEL_VIEW = ”
2.Since there was no room information, define the following in /public/extensions/SensorHeatmapsExtension.js
3.Modified the location information of the four sensors in /services/iot.mocked.js so that they are placed inside the cube of the room.
const SENSORS = {
'sensor-1': {
name: 'sensor_1-1',// An ID to identify this device
description: 'rack_1-1_Basic_sensor.',
groupName: 'Level 2',
location: {// World coordinates of this device
x: 70,
y: 0,
z: -5
},
objectId: 1
},
'sensor-2': {
name: 'sensor_1-2',
description: 'rack_1-2_Basic_sensor.',
groupName: 'Level 2',
location: {
x: 70,
y: -30,
z: -5
},
objectId: 2
},
'sensor-3': {
name: 'sensor_1-3',
description: 'rack_1-3_Basic_sensor.',
groupName: 'Level 2',
location: {
x: 75,
y: 0,
z: -5
},
objectId: 3
},
'sensor-4': {
name: 'sensor_1-4',
description: 'rack_1-4_Basic_sensor.',
groupName: 'Level 2',
location: {
x: 75,
y: -30,
z: -5
},
objectId: 4
}
};
4.Fixed _setupSurfaceShadingw in /public/extensions/SensorHeatmapsExtension.js as follows
async _setupSurfaceShading(model) {
if (!this.dataView) {
return; }
}
const DataVizCore = Autodesk.DataVisualization.Core;
const structureInfo = new DataVizCore.ModelStructureInfo(model);
let levelRoomsMap = await structureInfo.getLevelRoomsMap();
///////////////2.room define///////////////
let room_2 = new DataVizCore.Room(
2222, //id Room's DbId
"2F_Room",//name
Box3(new THREE.Vector3(60, -40. -20), new THREE.Vector3(100, 10, 10))//bounds
);
for (const [sensorId, sensor] of this.dataView.getSensors().entries()) {
if(sensor.objectId >= 1 && sensor.objectId <= 4){
room_2.addDevice(sensor);
}
}
levelRoomsMap.addRoomToLevel("Level 2", room_2); }
/////////////// 4.SurfaceShading ///////////////
const shadingGroup = new DataVizCore.SurfaceShadingGroup('iot-heatmap');
const rooms = new Map();
for (const [sensorId, sensor] of this.dataView.getSensors().entries()) {
if (!sensor.objectId) {
continue;
}
if (!rooms.has(room_2.id)) {
const room = new Autodesk.DataVisualization.Core.SurfaceShadingNode(room_2.name, room_2.id);
shadingGroup.addChild(room);
rooms.set(room_2.id, room);
}
const room = rooms.get(room_2.id); }
const types = Array.from(this.dataView.getChannels().keys());
room.addPoint(new Autodesk.DataVisualization.Core.SurfaceShadingPoint(sensorId, sensor.location, types));
}
this._surfaceShadingData = new DataVizCore.SurfaceShadingData();
this._surfaceShadingData.addChild(shadingGroup);
this._surfaceShadingData.initialize(model);
await this._dataVizExt.setupSurfaceShading(model, this._surfaceShadingData);
//this._dataVizExt.registerSurfaceShadingColors('temp', [0x00ff00, 0xffff00, 0xff0000]);
}