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 1.2 KiB

4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940
  1. function retrieve_ts(url: string; xstart: string; xend: string):integer; external 'ytrf_retrieve_ts@maps\YaTraf.dll stdcall';
  2. function GetIntParam(key: string): Integer; external 'ytrf_GetIntParam@maps\YaTraf.dll stdcall';
  3. function SetIntParam(key: string; val: Integer): integer; external 'ytrf_SetIntParam@maps\YaTraf.dll stdcall';
  4. function GetUTS: Longint; external 'ytrf_GetUTS@maps\YaTraf.dll stdcall';
  5. function ts_update_needed(delta: integer):integer;
  6. var
  7. lts, ts : integer;
  8. lts_key: string;
  9. begin
  10. result:=0;
  11. lts_key:='ytrf_lts';
  12. lts:=GetIntParam(lts_key);
  13. ts:=GetUTS;
  14. if (ts>lts+delta) then begin
  15. SetIntParam(lts_key, GetUTS);
  16. result:=1;
  17. end;
  18. end;
  19. function get_ts(delta: integer):integer;
  20. var
  21. ts_key, url, data: string;
  22. pt : LongInt;
  23. begin
  24. result:=0;
  25. ts_key:='ytrf_ts';
  26. if (ts_update_needed(delta)>0) then begin
  27. url:='http://trf.maps.yandex.net/trf/stat.js';
  28. result:=retrieve_ts(url, 'timestamp:"', '"');
  29. SetIntParam(ts_key, result);
  30. end else begin
  31. result:=GetIntParam(ts_key);
  32. end;
  33. end;
  34. begin
  35. ResultURL:='';
  36. if (GetZ<>0) then ResultURL:=GetURLBase+inttostr(GetX)+'&y='+inttostr(GetY)+'&z='+inttostr(GetZ-1)+'&tm='+inttostr(get_ts(60));
  37. end.