You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GetUrlScript.txt 2.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {-----------------------------------------------
  2. Èç ôàéëà ImageProperties.xml
  3. ------------------------------------------------}
  4. const
  5. m_nWidth = 9910;
  6. m_nHeight = 7476;
  7. var
  8. i, zoom, nMaxZoom, nTileGroup :Longint;
  9. {-----------------------------------------------
  10. Âîçâðàùàåò floor çíà÷åíèå
  11. ------------------------------------------------}
  12. function Floor(v :Extended) :Extended;
  13. begin
  14. Result := Trunc(v);
  15. if v < Result then Result := Result - 1.0;
  16. end;
  17. {-----------------------------------------------
  18. Âîçâðàùàåò ceil çíà÷åíèå
  19. ------------------------------------------------}
  20. function Ceil(v :Extended) :Extended;
  21. begin
  22. Result := Trunc(v);
  23. if v > Result then Result := Result + 1.0;
  24. end;
  25. {-----------------------------------------------
  26. Ïîëó÷åíèå ìàêñèìàëüíî âîçìîæíîãî Zoom'à
  27. ------------------------------------------------}
  28. procedure GetMaxZoom();
  29. var k, i :Longint;
  30. begin
  31. k := m_nWidth;
  32. if m_nHeight > m_nWidth then k := m_nHeight;
  33. i := 0;
  34. while k > 256 do
  35. begin
  36. k := Trunc(k / 2);
  37. Inc(i);
  38. end;
  39. nMaxZoom := i;
  40. end;
  41. {-----------------------------------------------
  42. Ïîëó÷åíèå êîëè÷åñòâà òàéëîâ íà äàííîì Zoom'å
  43. ------------------------------------------------}
  44. function GetTilesAtZoom(zoom: Longint) :Longint;
  45. var k :Extended;
  46. begin
  47. k := 256.0 * IntPower(2, nMaxZoom - zoom);
  48. Result := Trunc(Ceil(m_nWidth / k) * Ceil(m_nHeight / k));
  49. end;
  50. {-----------------------------------------------
  51. Êîëè÷åñòâî òàéëîâ ïðåäøåñòâóþùèõ äàííîìó Zoom'ó
  52. ------------------------------------------------}
  53. function GetTilesCount(nZoom: Longint) :Longint;
  54. var i: Longint;
  55. begin
  56. Result := 0;
  57. for i := 0 to nZoom - 1 do Result := Result + GetTilesAtZoom(i);
  58. end;
  59. {-----------------------------------------------
  60. Ïîëó÷åíèå URL òàéëà
  61. ------------------------------------------------}
  62. begin
  63. zoom := GetZ - 1;
  64. GetMaxZoom();
  65. nTileGroup := (GetX + GetY * Trunc(Ceil(m_nWidth / (256.0 * IntPower(2, nMaxZoom - zoom)))) + GetTilesCount(zoom)) div 256;
  66. ResultURL := GetURLBase + IntToStr(nTileGroup) + '/' + IntToStr(zoom) + '-' + IntToStr(GetX) + '-' + IntToStr(GetY) + '.jpg';
  67. { RequestHead := 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' + #13#10; }
  68. end.