CurveRoad.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import VectorType from "../enum/VectorType.js";
  2. import Road from "./Road.js";
  3. import Settings from "../Settings";
  4. export default class CurveRoad extends Road {
  5. constructor(startId, endId, vectorId) {
  6. super(startId, endId, vectorId);
  7. this.points = []; //中心线上一系列控制点。数组是从start到end。
  8. this.leftLanesCurves = []; //左车道曲线
  9. this.rightLanesCurves = []; //左车道曲线
  10. this.singleLanesCurves = []; //单向车道
  11. this.leftDrivewayCount = Settings.curveRoadLeftDrivewayCount; //左边的车道个数
  12. this.rightDrivewayCount = Settings.curveRoadRightDrivewayCount; //右边的车道个数
  13. this.leftWidth = Settings.leftCurveRoadWidth;
  14. this.rightWidth = Settings.rightCurveRoadWidth;
  15. this.midDivide = {
  16. leftMidDivide: [],
  17. leftMidDivideCurves: [],
  18. rightMidDivide: [],
  19. rightMidDivideCurves: [],
  20. midDivideWidth: Settings.curveRoadMidDivideWidth,
  21. };
  22. this.curves = [];
  23. this.singleCurveRoadWidth = Settings.singleCurveRoadWidth;
  24. this.singleCurveRoadDrivewayCount = Settings.singleCurveRoadDrivewayCount;
  25. this.geoType = VectorType.CurveRoad;
  26. this.setId(vectorId);
  27. }
  28. getLanesCount(dir) {
  29. if (this.way == Constant.oneWay) {
  30. return this.singleCurveRoadDrivewayCount;
  31. } else if (this.way == Constant.twoWay) {
  32. if (dir == "left") {
  33. return this.leftDrivewayCount;
  34. } else {
  35. return this.rightDrivewayCount;
  36. }
  37. }
  38. }
  39. }