Turfjs / Turfjs/turf

Use geokdbush for @turf/nearest-point

Open
#1,015 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

@turf/nearest-point performance
Dominant language
TypeScript
Stars
10.5k
Forks
1k
Avg merge
1h 11m
Merged PRs (30d)
4

Description

Use geokdbush for @turf/nearest-point

Seems like @turf/nearest-point could have a significant performance increase by leveraging @mourner's geokdbush.

Current code of @turf/nearest-point
function nearest(targetPoint, points) {
    var nearestPoint, minDist = Infinity;
    for (var i = 0; i < points.features.length; i++) {
        var distanceToPoint = distance(targetPoint, points.features[i]);
        if (distanceToPoint < minDist) {
            nearestPoint = points.features[i];
            minDist = distanceToPoint;
        }
    }
    return nearestPoint;
}
Dependent modules
  • @turf/point-on-surface

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the current nearest-point implementation shown in the issue and review how geokdbush provides nearest-point lookup. Check the dependent @turf/point-on-surface module for compatibility. Done means @turf/nearest-point uses geokdbush while preserving its existing result behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.