esps3857.fromEPSG4326() is returning NaN for Y when Math.tan() returns negative value
See original GitHub issueIn the output file for proj.js I noticed that the function only converts the longitude.
_ol_proj_.toLonLat = function(coordinate, opt_projection) {
var lonLat = _ol_proj_.transform(coordinate, opt_projection !== undefined ? opt_projection : 'EPSG:3857', 'EPSG:4326');
var lon = lonLat[0];
if (lon < -180 || lon > 180) {
lonLat[0] = _ol_math_.modulo(lon + 180, 360) - 180;
}
return lonLat;
};
I am not 100% sure why the latitude is being untouched
I was able to finish this function by added a few lines.
_ol_proj_.toLonLat = function(coordinate, opt_projection) {
var lonLat = _ol_proj_.transform(coordinate, opt_projection !== undefined ? opt_projection : 'EPSG:3857', 'EPSG:4326');
var lon = lonLat[0];
var lat = lonLat[1];
if (lon < -180 || lon > 180) {
lonLat[0] = _ol_math_.modulo(lon + 180, 360) - 180;
}
if (lat < -90 || lat > 90) {
lonLat[1] = _ol_math_.modulo(lat + 90, 360) - 90;
}
return lonLat;
};
Things were working properly after that.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Math.tan() - JavaScript - MDN Web Docs
The Math.tan() function returns the tangent of a number in radians.
Read more >Java is outputting the wrong value for a Math.tan() calculation
The argument of Math.tan() has to be in radians. Unless there is a compelling reason not to do so, I'd use radians for...
Read more >What is Math.tan() in Scala? - Educative.io
Return value. tan() returns the tangent of a number in radians that is sent as a parameter. If the parameter value is NaN...
Read more >Java Math tan() method with Examples - GeeksforGeeks
Math.tan() returns the trigonometric tangent of an angle. If the argument is NaN or an infinity, then the result returned is NaN.
Read more >Math.Tan(Double) Method (System) - Microsoft Learn
Returns the tangent of the specified angle. ... Tan() using System; class Sample { public static void Main() { double x = 1.0;...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Latitudes are expected to be in the range of -85.06 to 85.06. You are probably passing projected coordinates instead of longitudes and latitudes to
ol/proj/fromLonLat
orepst3857/fromEPSG4326
.This is expected for coordinates outside the projection’s validity extent. For EPSG:3857, this is latitude -85.06 to 85.06 (see https://epsg.io/3857).
The change you suggested above would not change the latitude if it was
NaN
already.Have you checked the input values you pass as
xy
totoLonLat()
?