//--------------------------------------------------------------------------- #include #pragma hdrstop #include "DownloaderF.h" //--------------------------------------------------------------------------- #pragma package(smart_init) static double Lon2TileX(double ALon, int AZoom) { return (ALon + 180.0) / 360.0 * pow(2.0, AZoom); } //--------------------------------------------------------------------------- static double Lat2TileY(double ALat, int AZoom) { return (1.0 - log(tan(ALat * M_PI/180.0) + 1.0 / cos(ALat * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, AZoom); } //--------------------------------------------------------------------------- static double TileX2Lon(double AX, int AZoom) { return AX / pow(2.0, AZoom) * 360.0 - 180; } //--------------------------------------------------------------------------- static double TileY2Lat(double AY, int AZoom) { double n = M_PI - 2.0 * M_PI * AY / pow(2.0, AZoom); return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n))); } //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- String g_sTileUrl = "http://xdworld.vworld.kr:8080/2d/Base/service/%d/%d/%d.png"; String getTileURL(double ALon, double ALat, int AZoom) { String sUrl; sUrl.printf(g_sTileUrl.c_str(), AZoom, (int)Lon2TileX(ALon, AZoom), (int)Lat2TileY(ALat, AZoom)); return sUrl; } //--------------------------------------------------------------------------- String getTileURL(int AX, int AY, int AZoom) { String sUrl; sUrl.printf(g_sTileUrl.c_str(), AZoom, AX, AY); return sUrl; } //---------------------------------------------------------------------------