2013-11-08 05:54:33 +08:00
|
|
|
describe("CRS.EPSG3395", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
var crs = L.CRS.EPSG3395;
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
describe("#latLngToPoint", function () {
|
|
|
|
it("projects a center point", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
|
2013-11-08 05:54:33 +08:00
|
|
|
});
|
2013-09-10 15:03:59 +08:00
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it("projects the northeast corner of the world", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
expect(crs.latLngToPoint(L.latLng(85.0840591556, 180), 0)).near(new L.Point(256, 0));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
describe("#pointToLatLng", function () {
|
|
|
|
it("reprojects a center point", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
|
2013-11-08 05:54:33 +08:00
|
|
|
});
|
2013-09-10 15:03:59 +08:00
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it("reprojects the northeast corner of the world", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0840591556, 180));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
describe("CRS.EPSG3857", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
var crs = L.CRS.EPSG3857;
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
describe("#latLngToPoint", function () {
|
|
|
|
it("projects a center point", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
expect(crs.latLngToPoint(L.latLng(0, 0), 0)).near(new L.Point(128, 128), 0.01);
|
2013-11-08 05:54:33 +08:00
|
|
|
});
|
2013-09-10 15:03:59 +08:00
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it("projects the northeast corner of the world", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
expect(crs.latLngToPoint(L.latLng(85.0511287798, 180), 0)).near(new L.Point(256, 0));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
describe("#pointToLatLng", function () {
|
|
|
|
it("reprojects a center point", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
expect(crs.pointToLatLng(new L.Point(128, 128), 0)).nearLatLng(L.latLng(0, 0), 0.01);
|
2013-11-08 05:54:33 +08:00
|
|
|
});
|
2013-09-10 15:03:59 +08:00
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it("reprojects the northeast corner of the world", function () {
|
2013-09-10 15:03:59 +08:00
|
|
|
expect(crs.pointToLatLng(new L.Point(256, 0), 0)).nearLatLng(L.latLng(85.0511287798, 180));
|
|
|
|
});
|
|
|
|
});
|
2013-11-27 16:05:08 +08:00
|
|
|
|
2013-11-28 22:04:14 +08:00
|
|
|
describe("#getProjectedBounds", function () {
|
2013-11-27 16:05:08 +08:00
|
|
|
it("gives correct size", function () {
|
|
|
|
var i,
|
|
|
|
worldSize = 256,
|
|
|
|
crsSize;
|
|
|
|
for (i = 0; i <= 22; i++) {
|
2013-11-28 22:04:14 +08:00
|
|
|
crsSize = crs.getProjectedBounds(i).getSize();
|
2013-11-27 16:05:08 +08:00
|
|
|
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++) {
|
2013-11-28 22:04:14 +08:00
|
|
|
crsSize = crs.getProjectedBounds(i).getSize();
|
2013-11-28 06:59:39 +08:00
|
|
|
expect(crsSize.x).equal(worldSize * 2);
|
2013-11-27 16:05:08 +08:00
|
|
|
// Lat bounds are half as high (-90/+90 compared to -180/+180)
|
2013-11-28 06:59:39 +08:00
|
|
|
expect(crsSize.y).equal(worldSize);
|
2013-11-27 16:05:08 +08:00
|
|
|
worldSize *= 2;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2013-11-08 05:54:33 +08:00
|
|
|
});
|