Skip to content

Commit 812f6e2

Browse files
committed
Use @turf/clean-coords to resolve [issue#2809](Turfjs/turf#2809) of Turfjs.
1 parent 128b143 commit 812f6e2

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@turf/along": "^7.1.0",
4242
"@turf/area": "^6.5.0",
4343
"@turf/bbox": "^6.5.0",
44+
"@turf/clean-coords": "^7.2.0",
4445
"@turf/helpers": "^6.5.0",
4546
"@turf/length": "^7.0.0",
4647
"@turf/nearest-point-on-line": "^7.0.0",

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/interactions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import maplibregl from 'maplibre-gl'
2525
import {default as turfAlong} from '@turf/along'
2626
import {default as turfBBox} from '@turf/bbox'
2727
import * as turf from '@turf/helpers'
28+
import * as turfCleanCoords from "@turf/clean-coords"
2829
import * as turfNearestPointOnLine from "@turf/nearest-point-on-line"
2930
import * as turfProjection from '@turf/projection'
3031

@@ -1427,7 +1428,7 @@ export class UserInteractions
14271428
if (annotation && annotation.centreline && 'lineString' in annotation) {
14281429
const line = annotation.lineString!
14291430
const clickedPoint = turf.point([lngLat.lng, lngLat.lat])
1430-
const linePoint = turfNearestPointOnLine.nearestPointOnLine(line, clickedPoint)
1431+
const linePoint = turfNearestPointOnLine.nearestPointOnLine(turfCleanCoords.cleanCoords(line), clickedPoint)
14311432
return {
14321433
location: linePoint.properties.location/annotation.lineLength!
14331434
}

0 commit comments

Comments
 (0)