Merge Elliptical Mercator fix by @Savvkin

This commit is contained in:
mourner 2011-12-13 16:23:22 +02:00
commit 12d3dc5e71
4 changed files with 14 additions and 9 deletions

View File

@ -69,6 +69,7 @@ Leaflet Changelog
* Fixed a bug that made selecting text in the attribution control impossible. [#279](https://github.com/CloudMade/Leaflet/issues/279)
* Fixed a bug when initializing a map in a non-empty div. [#278](https://github.com/CloudMade/Leaflet/issues/278)
* Fixed a bug where `movestart` didn't fire on panning animation.
* Fixed a bug in Elliptical Mercator formula that affeted `EPSG:3395` CRS (by [@Savvkin](https://github.com/Savvkin)). [#358](https://github.com/CloudMade/Leaflet/pull/358)
#### Browser bugfixes

10
dist/leaflet-src.js vendored
View File

@ -1484,16 +1484,17 @@ L.Projection.Mercator = {
max = this.MAX_LATITUDE,
lat = Math.max(Math.min(max, latlng.lat), -max),
r = this.R_MAJOR,
r2 = this.R_MINOR,
x = latlng.lng * d * r,
y = lat * d,
tmp = this.R_MINOR / r,
tmp = r2 / r,
eccent = Math.sqrt(1.0 - tmp * tmp),
con = eccent * Math.sin(y);
con = Math.pow((1 - con) / (1 + con), eccent * 0.5);
var ts = Math.tan(0.5 * ((Math.PI * 0.5) - y)) / con;
y = -r * Math.log(ts);
y = -r2 * Math.log(ts);
return new L.Point(x, y);
},
@ -1501,10 +1502,11 @@ L.Projection.Mercator = {
unproject: function (/*Point*/ point, /*Boolean*/ unbounded) /*-> LatLng*/ {
var d = L.LatLng.RAD_TO_DEG,
r = this.R_MAJOR,
r2 = this.R_MINOR,
lng = point.x * d / r,
tmp = this.R_MINOR / r,
tmp = r2 / r,
eccent = Math.sqrt(1 - (tmp * tmp)),
ts = Math.exp(- point.y / r),
ts = Math.exp(- point.y / r2),
phi = (Math.PI / 2) - 2 * Math.atan(ts),
numIter = 15,
tol = 1e-7,

2
dist/leaflet.js vendored

File diff suppressed because one or more lines are too long

View File

@ -10,16 +10,17 @@ L.Projection.Mercator = {
max = this.MAX_LATITUDE,
lat = Math.max(Math.min(max, latlng.lat), -max),
r = this.R_MAJOR,
r2 = this.R_MINOR,
x = latlng.lng * d * r,
y = lat * d,
tmp = this.R_MINOR / r,
tmp = r2 / r,
eccent = Math.sqrt(1.0 - tmp * tmp),
con = eccent * Math.sin(y);
con = Math.pow((1 - con) / (1 + con), eccent * 0.5);
var ts = Math.tan(0.5 * ((Math.PI * 0.5) - y)) / con;
y = -r * Math.log(ts);
y = -r2 * Math.log(ts);
return new L.Point(x, y);
},
@ -27,10 +28,11 @@ L.Projection.Mercator = {
unproject: function (/*Point*/ point, /*Boolean*/ unbounded) /*-> LatLng*/ {
var d = L.LatLng.RAD_TO_DEG,
r = this.R_MAJOR,
r2 = this.R_MINOR,
lng = point.x * d / r,
tmp = this.R_MINOR / r,
tmp = r2 / r,
eccent = Math.sqrt(1 - (tmp * tmp)),
ts = Math.exp(- point.y / r),
ts = Math.exp(- point.y / r2),
phi = (Math.PI / 2) - 2 * Math.atan(ts),
numIter = 15,
tol = 1e-7,