Added tests to verify size of EPSG3857 and 4326

This commit is contained in:
Per Liedman 2013-11-27 09:05:08 +01:00 committed by Vladimir Agafonkin
parent 6c4d607e4d
commit 294a7250d0
2 changed files with 34 additions and 1 deletions

View File

@ -44,4 +44,37 @@ describe("CRS.EPSG3857", function () {
expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0511287798, 180));
});
});
describe("#getSize", function () {
it("gives correct size", function () {
var i,
worldSize = 256,
crsSize;
for (i = 0; i <= 22; i++) {
crsSize = crs.getSize(i);
expect(crsSize.x).equal(worldSize);
expect(crsSize.y).equal(worldSize);
worldSize *= 2;
}
});
});
});
describe("CRS.EPSG4326", function () {
var crs = L.CRS.EPSG4326;
describe("#getSize", function () {
it("gives correct size", function () {
var i,
worldSize = 256,
crsSize;
for (i = 0; i <= 22; i++) {
crsSize = crs.getSize(i);
expect(crsSize.x).equal(worldSize);
// Lat bounds are half as high (-90/+90 compared to -180/+180)
expect(crsSize.y).equal(worldSize / 2);
worldSize *= 2;
}
});
});
});

View File

@ -11,5 +11,5 @@ L.Projection.LonLat = {
return new L.LatLng(point.y, point.x);
},
bounds: L.bounds([-180, -90], [180, 90])
bounds: L.bounds([-180, -90], [180, 90])
};