DownloaderF.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //---------------------------------------------------------------------------
  2. #include <math.h>
  3. #pragma hdrstop
  4. #include "DownloaderF.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. static double Lon2TileX(double ALon, int AZoom)
  8. {
  9. return (ALon + 180.0) / 360.0 * pow(2.0, AZoom);
  10. }
  11. //---------------------------------------------------------------------------
  12. static double Lat2TileY(double ALat, int AZoom)
  13. {
  14. 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);
  15. }
  16. //---------------------------------------------------------------------------
  17. static double TileX2Lon(double AX, int AZoom)
  18. {
  19. return AX / pow(2.0, AZoom) * 360.0 - 180;
  20. }
  21. //---------------------------------------------------------------------------
  22. static double TileY2Lat(double AY, int AZoom)
  23. {
  24. double n = M_PI - 2.0 * M_PI * AY / pow(2.0, AZoom);
  25. return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n)));
  26. }
  27. //---------------------------------------------------------------------------
  28. //---------------------------------------------------------------------------
  29. //---------------------------------------------------------------------------
  30. //---------------------------------------------------------------------------
  31. //---------------------------------------------------------------------------
  32. //---------------------------------------------------------------------------
  33. //---------------------------------------------------------------------------
  34. //---------------------------------------------------------------------------
  35. //---------------------------------------------------------------------------
  36. //---------------------------------------------------------------------------
  37. //---------------------------------------------------------------------------
  38. //---------------------------------------------------------------------------
  39. //---------------------------------------------------------------------------
  40. //---------------------------------------------------------------------------
  41. //---------------------------------------------------------------------------
  42. String g_sTileUrl = "http://xdworld.vworld.kr:8080/2d/Base/service/%d/%d/%d.png";
  43. String getTileURL(double ALon, double ALat, int AZoom)
  44. {
  45. String sUrl;
  46. sUrl.printf(g_sTileUrl.c_str(), AZoom, (int)Lon2TileX(ALon, AZoom), (int)Lat2TileY(ALat, AZoom));
  47. return sUrl;
  48. }
  49. //---------------------------------------------------------------------------
  50. String getTileURL(int AX, int AY, int AZoom)
  51. {
  52. String sUrl;
  53. sUrl.printf(g_sTileUrl.c_str(), AZoom, AX, AY);
  54. return sUrl;
  55. }
  56. //---------------------------------------------------------------------------