|
@@ -1,4 +1,10 @@
|
|
-import { SParser } from "@saga-web/big/lib/parser/SParser";
|
|
|
|
|
|
+import { SItemFactory, SParser } from "@saga-web/big/lib";
|
|
|
|
+// @ts-ignore
|
|
|
|
+import fengmap from "fengmap";
|
|
|
|
+import { Space } from "@saga-web/big/lib/types/floor/Space";
|
|
|
|
+import { Column } from "@saga-web/big/lib/types/floor/Column";
|
|
|
|
+import { VirtualWall } from "@saga-web/big/lib/types/floor/VirtualWall";
|
|
|
|
+import { Wall } from "@saga-web/big/lib/types/floor/Wall";
|
|
|
|
|
|
/**
|
|
/**
|
|
* 蜂鸟数据解析器
|
|
* 蜂鸟数据解析器
|
|
@@ -59,5 +65,194 @@ export class SFengParser extends SParser {
|
|
120008: "ParkingExit",
|
|
120008: "ParkingExit",
|
|
120009: "ParkingEntrance",
|
|
120009: "ParkingEntrance",
|
|
120010: "ParkingExitAndEntrance"
|
|
120010: "ParkingExitAndEntrance"
|
|
- };
|
|
|
|
|
|
+ };
|
|
|
|
+ /** 蜂鸟:底图应用名称 */
|
|
|
|
+ appName: string = "";
|
|
|
|
+ /** 当前蜂鸟map的id */
|
|
|
|
+ currentMapId: string = "";
|
|
|
|
+ /** 蜂鸟map绑定dom的id */
|
|
|
|
+ domId: string = "";
|
|
|
|
+ /** 蜂鸟:底图应用秘钥 */
|
|
|
|
+ key: string = "";
|
|
|
|
+ /** 底图服务器地址 */
|
|
|
|
+ serverUrl: string = "./data/";
|
|
|
|
+ /** 蜂鸟图 */
|
|
|
|
+ private readonly fmap: fengmap.FMMap;
|
|
|
|
+ /** 属于空间类型typeid */
|
|
|
|
+ spaceType: number[] = [
|
|
|
|
+ 100000,
|
|
|
|
+ 200000,
|
|
|
|
+ 900000,
|
|
|
|
+ 800000,
|
|
|
|
+ 200004,
|
|
|
|
+ 200003,
|
|
|
|
+ 200103,
|
|
|
|
+ 200203,
|
|
|
|
+ 200005,
|
|
|
|
+ 200002,
|
|
|
|
+ 200006,
|
|
|
|
+ 200007,
|
|
|
|
+ 200017,
|
|
|
|
+ 200018,
|
|
|
|
+ 200019,
|
|
|
|
+ 200020,
|
|
|
|
+ 200014,
|
|
|
|
+ 200009,
|
|
|
|
+ 200008,
|
|
|
|
+ 200011,
|
|
|
|
+ 200012,
|
|
|
|
+ 200013,
|
|
|
|
+ 200015,
|
|
|
|
+ 200016,
|
|
|
|
+ 200021,
|
|
|
|
+ 170006,
|
|
|
|
+ 170008,
|
|
|
|
+ 170007,
|
|
|
|
+ 170003,
|
|
|
|
+ 170001,
|
|
|
|
+ 100001,
|
|
|
|
+ 100004,
|
|
|
|
+ 100005,
|
|
|
|
+ 100007,
|
|
|
|
+ 140002,
|
|
|
|
+ 170002,
|
|
|
|
+ 150010,
|
|
|
|
+ 100003,
|
|
|
|
+ 140004,
|
|
|
|
+ 170005,
|
|
|
|
+ 120001
|
|
|
|
+ ];
|
|
|
|
+ /** 属于柱子类型的typeid */
|
|
|
|
+ columnType: number[] = [300002];
|
|
|
|
+ /** 属于墙类型的typeid */
|
|
|
|
+ wallType: number[] = [300000, 300001];
|
|
|
|
+ /** 属于虚拟墙类型的typeid */
|
|
|
|
+ virtualWallType: number[] = [
|
|
|
|
+ 200001,
|
|
|
|
+ 110001,
|
|
|
|
+ 200010,
|
|
|
|
+ 120008,
|
|
|
|
+ 120009,
|
|
|
|
+ 120010
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ /** 构造体 */
|
|
|
|
+ constructor(
|
|
|
|
+ domId: string,
|
|
|
|
+ mapServerURL: string,
|
|
|
|
+ key: string,
|
|
|
|
+ appName: string,
|
|
|
|
+ factory: SItemFactory
|
|
|
|
+ ) {
|
|
|
|
+ super(factory);
|
|
|
|
+ this.domId = domId;
|
|
|
|
+ this.key = key;
|
|
|
|
+ this.serverUrl = mapServerURL;
|
|
|
|
+ this.appName = appName;
|
|
|
|
+ this.fmap = new fengmap.FMMap({
|
|
|
|
+ container: document.getElementById(this.domId),
|
|
|
|
+ mapServerURL: this.serverUrl,
|
|
|
|
+ appName: this.appName,
|
|
|
|
+ key: this.key
|
|
|
|
+ });
|
|
|
|
+ } // Constructor
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 解析数据
|
|
|
|
+ *
|
|
|
|
+ * @param currentMapId 当前模型id
|
|
|
|
+ * @param groupId 当前楼层
|
|
|
|
+ * @param _fn 查询成功回调函数(返回参数为FloorData)
|
|
|
|
+ * */
|
|
|
|
+ parseData(currentMapId: string, groupId: string, _fn: Function): void {
|
|
|
|
+ this.fmap.openMapById(currentMapId, (err: any) => {
|
|
|
|
+ console.log("错误信息", err);
|
|
|
|
+ });
|
|
|
|
+ this.fmap.on("loadComplete", () => {
|
|
|
|
+ let obj = {};
|
|
|
|
+ // 创建搜索分析对象
|
|
|
|
+ let searchAnalyser = new fengmap.FMSearchAnalyser(this.fmap);
|
|
|
|
+ // 创建搜索请求体对象
|
|
|
|
+ let searchReq = new fengmap.FMSearchRequest();
|
|
|
|
+ searchReq.groupID = groupId;
|
|
|
|
+ searchReq.type = "Model";
|
|
|
|
+ searchAnalyser.query(searchReq, (result: any) => {
|
|
|
|
+ let spaces: Space[] = [],
|
|
|
|
+ columns: Column[] = [],
|
|
|
|
+ walls: Wall[] = [],
|
|
|
|
+ virtualWall: VirtualWall[] = [];
|
|
|
|
+ result = result
|
|
|
|
+ .map((t: any) => {
|
|
|
|
+ if (
|
|
|
|
+ t.target &&
|
|
|
|
+ t.target._data &&
|
|
|
|
+ t.target._data.vertices
|
|
|
|
+ ) {
|
|
|
|
+ let arr = t.target._data.vertices,
|
|
|
|
+ type = t.typeID,
|
|
|
|
+ outline = [];
|
|
|
|
+ for (let i = 0; i < arr.length - 1; i += 2) {
|
|
|
|
+ outline.push({
|
|
|
|
+ X: arr[i] - 12982584.99,
|
|
|
|
+ Y: arr[i + 1] - 4911901.56
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (this.spaceType.indexOf(type) > -1) {
|
|
|
|
+ spaces.push({
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ OutLine: [outline],
|
|
|
|
+ Name: t.target.name,
|
|
|
|
+ Location: {
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ Points: [this.getAverageVal([outline])]
|
|
|
|
+ },
|
|
|
|
+ Type: t.typeID
|
|
|
|
+ });
|
|
|
|
+ } else if (this.columnType.indexOf(type) > -1) {
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ columns.push({ OutLine: [outline] });
|
|
|
|
+ } else if (this.wallType.indexOf(type) > -1) {
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ walls.push({ OutLine: [outline] });
|
|
|
|
+ } else if (
|
|
|
|
+ this.virtualWallType.indexOf(type) > -1
|
|
|
|
+ ) {
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ virtualWall.push({ OutLine: [outline] });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .filter((item: any) => item);
|
|
|
|
+ obj = {
|
|
|
|
+ Spaces: spaces,
|
|
|
|
+ Columns: columns,
|
|
|
|
+ Walls: walls,
|
|
|
|
+ VirtualWalls: virtualWall
|
|
|
|
+ };
|
|
|
|
+ _fn(obj);
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 计算平均值
|
|
|
|
+ *
|
|
|
|
+ * @param Outline 轮廓线束
|
|
|
|
+ * @return object {X:X,Y:Y}x的平均值,y的平均值
|
|
|
|
+ * */
|
|
|
|
+ private getAverageVal(Outline: { X: number; Y: number }[][]): object {
|
|
|
|
+ let X = 0,
|
|
|
|
+ Y = 0,
|
|
|
|
+ len = Outline[0].length;
|
|
|
|
+ Outline[0].map(item => {
|
|
|
|
+ X += item.X;
|
|
|
|
+ Y += item.Y;
|
|
|
|
+ });
|
|
|
|
+ X = Number((X / len).toFixed(2));
|
|
|
|
+ Y = Number((Y / len).toFixed(2));
|
|
|
|
+ return {
|
|
|
|
+ X: X,
|
|
|
|
+ Y: Y
|
|
|
|
+ };
|
|
|
|
+ }
|
|
} // class SEquipParser
|
|
} // class SEquipParser
|