|
@@ -106,7 +106,7 @@ export class SFengParser extends SParser {
|
|
|
/** 蜂鸟:底图应用名称 */
|
|
|
appName: string = "";
|
|
|
/** 当前蜂鸟map的id */
|
|
|
- currentMapId: string = "";
|
|
|
+ mapId: string = "";
|
|
|
/** 蜂鸟map绑定dom的id */
|
|
|
domId: string = "";
|
|
|
/** 蜂鸟:底图应用秘钥 */
|
|
@@ -236,18 +236,85 @@ export class SFengParser extends SParser {
|
|
|
/**
|
|
|
* 解析数据
|
|
|
*
|
|
|
- * @param currentMapId 当前模型id
|
|
|
- * @param groupId 当前楼层(前台传入为gname)
|
|
|
+ * @param groupId 当前楼层((前台传入为gname))
|
|
|
* @param _fn 查询成功回调函数(返回参数为FloorData)
|
|
|
* */
|
|
|
- parseData(currentMapId: string, groupId: string, _fn: Function): void {
|
|
|
- // TODO 同一地图不需要重复加载
|
|
|
- this.fmap.openMapById(currentMapId, (err: any) => {
|
|
|
+ parseData(groupId: string, _fn: Function): void {
|
|
|
+ let obj = {};
|
|
|
+ // 切换至当前楼层才可查询
|
|
|
+ this.fmap.focusGroupID = groupId;
|
|
|
+ // 创建搜索分析对象
|
|
|
+ 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,
|
|
|
+ // @ts-ignore
|
|
|
+ Tag: SFengParser.typeIdMap[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 mapId 蜂鸟地图id
|
|
|
+ * @param _fn load成功回调
|
|
|
+ * */
|
|
|
+ loadMap(mapId: string, _fn: Function): void {
|
|
|
+ this.fmap.openMapById(mapId, (err: any): void => {
|
|
|
console.log("错误信息", err);
|
|
|
});
|
|
|
- this.fmap.on("loadComplete", () => {
|
|
|
- if (this.currentMapId != currentMapId) {
|
|
|
- this.currentMapId = currentMapId;
|
|
|
+ this.fmap.on("loadComplete", (): void => {
|
|
|
+ if (this.mapId != mapId) {
|
|
|
+ this.mapId = mapId;
|
|
|
this.gnameToGid = {};
|
|
|
// @ts-ignore
|
|
|
this.fmap.listGroups.forEach(t => {
|
|
@@ -255,80 +322,9 @@ export class SFengParser extends SParser {
|
|
|
this.gnameToGid[t.gname] = t.gid;
|
|
|
});
|
|
|
}
|
|
|
- let obj = {};
|
|
|
- // @ts-ignore
|
|
|
- groupId = this.gnameToGid[groupId];
|
|
|
- if (!groupId) {
|
|
|
- _fn({ err: "楼层不正确" });
|
|
|
- return;
|
|
|
- }
|
|
|
- // 切换至当前楼层才可查询
|
|
|
- this.fmap.focusGroupID = groupId;
|
|
|
- // 创建搜索分析对象
|
|
|
- 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,
|
|
|
- // @ts-ignore
|
|
|
- Tag: SFengParser.typeIdMap[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);
|
|
|
- });
|
|
|
+ _fn(this.gnameToGid);
|
|
|
});
|
|
|
- }
|
|
|
+ } // Function loadMap()
|
|
|
|
|
|
/**
|
|
|
* 计算平均值
|