Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

GetUrlScript.txt 2.7 KiB

4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
4 lat temu
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //******************************************************************************
  2. // LAYERS parameter: config_a_b_c
  3. // a = 1 for depth in meters, 2 for depth in feet, 3 for fathoms
  4. // b = 10.00: for 10.00 m safety depth (beginning of blue coloring) (unit equal to that set by a)
  5. // c = 0 for pristine Navionics charts, 1 for Sonar Charts
  6. //
  7. // TRANSPARENT parameter:
  8. // FALSE for non-layer
  9. // TRUE for layer
  10. //
  11. // UGC parameter:
  12. // FALSE for pristine Navionics charts
  13. // TRUE for additinal user-generated content icons
  14. //******************************************************************************
  15. const
  16. cReqParams = 'LAYERS=config_1_10.00_1&TRANSPARENT=TRUE&UGC=FALSE';
  17. //******************************************************************************
  18. const
  19. cTTL = 24*60*60; // 24 hour
  20. cNavTokenKey = 'NavToken=';
  21. cTimeStampKey = 'TimeStamp=';
  22. function CheckTTL(const ATimeStamp: AnsiString): Boolean;
  23. begin
  24. Result := ( (cTTL div 2) > GetUnixTime - StrToInt64Def(ATimeStamp, 0) );
  25. end;
  26. function GetNavToken: AnsiString;
  27. var
  28. VNavToken: AnsiString;
  29. VTimeStamp: AnsiString;
  30. VResponseCode: Cardinal;
  31. VResponseHeader, VResponseData: AnsiString;
  32. VRequestUrl, VRequestHeader: AnsiString;
  33. begin
  34. Result := '';
  35. if ScriptBuffer <> '' then begin
  36. VNavToken := GetBetween(ScriptBuffer, cNavTokenKey, ';');
  37. VTimeStamp := GetBetween(ScriptBuffer, cTimeStampKey, ';');
  38. if (VNavToken <> '') and (VTimeStamp <> '') and CheckTTL(VTimeStamp) then begin
  39. Result := VNavToken;
  40. end else begin
  41. ScriptBuffer := '';
  42. end;
  43. end;
  44. if (Result = '') and Assigned(Downloader) then begin
  45. VTimeStamp := IntToStr(GetUnixTime);
  46. VRequestUrl := 'https://backend.navionics.io/tile/get_key/Navionics_internalpurpose_00001/webapiv2.navionics.com?_=' + VTimeStamp;
  47. VRequestHeader := 'Origin: https://webapiv2.navionics.com' + #13#10 + 'Referer: https://webapiv2.navionics.com/examples/4000_gNavionicsOverlayExample.html';
  48. VResponseHeader := '';
  49. VResponseData := '';
  50. VResponseCode := Downloader.DoHttpRequest(VRequestUrl, VRequestHeader, '', VResponseHeader, VResponseData);
  51. if VResponseCode = 200 then begin
  52. Result := VResponseData;
  53. ScriptBuffer := cNavTokenKey + Result + ';' + cTimeStampKey + VTimeStamp + ';';
  54. end;
  55. end;
  56. end;
  57. //******************************************************************************
  58. var
  59. VNavToken: AnsiString;
  60. begin
  61. VNavToken := GetNavToken;
  62. if VNavToken <> '' then begin
  63. ResultURL := GetURLBase + IntToStr(GetZ-1) + '/' + IntToStr(GetX) + '/' +
  64. IntToStr(GetY) + '?' + cReqParams + '&' + 'navtoken=' + VNavToken;
  65. end else begin
  66. ResultURL := '';
  67. end;
  68. end.