ListenLayer.js 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286
  1. import { mathUtil } from "./Util/MathUtil";
  2. import { dataService } from "./Service/DataService.js";
  3. import { stateService } from "./Service/StateService.js";
  4. import { roadService } from "./Service/RoadService.js";
  5. import Constant from "./Constant.js";
  6. import VectorType from "./enum/VectorType.js";
  7. import SelectState from "./enum/SelectState.js";
  8. import bezierUtil from "./Util/bezierUtil.js";
  9. import { elementService } from "./Service/ElementService";
  10. import { coordinate } from "./Coordinate";
  11. import { draw } from "./Renderer/Draw.js";
  12. import { edgeService } from "./Service/EdgeService";
  13. import VectorCategory from "./enum/VectorCategory";
  14. export default class ListenLayer {
  15. constructor() {
  16. this.modifyPoint = null;
  17. }
  18. //开始监听,exceptVectorIds表示不考虑的元素
  19. /**
  20. *
  21. * @param exceptVectorIds:{
  22. exceptPointId,
  23. exceptLineId,
  24. exceptCurvePointId,
  25. exceptCurveLineId,
  26. exceptRoadPointId,
  27. exceptRoadIds,
  28. exceptCurveRoadPointId,
  29. exceptCurveRoadId,
  30. exceptCrossCrossPointId,
  31. exceptTextId,
  32. }
  33. * @returns
  34. */
  35. start(position, exceptVectorIds) {
  36. let flag = false;
  37. let selectInfo = {};
  38. if (!exceptVectorIds) {
  39. exceptVectorIds = {};
  40. }
  41. this.clear();
  42. selectInfo.curveRoadEdgeInfo = this.isSelectCurveRoad(
  43. position,
  44. exceptVectorIds.exceptCurveRoadId
  45. ); //包括edge
  46. selectInfo.roadEdgeInfo = this.isSelectRoad(
  47. position,
  48. exceptVectorIds.exceptRoadIds
  49. ); //包括edge
  50. selectInfo.curveRoadPointInfo = this.isSelectCurveRoadPoint(
  51. position,
  52. exceptVectorIds.exceptCurveRoadPointId
  53. );
  54. selectInfo.roadPointInfo = this.isSelectRoadPoint(
  55. position,
  56. exceptVectorIds.exceptRoadPointId
  57. );
  58. selectInfo.pointInfo = this.isSelectPoint(
  59. position,
  60. exceptVectorIds.exceptPointId
  61. );
  62. selectInfo.lineInfo = this.isSelectLine(
  63. position,
  64. exceptVectorIds.exceptLineId
  65. );
  66. selectInfo.curvePointInfo = this.isSelectCurvePoint(
  67. position,
  68. exceptVectorIds.exceptCurvePointId
  69. );
  70. selectInfo.curveLineInfo = this.isSelectCurveLine(
  71. position,
  72. exceptVectorIds.exceptCurveLineId
  73. );
  74. selectInfo.circleInfo = this.isSelectCircle(
  75. position,
  76. exceptVectorIds.exceptCircleId
  77. );
  78. //交叉口拐弯处的控制点
  79. selectInfo.crossPointInfo = this.isSelectCrossCrossPoint(
  80. position,
  81. exceptVectorIds.exceptCrossCrossPointId
  82. );
  83. selectInfo.textInfo = this.isSelectText(
  84. position,
  85. exceptVectorIds.exceptTextId
  86. );
  87. selectInfo.magnifierInfo = this.isSelectMagnifier(
  88. position,
  89. exceptVectorIds.exceptMagnifierId
  90. );
  91. this.setModifyPoint(position, selectInfo);
  92. flag = this.updateSelectItem();
  93. return flag;
  94. }
  95. isSelectCurvePoint(position, exceptCurvePointId) {
  96. let curvePointInfo = {
  97. curvePointId: null,
  98. type: null,
  99. distance: null,
  100. };
  101. let seqInfo = {};
  102. const curvePoints = dataService.getCurvePoints();
  103. for (const curvePointId in curvePoints) {
  104. if (curvePointId == exceptCurvePointId) {
  105. continue;
  106. }
  107. const curvePoint = dataService.getCurvePoint(curvePointId);
  108. const distance = mathUtil.getDistance(position, curvePoint);
  109. if (distance < Constant.minAdsorbPix) {
  110. if (curvePointInfo.curvePointId == null) {
  111. curvePointInfo = {
  112. curvePointId: curvePointId,
  113. type: VectorType.CurvePoint,
  114. distance: distance,
  115. };
  116. } else {
  117. if (distance < curvePointInfo.distance) {
  118. curvePointInfo = {
  119. curvePointId: curvePointId,
  120. type: VectorType.CurvePoint,
  121. distance: distance,
  122. };
  123. }
  124. }
  125. } else {
  126. if (Math.abs(position.x - curvePoint.x) < Constant.minAdsorbPix) {
  127. seqInfo.linkedCurvePointIdX = curvePointId;
  128. seqInfo.x = curvePoint.x;
  129. }
  130. if (Math.abs(position.y - curvePoint.y) < Constant.minAdsorbPix) {
  131. seqInfo.linkedPointIdY = curvePointId;
  132. seqInfo.y = curvePoint.y;
  133. }
  134. }
  135. }
  136. if (curvePointInfo.curvePointId) {
  137. curvePointInfo.linkedCurvePointId = curvePointInfo.curvePointId;
  138. const linkedCurvePoint = dataService.getCurvePoint(
  139. curvePointInfo.curvePointId
  140. );
  141. curvePointInfo.x = linkedCurvePoint.x;
  142. curvePointInfo.y = linkedCurvePoint.y;
  143. } else {
  144. if (seqInfo.hasOwnProperty("linkedCurvePointIdX")) {
  145. curvePointInfo.linkedCurvePointIdX = seqInfo.linkedCurvePointIdX;
  146. curvePointInfo.x = seqInfo.x;
  147. }
  148. if (seqInfo.hasOwnProperty("linkedCurvePointIdY")) {
  149. curvePointInfo.linkedCurvePointIdY = seqInfo.linkedCurvePointIdY;
  150. curvePointInfo.y = seqInfo.y;
  151. }
  152. if (
  153. curvePointInfo.hasOwnProperty("y") &&
  154. !curvePointInfo.hasOwnProperty("x")
  155. ) {
  156. curvePointInfo.x = position.x;
  157. }
  158. if (
  159. curvePointInfo.hasOwnProperty("x") &&
  160. !curvePointInfo.hasOwnProperty("y")
  161. ) {
  162. curvePointInfo.y = position.y;
  163. }
  164. }
  165. return curvePointInfo;
  166. }
  167. isSelectCurveLine(position, exceptCurveLineIds) {
  168. let curveLineInfo = {
  169. curveLineId: null,
  170. type: null,
  171. distance: null,
  172. };
  173. const curveLines = dataService.getCurveLines();
  174. for (const curveLineId in curveLines) {
  175. if (
  176. exceptCurveLineIds &&
  177. exceptCurveLineIds.hasOwnProperty(curveLineId)
  178. ) {
  179. continue;
  180. }
  181. const curveLine = dataService.getCurveLine(curveLineId);
  182. let startPoint = dataService.getCurvePoint(curveLine.startId);
  183. let endPoint = dataService.getCurvePoint(curveLine.endId);
  184. const comLine = mathUtil.createLine1(startPoint, endPoint);
  185. const join = mathUtil.getJoinLinePoint(position, comLine);
  186. const distance = mathUtil.getDistance(position, join);
  187. if (!mathUtil.isContainForSegment(join, startPoint, endPoint)) {
  188. continue;
  189. }
  190. if (distance < Constant.minAdsorbPix / 2) {
  191. curveLineInfo = {
  192. curveLineId: curveLineId,
  193. type: VectorType.CurveLine,
  194. distance: distance,
  195. };
  196. }
  197. }
  198. if (curveLineInfo.curveLineId) {
  199. const linkedLine = dataService.getLine(lineInfo.curveLineId);
  200. let startPoint = dataService.getCurvePoint(linkedLine.startId);
  201. let endPoint = dataService.getCurvePoint(linkedLine.endId);
  202. const linkedComLine = mathUtil.createLine1(startPoint, endPoint);
  203. const linkedPosition = mathUtil.getJoinLinePoint(position, linkedComLine);
  204. curveLineInfo.x = linkedPosition.x;
  205. curveLineInfo.y = linkedPosition.y;
  206. return curveLineInfo;
  207. }
  208. return curveLineInfo;
  209. }
  210. isSelectPoint(position, exceptPointId) {
  211. let pointInfo = {
  212. pointId: null,
  213. type: null,
  214. distance: null,
  215. };
  216. let seqInfo = {};
  217. const points = dataService.getPoints();
  218. for (const pointId in points) {
  219. if (pointId == exceptPointId) {
  220. continue;
  221. }
  222. const point = dataService.getPoint(pointId);
  223. if (point.getCategory() == VectorCategory.Point.TestBasePoint) {
  224. continue;
  225. }
  226. const distance = mathUtil.getDistance(position, point);
  227. if (distance < Constant.minAdsorbPix) {
  228. if (pointInfo.pointId == null) {
  229. pointInfo = {
  230. pointId: pointId,
  231. type: VectorType.Point,
  232. distance: distance,
  233. };
  234. } else {
  235. if (distance < pointInfo.distance) {
  236. pointInfo = {
  237. pointId: pointId,
  238. type: VectorType.Point,
  239. distance: distance,
  240. };
  241. }
  242. }
  243. } else {
  244. if (Math.abs(position.x - point.x) < Constant.minAdsorbPix) {
  245. seqInfo.linkedPointIdX = pointId;
  246. seqInfo.x = point.x;
  247. }
  248. if (Math.abs(position.y - point.y) < Constant.minAdsorbPix) {
  249. seqInfo.linkedPointIdY = pointId;
  250. seqInfo.y = point.y;
  251. }
  252. }
  253. }
  254. if (pointInfo.pointId) {
  255. pointInfo.linkedPointId = pointInfo.pointId;
  256. const linkedPoint = dataService.getPoint(pointInfo.pointId);
  257. pointInfo.x = linkedPoint.x;
  258. pointInfo.y = linkedPoint.y;
  259. } else {
  260. if (seqInfo.hasOwnProperty("linkedPointIdX")) {
  261. pointInfo.linkedPointIdX = seqInfo.linkedPointIdX;
  262. pointInfo.x = seqInfo.x;
  263. }
  264. if (seqInfo.hasOwnProperty("linkedPointIdY")) {
  265. pointInfo.linkedPointIdY = seqInfo.linkedPointIdY;
  266. pointInfo.y = seqInfo.y;
  267. }
  268. if (pointInfo.hasOwnProperty("y") && !pointInfo.hasOwnProperty("x")) {
  269. pointInfo.x = position.x;
  270. }
  271. if (pointInfo.hasOwnProperty("x") && !pointInfo.hasOwnProperty("y")) {
  272. pointInfo.y = position.y;
  273. }
  274. }
  275. return pointInfo;
  276. }
  277. isSelectLine(position, exceptLineIds) {
  278. let lineInfo = {
  279. lineId: null,
  280. type: null,
  281. distance: null,
  282. };
  283. const lines = dataService.getLines();
  284. for (const lineId in lines) {
  285. if (exceptLineIds && exceptLineIds.hasOwnProperty(lineId)) {
  286. continue;
  287. }
  288. const line = dataService.getLine(lineId);
  289. if (
  290. line.getCategory() == VectorCategory.Line.PositionLine ||
  291. line.getCategory() == VectorCategory.Line.BaseLine
  292. ) {
  293. continue;
  294. }
  295. let startPoint = dataService.getPoint(line.startId);
  296. let endPoint = dataService.getPoint(line.endId);
  297. const comLine = mathUtil.createLine1(startPoint, endPoint);
  298. const join = mathUtil.getJoinLinePoint(position, comLine);
  299. const distance = mathUtil.getDistance(position, join);
  300. if (!mathUtil.isContainForSegment(join, startPoint, endPoint)) {
  301. continue;
  302. }
  303. if (distance < Constant.minAdsorbPix / 2) {
  304. lineInfo = {
  305. lineId: lineId,
  306. type: VectorType.Line,
  307. distance: distance,
  308. };
  309. }
  310. }
  311. if (lineInfo.lineId) {
  312. const linkedLine = dataService.getLine(lineInfo.lineId);
  313. let startPoint = dataService.getPoint(linkedLine.startId);
  314. let endPoint = dataService.getPoint(linkedLine.endId);
  315. const linkedComLine = mathUtil.createLine1(startPoint, endPoint);
  316. const linkedPosition = mathUtil.getJoinLinePoint(position, linkedComLine);
  317. lineInfo.x = linkedPosition.x;
  318. lineInfo.y = linkedPosition.y;
  319. return lineInfo;
  320. }
  321. return lineInfo;
  322. }
  323. isSelectCircle(position, exceptCircleId) {
  324. let circleInfo = {
  325. circleId: null,
  326. type: null,
  327. distance: null,
  328. };
  329. const circles = dataService.getCircles();
  330. let distance;
  331. for (const circleId in circles) {
  332. if (circleId == exceptCircleId) {
  333. continue;
  334. }
  335. const circle = dataService.getCircle(circleId);
  336. for (let i = 0; i < circle.points.length; ++i) {
  337. distance = mathUtil.getDistance(position, circle.points[i]);
  338. if (distance < Constant.minAdsorbPix) {
  339. circleInfo = {
  340. circleId: circleId,
  341. type: VectorType.Circle,
  342. distance: distance,
  343. x: circle.points[i].x,
  344. y: circle.points[i].y,
  345. index: i,
  346. };
  347. return circleInfo;
  348. }
  349. }
  350. distance = mathUtil.getDistance(position, circle.center);
  351. if (distance < circle.radius) {
  352. if (circleInfo.circleId == null || distance < circleInfo.distance) {
  353. circleInfo = {
  354. circleId: circleId,
  355. type: VectorType.Circle,
  356. distance: distance,
  357. x: circle.center.x,
  358. y: circle.center.y,
  359. index: -1,
  360. };
  361. }
  362. }
  363. }
  364. return circleInfo;
  365. }
  366. // isSelectCurveLine(position, exceptCurveLineId) {
  367. // let curveLineInfo = {
  368. // curveLineId: null,
  369. // type: null,
  370. // distance: null,
  371. // };
  372. // let seqInfo = {};
  373. // const curveLines = dataService.getCurveLines();
  374. // for (const curveLineId in curveLines) {
  375. // if (curveLineId == exceptCurveLineId) {
  376. // continue;
  377. // }
  378. // const curveLine = dataService.getCurveLine(curveLineId);
  379. // let joinInfo = this.distanceForBezier(
  380. // position,
  381. // curveRoad.curves,
  382. // Constant.minAdsorbPix / 2
  383. // );
  384. // if (
  385. // mathUtil.isClockwise([curveRoad.points[0], joinInfo.position, position])
  386. // ) {
  387. // //选中了路
  388. // if (joinInfo.distance < curveRoad.leftWidth - Constant.minAdsorbPix) {
  389. // curveRoadInfo = {
  390. // curveRoadId: curveRoadId,
  391. // type: VectorType.CurveRoad,
  392. // distance: joinInfo.distance,
  393. // x: joinInfo.position.x,
  394. // y: joinInfo.position.y,
  395. // };
  396. // }
  397. // //选中了edge
  398. // else if (
  399. // joinInfo.distance <
  400. // curveRoad.leftWidth + Constant.minAdsorbPix
  401. // ) {
  402. // const leftCurveEdge = dataService.getCurveRoadEdge(
  403. // curveRoad.leftEdgeId
  404. // );
  405. // joinInfo = this.distanceForBezier(
  406. // position,
  407. // leftCurveEdge.curves,
  408. // curveRoad.leftWidth
  409. // );
  410. // const index = mathUtil.getIndexForCurvesPoints(
  411. // joinInfo.position,
  412. // curveRoad.points
  413. // );
  414. // curveEdgeInfo = {
  415. // curveEdgeId: curveRoad.leftEdgeId,
  416. // type: VectorType.CurveRoadEdge,
  417. // distance: joinInfo.distance,
  418. // selectIndex: index,
  419. // x: joinInfo.position.x,
  420. // y: joinInfo.position.y,
  421. // };
  422. // }
  423. // } else if (
  424. // !mathUtil.isClockwise([
  425. // curveRoad.points[0],
  426. // joinInfo.position,
  427. // position,
  428. // ])
  429. // ) {
  430. // //选中了路
  431. // if (joinInfo.distance < curveRoad.rightWidth - Constant.minAdsorbPix) {
  432. // curveRoadInfo = {
  433. // curveRoadId: curveRoadId,
  434. // type: VectorType.CurveRoad,
  435. // distance: joinInfo.distance,
  436. // x: joinInfo.position.x,
  437. // y: joinInfo.position.y,
  438. // };
  439. // }
  440. // //选中了edge
  441. // else if (
  442. // joinInfo.distance <
  443. // curveRoad.rightWidth + Constant.minAdsorbPix
  444. // ) {
  445. // const rightCurveEdge = dataService.getCurveRoadEdge(
  446. // curveRoad.rightEdgeId
  447. // );
  448. // joinInfo = this.distanceForBezier(
  449. // position,
  450. // rightCurveEdge.curves,
  451. // curveRoad.rightWidth
  452. // );
  453. // const index = mathUtil.getIndexForCurvesPoints(
  454. // joinInfo.position,
  455. // curveRoad.points
  456. // );
  457. // curveEdgeInfo = {
  458. // curveEdgeId: curveRoad.rightEdgeId,
  459. // type: VectorType.CurveRoadEdge,
  460. // distance: joinInfo.distance,
  461. // selectIndex: index,
  462. // x: joinInfo.position.x,
  463. // y: joinInfo.position.y,
  464. // };
  465. // }
  466. // }
  467. // }
  468. // if (curveRoadInfo.curveRoadId) {
  469. // return curveRoadInfo;
  470. // } else if (curveEdgeInfo.curveEdgeId) {
  471. // return curveEdgeInfo;
  472. // } else {
  473. // return {
  474. // curveRoadId: null,
  475. // curveEdgeId: null,
  476. // };
  477. // }
  478. // }
  479. isSelectRoadPoint(position, exceptRoadPointId) {
  480. let roadPointInfo = {
  481. roadPointId: null,
  482. type: null,
  483. distance: null,
  484. };
  485. let seqInfo = {};
  486. const roadPoints = dataService.getRoadPoints();
  487. for (const roadPointId in roadPoints) {
  488. if (roadPointId == exceptRoadPointId) {
  489. continue;
  490. }
  491. const roadPoint = dataService.getRoadPoint(roadPointId);
  492. const distance = mathUtil.getDistance(position, roadPoint);
  493. if (distance < Constant.minAdsorbPix) {
  494. if (roadPointInfo.roadPointId == null) {
  495. roadPointInfo = {
  496. roadPointId: roadPointId,
  497. type: VectorType.RoadPoint,
  498. distance: distance,
  499. };
  500. } else if (roadPointInfo.roadPointId != null) {
  501. if (distance < roadPointInfo.distance) {
  502. roadPointInfo = {
  503. roadPointId: roadPointId,
  504. type: VectorType.RoadPoint,
  505. distance: distance,
  506. };
  507. }
  508. }
  509. } else {
  510. if (Math.abs(position.x - roadPoint.x) < Constant.minAdsorbPix) {
  511. seqInfo.linkedRoadPointIdX = roadPointId;
  512. seqInfo.x = roadPoint.x;
  513. } else if (Math.abs(position.y - roadPoint.y) < Constant.minAdsorbPix) {
  514. seqInfo.linkedRoadPointIdY = roadPointId;
  515. seqInfo.y = roadPoint.y;
  516. }
  517. }
  518. }
  519. if (roadPointInfo.roadPointId) {
  520. const linkedPoint = dataService.getRoadPoint(roadPointInfo.roadPointId);
  521. roadPointInfo.x = linkedPoint.x;
  522. roadPointInfo.y = linkedPoint.y;
  523. }
  524. //因为这种纠正的权限最低
  525. else {
  526. if (seqInfo.hasOwnProperty("linkedRoadPointIdX")) {
  527. roadPointInfo.linkedRoadPointIdX = seqInfo.linkedRoadPointIdX;
  528. roadPointInfo.x = seqInfo.x;
  529. }
  530. if (seqInfo.hasOwnProperty("linkedRoadPointIdY")) {
  531. roadPointInfo.linkedRoadPointIdY = seqInfo.linkedRoadPointIdY;
  532. roadPointInfo.y = seqInfo.y;
  533. }
  534. if (
  535. roadPointInfo.hasOwnProperty("y") &&
  536. !roadPointInfo.hasOwnProperty("x")
  537. ) {
  538. roadPointInfo.x = position.x;
  539. }
  540. if (
  541. roadPointInfo.hasOwnProperty("x") &&
  542. !roadPointInfo.hasOwnProperty("y")
  543. ) {
  544. roadPointInfo.y = position.y;
  545. }
  546. }
  547. return roadPointInfo;
  548. }
  549. isSelectCurveRoadPoint(position, exceptCurveRoadPointId) {
  550. let curveRoadPointInfo = {
  551. curveRoadPointId: null,
  552. type: null,
  553. distance: null,
  554. };
  555. let seqInfo = {};
  556. const curveRoadPoints = dataService.getCurveRoadPoints();
  557. for (const curveRoadPointId in curveRoadPoints) {
  558. if (curveRoadPointId == exceptCurveRoadPointId) {
  559. continue;
  560. }
  561. const curveRoadPoint = dataService.getCurveRoadPoint(curveRoadPointId);
  562. const distance = mathUtil.getDistance(position, curveRoadPoint);
  563. if (distance < Constant.minAdsorbPix) {
  564. if (curveRoadPointInfo.curveRoadPointId == null) {
  565. curveRoadPointInfo = {
  566. curveRoadPointId: curveRoadPointId,
  567. type: VectorType.CurveRoadPoint,
  568. distance: distance,
  569. };
  570. } else {
  571. if (distance < curveRoadPointInfo.distance) {
  572. curveRoadPointInfo = {
  573. curveRoadPointId: curveRoadPointId,
  574. type: VectorType.CurveRoadPoint,
  575. distance: distance,
  576. };
  577. }
  578. }
  579. } else {
  580. if (Math.abs(position.x - curveRoadPoint.x) < Constant.minAdsorbPix) {
  581. seqInfo.linkedCurveRoadPointIdX = curveRoadPointId;
  582. seqInfo.x = curveRoadPoint.x;
  583. } else if (
  584. Math.abs(position.y - curveRoadPoint.y) < Constant.minAdsorbPix
  585. ) {
  586. seqInfo.linkedCurveRoadPointIdY = curveRoadPointId;
  587. seqInfo.y = curveRoadPoint.y;
  588. }
  589. }
  590. }
  591. if (curveRoadPointInfo.curveRoadPointId) {
  592. curveRoadPointInfo.linkedCurveRoadPointId =
  593. curveRoadPointInfo.curveRoadPointId;
  594. const linkedCurvePoint = dataService.getCurveRoadPoint(
  595. curveRoadPointInfo.curveRoadPointId
  596. );
  597. curveRoadPointInfo.x = linkedCurvePoint.x;
  598. curveRoadPointInfo.y = linkedCurvePoint.y;
  599. } else {
  600. if (seqInfo.hasOwnProperty("linkedCurveRoadPointIdX")) {
  601. curveRoadPointInfo.linkedCurveRoadPointIdX =
  602. seqInfo.linkedCurveRoadPointIdX;
  603. curveRoadPointInfo.x = seqInfo.x;
  604. } else if (seqInfo.hasOwnProperty("linkedCurveRoadPointIdY")) {
  605. curveRoadPointInfo.linkedCurveRoadPointIdY =
  606. seqInfo.linkedCurveRoadPointIdY;
  607. curveRoadPointInfo.y = seqInfo.y;
  608. }
  609. if (
  610. curveRoadPointInfo.hasOwnProperty("y") &&
  611. !curveRoadPointInfo.hasOwnProperty("x")
  612. ) {
  613. curveRoadPointInfo.x = position.x;
  614. }
  615. if (
  616. curveRoadPointInfo.hasOwnProperty("x") &&
  617. !curveRoadPointInfo.hasOwnProperty("y")
  618. ) {
  619. curveRoadPointInfo.y = position.y;
  620. }
  621. }
  622. return curveRoadPointInfo;
  623. }
  624. isSelectRoad(position, exceptRoadIds) {
  625. let roadInfo = {
  626. roadId: null,
  627. type: null,
  628. distance: null,
  629. };
  630. let edgeInfo = {
  631. edgeId: null,
  632. type: null,
  633. distance: null,
  634. dir: null,
  635. };
  636. const roads = dataService.getRoads();
  637. for (const roadId in roads) {
  638. if (exceptRoadIds != null && exceptRoadIds.hasOwnProperty(roadId)) {
  639. continue;
  640. }
  641. const road = dataService.getRoad(roadId);
  642. let startPoint = dataService.getRoadPoint(road.startId);
  643. let endPoint = dataService.getRoadPoint(road.endId);
  644. const leftEdge = dataService.getRoadEdge(road.leftEdgeId);
  645. const rightEdge = dataService.getRoadEdge(road.rightEdgeId);
  646. const roadLine = roadService.getMidLine(road);
  647. let join = mathUtil.getJoinLinePoint(position, roadLine);
  648. let distance = mathUtil.getDistance(position, join);
  649. if (
  650. mathUtil.isContainForSegment(join, startPoint, endPoint) &&
  651. distance < Constant.minAdsorbPix
  652. ) {
  653. if (!roadInfo.roadId || distance < roadInfo.distance) {
  654. roadInfo = {
  655. roadId: roadId,
  656. type: VectorType.Road,
  657. distance: distance,
  658. };
  659. }
  660. }
  661. //检查edge
  662. let leftLine = mathUtil.createLine1(leftEdge.start, leftEdge.end);
  663. join = mathUtil.getJoinLinePoint(position, leftLine);
  664. distance = mathUtil.getDistance(position, join);
  665. if (
  666. mathUtil.isContainForSegment(join, leftEdge.start, leftEdge.end) &&
  667. distance < Constant.minAdsorbPix
  668. ) {
  669. if (!edgeInfo.edgeId || distance < edgeInfo.distance) {
  670. edgeInfo = {
  671. edgeId: road.leftEdgeId,
  672. type: VectorType.RoadEdge,
  673. distance: distance,
  674. dir: "left",
  675. };
  676. }
  677. }
  678. let rightLine = mathUtil.createLine1(rightEdge.start, rightEdge.end);
  679. join = mathUtil.getJoinLinePoint(position, rightLine);
  680. distance = mathUtil.getDistance(position, join);
  681. if (
  682. mathUtil.isContainForSegment(join, rightEdge.start, rightEdge.end) &&
  683. distance < Constant.minAdsorbPix
  684. ) {
  685. if (!edgeInfo.edgeId || distance < edgeInfo.distance) {
  686. edgeInfo = {
  687. edgeId: road.rightEdgeId,
  688. type: VectorType.RoadEdge,
  689. distance: distance,
  690. dir: "right",
  691. };
  692. }
  693. }
  694. }
  695. if (
  696. roadInfo.roadId &&
  697. (!edgeInfo.edgeId || roadInfo.distance < edgeInfo.distance)
  698. ) {
  699. const linkedRoad = dataService.getRoad(roadInfo.roadId);
  700. const linkedRoadLine = roadService.getMidLine(linkedRoad);
  701. const linkedPosition = mathUtil.getJoinLinePoint(
  702. position,
  703. linkedRoadLine
  704. );
  705. roadInfo.x = linkedPosition.x;
  706. roadInfo.y = linkedPosition.y;
  707. return roadInfo;
  708. } else if (edgeInfo.edgeId) {
  709. if (edgeInfo.dir == "left") {
  710. const leftEdge = dataService.getRoadEdge(edgeInfo.edgeId);
  711. const leftLine = edgeService.getLine(leftEdge);
  712. const linkedPosition = mathUtil.getJoinLinePoint(position, leftLine);
  713. edgeInfo.x = linkedPosition.x;
  714. edgeInfo.y = linkedPosition.y;
  715. } else {
  716. const rightEdge = dataService.getRoadEdge(edgeInfo.edgeId);
  717. const rightLine = edgeService.getLine(rightEdge);
  718. const linkedPosition = mathUtil.getJoinLinePoint(position, rightLine);
  719. edgeInfo.x = linkedPosition.x;
  720. edgeInfo.y = linkedPosition.y;
  721. }
  722. return edgeInfo;
  723. }
  724. return {
  725. roadId: null,
  726. edgeId: null,
  727. };
  728. }
  729. isSelectCurveRoad(position, exceptCurveRoadId) {
  730. let curveRoadInfo = {
  731. curveRoadId: null,
  732. type: null,
  733. distance: null,
  734. };
  735. let curveEdgeInfo = {
  736. curveEdgeId: null,
  737. type: null,
  738. distance: null,
  739. };
  740. const curveRoads = dataService.getCurveRoads();
  741. for (const curveRoadId in curveRoads) {
  742. if (curveRoadId == exceptCurveRoadId) {
  743. continue;
  744. }
  745. const curveRoad = dataService.getCurveRoad(curveRoadId);
  746. let joinInfo = this.distanceForBezier(
  747. position,
  748. curveRoad.curves,
  749. Constant.minAdsorbPix
  750. );
  751. //选中了路
  752. if (joinInfo.distance < Constant.minAdsorbPix) {
  753. curveRoadInfo = {
  754. curveRoadId: curveRoadId,
  755. type: VectorType.CurveRoad,
  756. distance: joinInfo.distance,
  757. x: joinInfo.position.x,
  758. y: joinInfo.position.y,
  759. };
  760. }
  761. //检查edge
  762. else {
  763. const leftCurveEdge = dataService.getCurveRoadEdge(
  764. curveRoad.leftEdgeId
  765. );
  766. joinInfo = this.distanceForBezier(
  767. position,
  768. leftCurveEdge.curves,
  769. Constant.minAdsorbPix
  770. );
  771. if (joinInfo.distance < Constant.minAdsorbPix) {
  772. const index = mathUtil.getIndexForCurvesPoints(
  773. joinInfo.position,
  774. curveRoad.points
  775. );
  776. curveEdgeInfo = {
  777. curveEdgeId: curveRoad.leftEdgeId,
  778. type: VectorType.CurveRoadEdge,
  779. distance: joinInfo.distance,
  780. selectIndex: index,
  781. x: joinInfo.position.x,
  782. y: joinInfo.position.y,
  783. };
  784. } else {
  785. const rightCurveEdge = dataService.getCurveRoadEdge(
  786. curveRoad.rightEdgeId
  787. );
  788. joinInfo = this.distanceForBezier(
  789. position,
  790. rightCurveEdge.curves,
  791. Constant.minAdsorbPix
  792. );
  793. if (joinInfo.distance < Constant.minAdsorbPix) {
  794. const index = mathUtil.getIndexForCurvesPoints(
  795. joinInfo.position,
  796. curveRoad.points
  797. );
  798. curveEdgeInfo = {
  799. curveEdgeId: curveRoad.rightEdgeId,
  800. type: VectorType.CurveRoadEdge,
  801. distance: joinInfo.distance,
  802. selectIndex: index,
  803. x: joinInfo.position.x,
  804. y: joinInfo.position.y,
  805. };
  806. }
  807. }
  808. }
  809. }
  810. if (curveRoadInfo.curveRoadId) {
  811. return curveRoadInfo;
  812. } else if (curveEdgeInfo.curveEdgeId) {
  813. return curveEdgeInfo;
  814. } else {
  815. return {
  816. curveRoadId: null,
  817. curveEdgeId: null,
  818. };
  819. }
  820. }
  821. isSelectCrossCrossPoint(position, exceptCrossCrossPointId) {
  822. let crossCrossPointInfo = {
  823. crossCrossPointId: null,
  824. type: null,
  825. distance: null,
  826. };
  827. const crossPoints = dataService.getCrossPoints();
  828. for (const crossPointId in crossPoints) {
  829. if (crossPointId == exceptCrossCrossPointId) {
  830. continue;
  831. }
  832. const crossPoint = dataService.getCrossPoint2(crossPointId);
  833. const distance = mathUtil.getDistance(position, crossPoint.extremePoint);
  834. if (distance < Constant.minAdsorbPix) {
  835. crossCrossPointInfo = {
  836. crossCrossPointId: crossPointId,
  837. type: VectorType.CrossPoint,
  838. distance: distance,
  839. x: crossPoint.extremePoint.x,
  840. y: crossPoint.extremePoint.y,
  841. };
  842. }
  843. }
  844. return crossCrossPointInfo;
  845. }
  846. isSelectText(position, exceptTextId) {
  847. let textInfo = {
  848. textId: null,
  849. type: null,
  850. distance: null,
  851. };
  852. const texts = dataService.getTexts();
  853. for (const textId in texts) {
  854. if (textId == exceptTextId) {
  855. continue;
  856. }
  857. const text = dataService.getText(textId);
  858. const distance = mathUtil.getDistance(position, text.center);
  859. if (distance < Constant.minAdsorbPix) {
  860. textInfo = {
  861. textId: textId,
  862. type: VectorType.Text,
  863. distance: distance,
  864. x: text.center.x,
  865. y: text.center.y,
  866. };
  867. }
  868. }
  869. return textInfo;
  870. }
  871. isSelectMagnifier(position, exceptMagnifierId) {
  872. let magnifierInfo = {
  873. magnifierId: null,
  874. type: null,
  875. distance: null,
  876. };
  877. const magnifiers = dataService.getMagnifiers();
  878. for (const magnifierId in magnifiers) {
  879. if (magnifierId == exceptMagnifierId) {
  880. continue;
  881. }
  882. const magnifier = dataService.getMagnifier(magnifierId);
  883. const distance = mathUtil.getDistance(position, magnifier.position);
  884. if (distance < Constant.minAdsorbPix) {
  885. magnifierInfo = {
  886. magnifierId: magnifierId,
  887. type: VectorType.Magnifier,
  888. distance: distance,
  889. x: magnifier.position.x,
  890. y: magnifier.position.y,
  891. };
  892. }
  893. }
  894. return magnifierInfo;
  895. }
  896. /**
  897. *
  898. * @param info:{
  899. roadPointInfo,
  900. curveRoadPointInfo,
  901. roadEdgeInfo,
  902. curveRoadEdgeInfo,
  903. crossPointInfo,
  904. pointInfo,
  905. roadPointInfo
  906. }
  907. */
  908. setModifyPoint(position, info) {
  909. //优先级最高
  910. if (
  911. info &&
  912. (info.roadPointInfo.roadPointId ||
  913. info.curveRoadPointInfo.curveRoadPointId)
  914. ) {
  915. this.modifyPoint = {};
  916. if (
  917. info.roadPointInfo.roadPointId &&
  918. info.curveRoadPointInfo.curveRoadPointId
  919. ) {
  920. if (info.roadPointInfo.distance < info.curveRoadPointInfo.distance) {
  921. this.modifyPoint.linkedRoadPointId = info.roadPointInfo.roadPointId;
  922. this.modifyPoint.x = info.roadPointInfo.x;
  923. this.modifyPoint.y = info.roadPointInfo.y;
  924. } else {
  925. this.modifyPoint.linkedCurveRoadPointId =
  926. info.curveRoadPointInfo.curveRoadPointId;
  927. this.modifyPoint.x = info.curveRoadPointInfo.x;
  928. this.modifyPoint.y = info.curveRoadPointInfo.y;
  929. }
  930. } else if (info.roadPointInfo.roadPointId) {
  931. this.modifyPoint.linkedRoadPointId = info.roadPointInfo.roadPointId;
  932. this.modifyPoint.x = info.roadPointInfo.x;
  933. this.modifyPoint.y = info.roadPointInfo.y;
  934. } else if (info.curveRoadPointInfo.curveRoadPointId) {
  935. this.modifyPoint.linkedCurveRoadPointId =
  936. info.curveRoadPointInfo.curveRoadPointId;
  937. this.modifyPoint.x = info.curveRoadPointInfo.x;
  938. this.modifyPoint.y = info.curveRoadPointInfo.y;
  939. }
  940. } else if (
  941. info &&
  942. (info.pointInfo.pointId || info.curvePointInfo.curvePointId)
  943. ) {
  944. this.modifyPoint = {};
  945. if (info.pointInfo.pointId && info.curvePointInfo.curvePointId) {
  946. if (info.pointInfo.distance < info.curvePointInfo.distance) {
  947. this.modifyPoint.linkedPointId = info.pointInfo.pointId;
  948. this.modifyPoint.x = info.pointInfo.x;
  949. this.modifyPoint.y = info.pointInfo.y;
  950. } else {
  951. this.modifyPoint.linkedCurvePointId =
  952. info.curvePointInfo.curvePointId;
  953. this.modifyPoint.x = info.curvePointInfo.x;
  954. this.modifyPoint.y = info.curvePointInfo.y;
  955. }
  956. } else if (info.pointInfo.pointId) {
  957. this.modifyPoint.linkedPointId = info.pointInfo.pointId;
  958. this.modifyPoint.x = info.pointInfo.x;
  959. this.modifyPoint.y = info.pointInfo.y;
  960. } else if (info.curvePointInfo.curvePointId) {
  961. this.modifyPoint.linkedCurvePointId = info.curvePointInfo.curvePointId;
  962. this.modifyPoint.x = info.curvePointInfo.x;
  963. this.modifyPoint.y = info.curvePointInfo.y;
  964. }
  965. } else if (
  966. info &&
  967. (info.roadEdgeInfo.roadId || info.curveRoadEdgeInfo.curveRoadId)
  968. ) {
  969. this.modifyPoint = {};
  970. if (info.roadEdgeInfo.roadId && info.curveRoadEdgeInfo.curveRoadId) {
  971. if (roadEdgeInfo.distance < info.curveRoadEdgeInfo.distance) {
  972. this.modifyPoint.linkedRoadId = info.roadEdgeInfo.roadId;
  973. this.modifyPoint.x = info.roadEdgeInfo.x;
  974. this.modifyPoint.y = info.roadEdgeInfo.y;
  975. } else {
  976. this.modifyPoint.linkedCurveRoadId = curveRoadEdgeInfo.curveRoadId;
  977. this.modifyPoint.x = info.curveRoadEdgeInfo.x;
  978. this.modifyPoint.y = info.curveRoadEdgeInfo.y;
  979. }
  980. } else if (info.roadEdgeInfo.roadId) {
  981. this.modifyPoint.linkedRoadId = info.roadEdgeInfo.roadId;
  982. this.modifyPoint.x = info.roadEdgeInfo.x;
  983. this.modifyPoint.y = info.roadEdgeInfo.y;
  984. } else if (info.curveRoadEdgeInfo.curveRoadId) {
  985. this.modifyPoint.linkedCurveRoadId = info.curveRoadEdgeInfo.curveRoadId;
  986. this.modifyPoint.x = info.curveRoadEdgeInfo.x;
  987. this.modifyPoint.y = info.curveRoadEdgeInfo.y;
  988. }
  989. } else if (info && info.crossPointInfo.crossCrossPointId) {
  990. this.modifyPoint = {};
  991. this.modifyPoint.linkedCrossCrossPointId =
  992. info.crossPointInfo.crossCrossPointId;
  993. this.modifyPoint.x = info.crossPointInfo.x;
  994. this.modifyPoint.y = info.crossPointInfo.y;
  995. } else if (info && info.textInfo.textId) {
  996. this.modifyPoint = {};
  997. this.modifyPoint.textId = info.textInfo.textId;
  998. this.modifyPoint.x = info.textInfo.x;
  999. this.modifyPoint.y = info.textInfo.y;
  1000. } else if (info && info.magnifierInfo.magnifierId) {
  1001. this.modifyPoint = {};
  1002. this.modifyPoint.magnifierId = info.magnifierInfo.magnifierId;
  1003. this.modifyPoint.x = info.magnifierInfo.x;
  1004. this.modifyPoint.y = info.magnifierInfo.y;
  1005. } else if (
  1006. info &&
  1007. (info.roadEdgeInfo.edgeId || info.curveRoadEdgeInfo.curveEdgeId)
  1008. ) {
  1009. this.modifyPoint = {};
  1010. if (info.roadEdgeInfo.edgeId && info.curveRoadEdgeInfo.curveEdgeId) {
  1011. if (info.roadEdgeInfo.distance < info.curveRoadEdgeInfo.distance) {
  1012. this.modifyPoint.linkedEdgeId = info.roadEdgeInfo.edgeId;
  1013. this.modifyPoint.x = info.roadEdgeInfo.x;
  1014. this.modifyPoint.y = info.roadEdgeInfo.y;
  1015. } else {
  1016. this.modifyPoint.linkedCurveEdgeId =
  1017. info.curveRoadEdgeInfo.curveEdgeId;
  1018. this.modifyPoint.selectIndex = info.curveRoadEdgeInfo.selectIndex;
  1019. this.modifyPoint.x = info.curveRoadEdgeInfo.x;
  1020. this.modifyPoint.y = info.curveRoadEdgeInfo.y;
  1021. }
  1022. } else if (info.roadEdgeInfo.edgeId) {
  1023. this.modifyPoint.linkedEdgeId = info.roadEdgeInfo.edgeId;
  1024. this.modifyPoint.x = info.roadEdgeInfo.x;
  1025. this.modifyPoint.y = info.roadEdgeInfo.y;
  1026. } else if (info.curveRoadEdgeInfo.curveEdgeId) {
  1027. this.modifyPoint.linkedCurveEdgeId = info.curveRoadEdgeInfo.curveEdgeId;
  1028. this.modifyPoint.selectIndex = info.curveRoadEdgeInfo.selectIndex;
  1029. this.modifyPoint.x = info.curveRoadEdgeInfo.x;
  1030. this.modifyPoint.y = info.curveRoadEdgeInfo.y;
  1031. }
  1032. } else if (
  1033. info &&
  1034. (info.lineInfo.lineId || info.curveLineInfo.curveLineId)
  1035. ) {
  1036. this.modifyPoint = {};
  1037. if (info.lineInfo.lineId && info.curveLineInfo.curveLineId) {
  1038. if (info.lineInfo.distance < info.curveLineInfo.distance) {
  1039. this.modifyPoint.linkedLineId = info.lineInfo.lineId;
  1040. this.modifyPoint.x = info.lineInfo.x;
  1041. this.modifyPoint.y = info.lineInfo.y;
  1042. } else {
  1043. this.modifyPoint.linkedCurveLineId = info.curveLineInfo.curveLineId;
  1044. this.modifyPoint.x = info.curveLineInfo.x;
  1045. this.modifyPoint.y = info.curveLineInfo.y;
  1046. }
  1047. } else if (info.lineInfo.lineId) {
  1048. this.modifyPoint.linkedLineId = info.lineInfo.lineId;
  1049. this.modifyPoint.x = info.lineInfo.x;
  1050. this.modifyPoint.y = info.lineInfo.y;
  1051. } else if (info.curveLineInfo.curveLineId) {
  1052. this.modifyPoint.linkedCurveLineId = info.curveLineInfo.curveLineId;
  1053. this.modifyPoint.x = info.curveLineInfo.x;
  1054. this.modifyPoint.y = info.curveLineInfo.y;
  1055. }
  1056. } else if (info && info.circleInfo.circleId) {
  1057. this.modifyPoint = {};
  1058. this.modifyPoint.linkedCircleId = info.circleInfo.circleId;
  1059. this.modifyPoint.index = info.circleInfo.index;
  1060. this.modifyPoint.x = info.circleInfo.x;
  1061. this.modifyPoint.y = info.circleInfo.y;
  1062. } else if (info && info.roadPointInfo.linkedRoadPointIdX) {
  1063. this.modifyPoint = {};
  1064. this.modifyPoint.linkedRoadPointIdX =
  1065. info.roadPointInfo.linkedRoadPointIdX;
  1066. this.modifyPoint.x = info.roadPointInfo.x;
  1067. this.modifyPoint.y = info.roadPointInfo.y;
  1068. } else if (info && info.roadPointInfo.linkedRoadPointIdY) {
  1069. this.modifyPoint = {};
  1070. this.modifyPoint.linkedRoadPointIdY =
  1071. info.roadPointInfo.linkedRoadPointIdY;
  1072. this.modifyPoint.y = info.roadPointInfo.y;
  1073. this.modifyPoint.x = info.roadPointInfo.x;
  1074. } else if (info && info.curvePointInfo.linkedRoadPointIdX) {
  1075. this.modifyPoint = {};
  1076. this.modifyPoint.linkedRoadPointIdX =
  1077. info.curvePointInfo.linkedRoadPointIdX;
  1078. this.modifyPoint.x = info.curvePointInfo.x;
  1079. this.modifyPoint.y = position.y;
  1080. } else if (info && info.curvePointInfo.linkedRoadPointIdY) {
  1081. this.modifyPoint = {};
  1082. this.modifyPoint.linkedRoadPointIdY =
  1083. info.curvePointInfo.linkedRoadPointIdY;
  1084. this.modifyPoint.y = info.curvePointInfo.y;
  1085. this.modifyPoint.x = position.x;
  1086. } else if (
  1087. info &&
  1088. info.pointInfo.linkedPointIdX &&
  1089. !info.pointInfo.linkedPointIdY
  1090. ) {
  1091. this.modifyPoint = {};
  1092. this.modifyPoint.linkedPointIdX = info.pointInfo.linkedPointIdX;
  1093. this.modifyPoint.x = info.pointInfo.x;
  1094. this.modifyPoint.y = info.pointInfo.y;
  1095. } else if (
  1096. info &&
  1097. info.pointInfo.linkedPointIdY &&
  1098. !info.pointInfo.linkedPointIdX
  1099. ) {
  1100. this.modifyPoint = {};
  1101. this.modifyPoint.linkedPointIdY = info.pointInfo.linkedPointIdY;
  1102. this.modifyPoint.y = info.pointInfo.y;
  1103. this.modifyPoint.x = info.pointInfo.x;
  1104. } else if (
  1105. info &&
  1106. info.pointInfo.linkedPointIdY &&
  1107. info.pointInfo.linkedPointIdX
  1108. ) {
  1109. this.modifyPoint = {};
  1110. this.modifyPoint.linkedPointIdX = info.pointInfo.linkedPointIdX;
  1111. this.modifyPoint.linkedPointIdY = info.pointInfo.linkedPointIdY;
  1112. this.modifyPoint.y = info.pointInfo.y;
  1113. this.modifyPoint.x = info.pointInfo.x;
  1114. } else {
  1115. this.modifyPoint = null;
  1116. }
  1117. }
  1118. updateSelectItem() {
  1119. let selectItem = stateService.getSelectItem();
  1120. if (this.modifyPoint == null) {
  1121. if (selectItem != null) {
  1122. stateService.clearSelectItem();
  1123. return true;
  1124. } else {
  1125. return false;
  1126. }
  1127. } else if (this.modifyPoint.linkedRoadPointId) {
  1128. stateService.setSelectItem(
  1129. this.modifyPoint.linkedRoadPointId,
  1130. VectorType.RoadPoint,
  1131. SelectState.Select
  1132. );
  1133. } else if (this.modifyPoint.linkedCurveRoadPointId) {
  1134. stateService.setSelectItem(
  1135. this.modifyPoint.linkedCurveRoadPointId,
  1136. VectorType.CurveRoadPoint,
  1137. SelectState.Select
  1138. );
  1139. } else if (this.modifyPoint.linkedRoadId) {
  1140. stateService.setSelectItem(
  1141. this.modifyPoint.linkedRoadId,
  1142. VectorType.Road,
  1143. SelectState.Select
  1144. );
  1145. } else if (this.modifyPoint.linkedCurveRoadId) {
  1146. stateService.setSelectItem(
  1147. this.modifyPoint.linkedCurveRoadId,
  1148. VectorType.CurveRoad,
  1149. SelectState.Select
  1150. );
  1151. } else if (this.modifyPoint.linkedCrossCrossPointId) {
  1152. stateService.setSelectItem(
  1153. this.modifyPoint.linkedCrossCrossPointId,
  1154. VectorType.CrossPoint,
  1155. SelectState.Select
  1156. );
  1157. } else if (this.modifyPoint.textId) {
  1158. stateService.setSelectItem(
  1159. this.modifyPoint.textId,
  1160. VectorType.Text,
  1161. SelectState.Select
  1162. );
  1163. } else if (this.modifyPoint.magnifierId) {
  1164. stateService.setSelectItem(
  1165. this.modifyPoint.magnifierId,
  1166. VectorType.Magnifier,
  1167. SelectState.Select
  1168. );
  1169. } else if (this.modifyPoint.linkedEdgeId) {
  1170. stateService.setSelectItem(
  1171. this.modifyPoint.linkedEdgeId,
  1172. VectorType.RoadEdge,
  1173. SelectState.Select
  1174. );
  1175. } else if (this.modifyPoint.linkedCurveEdgeId) {
  1176. stateService.setSelectItem(
  1177. this.modifyPoint.linkedCurveEdgeId,
  1178. VectorType.CurveRoadEdge,
  1179. SelectState.Select
  1180. );
  1181. } else if (this.modifyPoint.linkedPointId) {
  1182. stateService.setSelectItem(
  1183. this.modifyPoint.linkedPointId,
  1184. VectorType.Point,
  1185. SelectState.Select
  1186. );
  1187. } else if (this.modifyPoint.linkedCurvePointId) {
  1188. stateService.setSelectItem(
  1189. this.modifyPoint.linkedCurvePointId,
  1190. VectorType.CurvePoint,
  1191. SelectState.Select
  1192. );
  1193. } else if (this.modifyPoint.linkedLineId) {
  1194. stateService.setSelectItem(
  1195. this.modifyPoint.linkedLineId,
  1196. VectorType.Line,
  1197. SelectState.Select
  1198. );
  1199. } else if (this.modifyPoint.linkedCurveLineId) {
  1200. stateService.setSelectItem(
  1201. this.modifyPoint.linkedCurveLineId,
  1202. VectorType.CurveLine,
  1203. SelectState.Select
  1204. );
  1205. } else if (this.modifyPoint.linkedCircleId) {
  1206. stateService.setSelectItem(
  1207. this.modifyPoint.linkedCircleId,
  1208. VectorType.Circle,
  1209. this.modifyPoint.index
  1210. );
  1211. }
  1212. let newSelectItem = stateService.getSelectItem();
  1213. if (selectItem == null && newSelectItem == null) {
  1214. return false;
  1215. } else if (selectItem == null && newSelectItem != null) {
  1216. return true;
  1217. } else if (selectItem != null && newSelectItem == null) {
  1218. return true;
  1219. } else if (selectItem.vectorId == newSelectItem.vectorId) {
  1220. return false;
  1221. } else {
  1222. return true;
  1223. }
  1224. }
  1225. distanceForBezier(position, curves, width) {
  1226. return mathUtil.getHitInfoForCurves(position, curves, width);
  1227. }
  1228. equalAndClone(info1, info2) {
  1229. let flag = true;
  1230. for (let key in info1) {
  1231. if (info1[key] != info2[key]) {
  1232. flag = false;
  1233. }
  1234. info1[key] = info2[key];
  1235. }
  1236. return flag;
  1237. }
  1238. clear() {
  1239. this.modifyPoint = null;
  1240. }
  1241. }
  1242. const listenLayer = new ListenLayer();
  1243. export { listenLayer };