Socket
Socket
Sign inDemoInstall

tilebelt

Package Overview
Dependencies
Maintainers
22
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tilebelt - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

28

index.js

@@ -85,3 +85,3 @@ // a tile is an array [x,y,z]

tile1[1] === tile2[1] &&
tile1[2] === tile2[2]
tile1[2] === tile2[2];
);

@@ -130,3 +130,26 @@ }

function bboxToTile(bboxCoords) {
var min = pointToTile(bboxCoords[0], bboxCoords[1], 32);
var max = pointToTile(bboxCoords[2], bboxCoords[3], 32);
var bbox = [min[0], min[1], max[0], max[1]];
var z = getBboxZoom(bbox);
var x = bbox[0] >> (32 - z);
var y = bbox[1] >> (32 - z);
return [x,y,z];
}
function getBboxZoom(bbox) {
var MAX_ZOOM = 28;
for (var z = 0; z < MAX_ZOOM; z++) {
var mask = 1 << (32 - (z + 1));
if (((bbox[0] & mask) != (bbox[2] & mask)) ||
((bbox[1] & mask) != (bbox[3] & mask))) {
return z;
}
}
return MAX_ZOOM;
}
module.exports = {

@@ -143,3 +166,4 @@ tileToGeoJSON: tileToGeoJSON,

quadkeyToTile: quadkeyToTile,
pointToTile: pointToTile
pointToTile: pointToTile,
bboxToTile: bboxToTile
};

2

package.json
{
"name": "tilebelt",
"version": "0.4.0",
"version": "0.5.0",
"description": "simple tile utilities",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -94,2 +94,12 @@ var test = require('tape'),

test('point to tile verified', function(t) {
var tile = tilebelt.pointToTile(-77.03239381313323,38.91326516559442,10);
t.equal(tile.length, 3);
t.equal(tile[0], 292);
t.equal(tile[1], 391);
t.equal(tile[2], 10);
t.equal(tilebelt.tileToQuadkey(tile), '0320100322')
t.end();
});
test('point and tile back and forth', function(t) {

@@ -102,5 +112,32 @@ var tile = tilebelt.pointToTile(10,10,10);

test('check key 03', function(t) {
var quadkey = '03'
t.equal(tilebelt.quadkeyToTile(quadkey).toString(), [1,1,2].toString())
var quadkey = '03';
t.equal(tilebelt.quadkeyToTile(quadkey).toString(), [1,1,2].toString());
t.end();
});
test('bbox to tile -- big', function(t) {
var bbox = [-84.72656249999999,
11.178401873711785,
-5.625,
61.60639637138628];
var tile = tilebelt.bboxToTile(bbox)
t.ok(tile, 'convert bbox to tile');
t.equal(tile[0], 1);
t.equal(tile[1], 1);
t.equal(tile[2], 2);
t.end();
})
test('bbox to tile -- dc', function(t) {
var bbox = [-77.04615354537964,
38.899967510782346,
-77.03664779663086,
38.90728142481329];
var tile = tilebelt.bboxToTile(bbox);
t.ok(tile, 'convert bbox to tile');
t.equal(tile[0], 9371);
t.equal(tile[1], 12534);
t.equal(tile[2], 15);
t.end();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc