123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //墙的边缘线
- import Geometry from "./Geometry.js";
- import VectorType from "../enum/VectorType.js";
- import VectorWight from "../enum/VectorWeight.js";
- import VectorStyle from "../enum/VectorStyle.js";
- import { mathUtil } from "../Util/MathUtil.js";
- import { dataService } from "../Service/DataService.js";
- import Constant from "../Constant";
- import { coordinate } from "../Coordinate";
- export default class RoadEdge extends Geometry {
- constructor(start, end, vectorId, parentId) {
- super();
- this.parent = parentId;
- this.start = {};
- this.end = {};
- this.vectorId = null;
- this.style = VectorStyle.SingleSolidLine;
- this.weight = VectorWight.Thinning;
- this.geoType = VectorType.RoadEdge;
- this.lineWidth = 4;
- this.roadSide = null;
- this.setId(vectorId);
- this.setPositions(start, end);
- }
- setPositions(point1, point2) {
- this.start.x = point1.x;
- this.start.y = point1.y;
- this.end.x = point2.x;
- this.end.y = point2.y;
- }
- setPosition(position, dir) {
- if (dir == "start") {
- mathUtil.clonePoint(this.start, position);
- } else if (dir == "end") {
- mathUtil.clonePoint(this.end, position);
- }
- }
- setLineWidth(value) {
- this.lineWidth = value;
- }
- getPosition(dir) {
- if (dir == "start") {
- return this.start;
- } else if (dir == "end") {
- return this.end;
- } else {
- return null;
- }
- }
- getLine() {
- let line = mathUtil.createLine1(this.start, this.end);
- return line;
- }
- initRoadSide() {
- // let line = this.getLine();
- let startPoint = this.start;
- let road = dataService.getRoad(this.parent);
- let endPoint = this.end;
- // let lines = mathUtil.getParallelLineForDistance(line, Constant.roadSideWidth);
- // let joinPoint = lines.line1;
- // for (let key in road) {
- // if (this.vectorId == road[key]) {
- // if (key == 'rightEdgeId') {
- // console.error('rightEdgeId')
- // joinPoint = lines.line2;
- // } else if (key == 'leftEdgeId') {
- // console.error('leftEdgeId')
- // joinPoint = lines.line1;
- // }
- // }
- // }
- // let point1 = mathUtil.getJoinLinePoint(startPoint, joinPoint);
- // let point2 = mathUtil.getJoinLinePoint(endPoint, joinPoint);
- if (!this.roadSide) {
- this.roadSide = {};
- this.roadSide["width"] = Constant.roadSideWidth;
- }
- let roadSidePoints = mathUtil.RectangleVertex(startPoint, endPoint, (this.roadSide.width * 2) / 5);
- for (let key in road) {
- if (this.vectorId == road[key]) {
- if (key == "rightEdgeId") {
- this.roadSide["start"] = roadSidePoints.rightEdgeStart;
- this.roadSide["end"] = roadSidePoints.rightEdgeEnd;
- } else if (key == "leftEdgeId") {
- this.roadSide["start"] = roadSidePoints.leftEdgeStart;
- this.roadSide["end"] = roadSidePoints.leftEdgeEnd;
- }
- }
- }
- // this.roadSide['start'] = point1;
- // this.roadSide['end'] = point2;
- }
- setRoadSideWidth(width) {
- this.roadSide.width = width;
- this.initRoadSide();
- }
- setRoadSide(roadSide) {
- this.roadSide = JSON.parse(JSON.stringify(roadSide));
- }
- removeRoadSide() {
- this.roadSide = null;
- }
- }
|