supercluster
Advanced tools
Comparing version 2.1.0 to 2.2.0
46
index.js
@@ -73,30 +73,44 @@ 'use strict'; | ||
getTile: function (z, x, y) { | ||
var tree = this.trees[this._limitZoom(z)]; | ||
var z2 = Math.pow(2, z); | ||
var extent = this.options.extent; | ||
var p = this.options.radius / extent; | ||
var tree = this.trees[this._limitZoom(z)]; | ||
var ids = tree.range( | ||
(x - p) / z2, | ||
(y - p) / z2, | ||
(x + 1 + p) / z2, | ||
(y + 1 + p) / z2); | ||
var r = this.options.radius; | ||
var p = r / extent; | ||
var top = (y - p) / z2; | ||
var bottom = (y + 1 + p) / z2; | ||
if (!ids.length) return null; | ||
var tile = { | ||
features: [] | ||
}; | ||
this._addTileFeatures( | ||
tree.range((x - p) / z2, top, (x + 1 + p) / z2, bottom), | ||
tree.points, x, y, z2, tile); | ||
if (x === 0) { | ||
this._addTileFeatures( | ||
tree.range(1 - p / z2, top, 1, bottom), | ||
tree.points, z2, y, z2, tile); | ||
} | ||
if (x === z2 - 1) { | ||
this._addTileFeatures( | ||
tree.range(0, top, p / z2, bottom), | ||
tree.points, -1, y, z2, tile); | ||
} | ||
return tile.features.length ? tile : null; | ||
}, | ||
_addTileFeatures: function (ids, points, x, y, z2, tile) { | ||
for (var i = 0; i < ids.length; i++) { | ||
var c = tree.points[ids[i]]; | ||
var feature = { | ||
var c = points[ids[i]]; | ||
tile.features.push({ | ||
type: 1, | ||
geometry: [[ | ||
Math.round(extent * (c.x * z2 - x)), | ||
Math.round(extent * (c.y * z2 - y)) | ||
Math.round(this.options.extent * (c.x * z2 - x)), | ||
Math.round(this.options.extent * (c.y * z2 - y)) | ||
]], | ||
tags: c.id !== -1 ? this.points[c.id].properties : getClusterProperties(c) | ||
}; | ||
tile.features.push(feature); | ||
}); | ||
} | ||
return tile; | ||
}, | ||
@@ -103,0 +117,0 @@ |
{ | ||
"name": "supercluster", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "A crazy fast geospatial point clustering library.", | ||
@@ -9,4 +9,14 @@ "main": "index.js", | ||
"test": "tap test", | ||
"cov": "tap test --cov" | ||
"cov": "tap test --cov", | ||
"build-dev": "mkdirp dist && browserify -d index.js -s supercluster > dist/supercluster.js", | ||
"build-min": "mkdirp dist && browserify index.js -s supercluster | uglifyjs -c warnings=false -m > dist/supercluster.min.js", | ||
"prepublish": "npm run build-dev && npm run build-min" | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/mapbox/supercluster.git" | ||
}, | ||
"keywords": [ | ||
@@ -23,5 +33,8 @@ "clustering", | ||
"devDependencies": { | ||
"browserify": "^13.1.0", | ||
"eslint": "^2.7.0", | ||
"eslint-config-mourner": "^2.0.1", | ||
"tap": "^5.7.1" | ||
"mkdirp": "^0.5.1", | ||
"tap": "^5.7.1", | ||
"uglifyjs": "^2.4.10" | ||
}, | ||
@@ -28,0 +41,0 @@ "eslintConfig": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
50667
6
628
6
2
4
1