Geographic Information Systems Asked by Majed DH on August 11, 2021
Is there any math formula for transforming from EPSG:4326 to EPSG:3857 ?
i want to implement it in php code
Projection EPSG:3857
uses the method EPSG:1024
for Forward and Reverse calculations.
The method is fully documented at Geomatics Guidance Note No 7, part 2
There's an mathematical example at page 40 where you can use to cross-reference your code.
17/11/2020 EDIT: The link to the above documentation from times to times, gets broken as things evolve. If that happens please feel free to update it as necessary.
Correct answer by nickves on August 11, 2021
I got a C# code for using in unity engine.
Here the code below :
public static double[] latLonToMeters(double lat, double lon)
{
//Debug.Log(Mathd.Tan((90d + lat) * Mathd.PI / 720));
//Debug.Log(Mathd.Tan((90d + lat) * Mathd.PI / 360d));
double[] meters = new double[2];
meters[0] = lat * originShift / 180d;
meters[1] = Mathd.Log(Mathd.Tan((90d+lon) * Mathd.PI / 360d)) / (Mathd.PI / 180d);
//meters[1] = Mathd.Log(5) / (Mathd.PI / 180d);
meters[1] = meters[1] * originShift / 180d;
return meters;
}
Answered by user144482 on August 11, 2021
PHP code:
function convert4326to3857($x, $y)
{
return [
$x * 180 / 20037508.34,
atan(exp($y / 111319.490778 * pi() / 180)) * 360 / pi() - 90
];
}
Answered by neubert on August 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP