({ x, y })
| 16 | } |
| 17 | |
| 18 | function world2LatLng({ x, y }) { |
| 19 | const n = Math.PI - 2 * Math.PI * y; |
| 20 | |
| 21 | // TODO test that this is faster |
| 22 | // 360 * Math.atan(Math.exp((180 - y * 360) * Math.PI / 180)) / Math.PI - 90; |
| 23 | return { |
| 24 | lat: (180 / Math.PI) * Math.atan(0.5 * (Math.exp(n) - Math.exp(-n))), |
| 25 | lng: x * 360 - 180, |
| 26 | }; |
| 27 | } |
| 28 | |
| 29 | // Thank you wiki https://en.wikipedia.org/wiki/Geographic_coordinate_system |
| 30 | function latLng2MetersPerDegree({ lat }) { |