@@ -15,15 +15,25 @@ const getIntersectedLinesAndPoint = (coordinate, lines, map, snapTolerance) => {
15
15
const isPointAlreadyExist = { } ;
16
16
const mousePx = map . getPixelFromCoordinate ( coordinate ) ;
17
17
18
- lines . forEach ( ( lineA ) => {
19
- lines . forEach ( ( lineB ) => {
20
- const intersections = OverlayOp . intersection (
21
- parser . read ( lineA . getGeometry ( ) ) ,
22
- parser . read ( lineB . getGeometry ( ) ) ,
23
- ) ;
24
- const coord = intersections ?. getCoordinates ( ) [ 0 ] ;
18
+ const parsedLines = lines . map ( ( line ) => [
19
+ line ,
20
+ parser . read ( line . getGeometry ( ) ) ,
21
+ ] ) ;
22
+ parsedLines . forEach ( ( [ lineA , parsedLineA ] ) => {
23
+ parsedLines . forEach ( ( [ lineB , parsedLineB ] ) => {
24
+ if ( lineA === lineB || isSameLines ( lineA , lineB , map ) ) {
25
+ return ;
26
+ }
25
27
26
- if ( coord && lineA !== lineB && ! isSameLines ( lineA , lineB , map ) ) {
28
+ let intersections ;
29
+ try {
30
+ intersections = OverlayOp . intersection ( parsedLineA , parsedLineB ) ;
31
+ } catch ( e ) {
32
+ return ; // The OverlayOp will sometimes error with topology errors for certain lines
33
+ }
34
+
35
+ const coord = intersections ?. getCoordinates ( ) [ 0 ] ;
36
+ if ( coord ) {
27
37
intersections . getCoordinates ( ) . forEach ( ( { x, y } ) => {
28
38
if (
29
39
getDistance ( map . getPixelFromCoordinate ( [ x , y ] ) , mousePx ) <=
0 commit comments