Skip to content

Commit

Permalink
Merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
timfpark committed Jul 29, 2019
2 parents 4dcf159 + fba6dfa commit 7582564
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 68 deletions.
26 changes: 13 additions & 13 deletions js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "geotile",
"homepage": "https://github.com/timfpark/geotile",
"author": "Tim Park <[email protected]>",
"version": "0.1.11",
"version": "0.1.12",
"dependencies": {},
"main": "./tile",
"scripts": {
Expand Down
112 changes: 60 additions & 52 deletions js/test/units/tile.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"use strict";
'use strict';

var assert = require("assert"),
Tile = require("../../tile");
var assert = require('assert'),
Tile = require('../../tile');

describe("geotile", function() {
it("can map latitude, longitude, zoom level to tileId", function(done) {
describe('geotile', function() {
it('can map latitude, longitude, zoom level to tileId', function(done) {
let tileId = Tile.tileIdFromLatLong(36.9719, -122.0264, 10);
assert.equal(tileId, "10_398_164");
assert.equal(tileId, '10_398_164');
done();
});

it("can create tile object from tileId", function(done) {
let tile = Tile.tileFromTileId("10_398_164");
it('can create tile object from tileId', function(done) {
let tile = Tile.tileFromTileId('10_398_164');

assert.equal(tile.zoom, 10);

Expand All @@ -28,15 +28,15 @@ describe("geotile", function() {
done();
});

it("can get tile ids for a range of zoom levels", function(done) {
it('can get tile ids for a range of zoom levels', function(done) {
let tileIds = Tile.tileIdsForZoomLevels(36.9719, -122.0264, 10, 12);

assert.deepEqual(tileIds, ["10_398_164", "11_797_329", "12_1594_659"]);
assert.deepEqual(tileIds, ['10_398_164', '11_797_329', '12_1594_659']);

done();
});

it("can get tile ids for bounding box", function(done) {
it('can get tile ids for bounding box', function(done) {
let tileIds = Tile.tileIdsForBoundingBox(
{
north: 37.16,
Expand All @@ -48,73 +48,81 @@ describe("geotile", function() {
);

assert.deepEqual(tileIds, [
"11_796_328",
"11_796_329",
"11_796_330",
"11_797_328",
"11_797_329",
"11_797_330"
'11_796_328',
'11_796_329',
'11_796_330',
'11_797_328',
'11_797_329',
'11_797_330'
]);

done();
});

it("can get children for tile id", function(done) {
let tileIds = Tile.childrenForTileId("10_398_164");
it('can get children for tile id', function(done) {
let tileIds = Tile.childrenForTileId('10_398_164');

assert.deepEqual(tileIds, [
"11_796_329",
"11_796_328",
"11_797_329",
"11_797_328"
'11_796_329',
'11_796_328',
'11_797_329',
'11_797_328'
]);

done();
});

it("can get children for tile id at a zoom level", function(done) {
let tileIds = Tile.childrenForTileIdAtZoom("10_398_164", 12);
it('can get children for tile id at a zoom level', function(done) {
let tileIds = Tile.childrenForTileIdAtZoom('10_398_164', 12);

assert.deepEqual(tileIds, [
"12_1592_659",
"12_1592_658",
"12_1593_659",
"12_1593_658",
"12_1592_657",
"12_1592_656",
"12_1593_657",
"12_1593_656",
"12_1594_659",
"12_1594_658",
"12_1595_659",
"12_1595_658",
"12_1594_657",
"12_1594_656",
"12_1595_657",
"12_1595_656"
'12_1592_659',
'12_1592_658',
'12_1593_659',
'12_1593_658',
'12_1592_657',
'12_1592_656',
'12_1593_657',
'12_1593_656',
'12_1594_659',
'12_1594_658',
'12_1595_659',
'12_1595_658',
'12_1594_657',
'12_1594_656',
'12_1595_657',
'12_1595_656'
]);

done();
});

it("can get neighbors for tile id", function(done) {
let tileIds = Tile.neighborIds("10_398_164");
it('can get neighbors for tile id', function(done) {
let tileIds = Tile.neighborIds('10_398_164');

assert.deepEqual(tileIds, [
"10_398_165",
"10_399_165",
"10_399_164",
"10_399_163",
"10_398_163",
"10_397_163",
"10_397_164",
"10_397_165"
'10_398_165',
'10_399_165',
'10_399_164',
'10_399_163',
'10_398_163',
'10_397_163',
'10_397_164',
'10_397_165'
]);

done();
});

it("can get most zoomed in common zoom level for corners of bounding box", function(done) {
it('can get neighbors for tile id at edge', function(done) {
let tileIds = Tile.neighborIds('10_0_0');

assert.deepEqual(tileIds, ['10_0_1', '10_1_1', '10_1_0']);

done();
});

it('can get most zoomed in common zoom level for corners of bounding box', function(done) {
let commonZoom = Tile.commonZoomFromBoundingBox({
north: 37.050809,
south: 36.969512,
Expand Down
7 changes: 5 additions & 2 deletions js/tile.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ Tile.decodeTileId = function(tileId) {
};

Tile.tileIdFromRowColumn = function(row, column, zoom) {
return zoom + '_' + row + '_' + column;
if (row < 0 || column < 0 || zoom < 0) return null;
else return zoom + '_' + row + '_' + column;
};

Tile.tileIndexInZoomLevel = function(row, column, zoom) {
Expand Down Expand Up @@ -192,7 +193,9 @@ Tile.neighborIds = function(tileId) {
decodedId.column + 1,
decodedId.zoom
)
];
].filter(tileId => {
return tileId !== null;
});
};

Tile.commonZoomFromBoundingBox = function(bbox) {
Expand Down

0 comments on commit 7582564

Please sign in to comment.