Open ruellm opened 6 years ago
As you noted this formula is using mercator projection, from wikipedia:
formulae are written in terms of the globe radius R. It is often convenient to work directly with the map width W = 2πR. For example, the basic transformation equations become
w is the width of the map you want to render. (think in terms of circumference =2πR of globe in context of your app) Value of 2000 was selected based on the scale of map needed. (though I kept SCALE value too but is not really needed as could be combined into one) Small value will result in smaller map, and increasing it will render same thing but scaled. Hope this helps.
On Thu, Jul 12, 2018 at 7:50 PM, ruellm notifications@github.com wrote:
hi, thank you for the code, it really helps a lot, however, i have a question with your formula on converting the latitude and longitude to world space opengl coordinates
Here is your code:
double convert_lat_to_y(double lat) { double y = 0, w = 2000; double latRad = m3dDegToRad(lat); y = (w / (2 M_PI) log(tan(M_PI / 4 + latRad / 2)) * SCALE); y = y + map.shiftY; return y; }
double convert_lon_to_x(double lon) { double x = 0, w = 2000; float lonRad = m3dDegToRad(lon);
x = ((w / (2 M_PI)) (lonRad)* SCALE); x = -(x + map.shiftX);
return x;
}
i recognize that most part of this are mercator projection formula, but my question is how did you arrive the value for the "w" variable and set it to 2000? can you explain a little? I cant find the reasoning behind that value, as when i checked about the formula, that should be the total pixel width of the map, and i cannot fathom why you set it to 2000, cant find the reason behind, even if i read both the OSM and Overpass API documentation.
can you explain the value behind this? thanks
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Anubha-Banerjee/3d-mapLand/issues/2, or mute the thread https://github.com/notifications/unsubscribe-auth/AC-DbRLGTr6sJx2scZG1yHUJqj3OVAi2ks5uF1stgaJpZM4VM8J3 .
-- Anubha
hi, thank you for the code, it really helps a lot, however, i have a question with your formula on converting the latitude and longitude to world space opengl coordinates
Here is your code:
i recognize that most part of this are mercator projection formula, but my question is how did you arrive the value for the "w" variable and set it to 2000? can you explain a little? I cant find the reasoning behind that value, as when i checked about the formula, that should be the total pixel width of the map, and i cannot fathom why you set it to 2000, cant find the reason behind, even if i read both the OSM and Overpass API documentation.
can you explain the value behind this? thanks