From 1fa4b6406ddf1a370128a22f093aae08a8fc1704 Mon Sep 17 00:00:00 2001 From: sasgis <> Date: Sat, 12 Dec 1970 12:00:00 +0000 Subject: [PATCH] update zmp --- .../GetUrlScript.txt | 75 +++++++++++++------ .../navionics.SonarChart.zmp/GetUrlScript.txt | 75 +++++++++++++------ _water/navionics.layer.zmp/GetUrlScript.txt | 75 +++++++++++++------ _water/navionics.zmp/GetUrlScript.txt | 75 +++++++++++++------ 4 files changed, 216 insertions(+), 84 deletions(-) diff --git a/_water/navionics.SonarChart.layer.zmp/GetUrlScript.txt b/_water/navionics.SonarChart.layer.zmp/GetUrlScript.txt index fbec165c1..2e229080d 100644 --- a/_water/navionics.SonarChart.layer.zmp/GetUrlScript.txt +++ b/_water/navionics.SonarChart.layer.zmp/GetUrlScript.txt @@ -1,44 +1,77 @@ +//****************************************************************************** // LAYERS parameter: config_a_b_c // a = 1 for depth in meters, 2 for depth in feet, 3 for fathoms // b = 10.00: for 10.00 m safety depth (beginning of blue coloring) (unit equal to that set by a) // c = 0 for pristine Navionics charts, 1 for Sonar Charts -// TRANSPARENT parameter: FALSE for non-layer, TRUE for layer -// UGC parameter: FALSE for pristine Navionics charts, TRUE for additinal user-generated content icons +// +// TRANSPARENT parameter: +// FALSE for non-layer +// TRUE for layer +// +// UGC parameter: +// FALSE for pristine Navionics charts +// TRUE for additinal user-generated content icons +//****************************************************************************** + +const + cReqParams = 'LAYERS=config_1_10.00_1&TRANSPARENT=TRUE&UGC=FALSE'; + +//****************************************************************************** + +const + cTTL = 24*60*60; // 24 hour + cNavTokenKey = 'NavToken='; + cTimeStampKey = 'TimeStamp='; + +function CheckTTL(const ATimeStamp: AnsiString): Boolean; +begin + Result := ( (cTTL div 2) > GetUnixTime - StrToInt64Def(ATimeStamp, 0) ); +end; function GetNavToken: AnsiString; var - VTimeStamp: AnsiString; + VNavToken: AnsiString; + VTimeStamp: AnsiString; VResponseCode: Cardinal; VResponseHeader, VResponseData: AnsiString; - VRequestUrl, VRequestHeader, VPostData: AnsiString; + VRequestUrl: AnsiString; begin - Result := 'ERROR_1'; + Result := ''; if ScriptBuffer <> '' then begin - Result := ScriptBuffer; - Exit; + VNavToken := GetBetween(ScriptBuffer, cNavTokenKey, ';'); + VTimeStamp := GetBetween(ScriptBuffer, cTimeStampKey, ';'); + if (VNavToken <> '') and (VTimeStamp <> '') and CheckTTL(VTimeStamp) then begin + Result := VNavToken; + end else begin + ScriptBuffer := ''; + end; end; - if Assigned(Downloader) then begin - VTimeStamp := IntToStr(GetUnixTime); + if (Result = '') and Assigned(Downloader) then begin + VTimeStamp := IntToStr(GetUnixTime); VRequestUrl := 'https://backend.navionics.io/tile/get_key/Navionics_internalpurpose_00001/webapiv2.navionics.com?_=' + VTimeStamp; - VRequestHeader := ''; - VPostData := ''; VResponseHeader := ''; - VResponseData := ''; - - VResponseCode := Downloader.DoHttpRequest(VRequestUrl, VRequestHeader, VPostData, VResponseHeader, VResponseData); + VResponseData := ''; + VResponseCode := Downloader.DoHttpRequest(VRequestUrl, '', '', VResponseHeader, VResponseData); if VResponseCode = 200 then begin - ScriptBuffer := VResponseData; - Result := ScriptBuffer; - end else begin - ScriptBuffer := 'ERROR_2'; + Result := VResponseData; + ScriptBuffer := cNavTokenKey + Result + ';' + cTimeStampKey + VTimeStamp + ';'; end; end; - end; -begin - ResultURL:=GetURLBase+inttostr(GetZ-1)+'/'+inttostr(GetX)+'/'+inttostr(GetY)+'?LAYERS=config_1_10.00_1&TRANSPARENT=TRUE&UGC=FALSE&navtoken='+GetNavToken; +//****************************************************************************** + +var + VNavToken: AnsiString; +begin + VNavToken := GetNavToken; + if VNavToken <> '' then begin + ResultURL := GetURLBase + IntToStr(GetZ-1) + '/' + IntToStr(GetX) + '/' + + IntToStr(GetY) + '?' + cReqParams + '&' + 'navtoken=' + VNavToken; + end else begin + ResultURL := ''; + end; end. diff --git a/_water/navionics.SonarChart.zmp/GetUrlScript.txt b/_water/navionics.SonarChart.zmp/GetUrlScript.txt index f18360db0..74900090f 100644 --- a/_water/navionics.SonarChart.zmp/GetUrlScript.txt +++ b/_water/navionics.SonarChart.zmp/GetUrlScript.txt @@ -1,44 +1,77 @@ +//****************************************************************************** // LAYERS parameter: config_a_b_c // a = 1 for depth in meters, 2 for depth in feet, 3 for fathoms // b = 10.00: for 10.00 m safety depth (beginning of blue coloring) (unit equal to that set by a) // c = 0 for pristine Navionics charts, 1 for Sonar Charts -// TRANSPARENT parameter: FALSE for non-layer, TRUE for layer -// UGC parameter: FALSE for pristine Navionics charts, TRUE for additinal user-generated content icons +// +// TRANSPARENT parameter: +// FALSE for non-layer +// TRUE for layer +// +// UGC parameter: +// FALSE for pristine Navionics charts +// TRUE for additinal user-generated content icons +//****************************************************************************** + +const + cReqParams = 'LAYERS=config_1_10.00_1&TRANSPARENT=FALSE&UGC=FALSE'; + +//****************************************************************************** + +const + cTTL = 24*60*60; // 24 hour + cNavTokenKey = 'NavToken='; + cTimeStampKey = 'TimeStamp='; + +function CheckTTL(const ATimeStamp: AnsiString): Boolean; +begin + Result := ( (cTTL div 2) > GetUnixTime - StrToInt64Def(ATimeStamp, 0) ); +end; function GetNavToken: AnsiString; var - VTimeStamp: AnsiString; + VNavToken: AnsiString; + VTimeStamp: AnsiString; VResponseCode: Cardinal; VResponseHeader, VResponseData: AnsiString; - VRequestUrl, VRequestHeader, VPostData: AnsiString; + VRequestUrl: AnsiString; begin - Result := 'ERROR_1'; + Result := ''; if ScriptBuffer <> '' then begin - Result := ScriptBuffer; - Exit; + VNavToken := GetBetween(ScriptBuffer, cNavTokenKey, ';'); + VTimeStamp := GetBetween(ScriptBuffer, cTimeStampKey, ';'); + if (VNavToken <> '') and (VTimeStamp <> '') and CheckTTL(VTimeStamp) then begin + Result := VNavToken; + end else begin + ScriptBuffer := ''; + end; end; - if Assigned(Downloader) then begin - VTimeStamp := IntToStr(GetUnixTime); + if (Result = '') and Assigned(Downloader) then begin + VTimeStamp := IntToStr(GetUnixTime); VRequestUrl := 'https://backend.navionics.io/tile/get_key/Navionics_internalpurpose_00001/webapiv2.navionics.com?_=' + VTimeStamp; - VRequestHeader := ''; - VPostData := ''; VResponseHeader := ''; - VResponseData := ''; - - VResponseCode := Downloader.DoHttpRequest(VRequestUrl, VRequestHeader, VPostData, VResponseHeader, VResponseData); + VResponseData := ''; + VResponseCode := Downloader.DoHttpRequest(VRequestUrl, '', '', VResponseHeader, VResponseData); if VResponseCode = 200 then begin - ScriptBuffer := VResponseData; - Result := ScriptBuffer; - end else begin - ScriptBuffer := 'ERROR_2'; + Result := VResponseData; + ScriptBuffer := cNavTokenKey + Result + ';' + cTimeStampKey + VTimeStamp + ';'; end; end; - end; -begin - ResultURL:=GetURLBase+inttostr(GetZ-1)+'/'+inttostr(GetX)+'/'+inttostr(GetY)+'?LAYERS=config_1_10.00_1&TRANSPARENT=FALSE&UGC=FALSE&navtoken='+GetNavToken; +//****************************************************************************** + +var + VNavToken: AnsiString; +begin + VNavToken := GetNavToken; + if VNavToken <> '' then begin + ResultURL := GetURLBase + IntToStr(GetZ-1) + '/' + IntToStr(GetX) + '/' + + IntToStr(GetY) + '?' + cReqParams + '&' + 'navtoken=' + VNavToken; + end else begin + ResultURL := ''; + end; end. diff --git a/_water/navionics.layer.zmp/GetUrlScript.txt b/_water/navionics.layer.zmp/GetUrlScript.txt index e14b27f1d..721ac01bf 100644 --- a/_water/navionics.layer.zmp/GetUrlScript.txt +++ b/_water/navionics.layer.zmp/GetUrlScript.txt @@ -1,44 +1,77 @@ +//****************************************************************************** // LAYERS parameter: config_a_b_c // a = 1 for depth in meters, 2 for depth in feet, 3 for fathoms // b = 10.00: for 10.00 m safety depth (beginning of blue coloring) (unit equal to that set by a) // c = 0 for pristine Navionics charts, 1 for Sonar Charts -// TRANSPARENT parameter: FALSE for non-layer, TRUE for layer -// UGC parameter: FALSE for pristine Navionics charts, TRUE for additinal user-generated content icons +// +// TRANSPARENT parameter: +// FALSE for non-layer +// TRUE for layer +// +// UGC parameter: +// FALSE for pristine Navionics charts +// TRUE for additinal user-generated content icons +//****************************************************************************** + +const + cReqParams = 'LAYERS=config_1_10.00_0&TRANSPARENT=TRUE&UGC=FALSE'; + +//****************************************************************************** + +const + cTTL = 24*60*60; // 24 hour + cNavTokenKey = 'NavToken='; + cTimeStampKey = 'TimeStamp='; + +function CheckTTL(const ATimeStamp: AnsiString): Boolean; +begin + Result := ( (cTTL div 2) > GetUnixTime - StrToInt64Def(ATimeStamp, 0) ); +end; function GetNavToken: AnsiString; var - VTimeStamp: AnsiString; + VNavToken: AnsiString; + VTimeStamp: AnsiString; VResponseCode: Cardinal; VResponseHeader, VResponseData: AnsiString; - VRequestUrl, VRequestHeader, VPostData: AnsiString; + VRequestUrl: AnsiString; begin - Result := 'ERROR_1'; + Result := ''; if ScriptBuffer <> '' then begin - Result := ScriptBuffer; - Exit; + VNavToken := GetBetween(ScriptBuffer, cNavTokenKey, ';'); + VTimeStamp := GetBetween(ScriptBuffer, cTimeStampKey, ';'); + if (VNavToken <> '') and (VTimeStamp <> '') and CheckTTL(VTimeStamp) then begin + Result := VNavToken; + end else begin + ScriptBuffer := ''; + end; end; - if Assigned(Downloader) then begin - VTimeStamp := IntToStr(GetUnixTime); + if (Result = '') and Assigned(Downloader) then begin + VTimeStamp := IntToStr(GetUnixTime); VRequestUrl := 'https://backend.navionics.io/tile/get_key/Navionics_internalpurpose_00001/webapiv2.navionics.com?_=' + VTimeStamp; - VRequestHeader := ''; - VPostData := ''; VResponseHeader := ''; - VResponseData := ''; - - VResponseCode := Downloader.DoHttpRequest(VRequestUrl, VRequestHeader, VPostData, VResponseHeader, VResponseData); + VResponseData := ''; + VResponseCode := Downloader.DoHttpRequest(VRequestUrl, '', '', VResponseHeader, VResponseData); if VResponseCode = 200 then begin - ScriptBuffer := VResponseData; - Result := ScriptBuffer; - end else begin - ScriptBuffer := 'ERROR_2'; + Result := VResponseData; + ScriptBuffer := cNavTokenKey + Result + ';' + cTimeStampKey + VTimeStamp + ';'; end; end; - end; -begin - ResultURL:=GetURLBase+inttostr(GetZ-1)+'/'+inttostr(GetX)+'/'+inttostr(GetY)+'?LAYERS=config_1_10.00_0&TRANSPARENT=TRUE&UGC=FALSE&navtoken='+GetNavToken; +//****************************************************************************** + +var + VNavToken: AnsiString; +begin + VNavToken := GetNavToken; + if VNavToken <> '' then begin + ResultURL := GetURLBase + IntToStr(GetZ-1) + '/' + IntToStr(GetX) + '/' + + IntToStr(GetY) + '?' + cReqParams + '&' + 'navtoken=' + VNavToken; + end else begin + ResultURL := ''; + end; end. diff --git a/_water/navionics.zmp/GetUrlScript.txt b/_water/navionics.zmp/GetUrlScript.txt index 1a83a4ef7..906ff6237 100644 --- a/_water/navionics.zmp/GetUrlScript.txt +++ b/_water/navionics.zmp/GetUrlScript.txt @@ -1,44 +1,77 @@ +//****************************************************************************** // LAYERS parameter: config_a_b_c // a = 1 for depth in meters, 2 for depth in feet, 3 for fathoms // b = 10.00: for 10.00 m safety depth (beginning of blue coloring) (unit equal to that set by a) // c = 0 for pristine Navionics charts, 1 for Sonar Charts -// TRANSPARENT parameter: FALSE for non-layer, TRUE for layer -// UGC parameter: FALSE for pristine Navionics charts, TRUE for additinal user-generated content icons +// +// TRANSPARENT parameter: +// FALSE for non-layer +// TRUE for layer +// +// UGC parameter: +// FALSE for pristine Navionics charts +// TRUE for additinal user-generated content icons +//****************************************************************************** + +const + cReqParams = 'LAYERS=config_1_10.00_0&TRANSPARENT=FALSE&UGC=FALSE'; + +//****************************************************************************** + +const + cTTL = 24*60*60; // 24 hour + cNavTokenKey = 'NavToken='; + cTimeStampKey = 'TimeStamp='; + +function CheckTTL(const ATimeStamp: AnsiString): Boolean; +begin + Result := ( (cTTL div 2) > GetUnixTime - StrToInt64Def(ATimeStamp, 0) ); +end; function GetNavToken: AnsiString; var - VTimeStamp: AnsiString; + VNavToken: AnsiString; + VTimeStamp: AnsiString; VResponseCode: Cardinal; VResponseHeader, VResponseData: AnsiString; - VRequestUrl, VRequestHeader, VPostData: AnsiString; + VRequestUrl: AnsiString; begin - Result := 'ERROR_1'; + Result := ''; if ScriptBuffer <> '' then begin - Result := ScriptBuffer; - Exit; + VNavToken := GetBetween(ScriptBuffer, cNavTokenKey, ';'); + VTimeStamp := GetBetween(ScriptBuffer, cTimeStampKey, ';'); + if (VNavToken <> '') and (VTimeStamp <> '') and CheckTTL(VTimeStamp) then begin + Result := VNavToken; + end else begin + ScriptBuffer := ''; + end; end; - if Assigned(Downloader) then begin - VTimeStamp := IntToStr(GetUnixTime); + if (Result = '') and Assigned(Downloader) then begin + VTimeStamp := IntToStr(GetUnixTime); VRequestUrl := 'https://backend.navionics.io/tile/get_key/Navionics_internalpurpose_00001/webapiv2.navionics.com?_=' + VTimeStamp; - VRequestHeader := ''; - VPostData := ''; VResponseHeader := ''; - VResponseData := ''; - - VResponseCode := Downloader.DoHttpRequest(VRequestUrl, VRequestHeader, VPostData, VResponseHeader, VResponseData); + VResponseData := ''; + VResponseCode := Downloader.DoHttpRequest(VRequestUrl, '', '', VResponseHeader, VResponseData); if VResponseCode = 200 then begin - ScriptBuffer := VResponseData; - Result := ScriptBuffer; - end else begin - ScriptBuffer := 'ERROR_2'; + Result := VResponseData; + ScriptBuffer := cNavTokenKey + Result + ';' + cTimeStampKey + VTimeStamp + ';'; end; end; - end; -begin - ResultURL:=GetURLBase + IntToStr(GetZ-1) + '/' + IntToStr(GetX) + '/' + IntToStr(GetY) + '?LAYERS=config_1_10.00_0&TRANSPARENT=FALSE&UGC=FALSE&navtoken=' + GetNavToken; +//****************************************************************************** + +var + VNavToken: AnsiString; +begin + VNavToken := GetNavToken; + if VNavToken <> '' then begin + ResultURL := GetURLBase + IntToStr(GetZ-1) + '/' + IntToStr(GetX) + '/' + + IntToStr(GetY) + '?' + cReqParams + '&' + 'navtoken=' + VNavToken; + end else begin + ResultURL := ''; + end; end.