Open jgauchia opened 2 months ago
Hi Jordi, sorry, I forgot the question. yes, the screen coordinates are in the viewPort struct, in mercator projection. To get latitude and longitude from mercator coordinates you need a function. In C it would be (thanks to chatgpt :-) :
#include <math.h>
// Earth's radius in meters (WGS 84)
#define EARTH_RADIUS 6378137.0
double mercator_X_to_lon( double x) {
return (x / EARTH_RADIUS) * (180.0 / M_PI);
}
double mercator_Y_to_lat( double y) {
return (atan(sinh(y / EARTH_RADIUS))) * (180.0 / M_PI);
}
Then, in the viewPort you have the boundary box visible in screen. The corners of the visible map would be:
viewPort.bbox.min.x
viewPort.bbox.min.y
viewPort.bbox.max.x
viewPort.bbox.max.y
They are already adjusted depending on the zoom level and the position. You can pass them to the functions above to get the lat/lon coordinates. If you would need the coordinates of the center of the display only, you have it also: viewPort.center.x, viewPort.center.y
I think that it should work, but I have not tested it, maybe I miss something. Let me know if it works. Salutacions!
Hi @aresta no problem, I've closed the issue , but i needed this info. Oks, no problem I'll test It soon thank you! (Moltes gràcies)
Hi @aresta , how are you?
I've a little question.
It is possible to know, for the map being viewed (and with zoom level), the boundaries? (min-max latitude and longitude)
Thank you so much!