51 line
972 B

  1. const
  2. width=14002;
  3. height=19002;
  4. var TileGroup:integer;
  5. z:integer;
  6. i:integer;
  7. cur_width,cur_height:integer;
  8. maxZoom:integer;
  9. function TilesAtZoom(z:integer):integer;
  10. begin
  11. result:=(1+trunc(width/(256*intpower(2,(MaxZoom-z)))))*(1+trunc(height/(256*intpower(2,(MaxZoom-z)))));
  12. end;
  13. function getTileCount(zoom:integer):integer;
  14. var i:integer;
  15. begin
  16. Result:=0;
  17. for i:=1 to zoom do Result:=Result+TilesAtZoom(i);
  18. end;
  19. begin
  20. i:=1;cur_width:=0;
  21. while cur_width<width do
  22. begin
  23. cur_width:=round(256*intpower(2,i));
  24. i:=i+1;
  25. end;
  26. MaxZoom:=i;
  27. i:=1;cur_width:=0;
  28. while cur_width<height do
  29. begin
  30. cur_width:=round(256*intpower(2,i));
  31. i:=i+1;
  32. end;
  33. if i>MaxZoom then MaxZoom:=i;
  34. z:=GetZ-1;
  35. tilegroup:=(getTileCount(z) +GetX +GetY*(1+trunc(width/(256*intpower(2,(MaxZoom-z-1)))))) div 256;
  36. ResultURL:=GetURLBase+inttostr(tilegroup)+'/'+inttostr(z)+'-'+inttostr(GetX)+'-'+inttostr(GetY)+'.jpg';
  37. end.