2013-11-08 05:54:33 +08:00
|
|
|
describe("Projection.Mercator", function () {
|
2010-09-07 16:59:58 +08:00
|
|
|
var p = L.Projection.Mercator;
|
2013-02-20 00:18:15 +08:00
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
describe("#project", function () {
|
|
|
|
it("projects a center point", function () {
|
2015-09-25 20:37:07 +08:00
|
|
|
// edge cases
|
2013-03-02 05:49:20 +08:00
|
|
|
expect(p.project(new L.LatLng(0, 0))).near(new L.Point(0, 0));
|
2013-03-02 06:14:14 +08:00
|
|
|
});
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it("projects the northeast corner of the world", function () {
|
2014-01-03 23:37:28 +08:00
|
|
|
expect(p.project(new L.LatLng(85.0840591556, 180))).near(new L.Point(20037508, 20037508));
|
2013-03-02 06:14:14 +08:00
|
|
|
});
|
2013-02-20 00:18:15 +08:00
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it("projects the southwest corner of the world", function () {
|
2014-01-03 23:37:28 +08:00
|
|
|
expect(p.project(new L.LatLng(-85.0840591556, -180))).near(new L.Point(-20037508, -20037508));
|
2013-03-02 06:14:14 +08:00
|
|
|
});
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it("projects other points", function () {
|
|
|
|
expect(p.project(new L.LatLng(50, 30))).near(new L.Point(3339584, 6413524));
|
2013-06-24 22:42:15 +08:00
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
// from https://github.com/Leaflet/Leaflet/issues/1578
|
|
|
|
expect(p.project(new L.LatLng(51.9371170300465, 80.11230468750001)))
|
|
|
|
.near(new L.Point(8918060.964088084, 6755099.410887127));
|
2010-09-07 16:59:58 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
describe("#unproject", function () {
|
2013-03-02 06:14:14 +08:00
|
|
|
function pr(point) {
|
|
|
|
return p.project(p.unproject(point));
|
|
|
|
}
|
2013-02-20 00:18:15 +08:00
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it("unprojects a center point", function () {
|
2013-03-02 05:49:20 +08:00
|
|
|
expect(pr(new L.Point(0, 0))).near(new L.Point(0, 0));
|
2013-03-02 06:14:14 +08:00
|
|
|
});
|
|
|
|
|
2013-11-08 05:54:33 +08:00
|
|
|
it("unprojects pi points", function () {
|
2013-03-02 05:49:20 +08:00
|
|
|
expect(pr(new L.Point(-Math.PI, Math.PI))).near(new L.Point(-Math.PI, Math.PI));
|
|
|
|
expect(pr(new L.Point(-Math.PI, -Math.PI))).near(new L.Point(-Math.PI, -Math.PI));
|
2013-02-20 00:18:15 +08:00
|
|
|
|
2013-03-02 05:49:20 +08:00
|
|
|
expect(pr(new L.Point(0.523598775598, 1.010683188683))).near(new L.Point(0.523598775598, 1.010683188683));
|
2010-09-07 16:59:58 +08:00
|
|
|
});
|
2013-06-24 22:42:15 +08:00
|
|
|
|
|
|
|
it('unprojects other points', function () {
|
|
|
|
// from https://github.com/Leaflet/Leaflet/issues/1578
|
|
|
|
expect(pr(new L.Point(8918060.964088084, 6755099.410887127)));
|
|
|
|
});
|
2010-09-07 00:17:27 +08:00
|
|
|
});
|
2013-02-20 00:18:15 +08:00
|
|
|
});
|
2013-11-30 00:50:31 +08:00
|
|
|
describe("Projection.SphericalMercator", function () {
|
2013-10-04 01:08:19 +08:00
|
|
|
var p = L.Projection.SphericalMercator;
|
|
|
|
|
2013-11-30 00:50:31 +08:00
|
|
|
describe("#project", function () {
|
|
|
|
it("projects a center point", function () {
|
2015-09-25 20:37:07 +08:00
|
|
|
// edge cases
|
2013-10-04 01:08:19 +08:00
|
|
|
expect(p.project(new L.LatLng(0, 0))).near(new L.Point(0, 0));
|
|
|
|
});
|
|
|
|
|
2013-11-30 00:50:31 +08:00
|
|
|
it("projects the northeast corner of the world", function () {
|
2014-01-03 23:37:28 +08:00
|
|
|
expect(p.project(new L.LatLng(85.0511287798, 180))).near(new L.Point(20037508, 20037508));
|
2013-10-04 01:08:19 +08:00
|
|
|
});
|
|
|
|
|
2013-11-30 00:50:31 +08:00
|
|
|
it("projects the southwest corner of the world", function () {
|
2014-01-03 23:37:28 +08:00
|
|
|
expect(p.project(new L.LatLng(-85.0511287798, -180))).near(new L.Point(-20037508, -20037508));
|
2013-10-04 01:08:19 +08:00
|
|
|
});
|
|
|
|
|
2013-11-30 00:50:31 +08:00
|
|
|
it("projects other points", function () {
|
|
|
|
expect(p.project(new L.LatLng(50, 30))).near(new L.Point(3339584, 6446275));
|
2013-10-04 01:08:19 +08:00
|
|
|
|
2013-11-30 00:50:31 +08:00
|
|
|
// from https://github.com/Leaflet/Leaflet/issues/1578
|
|
|
|
expect(p.project(new L.LatLng(51.9371170300465, 80.11230468750001)))
|
2017-08-31 14:58:42 +08:00
|
|
|
.near(new L.Point(8918060.96409, 6788763.38325));
|
2013-10-04 01:08:19 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-11-30 00:50:31 +08:00
|
|
|
describe("#unproject", function () {
|
2013-10-04 01:08:19 +08:00
|
|
|
function pr(point) {
|
|
|
|
return p.project(p.unproject(point));
|
|
|
|
}
|
|
|
|
|
2013-11-30 00:50:31 +08:00
|
|
|
it("unprojects a center point", function () {
|
2013-10-04 01:08:19 +08:00
|
|
|
expect(pr(new L.Point(0, 0))).near(new L.Point(0, 0));
|
|
|
|
});
|
|
|
|
|
2013-11-30 00:50:31 +08:00
|
|
|
it("unprojects pi points", function () {
|
2013-10-04 01:08:19 +08:00
|
|
|
expect(pr(new L.Point(-Math.PI, Math.PI))).near(new L.Point(-Math.PI, Math.PI));
|
|
|
|
expect(pr(new L.Point(-Math.PI, -Math.PI))).near(new L.Point(-Math.PI, -Math.PI));
|
|
|
|
|
|
|
|
expect(pr(new L.Point(0.523598775598, 1.010683188683))).near(new L.Point(0.523598775598, 1.010683188683));
|
|
|
|
});
|
|
|
|
|
|
|
|
it('unprojects other points', function () {
|
|
|
|
// from https://github.com/Leaflet/Leaflet/issues/1578
|
|
|
|
expect(pr(new L.Point(8918060.964088084, 6755099.410887127)));
|
|
|
|
});
|
|
|
|
});
|
2013-11-30 00:50:31 +08:00
|
|
|
});
|