Skip to content

Commit 9ca1407

Browse files
committed
fix lat conversion
1 parent 75472d1 commit 9ca1407

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/utils/utils.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ function latLng2World({lat, lng}) {
66
const x = (lng / 360 + 0.5);
77
let y = (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);
88

9-
y = y < -1 // eslint-disable-line
10-
? -1
9+
y = y < 0 // eslint-disable-line
10+
? 0
1111
: y > 1
1212
? 1
1313
: y;
@@ -17,6 +17,8 @@ function latLng2World({lat, lng}) {
1717
function world2LatLng({x, y}) {
1818
const n = Math.PI - 2 * Math.PI * y;
1919

20+
// TODO test that this is faster
21+
// 360 * Math.atan(Math.exp((180 - y * 360) * Math.PI / 180)) / Math.PI - 90;
2022
return {
2123
lat: (180 / Math.PI * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n)))),
2224
lng: x * 360 - 180,

0 commit comments

Comments
 (0)