|
@@ -1,528 +1,543 @@
|
|
-import { floorplanData } from '../FloorplanData'
|
|
|
|
-import { coordinate } from '../Coordinate.js'
|
|
|
|
-import Constant from '../Constant'
|
|
|
|
|
|
+import { floorplanData } from "../FloorplanData";
|
|
|
|
+import { coordinate } from "../Coordinate.js";
|
|
|
|
+import Constant from "../Constant";
|
|
|
|
|
|
-import Title from '../Geometry/Title.js'
|
|
|
|
-import BgImage from '../Geometry/BgImage.js'
|
|
|
|
-import Compass from '../Geometry/Compass.js'
|
|
|
|
|
|
+import Title from "../Geometry/Title.js";
|
|
|
|
+import BgImage from "../Geometry/BgImage.js";
|
|
|
|
+import Compass from "../Geometry/Compass.js";
|
|
|
|
|
|
export class FloorplanService {
|
|
export class FloorplanService {
|
|
- constructor() {
|
|
|
|
- this.currentId = 0 // 当前可用id
|
|
|
|
- this.currentFloor = 0 // 当前楼层,第一层是0
|
|
|
|
- this.angle = 0 //旋转角度
|
|
|
|
|
|
+ constructor() {
|
|
|
|
+ this.currentId = 0; // 当前可用id
|
|
|
|
+ this.currentFloor = 0; // 当前楼层,第一层是0
|
|
|
|
+ this.angle = 0; //旋转角度
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setCurrentId(id) {
|
|
|
|
+ this.currentId = id;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getCurrentId() {
|
|
|
|
+ return this.currentId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updateCurrentId() {
|
|
|
|
+ ++this.currentId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setCurrentFloor(floor) {
|
|
|
|
+ if (floorplanData.floors.length == 1) {
|
|
|
|
+ this.currentFloor = 0;
|
|
|
|
+ } else {
|
|
|
|
+ this.currentFloor = floor;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getCurrentFloor() {
|
|
|
|
+ return this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getFloorNum() {
|
|
|
|
+ return floorplanData.floors.length;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ initFloor(floorNum) {
|
|
|
|
+ floorplanData.initFloor(floorNum);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getFloors() {
|
|
|
|
+ return floorplanData.floors;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getPoint(pointId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ return floorplanData.floors[floor].points[pointId];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ deletePoint(pointId, wallId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ let point = this.getPoint(pointId);
|
|
|
|
+ //有可能先删除墙,导致点没了
|
|
|
|
+ if (point) {
|
|
|
|
+ if (Object.keys(point.parent).length == 0) {
|
|
|
|
+ point = null;
|
|
|
|
+ delete floorplanData.floors[floor].points[pointId];
|
|
|
|
+ } else if (Object.keys(point.parent).length == 1 && !wallId) {
|
|
|
|
+ delete floorplanData.floors[floor].points[pointId];
|
|
|
|
+ } else if (
|
|
|
|
+ Object.keys(point.parent).length == 1 &&
|
|
|
|
+ point.parent[wallId]
|
|
|
|
+ ) {
|
|
|
|
+ delete floorplanData.floors[floor].points[pointId];
|
|
|
|
+ } else if (
|
|
|
|
+ Object.keys(point.parent).length == 1 &&
|
|
|
|
+ !point.parent[wallId]
|
|
|
|
+ ) {
|
|
|
|
+ return;
|
|
|
|
+ } else {
|
|
|
|
+ delete point.parent[wallId];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getWall(wallId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ return floorplanData.floors[floor].walls[wallId];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ deleteWall(wallId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ let wall = this.getWall(wallId, floor);
|
|
|
|
+
|
|
|
|
+ this.deletePoint(wall.start, wallId, floor);
|
|
|
|
+ this.deletePoint(wall.end, wallId, floor);
|
|
|
|
+ delete floorplanData.floors[floor].walls[wallId];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getAngle() {
|
|
|
|
+ return this.angle;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setAngle(angle) {
|
|
|
|
+ this.angle = angle;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getFloorData(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ return floorplanData.floors[floor];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getWalls(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
-
|
|
|
|
- setCurrentId(id) {
|
|
|
|
- this.currentId = id
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getCurrentId() {
|
|
|
|
- return this.currentId
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- updateCurrentId() {
|
|
|
|
- ++this.currentId
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- setCurrentFloor(floor) {
|
|
|
|
- if (floorplanData.floors.length == 1) {
|
|
|
|
- this.currentFloor = 0
|
|
|
|
- } else {
|
|
|
|
- this.currentFloor = floor
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getCurrentFloor() {
|
|
|
|
- return this.currentFloor
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getFloorNum() {
|
|
|
|
- return floorplanData.floors.length
|
|
|
|
|
|
+ return floorplanData.floors[floor].walls;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getPoints(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].points;
|
|
|
|
+ }
|
|
|
|
|
|
- initFloor(floorNum) {
|
|
|
|
- floorplanData.initFloor(floorNum)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getFloors() {
|
|
|
|
- return floorplanData.floors
|
|
|
|
- }
|
|
|
|
|
|
+ addWall(wall, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ floorplanData.floors[floor].walls[wall.vectorId] = wall;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ addPoint(point, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ floorplanData.floors[floor].points[point.vectorId] = point;
|
|
|
|
+ }
|
|
|
|
|
|
- getPoint(pointId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].points[pointId]
|
|
|
|
|
|
+ addRectangle(rectangle, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].rectangles[rectangle.vectorId] = rectangle;
|
|
|
|
+ }
|
|
|
|
|
|
- deletePoint(pointId, wallId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let point = this.getPoint(pointId)
|
|
|
|
- //有可能先删除墙,导致点没了
|
|
|
|
- if (point) {
|
|
|
|
- if (Object.keys(point.parent).length == 0) {
|
|
|
|
- point = null
|
|
|
|
- delete floorplanData.floors[floor].points[pointId]
|
|
|
|
- } else if (Object.keys(point.parent).length == 1 && !wallId) {
|
|
|
|
- delete floorplanData.floors[floor].points[pointId]
|
|
|
|
- } else if (Object.keys(point.parent).length == 1 && point.parent[wallId]) {
|
|
|
|
- delete floorplanData.floors[floor].points[pointId]
|
|
|
|
- } else if (Object.keys(point.parent).length == 1 && !point.parent[wallId]) {
|
|
|
|
- return
|
|
|
|
- } else {
|
|
|
|
- delete point.parent[wallId]
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ getRectangle(rectangleId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].rectangles[rectangleId];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ deleteRectangle(rectangleId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ let rectangle = this.getRectangle(rectangleId, floor);
|
|
|
|
+ rectangle = null;
|
|
|
|
+ delete floorplanData.floors[floor].rectangles[rectangleId];
|
|
|
|
+ }
|
|
|
|
|
|
- getWall(wallId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].walls[wallId]
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- deleteWall(wallId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let wall = this.getWall(wallId, floor)
|
|
|
|
-
|
|
|
|
- this.deletePoint(wall.start, wallId, floor)
|
|
|
|
- this.deletePoint(wall.end, wallId, floor)
|
|
|
|
- delete floorplanData.floors[floor].walls[wallId]
|
|
|
|
|
|
+ addCircle(circle, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].circles[circle.vectorId] = circle;
|
|
|
|
+ }
|
|
|
|
|
|
- getAngle() {
|
|
|
|
- return this.angle
|
|
|
|
|
|
+ getCircle(circleId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].circles[circleId];
|
|
|
|
+ }
|
|
|
|
|
|
- setAngle(angle) {
|
|
|
|
- this.angle = angle
|
|
|
|
|
|
+ deleteCircle(circleId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ let circle = this.getCircle(circleId, floor);
|
|
|
|
+ circle = null;
|
|
|
|
+ delete floorplanData.floors[floor].circles[circleId];
|
|
|
|
+ }
|
|
|
|
|
|
- getFloorData(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor]
|
|
|
|
|
|
+ addArrow(arrow, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].arrows[arrow.vectorId] = arrow;
|
|
|
|
+ }
|
|
|
|
|
|
- getWalls(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].walls
|
|
|
|
|
|
+ getArrow(arrowId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].arrows[arrowId];
|
|
|
|
+ }
|
|
|
|
|
|
- getPoints(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].points
|
|
|
|
|
|
+ deleteArrow(arrowId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ let arrow = this.getArrow(arrowId, floor);
|
|
|
|
+ arrow = null;
|
|
|
|
+ delete floorplanData.floors[floor].arrows[arrowId];
|
|
|
|
+ }
|
|
|
|
|
|
- addWall(wall, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].walls[wall.vectorId] = wall
|
|
|
|
|
|
+ addIcon(icon, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].icons[icon.vectorId] = icon;
|
|
|
|
+ }
|
|
|
|
|
|
- addPoint(point, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].points[point.vectorId] = point
|
|
|
|
|
|
+ getIcon(iconId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].icons[iconId];
|
|
|
|
+ }
|
|
|
|
|
|
- addRectangle(rectangle,floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].rectangles[rectangle.vectorId] = rectangle
|
|
|
|
|
|
+ deleteIcon(iconId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ let icon = this.getIcon(iconId, floor);
|
|
|
|
+ icon = null;
|
|
|
|
+ delete floorplanData.floors[floor].icons[iconId];
|
|
|
|
+ }
|
|
|
|
|
|
- getRectangle(rectangleId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].rectangles[rectangleId]
|
|
|
|
|
|
+ addSign(sign, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].signs[sign.vectorId] = sign;
|
|
|
|
+ }
|
|
|
|
|
|
- deleteRectangle(rectangleId, floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let rectangle = this.getRectangle(rectangleId, floor)
|
|
|
|
- rectangle = null
|
|
|
|
- delete floorplanData.floors[floor].rectangles[rectangleId]
|
|
|
|
|
|
+ getSign(signId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].signs[signId];
|
|
|
|
+ }
|
|
|
|
|
|
- addCircle(circle,floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].circles[circle.vectorId] = circle
|
|
|
|
|
|
+ deleteSign(signId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ let sign = this.getSign(signId, floor);
|
|
|
|
+ sign = null;
|
|
|
|
+ delete floorplanData.floors[floor].signs[signId];
|
|
|
|
+ }
|
|
|
|
|
|
- getCircle(circleId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].circles[circleId]
|
|
|
|
|
|
+ addTag(tag, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].tags[tag.vectorId] = tag;
|
|
|
|
+ }
|
|
|
|
|
|
- deleteCircle(circleId, floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let circle = this.getCircle(circleId, floor)
|
|
|
|
- circle = null
|
|
|
|
- delete floorplanData.floors[floor].circles[circleId]
|
|
|
|
|
|
+ getTag(tagId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].tags[tagId];
|
|
|
|
+ }
|
|
|
|
|
|
- addArrow(arrow,floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].arrows[arrow.vectorId] = arrow
|
|
|
|
|
|
+ deleteTag(tagId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ let tag = this.getTag(tagId, floor);
|
|
|
|
+ tag = null;
|
|
|
|
+ delete floorplanData.floors[floor].tags[tagId];
|
|
|
|
+ }
|
|
|
|
|
|
- getArrow(arrowId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].arrows[arrowId]
|
|
|
|
|
|
+ getTags(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].tags;
|
|
|
|
+ }
|
|
|
|
|
|
- deleteArrow(arrowId, floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let arrow = this.getArrow(arrowId, floor)
|
|
|
|
- arrow = null
|
|
|
|
- delete floorplanData.floors[floor].arrows[arrowId]
|
|
|
|
|
|
+ addCustomImage(customImage, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].customImages[customImage.vectorId] =
|
|
|
|
+ customImage;
|
|
|
|
+ }
|
|
|
|
|
|
- addIcon(icon,floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].icons[icon.vectorId] = icon
|
|
|
|
|
|
+ getCustomImage(customImageId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].customImages[customImageId];
|
|
|
|
+ }
|
|
|
|
|
|
- getIcon(iconId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].icons[iconId]
|
|
|
|
|
|
+ deleteCustomImage(customImageId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ let customImage = this.getCustomImage(customImageId, floor);
|
|
|
|
+ customImage = null;
|
|
|
|
+ delete floorplanData.floors[floor].customImages[customImageId];
|
|
|
|
+ }
|
|
|
|
|
|
- deleteIcon(iconId, floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let icon = this.getIcon(iconId, floor)
|
|
|
|
- icon = null
|
|
|
|
- delete floorplanData.floors[floor].icons[iconId]
|
|
|
|
|
|
+ getBgImage(bgImageId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].bgImage;
|
|
|
|
+ }
|
|
|
|
|
|
- addSign(sign, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].signs[sign.vectorId] = sign
|
|
|
|
|
|
+ deleteBgImage(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].bgImage = {};
|
|
|
|
+ }
|
|
|
|
|
|
- getSign(signId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].signs[signId]
|
|
|
|
|
|
+ addBgImage(bgImage, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].bgImage = bgImage;
|
|
|
|
+ }
|
|
|
|
|
|
- deleteSign(signId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let sign = this.getSign(signId, floor)
|
|
|
|
- sign = null
|
|
|
|
- delete floorplanData.floors[floor].signs[signId]
|
|
|
|
|
|
+ addTable(table, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].tables[table.vectorId] = table;
|
|
|
|
+ }
|
|
|
|
|
|
- addTag(tag, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].tags[tag.vectorId] = tag
|
|
|
|
|
|
+ getTable(tableId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].tables[tableId];
|
|
|
|
+ }
|
|
|
|
|
|
- getTag(tagId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].tags[tagId]
|
|
|
|
|
|
+ deleteTable(tableId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ let table = this.getTable(tableId, floor);
|
|
|
|
+ table = null;
|
|
|
|
+ delete floorplanData.floors[floor].tables[tableId];
|
|
|
|
+ }
|
|
|
|
|
|
- deleteTag(tagId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let tag = this.getTag(tagId, floor)
|
|
|
|
- tag = null
|
|
|
|
- delete floorplanData.floors[floor].tags[tagId]
|
|
|
|
|
|
+ getTables(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].tables;
|
|
|
|
+ }
|
|
|
|
|
|
- getTags(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].tags
|
|
|
|
|
|
+ addCell(cell, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ floorplanData.floors[floor].cells[cell.vectorId] = cell;
|
|
|
|
+ }
|
|
|
|
|
|
- addCustomImage(customImage, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].customImages[customImage.vectorId] = customImage
|
|
|
|
|
|
+ getCell(cellId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].cells[cellId];
|
|
|
|
+ }
|
|
|
|
|
|
- getCustomImage(customImageId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].customImages[customImageId]
|
|
|
|
|
|
+ deleteCell(cellId, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ let cell = this.getCell(cellId, floor);
|
|
|
|
+ cell = null;
|
|
|
|
+ delete floorplanData.floors[floor].cells[cellId];
|
|
|
|
+ }
|
|
|
|
|
|
- deleteCustomImage(customImageId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let customImage = this.getCustomImage(customImageId, floor)
|
|
|
|
- customImage = null
|
|
|
|
- delete floorplanData.floors[floor].customImages[customImageId]
|
|
|
|
|
|
+ getCells(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].cells;
|
|
|
|
+ }
|
|
|
|
|
|
- getBgImage(bgImageId,floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].bgImage
|
|
|
|
|
|
+ getRectangles(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].rectangles;
|
|
|
|
+ }
|
|
|
|
|
|
- deleteBgImage(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].bgImage = {}
|
|
|
|
|
|
+ getCircles(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].circles;
|
|
|
|
+ }
|
|
|
|
|
|
- addBgImage(bgImage, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].bgImage = bgImage
|
|
|
|
|
|
+ getArrows(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].arrows;
|
|
|
|
+ }
|
|
|
|
|
|
- addTable(table, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].tables[table.vectorId] = table
|
|
|
|
|
|
+ getIcons(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
-
|
|
|
|
- getTable(tableId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].tables[tableId]
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- deleteTable(tableId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let table = this.getTable(tableId, floor)
|
|
|
|
- table = null
|
|
|
|
- delete floorplanData.floors[floor].tables[tableId]
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getTables(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].tables
|
|
|
|
|
|
+ return floorplanData.floors[floor].icons;
|
|
|
|
+ }
|
|
|
|
+ getSigns(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
}
|
|
}
|
|
|
|
+ return floorplanData.floors[floor].signs;
|
|
|
|
+ }
|
|
|
|
|
|
- addCell(cell, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].cells[cell.vectorId] = cell
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getCell(cellId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].cells[cellId]
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- deleteCell(cellId, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- let cell = this.getCell(cellId, floor)
|
|
|
|
- cell = null
|
|
|
|
- delete floorplanData.floors[floor].cells[cellId]
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getCells(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].cells
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getRectangles(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].rectangles
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getCircles(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].circles
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getArrows(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].arrows
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getIcons(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].icons
|
|
|
|
- }
|
|
|
|
- getSigns(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].signs
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getCustomImages(floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].customImages
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- clear() {
|
|
|
|
- if (floorplanData.floors[this.currentFloor]) {
|
|
|
|
- floorplanData.floors[this.currentFloor].points = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].walls = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].rectangles = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].circles = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].tags = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].tables = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].cells = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].signs = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].customImages = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].arrows = {}
|
|
|
|
- floorplanData.floors[this.currentFloor].icons = []
|
|
|
|
- floorplanData.floors[this.currentFloor].bgImage = {}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- deleteFloorData() {
|
|
|
|
- floorplanData.floors = []
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- createTitle(value,vectorId,floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- const title = new Title(value,vectorId,floor)
|
|
|
|
- return title
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- addTitle(title, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].title = title
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- updateTitle(value,floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- const title = floorplanData.floors[floor].title
|
|
|
|
- title.setValue(value)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- getTitle(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].title
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- createCompass(value,vectorId,floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- const compass = new Compass(value,vectorId,floor)
|
|
|
|
- return compass
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- addCompass(compass, floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- floorplanData.floors[floor].compass = compass
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- updateCompass(value,floor){
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- const compass = floorplanData.floors[floor].compass
|
|
|
|
- compass.setAngle(value)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // eslint-disable-next-line no-dupe-class-members
|
|
|
|
- getCompass(floor) {
|
|
|
|
- if (floor == null || typeof floor == 'undefined') {
|
|
|
|
- floor = this.currentFloor
|
|
|
|
- }
|
|
|
|
- return floorplanData.floors[floor].compass
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- async loadImageData(src){
|
|
|
|
- const imageData = await new Promise((resolve, reject) => {
|
|
|
|
- var img = new Image()
|
|
|
|
- img.src = src;
|
|
|
|
- img.crossOrigin=""
|
|
|
|
- img.onload = function () {
|
|
|
|
- resolve(img)
|
|
|
|
- }.bind(this)
|
|
|
|
- })
|
|
|
|
- return imageData
|
|
|
|
- }
|
|
|
|
|
|
+ getCustomImages(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ return floorplanData.floors[floor].customImages;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ clear() {
|
|
|
|
+ if (floorplanData.floors[this.currentFloor]) {
|
|
|
|
+ floorplanData.floors[this.currentFloor].points = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].walls = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].rectangles = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].circles = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].tags = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].tables = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].cells = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].signs = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].customImages = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].arrows = {};
|
|
|
|
+ floorplanData.floors[this.currentFloor].icons = [];
|
|
|
|
+ floorplanData.floors[this.currentFloor].bgImage = {};
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ deleteFloorData() {
|
|
|
|
+ floorplanData.floors = [];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ createTitle(value, vectorId, floor, noShow = false) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ const title = new Title(value, vectorId, floor, noShow);
|
|
|
|
+ return title;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ addTitle(title, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ floorplanData.floors[floor].title = title;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updateTitle(value, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ const title = floorplanData.floors[floor].title;
|
|
|
|
+ title.setValue(value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ getTitle(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ return floorplanData.floors[floor].title;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ createCompass(value, vectorId, floor, noShow = false) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ // debugger
|
|
|
|
+ const compass = new Compass(value, vectorId, floor, noShow);
|
|
|
|
+ return compass;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ addCompass(compass, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ floorplanData.floors[floor].compass = compass;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updateCompass(value, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ const compass = floorplanData.floors[floor].compass;
|
|
|
|
+ compass.setAngle(value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // eslint-disable-next-line no-dupe-class-members
|
|
|
|
+ getCompass(floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ return floorplanData.floors[floor].compass;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setBoardFrame(noBoardFrame, floor) {
|
|
|
|
+ if (floor == null || typeof floor == "undefined") {
|
|
|
|
+ floor = this.currentFloor;
|
|
|
|
+ }
|
|
|
|
+ floorplanData.floors[floor].noBoardFrame = noBoardFrame;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async loadImageData(src) {
|
|
|
|
+ const imageData = await new Promise((resolve, reject) => {
|
|
|
|
+ var img = new Image();
|
|
|
|
+ img.src = src;
|
|
|
|
+ img.crossOrigin = "";
|
|
|
|
+ img.onload = function () {
|
|
|
|
+ resolve(img);
|
|
|
|
+ }.bind(this);
|
|
|
|
+ });
|
|
|
|
+ return imageData;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
-const floorplanService = new FloorplanService()
|
|
|
|
-export { floorplanService }
|
|
|
|
|
|
+const floorplanService = new FloorplanService();
|
|
|
|
+export { floorplanService };
|