Merge pull request #253 from tmcw/simple-hull

Simplify QuickHull generation. Fixes #249
This commit is contained in:
Dave Leaver
2013-10-13 14:10:44 -07:00
2 changed files with 7 additions and 26 deletions
+4 -16
View File
@@ -25,22 +25,10 @@ describe('quickhull', function () {
{ lat: 0, lng: 10 },
{ lat: 5, lng: 5 },
])).to.eql([
[
{ lat: 0, lng: 10 },
{ lat: 10, lng: 10 }
],
[
{ lat: 10, lng: 10 },
{ lat: 10, lng: 0 },
],
[
{ lat: 10, lng: 0 },
{ lat: 0, lng: 0 }
],
[
{ lat: 0, lng: 0 },
{ lat: 0, lng: 10 }
]
{ lat: 0, lng: 10 },
{ lat: 10, lng: 10 },
{ lat: 10, lng: 0 },
{ lat: 0, lng: 0 },
]);
});
});
+3 -10
View File
@@ -94,7 +94,7 @@ Retrieved from: http://en.literateprograms.org/Quickhull_(Javascript)?oldid=1843
);
return convexHullBaseLines;
} else { // if there is no more point "outside" the base line, the current base line is part of the convex hull
return [baseLine];
return [baseLine[0]];
}
},
@@ -133,20 +133,13 @@ L.MarkerCluster.include({
getConvexHull: function () {
var childMarkers = this.getAllChildMarkers(),
points = [],
hullLatLng = [],
hull, p, i;
p, i;
for (i = childMarkers.length - 1; i >= 0; i--) {
p = childMarkers[i].getLatLng();
points.push(p);
}
hull = L.QuickHull.getConvexHull(points);
for (i = hull.length - 1; i >= 0; i--) {
hullLatLng.push(hull[i][0]);
}
return hullLatLng;
return L.QuickHull.getConvexHull(points);
}
});