Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid extraneous tiles that are just outside the frame #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ os: Visual Studio 2015

environment:
matrix:
- nodejs_version: "0.10.40"
- nodejs_version: "4.4.1"

platform:
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ abaculus.tileList = function(z, s, center, tileSize) {
y = center.y,
w = center.w,
h = center.h;
var dimensions = {x: w, y: h};
var dimensions = {x: w - 1, y: h - 1};
var size = tileSize || 256;
var ts = Math.floor(size * s);

Expand Down
20 changes: 20 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,27 @@ describe('create list of tile coordinates', function() {
var coords = printer.tileList(zoom, scale, center);
assert.deepEqual(JSON.stringify(coords), JSON.stringify(expectedCoords));
});
it('should avoid extranious images', function() {
var zoom = 11,
scale = 1,
width = 256,
height = 256,
center = { w: width, h: height, x: 118912, y: 214912 };

var expectedCoords = {
tiles: [
{ z: 11, x: 464, y: 839, px: 0, py: 0},
// {z: 11, x: 464, y: 840, px: 0, py: 256 },
// { z: 11, x: 465, y: 839, px: 256, py: 0 },
// { z: 11, x: 465, y: 840, px: 256, py: 256 }
],
dimensions: {x: width, y: height},
center: { row: 839, column: 464, zoom: 11 },
scale: scale
};
var coords = printer.tileList(zoom, scale, center);
assert.deepEqual(JSON.stringify(coords), JSON.stringify(expectedCoords));
});
it('should return a tiles object with correct coords when image is much bigger than world', function() {
var zoom = 1,
scale = 1,
Expand Down