利用instanceTree倒推退出dbId
/**
* elid转换dbid
* @param elIds {Array}
* @returns dbIds {Array}
*/
elIdToDbId(elIds){
let itNodeAccess = this.viewer.model.getData().instanceTree.nodeAccess;
let dbIds=[];
elIds.forEach(elId=>{
let elIdIndex = itNodeAccess.nameSuffixes.indexOf(elId);
let dbId = this.findKeyByValue(elIdIndex,itNodeAccess.dbIdToIndex);
dbIds.push(dbId)
})
return dbIds;
}
/**
*
* @param value value 值
* @param data 对象
* @param compare
* @returns {string} 对象的key
*/
findKeyByValue (value,data, compare = (a, b) => a === b) {
return Object.keys(data).find(k => compare(data[k], value))
}
/**
* dbid转换elid
* @param dbIds {Array}
* @returns elIds {Array}
*/
dbIdToElId(dbIds){
const it = this.viewer.model.getData().instanceTree;
let elIds=[];
dbIds.forEach(dbId=>{
let dbIdIndex = it.nodeAccess.dbIdToIndex[dbId];
let elId = it.nodeAccess.nameSuffixes[dbIdIndex];
elIds.push(elId)
})
return elIds;
}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。