
// **********
// Our Main Downloader Code
// **********

var
  max_y : integer;
  new_y : integer;

begin
	RequestHead:='Referer: https://www.c-map.com/chartexplorer';
   if (GetZ < 9) then begin
		ResultURL := 'https://tiles.c-map.com/wmts/maxnp_noaa/webmercator/'  + IntToStr(GetZ-1) +'/' + IntToStr(GetX) + '/' + IntToStr(GetY) + '.png';    
	end
	else begin


   max_y := round(Power(2,(GetZ-1)));
   new_y := round(abs(max_y - GetY -1 ));
   ResultURL := 'https://www.globalterramaps.com/GetMyPNG.php?z=' + inttostr(GetZ-1) + '&x=' + inttostr(GetX) +'&y=' +inttostr(new_y)
   
   end

end.
