[Pkg-javascript-commits] [leaflet-markercluster] 80/219: Update MarkerCluster.QuickHull.js
Jonas Smedegaard
dr at jones.dk
Sat May 7 09:39:13 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository leaflet-markercluster.
commit e9889719da01b039cfc3f4edb9a97b77748279a7
Author: olive380 <olive380 at users.noreply.github.com>
Date: Tue Aug 4 19:31:21 2015 +0200
Update MarkerCluster.QuickHull.js
When all markers are located at same latitude, getConvexHull() fails.
This proposal gets ride of this limitation.
---
src/MarkerCluster.QuickHull.js | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/src/MarkerCluster.QuickHull.js b/src/MarkerCluster.QuickHull.js
index b0819d5..9a59cc4 100644
--- a/src/MarkerCluster.QuickHull.js
+++ b/src/MarkerCluster.QuickHull.js
@@ -107,21 +107,41 @@ Retrieved from: http://en.literateprograms.org/Quickhull_(Javascript)?oldid=1843
*/
getConvexHull: function (latLngs) {
// find first baseline
- var maxLat = false, minLat = false,
- maxPt = null, minPt = null,
- i;
+ var maxLat = false, minLat = false,
+ maxLng = false, minLng = false,
+ maxLatPt = null, minLatPt = null,
+ maxLngPt = null, minLngPt = null,
+ maxPt = null, minPt = null,
+ i;
for (i = latLngs.length - 1; i >= 0; i--) {
var pt = latLngs[i];
if (maxLat === false || pt.lat > maxLat) {
- maxPt = pt;
+ maxLatPt = pt;
maxLat = pt.lat;
}
if (minLat === false || pt.lat < minLat) {
- minPt = pt;
+ minLatPt = pt;
minLat = pt.lat;
}
+ if (maxLng === false || pt.lng > maxLng) {
+ maxLngPt = pt;
+ maxLng = pt.lng;
+ }
+ if (minLng === false || pt.lng < minLng) {
+ minLngPt = pt;
+ minLng = pt.lng;
+ }
+ }
+
+ if (minLat !== maxLat) {
+ minPt = minLatPt;
+ maxPt = maxLatPt;
+ } else {
+ minPt = minLngPt;
+ maxPt = maxLngPt;
}
+
var ch = [].concat(this.buildConvexHull([minPt, maxPt], latLngs),
this.buildConvexHull([maxPt, minPt], latLngs));
return ch;
--
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