Use geoEuclideanDistance for simpler code

This commit is contained in:
Bryan Housel
2016-10-18 00:56:18 -04:00
parent ad17220577
commit 0d0b9b0d9b
3 changed files with 18 additions and 22 deletions
+2 -1
View File
@@ -1,4 +1,5 @@
import { actionDeleteNode } from './delete_node';
import { geoEuclideanDistance } from '../geo/index';
/*
@@ -60,7 +61,7 @@ export function actionStraighten(wayId, projection) {
points = nodes.map(function(n) { return projection(n.loc); }),
startPoint = points[0],
endPoint = points[points.length-1],
threshold = 0.2 * Math.sqrt(Math.pow(startPoint[0] - endPoint[0], 2) + Math.pow(startPoint[1] - endPoint[1], 2)),
threshold = 0.2 * geoEuclideanDistance(startPoint, endPoint),
i;
if (threshold === 0) {