Adds rpm specs to migration repo
This commit is contained in:
1 parent
acee7b8766
commit
7f035543e2
145 files changed
+13982
No files matched your search
Vendored
Executable
+233
@@ -0,0 +1,233 @@
|
||||
// $Id$
|
||||
// $HeadURL$
|
||||
// $Author$
|
||||
// Created by Manfred Gronak, 2021-03
|
||||
var fs = require("fs");
|
||||
var parser = require('xml2json');
|
||||
var format = require('xml-formatter');
|
||||
|
||||
var util = require('util');
|
||||
var path = require('path');
|
||||
|
||||
/****************** Hier editieren **********************/
|
||||
// Verschiebung der BSM weiter weg von der Wand
|
||||
var delta = 0.11;
|
||||
|
||||
/********************************************************/
|
||||
|
||||
module.exports = function() {
|
||||
|
||||
this.BSM_pos = function BSM_pos(OriginalxmlFile) {
|
||||
|
||||
var xmlFileNeu = OriginalxmlFile + "_neu";
|
||||
|
||||
var content = fs.readFileSync(OriginalxmlFile);
|
||||
|
||||
var lines = content + '';
|
||||
lines = lines.split("\n");
|
||||
|
||||
// try to save the comment generated by Structure Explorer to be re-inserted later
|
||||
var comment;
|
||||
if (lines[2].includes('HdrLastDate')) {
|
||||
comment = lines[2];
|
||||
|
||||
var idx = comment.lastIndexOf("-->");
|
||||
if (idx > 10)
|
||||
comment = [comment.slice(0, idx), "- PostProcessed by SLTE $Rev$", comment.slice(idx)].join('');
|
||||
}
|
||||
|
||||
console.log("OriginalxmlFile=" + OriginalxmlFile);
|
||||
console.log("Filename=" + path.basename(OriginalxmlFile) );
|
||||
|
||||
var FileNamesArray = path.basename(OriginalxmlFile).split('.');
|
||||
var bldg_name = FileNamesArray[0];
|
||||
console.log("bldg_name = '" + bldg_name + "'" );
|
||||
const specialMovementArray = {
|
||||
"bldg_3106_11005": "0.150012345678",
|
||||
"bldg_3138_11003": "0.150012345678",
|
||||
"bldg_3139_11010": "0.150012345678",
|
||||
"bldg_3139_11011": "0.150012345678",
|
||||
"bldg_3140_11004": "0.160012345678",
|
||||
"bldg_3144_11008": "0.150012345678",
|
||||
"bldg_3144_11010": "0.150012345678",
|
||||
"bldg_3148_11006": "0.150012345678",
|
||||
"bldg_3152_11006": "0.150012345678",
|
||||
"bldg_3152_11007": "0.150012345678",
|
||||
"bldg_3156_11022": "0.150012345678",
|
||||
"bldg_3159_11012": "0.150012345678",
|
||||
|
||||
"bldg_2100_11002": "0.250012345678",
|
||||
"bldg_4115_11003": "0.150012345678",
|
||||
"bldg_4115_11005": "0.150012345678",
|
||||
"bldg_4115_11006": "0.150012345678",
|
||||
"bldg_4115_11007": "0.150012345678",
|
||||
"bldg_4115_11017": "0.150012345678",
|
||||
"bldg_4147_11012": "0.150012345678",
|
||||
"bldg_4155_11003": "0.150012345678",
|
||||
"bldg_4194_11002": "0.250012345678",
|
||||
|
||||
"bldg_4119_11007": "0.250012345678",
|
||||
"bldg_4120_11008": "0.250012345678",
|
||||
"bldg_4121_11010": "0.150012345678",
|
||||
"bldg_4121_11014": "0.150012345678",
|
||||
"bldg_4122_11009": "0.150012345678",
|
||||
"bldg_4122_11012": "0.150012345678",
|
||||
"bldg_4123_11001": "0.150012345678",
|
||||
"bldg_4123_11003": "0.150012345678",
|
||||
"bldg_4123_11013": "0.150012345678",
|
||||
|
||||
"bldg_4130_11006": "0.250012345678",
|
||||
"bldg_4130_11008": "0.250012345678",
|
||||
"bldg_4130_11009": "0.250012345678",
|
||||
}
|
||||
console.log("specialMovementArray " + util.inspect(specialMovementArray, {showHidden: false, depth: 2}));
|
||||
|
||||
|
||||
var jsonFileInhalt = parser.toJson(content, {
|
||||
reversible: true
|
||||
});
|
||||
var jsonContent = JSON.parse(jsonFileInhalt);
|
||||
|
||||
|
||||
// start with "1" to skip bldg FOOTPRINT
|
||||
var j;
|
||||
for (j = 1; j < Object.keys(jsonContent.STREIF.Header.Group.Group).length; j++) {
|
||||
// test, ob Element jsonContent.STREIF.Header.Group.Group[j] vorhanden ist
|
||||
//console.log("0 SHGGS " + j + "-" + util.inspect(jsonContent.STREIF.Header.Group.Group[j], { showHidden: false, depth: 3}));
|
||||
|
||||
if (jsonContent.STREIF.Header.Group.Group[j].Switch) {
|
||||
// console.log("1 SHGGS " + j + "-" + util.inspect(jsonContent.STREIF.Header.Group.Group[j].Switch, {showHidden: false, depth: 2}));
|
||||
|
||||
// in case of just a single room per floor,
|
||||
// -> jsonContent.STREIF.Header.Group.Group[j].Switch is NOT an array
|
||||
// -> jsonContent.STREIF.Header.Group.Group[j].Switch).length is undefined!
|
||||
// ==> wrap into an array:
|
||||
if (!Array.isArray(jsonContent.STREIF.Header.Group.Group[j].Switch)) {
|
||||
// wrap obj into an array
|
||||
var dummy = new Array;
|
||||
dummy[0] = jsonContent.STREIF.Header.Group.Group[j].Switch;
|
||||
jsonContent.STREIF.Header.Group.Group[j].Switch = dummy;
|
||||
}
|
||||
if (!Array.isArray(jsonContent.STREIF.Header.Group.Group[j].Switch))
|
||||
console.log("Switch noArray at " + OriginalxmlFile);
|
||||
|
||||
|
||||
var k;
|
||||
for (k = 0; k < Object.keys(jsonContent.STREIF.Header.Group.Group[j].Switch).length; k++) {
|
||||
// test, ob Elelemant jsonContent.STREIF.Header.Group.Group[j].Switch[k]] vorhanden ist
|
||||
if (jsonContent.STREIF.Header.Group.Group[j].Switch[k]) {
|
||||
|
||||
//console.log("2 SHGGS " + util.inspect(jsonContent.STREIF.Header.Group.Group[j].Switch[k], {showHidden: false, depth: 1}));
|
||||
console.log("2 SHGGS " + jsonContent.STREIF.Header.Group.Group[j].Switch[k].Name.$t);
|
||||
|
||||
|
||||
if (jsonContent.STREIF.Header.Group.Group[j].Switch[k].Group == null) {
|
||||
console.log("Missing GroupNode1 at " + OriginalxmlFile + ", Data:" + util.inspect(jsonContent.STREIF.Header.Group.Group[j].Switch[k], {showHidden: false, depth: 2}));
|
||||
continue;
|
||||
}
|
||||
if (jsonContent.STREIF.Header.Group.Group[j].Switch[k].Group.External_Reference == null) {
|
||||
console.log("Missing GroupNode2 at " + OriginalxmlFile + ", Data:" + util.inspect(jsonContent.STREIF.Header.Group.Group[j].Switch[k].Group, {showHidden: false, depth: 2}));
|
||||
continue;
|
||||
}
|
||||
|
||||
// convert object to array to enable forEach:
|
||||
if (!Array.isArray(jsonContent.STREIF.Header.Group.Group[j].Switch[k].Group.External_Reference)){
|
||||
jsonContent.STREIF.Header.Group.Group[j].Switch[k].Group.External_Reference = [jsonContent.STREIF.Header.Group.Group[j].Switch[k].Group.External_Reference]
|
||||
}
|
||||
|
||||
|
||||
if (!Array.isArray(jsonContent.STREIF.Header.Group.Group[j].Switch[k].Group.External_Reference))
|
||||
console.log("External_Reference: noArray at " + OriginalxmlFile);
|
||||
|
||||
jsonContent.STREIF.Header.Group.Group[j].Switch[k].Group.External_Reference.forEach(extRef => {
|
||||
|
||||
console.log("XXXX current extRe " + util.inspect(extRef, { showHidden: false, depth: 3}));
|
||||
|
||||
var ID = ~~(extRef.SubId.ID / 1000);
|
||||
if (ID == 11) {
|
||||
var finalDelta = delta;
|
||||
var idx = bldg_name + "_" +extRef.SubId.ID;
|
||||
if (specialMovementArray[idx])
|
||||
{
|
||||
finalDelta = specialMovementArray[idx];
|
||||
console.log("specialMovementArray: found, finalDelta= " + finalDelta);
|
||||
}
|
||||
|
||||
console.log("adjust on item ..." + util.inspect(extRef, { showHidden: false, depth: 2 }));
|
||||
extRef.Coord.X = parseFloat(extRef.Coord.X) + (finalDelta * parseFloat(extRef.Dir.X));
|
||||
extRef.Coord.Y = parseFloat(extRef.Coord.Y) + (finalDelta * parseFloat(extRef.Dir.Y));
|
||||
extRef.Coord.Z = parseFloat(extRef.Coord.Z) + (finalDelta * parseFloat(extRef.Dir.Z));
|
||||
console.log("adjust on item " + util.inspect(extRef, { showHidden: false, depth: 2 }) + " done");
|
||||
}
|
||||
|
||||
}); // forEach
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handle outdoor elements:
|
||||
// console.log("outdoor SHGGS " + j + "-" + util.inspect(jsonContent.STREIF.Header.Group.External_Reference, { showHidden: false, depth: 3}));
|
||||
|
||||
|
||||
if (!Array.isArray(jsonContent.STREIF.Header.Group.External_Reference)) {
|
||||
jsonContent.STREIF.Header.Group.External_Reference = [jsonContent.STREIF.Header.Group.External_Reference]
|
||||
}
|
||||
|
||||
jsonContent.STREIF.Header.Group.External_Reference.forEach(extRef => {
|
||||
|
||||
// console.log("outdoor current extRe " + util.inspect(extRef, { showHidden: false, depth: 3}));
|
||||
|
||||
var ID = ~~(extRef.SubId.ID / 1000);
|
||||
if (ID == 11) {
|
||||
var finalDelta = delta;
|
||||
var idx = bldg_name + "_" +extRef.SubId.ID;
|
||||
if (specialMovementArray[idx])
|
||||
{
|
||||
finalDelta = specialMovementArray[idx];
|
||||
console.log("specialMovementArray: found, finalDelta= " + finalDelta);
|
||||
}
|
||||
|
||||
console.log("outdoor: adjust on item ..." + util.inspect(extRef, { showHidden: false, depth: 2 }));
|
||||
extRef.Coord.X = parseFloat(extRef.Coord.X) + (finalDelta * parseFloat(extRef.Dir.X));
|
||||
extRef.Coord.Y = parseFloat(extRef.Coord.Y) + (finalDelta * parseFloat(extRef.Dir.Y));
|
||||
extRef.Coord.Z = parseFloat(extRef.Coord.Z) + (finalDelta * parseFloat(extRef.Dir.Z));
|
||||
console.log("outdoor: adjust on item " + util.inspect(extRef, { showHidden: false, depth: 2 }) + " done");
|
||||
}
|
||||
}); // forEach
|
||||
|
||||
|
||||
|
||||
var Rooms = jsonContent;
|
||||
|
||||
var stringified = JSON.stringify(Rooms);
|
||||
var ausgabe = parser.toXml(stringified);
|
||||
|
||||
|
||||
if (comment)
|
||||
var formattedXml = '<?xml version="1.0" ?>' + '\n' + comment + '\n' + format(ausgabe, {
|
||||
collapseContent: true,
|
||||
lineSeparator: '\n'
|
||||
});
|
||||
else
|
||||
var formattedXml = '<?xml version="1.0" ?>' + '\n' + format(ausgabe, {
|
||||
collapseContent: true,
|
||||
lineSeparator: '\n'
|
||||
});
|
||||
|
||||
// Renoir-repos has xml files without svn:eol-style.
|
||||
// So 'svn co' will create files with CR+LF (Windows EOL)
|
||||
// To enable an svn diff showingf only the real differences, write with CR+LF:
|
||||
|
||||
// write to < OriginalxmlFile | xmlFileNeu >
|
||||
fs.writeFileSync(OriginalxmlFile, formattedXml, function(err) {
|
||||
// If an error occurred, show it
|
||||
if (err) {
|
||||
console.log("Error on writing file: " + OriginalxmlFile);
|
||||
console.err(err);
|
||||
}
|
||||
});
|
||||
|
||||
} // end of function
|
||||
} // export
|
||||
Vendored
Executable
+160
@@ -0,0 +1,160 @@
|
||||
// $Id$
|
||||
// $HeadURL$
|
||||
// $Author$
|
||||
// Created by Manfred Gronak, , 2021-04
|
||||
|
||||
var fs = require("fs");
|
||||
var path = require("path");
|
||||
var parser = require('xml2json');
|
||||
var util = require("util");
|
||||
|
||||
|
||||
var stableSort = (arr, compare) => arr
|
||||
.map((item, index) => ({
|
||||
item,
|
||||
index
|
||||
}))
|
||||
.sort((a, b) => compare(a.item, b.item) || a.index - b.index)
|
||||
.map(({
|
||||
item
|
||||
}) => item)
|
||||
|
||||
|
||||
|
||||
module.exports = function() {
|
||||
|
||||
this.EGCU_conf = function EGCU_conf(OriginalxmlFile) {
|
||||
|
||||
// console.log("EGCU_CONF: orgFile", OriginalxmlFile);
|
||||
|
||||
//OriginalxmlFile = ../GuezBuildings/buildings/bldg_1235/bldg_1235.flt.xml
|
||||
// dirname = ../GuezBuildings/buildings/bldg_1235
|
||||
// basename = bldg_1235
|
||||
// newname ../GuezBuildings/buildings/bldg_1235/bldg_1235.egcu.xml
|
||||
var dirname = path.dirname(OriginalxmlFile);
|
||||
var basename = path.basename(OriginalxmlFile, '.flt.xml');
|
||||
var newFileName = dirname + '/' + basename + '.egcu2room.xml';
|
||||
|
||||
|
||||
var content = fs.readFileSync(OriginalxmlFile);
|
||||
|
||||
var jsonFileInhalt = parser.toJson(content);
|
||||
var jsonContent = JSON.parse(jsonFileInhalt);
|
||||
|
||||
var numberOfBDI = 0;
|
||||
var BDI_Elements_Raw = [];
|
||||
|
||||
// convert object to array to enable forEach:
|
||||
if (!Array.isArray(jsonContent.STREIF.Header.Group.External_Reference)){
|
||||
jsonContent.STREIF.Header.Group.External_Reference = [jsonContent.STREIF.Header.Group.External_Reference]
|
||||
}
|
||||
|
||||
jsonContent.STREIF.Header.Group.External_Reference.forEach(Element => {
|
||||
|
||||
if (Element.Name.substring(0, 6) == 'BDI_P_') {
|
||||
BDI_Elements_Raw.push(Element);
|
||||
numberOfBDI = numberOfBDI + 1;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
var BDI_Elements = stableSort(BDI_Elements_Raw, (a, b) => a.Coord.Z - b.Coord.Z);
|
||||
|
||||
|
||||
var Switch_Elements = [];
|
||||
|
||||
jsonContent.STREIF.Header.Group.Group.forEach(Group => {
|
||||
Switch_Elements.push(Group.Switch);
|
||||
});
|
||||
|
||||
var i;
|
||||
|
||||
var Rooms = [];
|
||||
|
||||
|
||||
for (i = 1; i < Object.keys(Switch_Elements).length; i++) {
|
||||
var j;
|
||||
if (util.isArray(Switch_Elements[i])) {
|
||||
// console.log(Object.keys(Switch_Elements[i]).length);
|
||||
for (j = 0; j < Object.keys(Switch_Elements[i]).length; j++) {
|
||||
Rooms.push(Switch_Elements[i][j]);
|
||||
}
|
||||
} else {
|
||||
Rooms.push(Switch_Elements[i]);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Test auf mindestens EGCU in einer Etage... ");
|
||||
|
||||
// Test auf mindestens EGCU in einer Etage
|
||||
BDI_Elements.forEach(BDI => {
|
||||
var k = 0;
|
||||
BDI_Elements.forEach(BDI2 => {
|
||||
if (parseInt(BDI.Coord.Z) == parseInt(BDI2.Coord.Z))
|
||||
k = k + 1;
|
||||
});
|
||||
if (k > 1) {
|
||||
console.log("EGCU_CONF: mehr als eine EGCU pro Etage " + OriginalxmlFile + " -> " + k);
|
||||
// process.exit();
|
||||
}
|
||||
});
|
||||
|
||||
var EgcuToRooms = "<EgcusToRooms>\n";
|
||||
var z = 0;
|
||||
|
||||
BDI_Elements.forEach(BDI => {
|
||||
z = z + 1;
|
||||
EgcuToRooms = EgcuToRooms + " <Egcu>\n <Mountpoint>\n";
|
||||
EgcuToRooms = EgcuToRooms + " <Name>" + BDI.Name + "</Name>\n";
|
||||
EgcuToRooms = EgcuToRooms + " <SubId>" + BDI.SubId.ID + "</SubId>\n";
|
||||
EgcuToRooms = EgcuToRooms + " </Mountpoint>\n <Rooms>\n";
|
||||
|
||||
|
||||
Rooms.forEach(Room => {
|
||||
|
||||
console.log("Room === " + util.inspect(Room, { showHidden: false, depth: 3}));
|
||||
|
||||
if (Object.keys(BDI_Elements).length == 1) {
|
||||
if (typeof(Room) !== 'undefined') {
|
||||
EgcuToRooms = EgcuToRooms + " <Name>" + Room.Name + "</Name>\n";
|
||||
EgcuToRooms = EgcuToRooms + " <SubId>" + Room.SubId.ID + "</SubId>\n";
|
||||
}
|
||||
} else {
|
||||
|
||||
if (typeof(Room) !== 'undefined') {
|
||||
console.log("XXXX Room === " + util.inspect(Room, { showHidden: false, depth: 3}));
|
||||
console.log("XXXX BDI === " + util.inspect(BDI, { showHidden: false, depth: 3}));
|
||||
var difference = BDI.Coord.Z - Room.Group.BBox_Min.Z;
|
||||
if (parseInt(difference) == 0) {
|
||||
EgcuToRooms = EgcuToRooms + " <Name>" + Room.Name + "</Name>\n";
|
||||
EgcuToRooms = EgcuToRooms + " <SubId>" + Room.SubId.ID + "</SubId>\n";
|
||||
}
|
||||
if (numberOfBDI == z) {
|
||||
if (parseInt(difference) < 0) {
|
||||
EgcuToRooms = EgcuToRooms + " <Name>" + Room.Name + "</Name>\n";
|
||||
EgcuToRooms = EgcuToRooms + " <SubId>" + Room.SubId.ID + "</SubId>\n";
|
||||
}
|
||||
}
|
||||
} // if
|
||||
} // if
|
||||
});
|
||||
EgcuToRooms = EgcuToRooms + " </Rooms>\n </Egcu>\n"
|
||||
});
|
||||
|
||||
EgcuToRooms = EgcuToRooms + '</EgcusToRooms>\n';
|
||||
|
||||
|
||||
console.log(newFileName);
|
||||
// console.log(EgcuToRooms);
|
||||
|
||||
|
||||
fs.writeFileSync(newFileName, EgcuToRooms, function(err) {
|
||||
// If an error occurred, show it and return
|
||||
console.log("EgcuToRooms.xml geschrieben")
|
||||
if (err) return console.error(err);
|
||||
// Successfully wrote binary contents to the file!
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Vendored
Executable
+101
@@ -0,0 +1,101 @@
|
||||
// $Id$
|
||||
// $HeadURL$
|
||||
// $Author$
|
||||
// Created by Manfred Gronak, , 2021-03
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
// require ('./analyse_vmw_file.js')();
|
||||
require ('./replace_transistion_factors.js')();
|
||||
require('./BSM_pos.js')();
|
||||
require('./egcu_conf.js')();
|
||||
require('./vwmXmlToVrmlWrl.js')();
|
||||
|
||||
require('./simplify_polygons.js')();
|
||||
|
||||
var myArgs = process.argv.slice(2);
|
||||
|
||||
console.log('myArgs: ', myArgs);
|
||||
|
||||
|
||||
// const GUEZ_DIR = '/media/tbox/423F-1127/DATENGEBAEUDE_GUEZ';
|
||||
// const GUEZ_DIR = '/shd/CTC/TOOLS/GuezBuildings/buildingsXXXXX';
|
||||
|
||||
const GUEZ_DIR = myArgs[0];
|
||||
console.log('adjust file at directory: ', GUEZ_DIR);
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
|
||||
|
||||
fs.readdir(GUEZ_DIR, (err, files) => {
|
||||
|
||||
if (err) return console.error(err);
|
||||
|
||||
|
||||
|
||||
var DirNames = files.toString();
|
||||
|
||||
var DirNamesArray = DirNames.split(',');
|
||||
|
||||
DirNamesArray.forEach(DirName => {
|
||||
if (DirName.substring(0, 5) == 'bldg_') {
|
||||
console.log("Working at directory: " + DirName);
|
||||
|
||||
if ( (DirName == 'bldg_1141n') ||
|
||||
(DirName == 'bldg_1102_Treppen') )
|
||||
{
|
||||
console.log("Skip subdir '", DirName + "'");
|
||||
return;
|
||||
}
|
||||
|
||||
fs.readdir(GUEZ_DIR + '/' + DirName, (err, subdir_files) => {
|
||||
if (err) return console.error(err);
|
||||
var SubDirNames = subdir_files.toString();
|
||||
var FileNamesArray = SubDirNames.split(',');
|
||||
|
||||
FileNamesArray.forEach(FileName => {
|
||||
|
||||
var FileNamePartArray = FileName.split('.');
|
||||
// console.log("process file: ", FileNamePartArray);
|
||||
// if (FileNamePartArray[0] == 'bldg_1199' && FileNamePartArray[2] == 'VWM_Building' && FileNamePartArray[3] == 'xml' && FileNamePartArray.length == 4) {
|
||||
if (FileNamePartArray[2] == 'VWM_Building' && FileNamePartArray[3] == 'xml' && FileNamePartArray.length == 4) {
|
||||
|
||||
var File_Path = GUEZ_DIR + '/' + DirName + '/' + FileName;
|
||||
console.log("XXXXX1 File_Path: " + File_Path );
|
||||
simplify_polygons(File_Path); // Aktiviert wg. blgd_0910_Raum2201_Wall0 (8 vertex -> 4) - GUEZE-1004
|
||||
console.log("XXXXX2 File_Path: " + File_Path );
|
||||
replace_transistion_factors(File_Path);
|
||||
|
||||
// create wrl files (VRML). Usefull to find missing outerwalls:
|
||||
console.log("XXXXX3 File_Path: " + File_Path );
|
||||
VwmXmlToWrl(File_Path)
|
||||
} // end if
|
||||
|
||||
|
||||
if (FileNamePartArray[1] == 'flt' && FileNamePartArray[2] == 'xml' && FileNamePartArray.length == 3) {
|
||||
var File_Path = GUEZ_DIR + '/' + DirName + '/' + FileName;
|
||||
console.log("XXXXX4 File_Path: " + File_Path );
|
||||
BSM_pos(File_Path);
|
||||
}
|
||||
|
||||
if (FileNamePartArray[1] == 'flt' && FileNamePartArray[2] == 'xml' && FileNamePartArray.length == 3) {
|
||||
var File_Path = GUEZ_DIR + '/' + DirName + '/' + FileName;
|
||||
console.log("XXXXX5 File_Path: " + File_Path );
|
||||
EGCU_conf(File_Path);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}); // readdir
|
||||
|
||||
|
||||
|
||||
} // end if
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
Vendored
Executable
+288
@@ -0,0 +1,288 @@
|
||||
// $Id$
|
||||
// $HeadURL$
|
||||
// $Author$
|
||||
// Created by Manfred Gronak, 2021-03
|
||||
const fs = require('fs');
|
||||
|
||||
var parser = require('xml2json');
|
||||
|
||||
var js2xmlparser = require('js2xmlparser');
|
||||
var format = require('xml-formatter');
|
||||
|
||||
var util = require('util');
|
||||
|
||||
/****************** Hier editieren **********************/
|
||||
// Das ist der Transistion Factor, der für alle vertikalen Transitionen eingetragen werden soll
|
||||
// Muss ausgetestet werden.
|
||||
var TransitionFactor_vertical = 0.15;
|
||||
var TransitionFactor_horizontal_min = 0.03; // former MG=0.1
|
||||
|
||||
var TransitionFactor_horizontal_min_limit = 0.03;
|
||||
|
||||
var BelowGroundBldgs = ['U_Bahn', 'xxx'];
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
module.exports = function() {
|
||||
|
||||
this.replace_transistion_factors = function replace_transistion_factors(xmlFile) {
|
||||
|
||||
const OriginalVWMFile = xmlFile;
|
||||
|
||||
var content = fs.readFileSync(OriginalVWMFile);
|
||||
|
||||
var jsonFileInhalt;
|
||||
var jsonContent;
|
||||
try {
|
||||
jsonFileInhalt = parser.toJson(content);
|
||||
jsonContent = JSON.parse(jsonFileInhalt);
|
||||
} catch (e) {
|
||||
console.log("Parsing error bei Datei " + OriginalVWMFile + " -> " + e.message); // Datei geschrieben
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var BuildingName = jsonContent.BuildingVulnerability.BuildingName;
|
||||
BuildingName = BuildingName.substring(5); // bldg_U_Bahn -> U_Bahn
|
||||
|
||||
if (BelowGroundBldgs.includes(BuildingName))
|
||||
{
|
||||
console.log("BuildingName '" + BuildingName + "' -> use special values (like TransistionFactors)");
|
||||
TransitionFactor_vertical = 0.129988;
|
||||
TransitionFactor_horizontal_min = 0.129999; // U-Bahn
|
||||
}
|
||||
|
||||
|
||||
|
||||
// try to save the comment generated by Structure Explorer to be re-inserted later
|
||||
var lines = content + '';
|
||||
lines = lines.split("\n");
|
||||
|
||||
var comment;
|
||||
if (lines[2].includes('HdrLastDate')) {
|
||||
comment = lines[2];
|
||||
|
||||
var idx = comment.lastIndexOf("-->");
|
||||
if (idx > 10)
|
||||
comment = [comment.slice(0, idx), "- PostProcessed by SLTE $Rev$", comment.slice(idx)].join('');
|
||||
}
|
||||
|
||||
|
||||
var i;
|
||||
var RoomId;
|
||||
var NeighborRoomRoomId;
|
||||
var index;
|
||||
|
||||
var RoomArray = jsonContent.BuildingVulnerability.Rooms.Room;
|
||||
if (RoomArray == null) {
|
||||
console.log("Datei " + OriginalVWMFile + ": " + " WARNING, no RoomArray detected");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
console.log("Datei " + OriginalVWMFile + ": " + Object.keys(jsonContent.BuildingVulnerability.Rooms.Room).length + " Rooms detected");
|
||||
|
||||
if (Array.isArray(jsonContent.BuildingVulnerability.Rooms.Room)) {
|
||||
// console.log("1Array: ");
|
||||
} else {
|
||||
// No Array..
|
||||
// wrap obj into an array to ensure 'RoomArray.forEach(...'
|
||||
var dummy = new Array;
|
||||
dummy[0] = jsonContent.BuildingVulnerability.Rooms.Room;
|
||||
jsonContent.BuildingVulnerability.Rooms.Room = dummy;
|
||||
}
|
||||
|
||||
|
||||
// check number of floors:
|
||||
var maxfloor = -1;
|
||||
var roomsPerFloor = new Map;
|
||||
for (i = 0; i < Object.keys(jsonContent.BuildingVulnerability.Rooms.Room).length; i++) {
|
||||
console.log("RaumID " + jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId);
|
||||
|
||||
var floor = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId - 2000);
|
||||
floor = ~~(floor / 100);
|
||||
console.log(" floor=" + floor);
|
||||
if (floor > maxfloor)
|
||||
maxfloor = floor;
|
||||
|
||||
var maxRoomNumber = jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId - 2000;
|
||||
maxRoomNumber = maxRoomNumber - (floor*100.0);
|
||||
console.log(" maxRoomNumber " + maxRoomNumber + " (" + jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId + ")");
|
||||
|
||||
|
||||
console.log(" roomsPerFloor " + ", Data:" + util.inspect(roomsPerFloor, {showHidden: false, depth: 2}));
|
||||
|
||||
console.log(" roomsPerFloor " + roomsPerFloor);
|
||||
if (!roomsPerFloor.has(floor))
|
||||
roomsPerFloor.set(floor, 0);
|
||||
|
||||
if (maxRoomNumber > roomsPerFloor.get(floor))
|
||||
{
|
||||
console.log(" update: maxRoomNumber=" + maxRoomNumber + " at floor " + floor);
|
||||
roomsPerFloor.set(floor, maxRoomNumber);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("maxfloor " + maxfloor);
|
||||
|
||||
|
||||
var removeCandidates = new Array;
|
||||
|
||||
for (i = 0; i < Object.keys(jsonContent.BuildingVulnerability.Rooms.Room).length; i++) {
|
||||
// Reduzierung auf die Etage
|
||||
// console.log("RaumID" + jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId);
|
||||
|
||||
if (jsonContent.BuildingVulnerability.Rooms.Room[i] == null) {
|
||||
console.log("Missing RoomId at " + OriginalVWMFile);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
RoomId = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId / 100);
|
||||
// console.log(RoomId);
|
||||
var j;
|
||||
// console.log(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms);
|
||||
// Test, ob ein Raum keine Nachbarraeume hat. Wenn dann entfernen
|
||||
if (!jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom) {
|
||||
|
||||
var roomToBeRemove = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId - 2000);
|
||||
var roomFloor = ~~(roomToBeRemove / 100);
|
||||
|
||||
// Nur oberste Etage, nur wenn mehr als eine Etage:
|
||||
if (roomFloor == maxfloor && roomsPerFloor.size > 1) {
|
||||
console.log("Element RoomId " + jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId + " muesste entfernt werden at: " + OriginalVWMFile + " (maxfloor=" + maxfloor + ", rooms at previous floor:" + roomsPerFloor.get(maxfloor-1) + "m i=" + i +")");
|
||||
removeCandidates.push({'roomToBeRemovedCandidateIdx' : i, 'roomToBeRemovedCandidateRoomNumber' : jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId});
|
||||
// // delete jsonContent.BuildingVulnerability.Rooms.Room[i];
|
||||
} else
|
||||
console.log("Skip Element RoomId " + jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId + " wird entfernt at: " + OriginalVWMFile + " (maxfloor=" + maxfloor + ")");
|
||||
|
||||
|
||||
} else {
|
||||
//console.log(Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[0].NeighborRooms.NeighborRoom).length);
|
||||
|
||||
for (j = 0; j < Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom).length; j++) {
|
||||
|
||||
// console.log(jsonContent.BuildingVulnerability.Rooms.Room[0].NeighborRooms.NeighborRoom.NeighborRoom.RoomId);
|
||||
// Test, ob Raeume in der gleiche Etage liegen. Wenn nicht dann Transistion Faktoren einschreiben
|
||||
// console.log(Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom).length);
|
||||
if (Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom).length == 1) {
|
||||
NeighborRoomId = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom.RoomId / 100);
|
||||
if (RoomId != NeighborRoomId)
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom.TransitionFactor = TransitionFactor_vertical;
|
||||
else {
|
||||
if (jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom.TransitionFactor <= TransitionFactor_horizontal_min)
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom.TransitionFactor = TransitionFactor_horizontal_min;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (typeof jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j] !== 'undefined') {
|
||||
// console.log(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j].RoomId);
|
||||
NeighborRoomId = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j].RoomId / 100);
|
||||
if (RoomId != NeighborRoomId)
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j].TransitionFactor = TransitionFactor_vertical;
|
||||
else {
|
||||
if (jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j].TransitionFactor <= TransitionFactor_horizontal_min)
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j].TransitionFactor = TransitionFactor_horizontal_min;
|
||||
}
|
||||
} else { // if undefined
|
||||
// console.log("NeighborRooms.NeighborRoom is undefined at: " + OriginalVWMFile);
|
||||
// relevant for bldg_salchau_tunnel.flt.VWM_Building.xml, bldg_BN_Kanaele and many more (78 files at this moment)
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.TransitionFactor = TransitionFactor_vertical;
|
||||
}
|
||||
} // if
|
||||
} // for
|
||||
}
|
||||
}
|
||||
|
||||
// check
|
||||
|
||||
if (Object.keys(removeCandidates).length > 0) {
|
||||
// how can we process 2 rooms at the roof ??? (like Guez bldg_2101)
|
||||
if (Object.keys(removeCandidates).length > 1) {
|
||||
console.log("ERROR at " + OriginalVWMFile + " : adding neighbor failed, more then one removeCandidates: size=" + Object.keys(removeCandidates).length);
|
||||
} else {
|
||||
|
||||
removeCandidates.forEach(item => {
|
||||
var roomToBeRemovedCandidateIdx = item.roomToBeRemovedCandidateIdx;
|
||||
var roomToBeRemovedCandidateRoomNumber = item.roomToBeRemovedCandidateRoomNumber;
|
||||
|
||||
if (roomToBeRemovedCandidateIdx > 0)
|
||||
{
|
||||
console.log("roomToBeRemovedCandidateIdx=" + roomToBeRemovedCandidateIdx + ", roomToBeRemovedCandidateRoomNumber=" + roomToBeRemovedCandidateRoomNumber);
|
||||
|
||||
// console.log("NeighborRooms " + util.inspect(jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1], {showHidden: false, depth: 3}));
|
||||
// console.log("NeighborRooms " + Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1].NeighborRooms.NeighborRoom).length );
|
||||
|
||||
var lowerRoomId = jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1].RoomId;
|
||||
|
||||
// add lower to topmost room:
|
||||
{
|
||||
// console.log("jsonContent11 " + util.inspect(jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx], {showHidden: false, depth: 5}));
|
||||
|
||||
if (typeof jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx].NeighborRooms.NeighborRoom == 'undefined') {
|
||||
// expected:
|
||||
console.log(OriginalVWMFile + ", adding neighbor, part 1: lowerRoomId=" + lowerRoomId + " to topmost room=" + roomToBeRemovedCandidateRoomNumber );
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx].NeighborRooms['NeighborRoom'] = [ {"RoomId": lowerRoomId, "TransitionFactor": 0.99999} ];
|
||||
} else {
|
||||
console.log("ERROR at " + OriginalVWMFile + " : adding neighbor part 1");
|
||||
}
|
||||
// console.log("jsonContent22 " + util.inspect(jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx], {showHidden: false, depth: 5}));
|
||||
}
|
||||
|
||||
// add topmost to lower:
|
||||
{
|
||||
// console.log("jsonContent33 " + util.inspect(jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1], {showHidden: false, depth: 3}));
|
||||
|
||||
if (Array.isArray(jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1].NeighborRooms.NeighborRoom))
|
||||
{
|
||||
// expected:
|
||||
console.log(OriginalVWMFile + ", adding neighbor, part 2a: to lower room : " + jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1].RoomId);
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1].NeighborRooms.NeighborRoom.push({"RoomId": roomToBeRemovedCandidateRoomNumber, "TransitionFactor": 0.99999});
|
||||
} else {
|
||||
console.log(OriginalVWMFile + ", adding neighbor, part 2b: to lower room : " + jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1].RoomId);
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1].NeighborRooms.NeighborRoom = [{"RoomId": roomToBeRemovedCandidateRoomNumber, "TransitionFactor": 0.99999}];
|
||||
}
|
||||
// console.log("jsonContent44 " + util.inspect(jsonContent.BuildingVulnerability.Rooms.Room[roomToBeRemovedCandidateIdx-1], {showHidden: false, depth: 3}));
|
||||
}
|
||||
|
||||
} // if
|
||||
}) // forEach
|
||||
} // if
|
||||
}// if
|
||||
|
||||
|
||||
|
||||
// delete jsonContent.BuildingVulnerability.Rooms.Room[index].NeighborRooms.NeighborRoom.NeighborRoom;
|
||||
// jsonContent.BuildingVulnerability.Rooms.Room[index].NeighborRooms.NeighborRoom["TransitionFactor"] = TransitionFactor_vertical;
|
||||
// jsonContent.BuildingVulnerability.Rooms.Room[index].NeighborRooms.NeighborRoom["RoomId"] = NeighborRoomRoomId;
|
||||
|
||||
|
||||
var Rooms = jsonContent.BuildingVulnerability;
|
||||
var ausgabe = js2xmlparser.parse("BuildingVulnerability", Rooms);
|
||||
|
||||
if (comment) {
|
||||
var idxOfLine = ausgabe.indexOf("<BuildingName>")
|
||||
// console.log("idxOfLine: " + idxOfLine);
|
||||
var ausgabe2 = [ausgabe.slice(0, idxOfLine), comment, ausgabe.slice(idxOfLine)].join('');
|
||||
ausgabe = ausgabe2;
|
||||
}
|
||||
|
||||
var formattedXml = format(ausgabe, {
|
||||
collapseContent: true,
|
||||
lineSeparator: '\n'
|
||||
});
|
||||
|
||||
|
||||
|
||||
fs.writeFileSync(OriginalVWMFile, formattedXml, function(err) {
|
||||
// If an error occurred, show it
|
||||
if (err) {
|
||||
console.log("Error on writing file: " + OriginalVWMFile);
|
||||
console.err(err);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/********************************************************************************************************/
|
||||
} // end exports
|
||||
Vendored
Executable
+355
@@ -0,0 +1,355 @@
|
||||
// $Id$
|
||||
// $HeadURL$
|
||||
// $Author$
|
||||
// Created by Norbert Thoden, 2021-12-22
|
||||
const fs = require('fs');
|
||||
|
||||
var parser = require('xml2json');
|
||||
|
||||
var js2xmlparser = require('js2xmlparser');
|
||||
var format = require('xml-formatter');
|
||||
|
||||
var util = require('util');
|
||||
|
||||
/****************** Hier editieren **********************/
|
||||
var BelowGroundBldgs = ['U_Bahn', 'xxx'];
|
||||
|
||||
var tolerance = 0.1;
|
||||
var highQuality = true;
|
||||
|
||||
|
||||
/*****************************************************************************************/
|
||||
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
/*
|
||||
* (c) 2013, Vladimir Agafonkin
|
||||
* Simplify.js, a high-performance JS polyline simplification library
|
||||
* mourner.github.io/simplify-js
|
||||
*/
|
||||
|
||||
// to suit your point format, run search/replace for '.x', '.y' and '.z';
|
||||
// (configurability would draw significant performance overhead)
|
||||
|
||||
// square distance between 2 points
|
||||
function getSquareDistance(p1, p2) {
|
||||
|
||||
var dx = p1.X - p2.X,
|
||||
dy = p1.Y - p2.Y,
|
||||
dz = p1.Z - p2.Z;
|
||||
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
// square distance from a point to a segment
|
||||
function getSquareSegmentDistance(p, p1, p2) {
|
||||
|
||||
var x = p1.X,
|
||||
y = p1.Y,
|
||||
z = p1.Z,
|
||||
|
||||
dx = p2.X - x,
|
||||
dy = p2.Y - y,
|
||||
dz = p2.Z - z;
|
||||
|
||||
if (dx !== 0 || dy !== 0 || dz !== 0) {
|
||||
|
||||
var t = ((p.X - x) * dx + (p.Y - y) * dy + (p.Z - z) * dz) /
|
||||
(dx * dx + dy * dy + dz * dz);
|
||||
|
||||
if (t > 1) {
|
||||
x = p2.X;
|
||||
y = p2.Y;
|
||||
z = p2.Z;
|
||||
|
||||
} else if (t > 0) {
|
||||
x += dx * t;
|
||||
y += dy * t;
|
||||
z += dz * t;
|
||||
}
|
||||
}
|
||||
|
||||
dx = p.X - x;
|
||||
dy = p.Y - y;
|
||||
dz = p.Z - z;
|
||||
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
// the rest of the code doesn't care for the point format
|
||||
|
||||
// basic distance-based simplification
|
||||
function simplifyRadialDistance(points, sqTolerance) {
|
||||
|
||||
var prevPoint = points[0],
|
||||
newPoints = [prevPoint],
|
||||
point;
|
||||
|
||||
for (var i = 1, len = points.length; i < len; i++) {
|
||||
point = points[i];
|
||||
|
||||
if (getSquareDistance(point, prevPoint) > sqTolerance) {
|
||||
newPoints.push(point);
|
||||
prevPoint = point;
|
||||
}
|
||||
}
|
||||
|
||||
if (prevPoint !== point) {
|
||||
newPoints.push(point);
|
||||
}
|
||||
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
// simplification using optimized Douglas-Peucker algorithm with recursion elimination
|
||||
function simplifyDouglasPeucker(points, sqTolerance) {
|
||||
|
||||
var len = points.length,
|
||||
MarkerArray = typeof Uint8Array !== 'undefined' ? Uint8Array : Array,
|
||||
markers = new MarkerArray(len),
|
||||
|
||||
first = 0,
|
||||
last = len - 1,
|
||||
|
||||
stack = [],
|
||||
newPoints = [],
|
||||
|
||||
i, maxSqDist, sqDist, index;
|
||||
|
||||
markers[first] = markers[last] = 1;
|
||||
|
||||
while (last) {
|
||||
|
||||
maxSqDist = 0;
|
||||
|
||||
for (i = first + 1; i < last; i++) {
|
||||
sqDist = getSquareSegmentDistance(points[i], points[first], points[last]);
|
||||
|
||||
if (sqDist > maxSqDist) {
|
||||
index = i;
|
||||
maxSqDist = sqDist;
|
||||
}
|
||||
}
|
||||
|
||||
if (maxSqDist > sqTolerance) {
|
||||
markers[index] = 1;
|
||||
stack.push(first, index, index, last);
|
||||
}
|
||||
|
||||
last = stack.pop();
|
||||
first = stack.pop();
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (markers[i]) {
|
||||
newPoints.push(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return newPoints;
|
||||
}
|
||||
|
||||
|
||||
function simplify(points, tolerance, highestQuality) {
|
||||
|
||||
var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1;
|
||||
|
||||
points = highestQuality ? points : simplifyRadialDistance(points, sqTolerance);
|
||||
points = simplifyDouglasPeucker(points, sqTolerance);
|
||||
|
||||
return points;
|
||||
}
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
/*****************************************************************************************/
|
||||
|
||||
|
||||
|
||||
module.exports = function() {
|
||||
|
||||
this.simplify_polygons = function simplify_polygons(xmlFile) {
|
||||
|
||||
const OriginalVWMFile = xmlFile;
|
||||
|
||||
var content = fs.readFileSync(OriginalVWMFile);
|
||||
|
||||
var jsonFileInhalt;
|
||||
var jsonContent;
|
||||
try {
|
||||
jsonFileInhalt = parser.toJson(content);
|
||||
jsonContent = JSON.parse(jsonFileInhalt);
|
||||
} catch (e) {
|
||||
console.log("Parsing error bei Datei " + OriginalVWMFile + " -> " + e.message); // Datei geschrieben
|
||||
return;
|
||||
}
|
||||
|
||||
var BuildingName = jsonContent.BuildingVulnerability.BuildingName;
|
||||
BuildingName = BuildingName.substring(5); // bldg_U_Bahn -> U_Bahn
|
||||
|
||||
var RoomArray = jsonContent.BuildingVulnerability.Rooms.Room;
|
||||
if (RoomArray == null) {
|
||||
console.log("Datei " + OriginalVWMFile + ": " + " WARNING, no RoomArray detected");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Array.isArray(RoomArray)){
|
||||
RoomArray = [RoomArray]
|
||||
}
|
||||
console.log("Datei " + OriginalVWMFile + ": " + Object.keys(jsonContent.BuildingVulnerability.Rooms.Room).length + " Rooms detected");
|
||||
console.log("Datei " + OriginalVWMFile + ": " + RoomArray.length + " Rooms detected");
|
||||
|
||||
RoomArray.forEach(Room => {
|
||||
|
||||
// console.log("Bldg " + BuildingName + " - RoomId: " + Room.RoomId);
|
||||
|
||||
var OuterWallArray = Room.RoomOuterWalls.OuterWall;
|
||||
|
||||
//sometimes there are no walls: OuterWallArray is undefined
|
||||
if (!OuterWallArray)
|
||||
{
|
||||
console.log("Bldg " + BuildingName + " / room " + Room.RoomId + " has no walls") ;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Array.isArray(OuterWallArray)){
|
||||
OuterWallArray = [OuterWallArray]
|
||||
}
|
||||
|
||||
|
||||
if (!OuterWallArray)
|
||||
{
|
||||
console.log("Bldg " + BuildingName + " / room " + Room.RoomId + " has no walls") ;
|
||||
return;
|
||||
}
|
||||
|
||||
var wallIdx =-1;
|
||||
OuterWallArray.forEach(Outerwall => {
|
||||
wallIdx++;
|
||||
// console.log(" Outerwall " + "idx=" + wallIdx + " : " + util.inspect(Outerwall, {showHidden: false, depth: 3}));
|
||||
|
||||
//
|
||||
// Wall itself
|
||||
//
|
||||
|
||||
// console.log(" Outerwall: " + Outerwall.OuterWallAreaElement);
|
||||
var PolygonPoints = Outerwall.OuterWallAreaElement.PolygonPoint;
|
||||
|
||||
var polyLengthOrg = PolygonPoints.length;
|
||||
// console.log(" WALL PolygonPoints-Org= " + polyLengthOrg) ;
|
||||
// console.log(" WALL data=" + util.inspect(PolygonPoints, {showHidden: false, depth: 2}));
|
||||
PolygonPoints.forEach(PolygonPoint => {
|
||||
PolygonPoint.X = parseFloat(PolygonPoint.X);
|
||||
PolygonPoint.Y = parseFloat(PolygonPoint.Y);
|
||||
PolygonPoint.Z = parseFloat(PolygonPoint.Z);
|
||||
//console.log(" WALL Point= " + PolygonPoint.X + " " + PolygonPoint.Y + " " + PolygonPoint.Z) ;
|
||||
});
|
||||
|
||||
// There are some walls/rectangles with a very short side (~10cm). Most of them are correct.
|
||||
// Avoid them being modified to a triangle/line:
|
||||
if (PolygonPoints.length > 4)
|
||||
{
|
||||
PolygonPoints = simplify(PolygonPoints, tolerance, highQuality);
|
||||
var polyLengthNew = PolygonPoints.length;
|
||||
// console.log(" PolygonPoints-New= " + polyLengthNew) ;
|
||||
|
||||
if (polyLengthOrg != polyLengthNew)
|
||||
console.log(" WALL Bldg " + BuildingName + " / room " + Room.RoomId + " / wallIdx " + wallIdx + ": " + " Outerwall: length changes from " + polyLengthOrg + " to " + polyLengthNew);
|
||||
|
||||
// console.log(" data=" + util.inspect(PolygonPoints, {showHidden: false, depth: 2}));
|
||||
|
||||
// PolygonPoints.forEach(PolygonPoint => {
|
||||
// console.log(" Point= " + PolygonPoint.X + " " + PolygonPoint.Y + " " + PolygonPoint.Z) ;
|
||||
// });
|
||||
|
||||
// write simplified data back:
|
||||
Outerwall.OuterWallAreaElement.PolygonPoint = PolygonPoints;
|
||||
} else {
|
||||
console.log(" WALL Bldg " + BuildingName + " / room " + Room.RoomId + " / wallIdx " + wallIdx + ": Skip due to short length: " + polyLengthOrg);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// ExclusionZones bldg_1199 is complex and therefore good for verification
|
||||
//
|
||||
{
|
||||
// node: Outerwall has ExclusionZones:
|
||||
// console.log(" ---- ExclZone ExclusionZonesArray= " + util.inspect(Outerwall.ExclusionZones, {showHidden: false, depth: 4}));
|
||||
|
||||
var ExclusionZonesArray = Outerwall.ExclusionZones.ExclusionZone;
|
||||
if (!ExclusionZonesArray)
|
||||
return;
|
||||
|
||||
if (!Array.isArray(ExclusionZonesArray)) {
|
||||
ExclusionZonesArray = [ExclusionZonesArray]
|
||||
}
|
||||
|
||||
// console.log(" ExclZone ExclusionZonesArray.length= " + ExclusionZonesArray.length);
|
||||
|
||||
var EzIdx =-1;
|
||||
ExclusionZonesArray.forEach(ExclusionZone => {
|
||||
EzIdx++;
|
||||
|
||||
// console.log(" ExclZone ---- ExclusionZone " + "EzIdx=" + EzIdx + " : " + util.inspect(ExclusionZone, {showHidden: false, depth: 3}));
|
||||
|
||||
var ExclZonePolygonPoints = ExclusionZone.ExclusionZoneElement.PolygonPoint;
|
||||
var polyLengthOrg = ExclZonePolygonPoints.length;
|
||||
|
||||
// console.log(" ExclZone ExclZonePolygonPoints-Org=" + polyLengthOrg + " (Bldg " + BuildingName + " / room " + Room.RoomId + ")") ;
|
||||
// console.log(" ExclZone data=" + util.inspect(ExclZonePolygonPoints, {showHidden: false, depth: 2}));
|
||||
ExclZonePolygonPoints.forEach(PolygonPoint => {
|
||||
PolygonPoint.X = parseFloat(PolygonPoint.X);
|
||||
PolygonPoint.Y = parseFloat(PolygonPoint.Y);
|
||||
PolygonPoint.Z = parseFloat(PolygonPoint.Z);
|
||||
//console.log(" ExclZone Point= " + PolygonPoint.X + " " + PolygonPoint.Y + " " + PolygonPoint.Z) ;
|
||||
});
|
||||
|
||||
// Maybe in future there will be some ExclZone/rectangles with a very short side (~10cm)...
|
||||
// Avoid them being modified to a triangle/line:
|
||||
if (ExclZonePolygonPoints.length > 4)
|
||||
{
|
||||
ExclZonePolygonPoints = simplify(ExclZonePolygonPoints, tolerance, highQuality);
|
||||
var polyLengthNew = ExclZonePolygonPoints.length;
|
||||
// console.log(" ExclZone ExclZonePolygonPoints-New= " + polyLengthNew) ;
|
||||
|
||||
if (polyLengthOrg != polyLengthNew)
|
||||
console.log(" ExclZone Bldg " + BuildingName + " / room " + Room.RoomId + " / wallIdx " + wallIdx + " / EzIdx " + EzIdx + ": " + " ExclZone: length changes from " + polyLengthOrg + " to " + polyLengthNew) ;
|
||||
|
||||
// write simplified data back, part 1:
|
||||
ExclusionZone.ExclusionZoneElement.PolygonPoint = ExclZonePolygonPoints; //CHECK (e.g. bldg_1199)
|
||||
} else {
|
||||
console.log(" ExclZone Bldg " + BuildingName + " / room " + Room.RoomId + " / wallIdx " + wallIdx + " / EzIdx " + EzIdx + ": " + " Skip due to short length: " + polyLengthOrg) ;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// write simplified data back, part 2:
|
||||
Outerwall.ExclusionZones.ExclusionZone = ExclusionZonesArray //CHECK (e.g. bldg_1199)
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var Rooms = jsonContent.BuildingVulnerability;
|
||||
var ausgabe = js2xmlparser.parse("BuildingVulnerability", Rooms);
|
||||
|
||||
var formattedXml = format(ausgabe, {
|
||||
collapseContent: true,
|
||||
lineSeparator: '\n'
|
||||
});
|
||||
|
||||
|
||||
|
||||
fs.writeFileSync(OriginalVWMFile, formattedXml, function(err) {
|
||||
// If an error occurred, show it
|
||||
if (err) {
|
||||
console.log("Error on writing file: " + OriginalVWMFile);
|
||||
console.err(err);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/********************************************************************************************************/
|
||||
} // end exports
|
||||
Vendored
Executable
+108
@@ -0,0 +1,108 @@
|
||||
#!/usr/bin/nodejs
|
||||
|
||||
// $Id$
|
||||
// $HeadURL$
|
||||
// $Author$
|
||||
// Created by Manfred Gronak, 2021-03
|
||||
|
||||
var fs = require("fs");
|
||||
var parser = require('xml2json');
|
||||
var js2xmlparser = require('js2xmlparser');
|
||||
var format = require('xml-formatter');
|
||||
|
||||
/****************** Hier editieren **********************/
|
||||
// Das ist der Transistion Factor, der für alle vertikalen Transitionen eingetragen werden soll
|
||||
// Muss ausgetestet werden.
|
||||
var TransitionFactor_vertical = 0.15;
|
||||
var TransitionFactor_horizontal_min = 0.10;
|
||||
|
||||
var TransitionFactor_horizontal_min_limit = 0.05;
|
||||
/********************************************************/
|
||||
|
||||
if (process.argv.length === 2) {
|
||||
console.error('Filename for VWM expected');
|
||||
process.exit(1);
|
||||
}
|
||||
const OriginalVWMFile = process.argv[2];
|
||||
|
||||
|
||||
var VWMFileNeu = OriginalVWMFile + "_neu";
|
||||
|
||||
var content = fs.readFileSync(OriginalVWMFile);
|
||||
|
||||
var jsonFileInhalt = parser.toJson(content);
|
||||
var jsonContent = JSON.parse(jsonFileInhalt);
|
||||
|
||||
var i;
|
||||
var RoomId;
|
||||
var NeighborRoomRoomId;
|
||||
var index;
|
||||
|
||||
console.log(Object.keys(jsonContent.BuildingVulnerability.Rooms.Room).length + " Rooms detected");
|
||||
|
||||
for (i = 0; i < Object.keys(jsonContent.BuildingVulnerability.Rooms.Room).length; i++) {
|
||||
// Reduzierung auf die Etage
|
||||
console.log("RaumID" + jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId);
|
||||
RoomId = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId / 100);
|
||||
// console.log(RoomId);
|
||||
var j;
|
||||
// console.log(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms);
|
||||
// Test, ob ein Raum keine Nachbarraeume hat. Wenn dann entfernen
|
||||
if (!jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom) {
|
||||
console.log("Element RoomId " + jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId + " wird entfernt");
|
||||
delete jsonContent.BuildingVulnerability.Rooms.Room[i];
|
||||
} else {
|
||||
// console.log(Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[0].NeighborRooms.NeighborRoom).length);
|
||||
for (j = 0; j < Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom).length; j++) {
|
||||
|
||||
// console.log(jsonContent.BuildingVulnerability.Rooms.Room[0].NeighborRooms.NeighborRoom.NeighborRoom.RoomId);
|
||||
// Test, ob Raeume in der gleiche Etage liegen. Wenn nicht dann Transistion Faktoren einschreiben
|
||||
if (Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom).length == 1) {
|
||||
index = i;
|
||||
NeighborRoomRoomId = jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom.RoomId;
|
||||
NeighborRoomId = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom.RoomId / 100);
|
||||
if (RoomId != NeighborRoomId)
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom.TransitionFactor = TransitionFactor_vertical;
|
||||
if (RoomId == NeighborRoomId) {
|
||||
if (jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom.TransitionFactor <= TransitionFactor_horizontal_min_limit)
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom.TransitionFactor = TransitionFactor_horizontal_min;
|
||||
}
|
||||
} else {
|
||||
if (typeof jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j] !== 'undefined') {
|
||||
NeighborRoomId = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j].RoomId / 100);
|
||||
|
||||
if (RoomId != NeighborRoomId)
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j].TransitionFactor = TransitionFactor_vertical;
|
||||
if (RoomId == NeighborRoomId) {
|
||||
// if (jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j].TransitionFactor <= TransitionFactor_horizontal_min_limit)
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j].TransitionFactor = TransitionFactor_horizontal_min;
|
||||
}
|
||||
} else {
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.TransitionFactor = TransitionFactor_vertical;
|
||||
}
|
||||
|
||||
|
||||
} // end if
|
||||
// end for
|
||||
} // end else
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// delete jsonContent.BuildingVulnerability.Rooms.Room[index].NeighborRooms.NeighborRoom.NeighborRoom;
|
||||
// jsonContent.BuildingVulnerability.Rooms.Room[index].NeighborRooms.NeighborRoom["TransitionFactor"] = TransitionFactor_vertical;
|
||||
// jsonContent.BuildingVulnerability.Rooms.Room[index].NeighborRooms.NeighborRoom["RoomId"] = NeighborRoomRoomId;
|
||||
|
||||
|
||||
var Rooms = jsonContent.BuildingVulnerability;
|
||||
|
||||
var ausgabe = js2xmlparser.parse("BuildingVulnerability", Rooms);
|
||||
var formattedXml = format(ausgabe, {
|
||||
collapseContent: true,
|
||||
lineSeparator: '\n'
|
||||
});
|
||||
|
||||
|
||||
fs.writeFile(VWMFileNeu, formattedXml, function (err) {
|
||||
console.log(VWMFileNeu + " Datei geschrieben"); // Datei geschrieben
|
||||
});
|
||||
Vendored
Executable
+122
@@ -0,0 +1,122 @@
|
||||
// $Id$
|
||||
// $HeadURL$
|
||||
// $Author$
|
||||
// Created by Manfred Gronak, , 2021-05
|
||||
|
||||
var fs = require("fs");
|
||||
var parser = require('xml2json');
|
||||
|
||||
module.exports = function() {
|
||||
|
||||
this.VwmXmlToWrl = function VwmXmlToWrl(OriginalxmlFile) {
|
||||
console.log(" VwmXmlToWrl: "+ OriginalxmlFile); // Datei geschrieben
|
||||
|
||||
// if (OriginalxmlFile.includes("bldg_1287.flt.VWM_Building.xml")) {
|
||||
// console.log(" Skip VwmXmlToWrl: "+ OriginalxmlFile); // Datei geschrieben
|
||||
// } else {
|
||||
// return;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
var coordIndex = "]\n}\ncoordIndex [ ";
|
||||
var counter = 0;
|
||||
|
||||
var wrl_filename = OriginalxmlFile + ".wrl";
|
||||
|
||||
var content = fs.readFileSync(OriginalxmlFile);
|
||||
var jsonFileInhalt = parser.toJson(content);
|
||||
var jsonContent = JSON.parse(jsonFileInhalt);
|
||||
var i;
|
||||
|
||||
var resultfile = "#VRML V2.0 utf8\nBackground {\nskyColor 0.2 0.3 0.1}\nTransform {\ntranslation -2.5 -2.5 -2.5\n"
|
||||
resultfile = resultfile + "children [\n Shape {\nappearance Appearance {\nmaterial Material {\n";
|
||||
resultfile = resultfile + "diffuseColor 1 0 1\n}\n}\ngeometry IndexedFaceSet {\nsolid FALSE\n";
|
||||
resultfile = resultfile + "coord Coordinate {\npoint [\n";
|
||||
|
||||
var RoomArray = jsonContent.BuildingVulnerability.Rooms.Room;
|
||||
if (RoomArray == null) {
|
||||
console.log("Datei " + OriginalxmlFile + ": " + " WARNING, no RoomArray detected");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Array.isArray(RoomArray)) {
|
||||
// console.log("1Array: ");
|
||||
} else {
|
||||
// No Array..
|
||||
// wrap obj into an array to ensure 'RoomArray.forEach(...'
|
||||
var dummy = new Array;
|
||||
dummy[0] = RoomArray;
|
||||
RoomArray = dummy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RoomArray.forEach(Room => {
|
||||
|
||||
var OuterWallArray = Room.RoomOuterWalls.OuterWall;
|
||||
|
||||
if (Array.isArray(OuterWallArray)) {
|
||||
|
||||
OuterWallArray.forEach(Outerwall => {
|
||||
// console.log("Array: " + Outerwall.OuterWallAreaElement);
|
||||
var n = 0;
|
||||
var PolygonPoints = Outerwall.OuterWallAreaElement.PolygonPoint;
|
||||
|
||||
PolygonPoints.forEach(PolygonPoint => {
|
||||
// console.log(PolygonPoint.X + " " + PolygonPoint.Y + " " + PolygonPoint.Z) ;
|
||||
resultfile = resultfile + PolygonPoint.X + " " + PolygonPoint.Y + " " + PolygonPoint.Z + ",\n";
|
||||
|
||||
n = n + 1;
|
||||
counter = counter + 1;
|
||||
})
|
||||
|
||||
for (i = counter - n; i < counter; i++) {
|
||||
coordIndex = coordIndex + " " + i + ",";
|
||||
}
|
||||
coordIndex = coordIndex + " -1\n";
|
||||
});
|
||||
|
||||
} else {
|
||||
// console.log("NoArray: " + OuterWallArray);
|
||||
|
||||
if (OuterWallArray != undefined) {
|
||||
// RoomArray is object:
|
||||
// that means OuterWallArray could be used as (a single) Outerwall
|
||||
// console.log("OBJ" + OuterWallArray);
|
||||
|
||||
var n = 0;
|
||||
var PolygonPoints = OuterWallArray.OuterWallAreaElement.PolygonPoint;
|
||||
|
||||
PolygonPoints.forEach(PolygonPoint => {
|
||||
// console.log(PolygonPoint.X + " " + PolygonPoint.Y + " " + PolygonPoint.Z) ;
|
||||
resultfile = resultfile + PolygonPoint.X + " " + PolygonPoint.Y + " " + PolygonPoint.Z + ",\n";
|
||||
|
||||
n = n + 1;
|
||||
counter = counter + 1;
|
||||
})
|
||||
|
||||
for (i = counter - n; i < counter; i++) {
|
||||
coordIndex = coordIndex + " " + i + ",";
|
||||
}
|
||||
coordIndex = coordIndex + " -1\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
resultfile = resultfile + coordIndex;
|
||||
resultfile = resultfile + " ]\n}\n}\n]\n}\n";
|
||||
|
||||
fs.writeFileSync(wrl_filename, resultfile, function(err) {
|
||||
// If an error occurred, show it
|
||||
if(err)
|
||||
{
|
||||
console.log("Error on writing file: " + wrl_filename);
|
||||
console.err(err);
|
||||
}
|
||||
});
|
||||
|
||||
} // end of function
|
||||
} // export
|
||||
Vendored
Executable
+86
@@ -0,0 +1,86 @@
|
||||
// $Id$
|
||||
// $HeadURL$
|
||||
// $Author$
|
||||
// Created by Manfred Gronak, 2021-03
|
||||
|
||||
var fs = require("fs");
|
||||
var parser = require('xml2json');
|
||||
var util = require('util');
|
||||
|
||||
|
||||
|
||||
if (process.argv.length === 2) {
|
||||
console.error('Filename for VWM expected');
|
||||
process.exit(1);
|
||||
}
|
||||
const OriginalxmlFile = process.argv[2];
|
||||
|
||||
|
||||
|
||||
var content = fs.readFileSync(OriginalxmlFile);
|
||||
|
||||
var jsonFileInhalt = parser.toJson(content);
|
||||
|
||||
|
||||
var jsonContent = JSON.parse(jsonFileInhalt);
|
||||
|
||||
var i;
|
||||
|
||||
for (i = 0; i < Object.keys(jsonContent.BuildingVulnerability.Rooms.Room).length; i++) {
|
||||
|
||||
// console.log("1 SHGGS " + j + "-" + util.inspect(jsonContent.BuildingVulnerability.Rooms.Room, {showHidden: false, depth: 1}));
|
||||
|
||||
var RoomId = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId - 2000);
|
||||
RoomId = ~~(RoomId % 100);
|
||||
|
||||
var floor = ~~(jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId - 2000);
|
||||
floor = ~~(floor / 100);
|
||||
|
||||
if (RoomId == 1)
|
||||
console.log("***** floor=" + floor);
|
||||
|
||||
console.log(jsonContent.BuildingVulnerability.Rooms.Room[i].RoomId);
|
||||
|
||||
|
||||
|
||||
if (!jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom) {
|
||||
console.log("Keine NeighborRooms - muss entfernt werden");
|
||||
} else {
|
||||
|
||||
// console.log("2 SHGGS " + j + "-" + util.inspect(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom, {showHidden: false, depth: 1}));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (!Array.isArray(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom)) {
|
||||
// wrap obj into an array
|
||||
var dummy = new Array;
|
||||
dummy[0] = jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom;
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom = dummy;
|
||||
}
|
||||
|
||||
// console.log("Keine NeighborRooms - else" + Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom).length);
|
||||
|
||||
if (!Array.isArray(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom)) {
|
||||
// wrap obj into an array
|
||||
var dummy = new Array;
|
||||
dummy[0] = jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom;
|
||||
jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom = dummy;
|
||||
}
|
||||
|
||||
var j;
|
||||
for (j = 0; j < Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom).length; j++) {
|
||||
if (!jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j])
|
||||
continue;
|
||||
// console.log("XXX" + jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom);
|
||||
|
||||
// if (Object.keys(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom).length == 1) {
|
||||
// console.log(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom.NeighborRoom);
|
||||
// } else {
|
||||
console.log(jsonContent.BuildingVulnerability.Rooms.Room[i].NeighborRooms.NeighborRoom[j]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user