Skip to content

Commit

Permalink
Nearest neighbour (Turfjs#1411)
Browse files Browse the repository at this point in the history
* Add typescript validation fix
  • Loading branch information
rowanwins committed Jun 12, 2018
1 parent be397b4 commit 60b824f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/turf-nearest-neighbor-analysis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ function nearestNeighborAnalysis(dataset: FeatureCollection<any>, options?: {
const otherFeatures = featureCollection<Point>(features.filter((f, i) => {
return i !== index;
}));
return distance(feature, nearestPoint(feature, otherFeatures), {units});
// Have to add the ! to make typescript validation pass
// see https://stackoverflow.com/a/40350534/1979085
return distance(feature, nearestPoint(feature, otherFeatures).geometry!.coordinates, {units});
}).reduce((sum, value) => { return sum + value; }, 0) / n;

const populationDensity = n / convertArea(area(studyArea), 'meters', units);
Expand Down

0 comments on commit 60b824f

Please sign in to comment.