[Pkg-javascript-commits] [leaflet-markercluster] 422/479: Simplify QuickHull generation. Fixes #249

Jonas Smedegaard dr at jones.dk
Thu Oct 16 16:01:03 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository leaflet-markercluster.

commit 038f17f72529529afc5caa673f3b47d6997aa905
Author: Tom MacWright <tom at macwright.org>
Date:   Fri Sep 20 13:34:08 2013 -0400

    Simplify QuickHull generation. Fixes #249
---
 spec/suites/QuickHullSpec.js   | 20 ++++----------------
 src/MarkerCluster.QuickHull.js | 13 +++----------
 2 files changed, 7 insertions(+), 26 deletions(-)

diff --git a/spec/suites/QuickHullSpec.js b/spec/suites/QuickHullSpec.js
index 785f19e..a11325f 100644
--- a/spec/suites/QuickHullSpec.js
+++ b/spec/suites/QuickHullSpec.js
@@ -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 },
             ]);
         });
     });
diff --git a/src/MarkerCluster.QuickHull.js b/src/MarkerCluster.QuickHull.js
index b95ea26..b0819d5 100644
--- a/src/MarkerCluster.QuickHull.js
+++ b/src/MarkerCluster.QuickHull.js
@@ -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);
 	}
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/leaflet-markercluster.git



More information about the Pkg-javascript-commits mailing list