RoadEdge.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //墙的边缘线
  2. import Geometry from "./Geometry.js";
  3. import VectorType from "../enum/VectorType.js";
  4. import { mathUtil } from "../Util/MathUtil.js";
  5. export default class RoadEdge extends Geometry {
  6. constructor(start, end, vectorId, parentId) {
  7. super();
  8. this.parent = parentId;
  9. this.start = {};
  10. this.end = {};
  11. this.vectorId = null;
  12. this.geoType = VectorType.RoadEdge;
  13. this.setId(vectorId);
  14. this.setPositions(start, end);
  15. }
  16. setPositions(point1, point2) {
  17. this.start.x = point1.x;
  18. this.start.y = point1.y;
  19. this.end.x = point2.x;
  20. this.end.y = point2.y;
  21. }
  22. setPosition(position, dir) {
  23. if (dir == "start") {
  24. mathUtil.clonePoint(this.start, position);
  25. } else if (dir == "end") {
  26. mathUtil.clonePoint(this.end, position);
  27. }
  28. }
  29. getPosition(dir) {
  30. if (dir == "start") {
  31. return this.start;
  32. } else if (dir == "end") {
  33. return this.end;
  34. } else {
  35. return null;
  36. }
  37. }
  38. getLine() {
  39. let line = mathUtil.createLine1(this.start, this.end);
  40. return line;
  41. }
  42. }