maintain.js 4.29 KB
import maps from './mapUtils'

let SGWorld;
export default {
  methods: {
    getMap: {
      tree: {el: 'object', id: 'TerraExplorerInformationWindow', classid: 'CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1', style: { width: '10%', height: '100%'}}, 
      map: {el: 'object', id: 'TerraExplorer3DWindow', classid: "CLSID:3a4f9192-65a8-11d5-85c1-0001023952c1", style: { width: '90%', height: '100%' }}, 
      sgword: {el: 'object', id: 'SGWorld', classid: 'CLSID:3A4F919C-65A8-11D5-85C1-0001023952C1', style: { width: '1px', height: '1px' }}
    },
    getTree() {
      if(!(SGWorld = maps.sgWorld)) return;
      let tree = SGWorld.ProjectTree, current = tree.GetNextItem(SGWorld.ProjectTree.RootID, 18), child = undefined,
        arr = [{id : current, label : tree.GetItemName(current), children : []}], calculation = [current], last = [],
        position = {[current] : [0]}, index = 1,
      func = (a = 13) => {
        a === 11 && (child = []);
        while(current) {
          current = tree.GetNextItem(current, a);
          if(current)
            Object.prototype.toString.call(child) !== '[object Array]' ?
              arr.push({id : current, label : tree.GetItemName(current), children : []}) :
              (() => {
                let evalstr = 'arr', i = 0;
                for( ; i < last.length ; i++ ) evalstr += '[last['+i+']].children';
                evalstr += '.push({id : current, label : tree.GetItemName(current), children : []})'
                eval(evalstr);
              })(),
              calculation.push(current),
              position[current] = last.concat([index++]);
          a = 13;
        }
        for( ; current = calculation.shift() ; )
          if(tree.IsGroup(current)) {
            last = position[current];
            index = 0;
            func(11);
            break;
          }
      };
      func();
      return arr;
    },
    menu () {
      return {
        main : [
          {text : '新建组', func : 'ProjectTree.CreateGroup', args : ['新建组'], callback : 'Initialization'},
          {text : '加载矢量图层', func : 'Command.Execute', args : [1013, 5], callback : 'Initialization'},
          {text : '加载影像图层', func : 'Command.Execute', args : [1014, 2], callback : 'Initialization'},
          {text : '加载高程图层', func : 'Command.Execute', args : [1014, 19], callback : 'Initialization'},
          {text : '加载Kml图层', func : 'Command.Execute', args : [1013, 3], callback : 'Initialization'},
          {text : '加载3D网格图层', func : 'Command.Execute', args : [2110, 0], callback : 'Initialization'},
          {key : 'interest', text : '兴趣点', func : 'ProjectTree.CreateGroup', args : ['兴趣点'], callback : 'Initialization'},
          // {key : 'animation', text : '演示工具', func : 'ProjectTree.CreateGroup', args : ['演示工具'], callback : 'Initialization'},
          // this.presentation = maps.sgWorld.Creator.CreatePresentation(maps.sgWorld.ProjectTree.RootID, "自建飞行轨迹");
          {text : '演示工具', func : 'Creator.CreatePresentation', args : ['.RootID', '演示工具'], callback : 'playback'},
          {text : '树信息', func : 'Navigate.FlyTo', args : ['.id', 0]}
        ],
        public : [
          {text : '飞行到图层', func : 'Navigate.FlyTo', args : ['.id', 0]},
          {text : '跳转到图层', func : 'Navigate.FlyTo', args : ['.id', 0]},
          {text : '刷新图层', func : 'Navigate.FlyTo', args : ['.id', 0]},
          {text : '删除', func : 'ProjectTree.DeleteItem', args : ['.id'], callback : 'Initialization'},
          // {text : '重命名', func : 'ProjectTree.RenameGroup', args : ['.id', 'aaa']},
          {text : '属性表', func : 'Command.Execute', args : [1086, 0]},
          {text : '另存为', func : 'Command.Execute', args : [1089, 0]},
          {text : '属性', func : 'ProjectTree.EditItem', args : ['.id', 0]}
        ],
        play : [
          {text : '添加兴趣点', func : 'Command.Execute', args : [1099, 0]},
          {text : '播放漫游路线', args : [], callback : 'play'},
          {text : '停止', func : 'Command.Execute', args : [1113, 0]},
          {text : '上一个节点', func : 'Command.Execute', args : [1114, 0]},
          {text : '下一个节点', func : 'Command.Execute', args : [1115, 0]}
        ]
      }
    }
  }
}