some bugfix + full curl lib usage in comments
This commit is contained in:
394
PBMap.pb
394
PBMap.pb
@@ -175,7 +175,7 @@ Module PBMap
|
|||||||
HDDCachePath.s ; Path where to load and save tiles downloaded from server
|
HDDCachePath.s ; Path where to load and save tiles downloaded from server
|
||||||
DefaultOSMServer.s ; Base layer OSM server
|
DefaultOSMServer.s ; Base layer OSM server
|
||||||
WheelMouseRelative.i
|
WheelMouseRelative.i
|
||||||
UseCurl.i ; Use native PB http functions or specific included curl library functions
|
; UseCurl.i ; Use native PB http functions or specific included curl library functions
|
||||||
ScaleUnit.i ; Scale unit to use for measurements
|
ScaleUnit.i ; Scale unit to use for measurements
|
||||||
Proxy.i ; Proxy ON/OFF
|
Proxy.i ; Proxy ON/OFF
|
||||||
ProxyURL.s
|
ProxyURL.s
|
||||||
@@ -292,153 +292,153 @@ Module PBMap
|
|||||||
;- *** GetText - Translation purpose
|
;- *** GetText - Translation purpose
|
||||||
IncludeFile "gettext.pbi"
|
IncludeFile "gettext.pbi"
|
||||||
|
|
||||||
;- *** CURL specific
|
; ;- *** CURL specific
|
||||||
; (program has To be compiled in console format for curl debug infos)
|
; ; (program has To be compiled in console format for curl debug infos)
|
||||||
|
;
|
||||||
IncludeFile "libcurl.pbi" ; https://github.com/deseven/pbsamples/tree/master/crossplatform/libcurl
|
; IncludeFile "libcurl.pbi" ; https://github.com/deseven/pbsamples/tree/master/crossplatform/libcurl
|
||||||
|
;
|
||||||
Global *ReceiveHTTPToMemoryBuffer, ReceiveHTTPToMemoryBufferPtr.i, ReceivedData.s
|
; Global *ReceiveHTTPToMemoryBuffer, ReceiveHTTPToMemoryBufferPtr.i, ReceivedData.s
|
||||||
|
;
|
||||||
ProcedureC ReceiveHTTPWriteToMemoryFunction(*ptr, Size.i, NMemB.i, *Stream)
|
; ProcedureC ReceiveHTTPWriteToMemoryFunction(*ptr, Size.i, NMemB.i, *Stream)
|
||||||
Protected SizeProper.i = Size & 255
|
; Protected SizeProper.i = Size & 255
|
||||||
Protected NMemBProper.i = NMemB
|
; Protected NMemBProper.i = NMemB
|
||||||
If *ReceiveHTTPToMemoryBuffer = 0
|
; If *ReceiveHTTPToMemoryBuffer = 0
|
||||||
*ReceiveHTTPToMemoryBuffer = AllocateMemory(SizeProper * NMemBProper)
|
; *ReceiveHTTPToMemoryBuffer = AllocateMemory(SizeProper * NMemBProper)
|
||||||
If *ReceiveHTTPToMemoryBuffer = 0
|
; If *ReceiveHTTPToMemoryBuffer = 0
|
||||||
Error("Curl : Problem allocating memory")
|
; Error("Curl : Problem allocating memory")
|
||||||
EndIf
|
; EndIf
|
||||||
Else
|
; Else
|
||||||
*ReceiveHTTPToMemoryBuffer = ReAllocateMemory(*ReceiveHTTPToMemoryBuffer, MemorySize(*ReceiveHTTPToMemoryBuffer) + SizeProper * NMemBProper)
|
; *ReceiveHTTPToMemoryBuffer = ReAllocateMemory(*ReceiveHTTPToMemoryBuffer, MemorySize(*ReceiveHTTPToMemoryBuffer) + SizeProper * NMemBProper)
|
||||||
If *ReceiveHTTPToMemoryBuffer = 0
|
; If *ReceiveHTTPToMemoryBuffer = 0
|
||||||
Error("Curl : Problem reallocating memory")
|
; Error("Curl : Problem reallocating memory")
|
||||||
EndIf
|
; EndIf
|
||||||
EndIf
|
; EndIf
|
||||||
CopyMemory(*ptr, *ReceiveHTTPToMemoryBuffer + ReceiveHTTPToMemoryBufferPtr, SizeProper * NMemBProper)
|
; CopyMemory(*ptr, *ReceiveHTTPToMemoryBuffer + ReceiveHTTPToMemoryBufferPtr, SizeProper * NMemBProper)
|
||||||
ReceiveHTTPToMemoryBufferPtr + SizeProper * NMemBProper
|
; ReceiveHTTPToMemoryBufferPtr + SizeProper * NMemBProper
|
||||||
ProcedureReturn SizeProper * NMemBProper
|
; ProcedureReturn SizeProper * NMemBProper
|
||||||
EndProcedure
|
; EndProcedure
|
||||||
|
;
|
||||||
Procedure.i CurlReceiveHTTPToMemory(URL$, ProxyURL$="", ProxyPort$="", ProxyUser$="", ProxyPassword$="")
|
; Procedure.i CurlReceiveHTTPToMemory(URL$, ProxyURL$="", ProxyPort$="", ProxyUser$="", ProxyPassword$="")
|
||||||
Protected *Buffer, curl.i, Timeout.i, res.i, respcode.l
|
; Protected *Buffer, curl.i, Timeout.i, res.i, respcode.l
|
||||||
If Len(URL$)
|
; If Len(URL$)
|
||||||
curl = curl_easy_init()
|
; curl = curl_easy_init()
|
||||||
If curl
|
; If curl
|
||||||
Timeout = 3
|
; Timeout = 3
|
||||||
curl_easy_setopt(curl, #CURLOPT_URL, str2curl(URL$))
|
; curl_easy_setopt(curl, #CURLOPT_URL, str2curl(URL$))
|
||||||
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
|
; curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
|
||||||
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
|
; curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
|
||||||
curl_easy_setopt(curl, #CURLOPT_HEADER, 0)
|
; curl_easy_setopt(curl, #CURLOPT_HEADER, 0)
|
||||||
curl_easy_setopt(curl, #CURLOPT_FOLLOWLOCATION, 1)
|
; curl_easy_setopt(curl, #CURLOPT_FOLLOWLOCATION, 1)
|
||||||
curl_easy_setopt(curl, #CURLOPT_TIMEOUT, Timeout)
|
; curl_easy_setopt(curl, #CURLOPT_TIMEOUT, Timeout)
|
||||||
If PBMap\Options\Verbose
|
; If PBMap\Options\Verbose
|
||||||
curl_easy_setopt(curl, #CURLOPT_VERBOSE, 1)
|
; curl_easy_setopt(curl, #CURLOPT_VERBOSE, 1)
|
||||||
EndIf
|
; EndIf
|
||||||
curl_easy_setopt(curl, #CURLOPT_FAILONERROR, 1)
|
; curl_easy_setopt(curl, #CURLOPT_FAILONERROR, 1)
|
||||||
If Len(ProxyURL$)
|
; If Len(ProxyURL$)
|
||||||
;curl_easy_setopt(curl, #CURLOPT_HTTPPROXYTUNNEL, #True)
|
; ;curl_easy_setopt(curl, #CURLOPT_HTTPPROXYTUNNEL, #True)
|
||||||
If Len(ProxyPort$)
|
; If Len(ProxyPort$)
|
||||||
ProxyURL$ + ":" + ProxyPort$
|
; ProxyURL$ + ":" + ProxyPort$
|
||||||
EndIf
|
; EndIf
|
||||||
; Debug ProxyURL$
|
; ; Debug ProxyURL$
|
||||||
curl_easy_setopt(curl, #CURLOPT_PROXY, str2curl(ProxyURL$))
|
; curl_easy_setopt(curl, #CURLOPT_PROXY, str2curl(ProxyURL$))
|
||||||
If Len(ProxyUser$)
|
; If Len(ProxyUser$)
|
||||||
If Len(ProxyPassword$)
|
; If Len(ProxyPassword$)
|
||||||
ProxyUser$ + ":" + ProxyPassword$
|
; ProxyUser$ + ":" + ProxyPassword$
|
||||||
EndIf
|
; EndIf
|
||||||
;Debug ProxyUser$
|
; ;Debug ProxyUser$
|
||||||
curl_easy_setopt(curl, #CURLOPT_PROXYUSERPWD, str2curl(ProxyUser$))
|
; curl_easy_setopt(curl, #CURLOPT_PROXYUSERPWD, str2curl(ProxyUser$))
|
||||||
EndIf
|
; EndIf
|
||||||
EndIf
|
; EndIf
|
||||||
curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @ReceiveHTTPWriteToMemoryFunction())
|
; curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @ReceiveHTTPWriteToMemoryFunction())
|
||||||
res = curl_easy_perform(curl)
|
; res = curl_easy_perform(curl)
|
||||||
If res = #CURLE_OK
|
; If res = #CURLE_OK
|
||||||
*Buffer = AllocateMemory(ReceiveHTTPToMemoryBufferPtr)
|
; *Buffer = AllocateMemory(ReceiveHTTPToMemoryBufferPtr)
|
||||||
If *Buffer
|
; If *Buffer
|
||||||
CopyMemory(*ReceiveHTTPToMemoryBuffer, *Buffer, ReceiveHTTPToMemoryBufferPtr)
|
; CopyMemory(*ReceiveHTTPToMemoryBuffer, *Buffer, ReceiveHTTPToMemoryBufferPtr)
|
||||||
FreeMemory(*ReceiveHTTPToMemoryBuffer)
|
; FreeMemory(*ReceiveHTTPToMemoryBuffer)
|
||||||
*ReceiveHTTPToMemoryBuffer = #Null
|
; *ReceiveHTTPToMemoryBuffer = #Null
|
||||||
ReceiveHTTPToMemoryBufferPtr = 0
|
; ReceiveHTTPToMemoryBufferPtr = 0
|
||||||
Else
|
; Else
|
||||||
MyDebug("Problem allocating buffer", 4)
|
; MyDebug("Problem allocating buffer", 4)
|
||||||
EndIf
|
; EndIf
|
||||||
;curl_easy_cleanup(curl) ;Was its original place but moved below as it seems more logical to me.
|
; ;curl_easy_cleanup(curl) ;Was its original place but moved below as it seems more logical to me.
|
||||||
Else
|
; Else
|
||||||
curl_easy_getinfo(curl, #CURLINFO_HTTP_CODE, @respcode)
|
; curl_easy_getinfo(curl, #CURLINFO_HTTP_CODE, @respcode)
|
||||||
MyDebug("CURL : HTTP ERROR " + Str(respcode) , 8)
|
; MyDebug("CURL : HTTP ERROR " + Str(respcode) , 8)
|
||||||
curl_easy_cleanup(curl)
|
; curl_easy_cleanup(curl)
|
||||||
ProcedureReturn #False
|
; ProcedureReturn #False
|
||||||
EndIf
|
; EndIf
|
||||||
curl_easy_cleanup(curl)
|
; curl_easy_cleanup(curl)
|
||||||
Else
|
; Else
|
||||||
MyDebug("Can't Init CURL", 4)
|
; MyDebug("Can't Init CURL", 4)
|
||||||
EndIf
|
; EndIf
|
||||||
EndIf
|
; EndIf
|
||||||
; Debug "Curl Buffer : " + Str(*Buffer)
|
; ; Debug "Curl Buffer : " + Str(*Buffer)
|
||||||
ProcedureReturn *Buffer
|
; ProcedureReturn *Buffer
|
||||||
EndProcedure
|
; EndProcedure
|
||||||
|
;
|
||||||
;Curl write callback (needed for win32 dll)
|
; ;Curl write callback (needed for win32 dll)
|
||||||
ProcedureC ReceiveHTTPWriteToFileFunction(*ptr, Size.i, NMemB.i, FileHandle.i)
|
; ProcedureC ReceiveHTTPWriteToFileFunction(*ptr, Size.i, NMemB.i, FileHandle.i)
|
||||||
ProcedureReturn WriteData(FileHandle, *ptr, Size * NMemB)
|
; ProcedureReturn WriteData(FileHandle, *ptr, Size * NMemB)
|
||||||
EndProcedure
|
; EndProcedure
|
||||||
|
;
|
||||||
Procedure.i CurlReceiveHTTPToFile(URL$, DestFileName$, ProxyURL$="", ProxyPort$="", ProxyUser$="", ProxyPassword$="")
|
; Procedure.i CurlReceiveHTTPToFile(URL$, DestFileName$, ProxyURL$="", ProxyPort$="", ProxyUser$="", ProxyPassword$="")
|
||||||
Protected *Buffer, curl.i, Timeout.i, res.i, respcode.l
|
; Protected *Buffer, curl.i, Timeout.i, res.i, respcode.l
|
||||||
Protected FileHandle.i
|
; Protected FileHandle.i
|
||||||
MyDebug("CurlReceiveHTTPToFile from " + URL$ + " " + ProxyURL$ + " " + ProxyPort$ + " " + ProxyUser$, 8)
|
; MyDebug("CurlReceiveHTTPToFile from " + URL$ + " " + ProxyURL$ + " " + ProxyPort$ + " " + ProxyUser$, 8)
|
||||||
MyDebug(" to file : " + DestFileName$, 8)
|
; MyDebug(" to file : " + DestFileName$, 8)
|
||||||
FileHandle = CreateFile(#PB_Any, DestFileName$)
|
; FileHandle = CreateFile(#PB_Any, DestFileName$)
|
||||||
If FileHandle And Len(URL$)
|
; If FileHandle And Len(URL$)
|
||||||
curl = curl_easy_init()
|
; curl = curl_easy_init()
|
||||||
If curl
|
; If curl
|
||||||
Timeout = 120
|
; Timeout = 120
|
||||||
curl_easy_setopt(curl, #CURLOPT_URL, str2curl(URL$))
|
; curl_easy_setopt(curl, #CURLOPT_URL, str2curl(URL$))
|
||||||
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
|
; curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYPEER, 0)
|
||||||
curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
|
; curl_easy_setopt(curl, #CURLOPT_SSL_VERIFYHOST, 0)
|
||||||
curl_easy_setopt(curl, #CURLOPT_HEADER, 0)
|
; curl_easy_setopt(curl, #CURLOPT_HEADER, 0)
|
||||||
curl_easy_setopt(curl, #CURLOPT_FOLLOWLOCATION, 1)
|
; curl_easy_setopt(curl, #CURLOPT_FOLLOWLOCATION, 1)
|
||||||
curl_easy_setopt(curl, #CURLOPT_TIMEOUT, Timeout)
|
; curl_easy_setopt(curl, #CURLOPT_TIMEOUT, Timeout)
|
||||||
If PBMap\Options\Verbose
|
; If PBMap\Options\Verbose
|
||||||
curl_easy_setopt(curl, #CURLOPT_VERBOSE, 1)
|
; curl_easy_setopt(curl, #CURLOPT_VERBOSE, 1)
|
||||||
EndIf
|
; EndIf
|
||||||
curl_easy_setopt(curl, #CURLOPT_FAILONERROR, 1)
|
; curl_easy_setopt(curl, #CURLOPT_FAILONERROR, 1)
|
||||||
;curl_easy_setopt(curl, #CURLOPT_CONNECTTIMEOUT, 60)
|
; ;curl_easy_setopt(curl, #CURLOPT_CONNECTTIMEOUT, 60)
|
||||||
If Len(ProxyURL$)
|
; If Len(ProxyURL$)
|
||||||
;curl_easy_setopt(curl, #CURLOPT_HTTPPROXYTUNNEL, #True)
|
; ;curl_easy_setopt(curl, #CURLOPT_HTTPPROXYTUNNEL, #True)
|
||||||
If Len(ProxyPort$)
|
; If Len(ProxyPort$)
|
||||||
ProxyURL$ + ":" + ProxyPort$
|
; ProxyURL$ + ":" + ProxyPort$
|
||||||
EndIf
|
; EndIf
|
||||||
MyDebug(ProxyURL$, 8)
|
; MyDebug(ProxyURL$, 8)
|
||||||
curl_easy_setopt(curl, #CURLOPT_PROXY, str2curl(ProxyURL$))
|
; curl_easy_setopt(curl, #CURLOPT_PROXY, str2curl(ProxyURL$))
|
||||||
If Len(ProxyUser$)
|
; If Len(ProxyUser$)
|
||||||
If Len(ProxyPassword$)
|
; If Len(ProxyPassword$)
|
||||||
ProxyUser$ + ":" + ProxyPassword$
|
; ProxyUser$ + ":" + ProxyPassword$
|
||||||
EndIf
|
; EndIf
|
||||||
MyDebug(ProxyUser$, 8)
|
; MyDebug(ProxyUser$, 8)
|
||||||
curl_easy_setopt(curl, #CURLOPT_PROXYUSERPWD, str2curl(ProxyUser$))
|
; curl_easy_setopt(curl, #CURLOPT_PROXYUSERPWD, str2curl(ProxyUser$))
|
||||||
EndIf
|
; EndIf
|
||||||
EndIf
|
; EndIf
|
||||||
curl_easy_setopt(curl, #CURLOPT_WRITEDATA, FileHandle)
|
; curl_easy_setopt(curl, #CURLOPT_WRITEDATA, FileHandle)
|
||||||
curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @ReceiveHTTPWriteToFileFunction())
|
; curl_easy_setopt(curl, #CURLOPT_WRITEFUNCTION, @ReceiveHTTPWriteToFileFunction())
|
||||||
res = curl_easy_perform(curl)
|
; res = curl_easy_perform(curl)
|
||||||
If res <> #CURLE_OK
|
; If res <> #CURLE_OK
|
||||||
curl_easy_getinfo(curl, #CURLINFO_HTTP_CODE, @respcode)
|
; curl_easy_getinfo(curl, #CURLINFO_HTTP_CODE, @respcode)
|
||||||
MyDebug("CURL : HTTP ERROR " + Str(respcode) , 8)
|
; MyDebug("CURL : HTTP ERROR " + Str(respcode) , 8)
|
||||||
CloseFile(FileHandle)
|
; CloseFile(FileHandle)
|
||||||
curl_easy_cleanup(curl)
|
; curl_easy_cleanup(curl)
|
||||||
ProcedureReturn #False
|
; ProcedureReturn #False
|
||||||
EndIf
|
; EndIf
|
||||||
curl_easy_cleanup(curl)
|
; curl_easy_cleanup(curl)
|
||||||
Else
|
; Else
|
||||||
MyDebug("Can't init CURL", 8)
|
; MyDebug("Can't init CURL", 8)
|
||||||
EndIf
|
; EndIf
|
||||||
CloseFile(FileHandle)
|
; CloseFile(FileHandle)
|
||||||
ProcedureReturn FileSize(DestFileName$)
|
; ProcedureReturn FileSize(DestFileName$)
|
||||||
EndIf
|
; EndIf
|
||||||
ProcedureReturn #False
|
; ProcedureReturn #False
|
||||||
EndProcedure
|
; EndProcedure
|
||||||
|
;
|
||||||
;- ***
|
; ;- ***
|
||||||
|
|
||||||
Procedure TechnicalImagesCreation()
|
Procedure TechnicalImagesCreation()
|
||||||
;"Loading" image
|
;"Loading" image
|
||||||
@@ -531,8 +531,8 @@ Module PBMap
|
|||||||
SelBool(Verbose)
|
SelBool(Verbose)
|
||||||
Case "warning"
|
Case "warning"
|
||||||
SelBool(Warning)
|
SelBool(Warning)
|
||||||
Case "usecurl"
|
; Case "usecurl"
|
||||||
SelBool(UseCurl)
|
; SelBool(UseCurl)
|
||||||
Case "wheelmouserelative"
|
Case "wheelmouserelative"
|
||||||
SelBool(WheelMouseRelative)
|
SelBool(WheelMouseRelative)
|
||||||
Case "showdegrees"
|
Case "showdegrees"
|
||||||
@@ -586,7 +586,7 @@ Module PBMap
|
|||||||
WritePreferenceInteger("MaxMemCache", \MaxMemCache)
|
WritePreferenceInteger("MaxMemCache", \MaxMemCache)
|
||||||
WritePreferenceInteger("Verbose", \Verbose)
|
WritePreferenceInteger("Verbose", \Verbose)
|
||||||
WritePreferenceInteger("Warning", \Warning)
|
WritePreferenceInteger("Warning", \Warning)
|
||||||
WritePreferenceInteger("UseCurl", \UseCurl)
|
; WritePreferenceInteger("UseCurl", \UseCurl)
|
||||||
WritePreferenceInteger("ShowDegrees", \ShowDegrees)
|
WritePreferenceInteger("ShowDegrees", \ShowDegrees)
|
||||||
WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos)
|
WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos)
|
||||||
WritePreferenceInteger("ShowScale", \ShowScale)
|
WritePreferenceInteger("ShowScale", \ShowScale)
|
||||||
@@ -644,7 +644,7 @@ Module PBMap
|
|||||||
\MaxMemCache = ReadPreferenceInteger("MaxMemCache", 20480) ;20 MiB, about 80 tiles in memory
|
\MaxMemCache = ReadPreferenceInteger("MaxMemCache", 20480) ;20 MiB, about 80 tiles in memory
|
||||||
\Verbose = ReadPreferenceInteger("Verbose", #True)
|
\Verbose = ReadPreferenceInteger("Verbose", #True)
|
||||||
\Warning = ReadPreferenceInteger("Warning", #False)
|
\Warning = ReadPreferenceInteger("Warning", #False)
|
||||||
\UseCurl = ReadPreferenceInteger("UseCurl", #True)
|
; \UseCurl = ReadPreferenceInteger("UseCurl", #True)
|
||||||
\ShowDegrees = ReadPreferenceInteger("ShowDegrees", #False)
|
\ShowDegrees = ReadPreferenceInteger("ShowDegrees", #False)
|
||||||
\ShowDebugInfos = ReadPreferenceInteger("ShowDebugInfos", #False)
|
\ShowDebugInfos = ReadPreferenceInteger("ShowDebugInfos", #False)
|
||||||
\ShowScale = ReadPreferenceInteger("ShowScale", #False)
|
\ShowScale = ReadPreferenceInteger("ShowScale", #False)
|
||||||
@@ -708,9 +708,9 @@ Module PBMap
|
|||||||
Next
|
Next
|
||||||
Delay(10)
|
Delay(10)
|
||||||
Until MapSize(PBMap\MemCache\Images()) = 0
|
Until MapSize(PBMap\MemCache\Images()) = 0
|
||||||
If PBMap\Options\UseCurl
|
; If PBMap\Options\UseCurl
|
||||||
curl_global_cleanup()
|
; curl_global_cleanup()
|
||||||
EndIf
|
; EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Macro Min(a,b)
|
Macro Min(a,b)
|
||||||
@@ -852,7 +852,6 @@ Module PBMap
|
|||||||
EndIf
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
;TODO : rotation fix
|
|
||||||
Procedure IsInDrawingBoundaries(*Drawing.DrawingParameters, *Position.GeographicCoordinates)
|
Procedure IsInDrawingBoundaries(*Drawing.DrawingParameters, *Position.GeographicCoordinates)
|
||||||
Protected Lat.d = *Position\Latitude, Lon.d = *Position\Longitude
|
Protected Lat.d = *Position\Latitude, Lon.d = *Position\Longitude
|
||||||
Protected LatNW.d = *Drawing\Bounds\NorthWest\Latitude, LonNW.d = *Drawing\Bounds\NorthWest\Longitude
|
Protected LatNW.d = *Drawing\Bounds\NorthWest\Latitude, LonNW.d = *Drawing\Bounds\NorthWest\Longitude
|
||||||
@@ -901,15 +900,15 @@ Module PBMap
|
|||||||
Protected *Buffer
|
Protected *Buffer
|
||||||
Protected nImage.i = -1
|
Protected nImage.i = -1
|
||||||
Protected FileSize.i, timg
|
Protected FileSize.i, timg
|
||||||
If PBMap\Options\UseCurl
|
; If PBMap\Options\UseCurl
|
||||||
FileSize = CurlReceiveHTTPToFile(TileURL, CacheFile, PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
; FileSize = CurlReceiveHTTPToFile(TileURL, CacheFile, PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
||||||
If FileSize > 0
|
; If FileSize > 0
|
||||||
MyDebug("Loaded from web " + TileURL + " as CacheFile " + CacheFile, 3)
|
; MyDebug("Loaded from web " + TileURL + " as CacheFile " + CacheFile, 3)
|
||||||
nImage = GetTileFromHDD(CacheFile)
|
; nImage = GetTileFromHDD(CacheFile)
|
||||||
Else
|
; Else
|
||||||
MyDebug("Problem loading from web " + TileURL, 3)
|
; MyDebug("Problem loading from web " + TileURL, 3)
|
||||||
EndIf
|
; EndIf
|
||||||
Else
|
; Else
|
||||||
HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
||||||
FileSize = ReceiveHTTPFile(TileURL, CacheFile)
|
FileSize = ReceiveHTTPFile(TileURL, CacheFile)
|
||||||
If FileSize > 0
|
If FileSize > 0
|
||||||
@@ -918,7 +917,7 @@ Module PBMap
|
|||||||
Else
|
Else
|
||||||
MyDebug("Problem loading from web " + TileURL, 3)
|
MyDebug("Problem loading from web " + TileURL, 3)
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
; EndIf
|
||||||
; **** IMPORTANT NOTICE
|
; **** IMPORTANT NOTICE
|
||||||
; I'm (djes) now using Curl only, as this original catchimage/saveimage method is a double operation (uncompress/recompress PNG)
|
; I'm (djes) now using Curl only, as this original catchimage/saveimage method is a double operation (uncompress/recompress PNG)
|
||||||
; and is modifying the original PNG image which could lead to PNG error (Idle has spent hours debunking the 1 bit PNG bug)
|
; and is modifying the original PNG image which could lead to PNG error (Idle has spent hours debunking the 1 bit PNG bug)
|
||||||
@@ -1620,8 +1619,6 @@ Module PBMap
|
|||||||
;***
|
;***
|
||||||
; Main drawing stuff
|
; Main drawing stuff
|
||||||
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
||||||
;Main rotation
|
|
||||||
;--r RotateCoordinates(*Drawing\RadiusX, *Drawing\RadiusY, PBMap\Angle)
|
|
||||||
;Clearscreen
|
;Clearscreen
|
||||||
VectorSourceColor(RGBA(150, 150, 150, 255))
|
VectorSourceColor(RGBA(150, 150, 150, 255))
|
||||||
FillVectorOutput()
|
FillVectorOutput()
|
||||||
@@ -1639,7 +1636,6 @@ Module PBMap
|
|||||||
If PBMap\Options\ShowDegrees And PBMap\Zoom > 2
|
If PBMap\Options\ShowDegrees And PBMap\Zoom > 2
|
||||||
DrawDegrees(*Drawing, 192)
|
DrawDegrees(*Drawing, 192)
|
||||||
EndIf
|
EndIf
|
||||||
;--r ResetCoordinates()
|
|
||||||
If PBMap\Options\ShowPointer
|
If PBMap\Options\ShowPointer
|
||||||
DrawPointer(*Drawing)
|
DrawPointer(*Drawing)
|
||||||
EndIf
|
EndIf
|
||||||
@@ -1909,12 +1905,12 @@ Module PBMap
|
|||||||
; Debug *Buffer
|
; Debug *Buffer
|
||||||
; Debug MemorySize(*Buffer)
|
; Debug MemorySize(*Buffer)
|
||||||
; Protected JSon.s = PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8)
|
; Protected JSon.s = PeekS(*Buffer, MemorySize(*Buffer), #PB_UTF8)
|
||||||
If PBMap\Options\UseCurl
|
; If PBMap\Options\UseCurl
|
||||||
Size = CurlReceiveHTTPToFile(Query, JSONFileName, PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
; Size = CurlReceiveHTTPToFile(Query, JSONFileName, PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
||||||
Else
|
; Else
|
||||||
HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
||||||
Size = CurlReceiveHTTPToFile(Query, JSONFileName)
|
Size = ReceiveHTTPFile(Query, JSONFileName)
|
||||||
EndIf
|
; EndIf
|
||||||
If LoadJSON(0, JSONFileName) = 0
|
If LoadJSON(0, JSONFileName) = 0
|
||||||
;Demivec's code
|
;Demivec's code
|
||||||
MyDebug( JSONErrorMessage() + " at position " +
|
MyDebug( JSONErrorMessage() + " at position " +
|
||||||
@@ -2011,7 +2007,8 @@ Module PBMap
|
|||||||
PBMap\Moving = #False
|
PBMap\Moving = #False
|
||||||
CanvasMouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\Drawing\RadiusX
|
CanvasMouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\Drawing\RadiusX
|
||||||
CanvasMouseY = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) - PBMap\Drawing\RadiusY
|
CanvasMouseY = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) - PBMap\Drawing\RadiusY
|
||||||
;--r StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
; rotation wip
|
||||||
|
; StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
||||||
; RotateCoordinates(0, 0, PBMap\Angle)
|
; RotateCoordinates(0, 0, PBMap\Angle)
|
||||||
; CanvasMouseX = ConvertCoordinateX(MouseX, MouseY, #PB_Coordinate_Device, #PB_Coordinate_User)
|
; CanvasMouseX = ConvertCoordinateX(MouseX, MouseY, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||||
; CanvasMouseY = ConvertCoordinateY(MouseX, MouseY, #PB_Coordinate_Device, #PB_Coordinate_User)
|
; CanvasMouseY = ConvertCoordinateY(MouseX, MouseY, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||||
@@ -2233,8 +2230,8 @@ Module PBMap
|
|||||||
EndSelect
|
EndSelect
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
; Redraws at regular intervals
|
||||||
Procedure TimerEvents()
|
Procedure TimerEvents()
|
||||||
;Redraw at regular intervals
|
|
||||||
If EventTimer() = PBMap\Timer And (PBMap\Redraw Or PBMap\Dirty)
|
If EventTimer() = PBMap\Timer And (PBMap\Redraw Or PBMap\Dirty)
|
||||||
Drawing()
|
Drawing()
|
||||||
EndIf
|
EndIf
|
||||||
@@ -2281,16 +2278,21 @@ Module PBMap
|
|||||||
If PBMap\Options\DefaultOSMServer <> ""
|
If PBMap\Options\DefaultOSMServer <> ""
|
||||||
AddMapServerLayer("OSM", 1, PBMap\Options\DefaultOSMServer)
|
AddMapServerLayer("OSM", 1, PBMap\Options\DefaultOSMServer)
|
||||||
EndIf
|
EndIf
|
||||||
If PBMap\Options\UseCurl
|
; If PBMap\Options\UseCurl
|
||||||
curl_global_init(#CURL_GLOBAL_WIN32)
|
; curl_global_init(#CURL_GLOBAL_WIN32)
|
||||||
EndIf
|
; EndIf
|
||||||
TechnicalImagesCreation()
|
TechnicalImagesCreation()
|
||||||
SetLocation(0, 0)
|
SetLocation(0, 0)
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
EndModule
|
EndModule
|
||||||
|
|
||||||
;-**** Example of application ****
|
;****************************************************************
|
||||||
|
;
|
||||||
|
;- Example of application
|
||||||
|
;
|
||||||
|
;****************************************************************
|
||||||
|
|
||||||
CompilerIf #PB_Compiler_IsMainFile
|
CompilerIf #PB_Compiler_IsMainFile
|
||||||
InitNetwork()
|
InitNetwork()
|
||||||
|
|
||||||
@@ -2301,8 +2303,8 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
#Gdt_Right
|
#Gdt_Right
|
||||||
#Gdt_Up
|
#Gdt_Up
|
||||||
#Gdt_Down
|
#Gdt_Down
|
||||||
#Gdt_RotateLeft
|
;#Gdt_RotateLeft
|
||||||
#Gdt_RotateRight
|
;#Gdt_RotateRight
|
||||||
#Button_4
|
#Button_4
|
||||||
#Button_5
|
#Button_5
|
||||||
#Combo_0
|
#Combo_0
|
||||||
@@ -2370,8 +2372,8 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
ResizeGadget(#Text_1,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Text_1,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_Left, WindowWidth(#Window_0) - 150 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Gdt_Left, WindowWidth(#Window_0) - 150 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_Right,WindowWidth(#Window_0) - 90 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Gdt_Right,WindowWidth(#Window_0) - 90 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_RotateLeft, WindowWidth(#Window_0) - 150 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
;ResizeGadget(#Gdt_RotateLeft, WindowWidth(#Window_0) - 150 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_RotateRight,WindowWidth(#Window_0) - 90 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
;ResizeGadget(#Gdt_RotateRight,WindowWidth(#Window_0) - 90 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_Up, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Gdt_Up, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_Down, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Gdt_Down, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Text_2,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Text_2,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
@@ -2399,8 +2401,8 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
LoadFont(2, "Arial", 8)
|
LoadFont(2, "Arial", 8)
|
||||||
|
|
||||||
TextGadget(#Text_1, 530, 50, 60, 15, "Movements")
|
TextGadget(#Text_1, 530, 50, 60, 15, "Movements")
|
||||||
ButtonGadget(#Gdt_RotateLeft, 550, 070, 30, 30, "LRot") : SetGadgetFont(#Gdt_RotateLeft, FontID(2))
|
;ButtonGadget(#Gdt_RotateLeft, 550, 070, 30, 30, "LRot") : SetGadgetFont(#Gdt_RotateLeft, FontID(2))
|
||||||
ButtonGadget(#Gdt_RotateRight, 610, 070, 30, 30, "RRot") : SetGadgetFont(#Gdt_RotateRight, FontID(2))
|
;ButtonGadget(#Gdt_RotateRight, 610, 070, 30, 30, "RRot") : SetGadgetFont(#Gdt_RotateRight, FontID(2))
|
||||||
ButtonGadget(#Gdt_Left, 550, 100, 30, 30, Chr($25C4)) : SetGadgetFont(#Gdt_Left, FontID(0))
|
ButtonGadget(#Gdt_Left, 550, 100, 30, 30, Chr($25C4)) : SetGadgetFont(#Gdt_Left, FontID(0))
|
||||||
ButtonGadget(#Gdt_Right, 610, 100, 30, 30, Chr($25BA)) : SetGadgetFont(#Gdt_Right, FontID(0))
|
ButtonGadget(#Gdt_Right, 610, 100, 30, 30, Chr($25BA)) : SetGadgetFont(#Gdt_Right, FontID(0))
|
||||||
ButtonGadget(#Gdt_Up, 580, 070, 30, 30, Chr($25B2)) : SetGadgetFont(#Gdt_Up, FontID(0))
|
ButtonGadget(#Gdt_Up, 580, 070, 30, 30, Chr($25B2)) : SetGadgetFont(#Gdt_Up, FontID(0))
|
||||||
@@ -2441,7 +2443,7 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
PBMap::SetOption("ShowScale", "1")
|
PBMap::SetOption("ShowScale", "1")
|
||||||
PBMap::SetOption("ShowMarkersLegend", "1")
|
PBMap::SetOption("ShowMarkersLegend", "1")
|
||||||
PBMap::SetOption("ShowTrackKms", "1")
|
PBMap::SetOption("ShowTrackKms", "1")
|
||||||
PBMap::SetOption("UseCurl", "0")
|
; PBMap::SetOption("UseCurl", "0")
|
||||||
PBMap::SetOption("ColourFocus", "$FFFF00AA")
|
PBMap::SetOption("ColourFocus", "$FFFF00AA")
|
||||||
;PBMap::CleanCache()
|
;PBMap::CleanCache()
|
||||||
PBMap::MapGadget(#Map, 10, 10, 512, 512)
|
PBMap::MapGadget(#Map, 10, 10, 512, 512)
|
||||||
@@ -2466,12 +2468,12 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
PBMap::SetLocation(0, 10* -360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative)
|
PBMap::SetLocation(0, 10* -360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative)
|
||||||
Case #Gdt_Right
|
Case #Gdt_Right
|
||||||
PBMap::SetLocation(0, 10* 360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative)
|
PBMap::SetLocation(0, 10* 360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative)
|
||||||
Case #Gdt_RotateLeft
|
;Case #Gdt_RotateLeft
|
||||||
PBMAP::SetAngle(-5,#PB_Relative)
|
; PBMAP::SetAngle(-5,#PB_Relative)
|
||||||
PBMap::Refresh()
|
; PBMap::Refresh()
|
||||||
Case #Gdt_RotateRight
|
;Case #Gdt_RotateRight
|
||||||
PBMAP::SetAngle(5,#PB_Relative)
|
; PBMAP::SetAngle(5,#PB_Relative)
|
||||||
PBMap::Refresh()
|
; PBMap::Refresh()
|
||||||
Case #Button_4
|
Case #Button_4
|
||||||
PBMap::SetZoom(1)
|
PBMap::SetZoom(1)
|
||||||
Case #Button_5
|
Case #Button_5
|
||||||
@@ -2546,9 +2548,9 @@ CompilerEndIf
|
|||||||
|
|
||||||
|
|
||||||
; IDE Options = PureBasic 5.60 beta 7 (Windows - x64)
|
; IDE Options = PureBasic 5.60 beta 7 (Windows - x64)
|
||||||
; CursorPosition = 908
|
; CursorPosition = 190
|
||||||
; FirstLine = 898
|
; FirstLine = 117
|
||||||
; Folding = ------------------
|
; Folding = -----------------
|
||||||
; EnableThread
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
||||||
; EnableUnicode
|
; EnableUnicode
|
Reference in New Issue
Block a user