Curl option, cache clean function, and cache directory better handling
+ some cleaning
This commit is contained in:
169
PBMap.pb
169
PBMap.pb
@@ -3,7 +3,7 @@
|
|||||||
; Description: Permits the use of tiled maps like
|
; Description: Permits the use of tiled maps like
|
||||||
; OpenStreetMap in a handy PureBASIC module
|
; OpenStreetMap in a handy PureBASIC module
|
||||||
; Author: Thyphoon, djes And Idle
|
; Author: Thyphoon, djes And Idle
|
||||||
; Date: Mai 17, 2016
|
; Date: March, 2017
|
||||||
; License: PBMap : Free, unrestricted, credit
|
; License: PBMap : Free, unrestricted, credit
|
||||||
; appreciated but not required.
|
; appreciated but not required.
|
||||||
; OSM : see http://www.openstreetmap.org/copyright
|
; OSM : see http://www.openstreetmap.org/copyright
|
||||||
@@ -16,10 +16,6 @@ CompilerIf #PB_Compiler_Thread = #False
|
|||||||
End
|
End
|
||||||
CompilerEndIf
|
CompilerEndIf
|
||||||
|
|
||||||
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
|
|
||||||
#Red = 255
|
|
||||||
compilerEndif
|
|
||||||
|
|
||||||
EnableExplicit
|
EnableExplicit
|
||||||
|
|
||||||
InitNetwork()
|
InitNetwork()
|
||||||
@@ -28,9 +24,21 @@ UsePNGImageEncoder()
|
|||||||
|
|
||||||
DeclareModule PBMap
|
DeclareModule PBMap
|
||||||
;-Show debug infos
|
;-Show debug infos
|
||||||
Global Verbose = 0
|
|
||||||
Global MyDebugLevel = 0
|
Global MyDebugLevel = 0
|
||||||
|
|
||||||
|
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
|
||||||
|
#Red = 255
|
||||||
|
CompilerEndIf
|
||||||
|
|
||||||
|
Global slash.s
|
||||||
|
|
||||||
|
CompilerSelect #PB_Compiler_OS
|
||||||
|
CompilerCase #PB_OS_Windows
|
||||||
|
slash = "\"
|
||||||
|
CompilerDefault
|
||||||
|
slash = "/"
|
||||||
|
CompilerEndSelect
|
||||||
|
|
||||||
#SCALE_NAUTICAL = 1
|
#SCALE_NAUTICAL = 1
|
||||||
#SCALE_KM = 0
|
#SCALE_KM = 0
|
||||||
|
|
||||||
@@ -80,6 +88,7 @@ DeclareModule PBMap
|
|||||||
Declare.i GetMode()
|
Declare.i GetMode()
|
||||||
Declare SetMode(Mode.i = #MODE_DEFAULT)
|
Declare SetMode(Mode.i = #MODE_DEFAULT)
|
||||||
Declare NominatimGeoLocationQuery(Address.s, *ReturnPosition= 0) ;Send back the position *ptr.GeographicCoordinates
|
Declare NominatimGeoLocationQuery(Address.s, *ReturnPosition= 0) ;Send back the position *ptr.GeographicCoordinates
|
||||||
|
Declare.i CleanCache()
|
||||||
EndDeclareModule
|
EndDeclareModule
|
||||||
|
|
||||||
Module PBMap
|
Module PBMap
|
||||||
@@ -182,6 +191,8 @@ Module PBMap
|
|||||||
ShowPointer.i
|
ShowPointer.i
|
||||||
TimerInterval.i
|
TimerInterval.i
|
||||||
MaxMemCache.i ; in MiB
|
MaxMemCache.i ; in MiB
|
||||||
|
Verbose.i ; Maximum debug informations
|
||||||
|
Warning.i ; Warning requesters
|
||||||
ShowMarkersNb.i
|
ShowMarkersNb.i
|
||||||
ShowMarkersLegend.i
|
ShowMarkersLegend.i
|
||||||
;Drawing stuff
|
;Drawing stuff
|
||||||
@@ -272,7 +283,7 @@ Module PBMap
|
|||||||
|
|
||||||
;Send debug infos to stdout (allowing mixed debug infos with curl or other libs)
|
;Send debug infos to stdout (allowing mixed debug infos with curl or other libs)
|
||||||
Procedure MyDebug(msg.s, DbgLevel = 0)
|
Procedure MyDebug(msg.s, DbgLevel = 0)
|
||||||
If Verbose And DbgLevel >= MyDebugLevel
|
If PBMap\Options\Verbose And DbgLevel >= MyDebugLevel
|
||||||
PrintN(msg)
|
PrintN(msg)
|
||||||
;Debug msg
|
;Debug msg
|
||||||
EndIf
|
EndIf
|
||||||
@@ -319,7 +330,7 @@ Module PBMap
|
|||||||
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 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)
|
||||||
@@ -387,7 +398,7 @@ Module PBMap
|
|||||||
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 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)
|
||||||
@@ -516,12 +527,10 @@ Module PBMap
|
|||||||
PBMap\Options\HDDCachePath = Value
|
PBMap\Options\HDDCachePath = Value
|
||||||
Case "maxmemcache"
|
Case "maxmemcache"
|
||||||
PBMap\Options\MaxMemCache = Val(Value)
|
PBMap\Options\MaxMemCache = Val(Value)
|
||||||
Case "cleancache"
|
Case "verbose"
|
||||||
if DeleteDirectory(PBMap\Options\HDDCachePath, "", #PB_FileSystem_Recursive)
|
SelBool(Verbose)
|
||||||
MyDebug("Cache : " + PBMap\Options\HDDCachePath + " cleaned")
|
Case "warning"
|
||||||
else
|
SelBool(Warning)
|
||||||
MyDebug("Can't clean cache in " + PBMap\Options\HDDCachePath)
|
|
||||||
endif
|
|
||||||
Case "usecurl"
|
Case "usecurl"
|
||||||
SelBool(UseCurl)
|
SelBool(UseCurl)
|
||||||
Case "wheelmouserelative"
|
Case "wheelmouserelative"
|
||||||
@@ -575,6 +584,8 @@ Module PBMap
|
|||||||
PreferenceGroup("OPTIONS")
|
PreferenceGroup("OPTIONS")
|
||||||
WritePreferenceInteger("WheelMouseRelative", \WheelMouseRelative)
|
WritePreferenceInteger("WheelMouseRelative", \WheelMouseRelative)
|
||||||
WritePreferenceInteger("MaxMemCache", \MaxMemCache)
|
WritePreferenceInteger("MaxMemCache", \MaxMemCache)
|
||||||
|
WritePreferenceInteger("Verbose", \Verbose)
|
||||||
|
WritePreferenceInteger("Warning", \Warning)
|
||||||
WritePreferenceInteger("UseCurl", \UseCurl)
|
WritePreferenceInteger("UseCurl", \UseCurl)
|
||||||
WritePreferenceInteger("ShowDegrees", \ShowDegrees)
|
WritePreferenceInteger("ShowDegrees", \ShowDegrees)
|
||||||
WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos)
|
WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos)
|
||||||
@@ -627,10 +638,12 @@ Module PBMap
|
|||||||
\DefaultOSMServer = ReadPreferenceString("DefaultOSMServer", "http://tile.openstreetmap.org/")
|
\DefaultOSMServer = ReadPreferenceString("DefaultOSMServer", "http://tile.openstreetmap.org/")
|
||||||
|
|
||||||
PreferenceGroup("PATHS")
|
PreferenceGroup("PATHS")
|
||||||
\HDDCachePath = ReadPreferenceString("TilesCachePath", GetTemporaryDirectory())
|
\HDDCachePath = ReadPreferenceString("TilesCachePath", GetTemporaryDirectory() + "PBMap" + slash)
|
||||||
PreferenceGroup("OPTIONS")
|
PreferenceGroup("OPTIONS")
|
||||||
\WheelMouseRelative = ReadPreferenceInteger("WheelMouseRelative", #True)
|
\WheelMouseRelative = ReadPreferenceInteger("WheelMouseRelative", #True)
|
||||||
\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)
|
||||||
|
\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)
|
||||||
@@ -654,14 +667,6 @@ Module PBMap
|
|||||||
|
|
||||||
Procedure.i AddMapServerLayer(LayerName.s, Order.i, ServerURL.s = "http://tile.openstreetmap.org/", TileSize = 256, ZoomMin = 0, ZoomMax = 18)
|
Procedure.i AddMapServerLayer(LayerName.s, Order.i, ServerURL.s = "http://tile.openstreetmap.org/", TileSize = 256, ZoomMin = 0, ZoomMax = 18)
|
||||||
Protected *Ptr = AddElement(PBMap\Layers())
|
Protected *Ptr = AddElement(PBMap\Layers())
|
||||||
Protected DirName.s = PBMap\Options\HDDCachePath + LayerName + "\"
|
|
||||||
If FileSize(DirName) <> -2
|
|
||||||
If CreateDirectory(DirName) = #False ; Creates a directory based on the layer name
|
|
||||||
Error("Can't create the following cache directory : " + DirName)
|
|
||||||
Else
|
|
||||||
MyDebug(DirName + " successfully created", 4)
|
|
||||||
EndIf
|
|
||||||
EndIf
|
|
||||||
If *Ptr
|
If *Ptr
|
||||||
PBMap\Layers()\Name = LayerName
|
PBMap\Layers()\Name = LayerName
|
||||||
PBMap\Layers()\Order = Order
|
PBMap\Layers()\Order = Order
|
||||||
@@ -703,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\Curl
|
If PBMap\Options\UseCurl
|
||||||
curl_global_cleanup()
|
curl_global_cleanup()
|
||||||
endif
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Macro Min(a,b)
|
Macro Min(a,b)
|
||||||
@@ -896,7 +901,7 @@ 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\Curl
|
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)
|
||||||
@@ -913,7 +918,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)
|
||||||
@@ -1062,23 +1067,35 @@ Module PBMap
|
|||||||
kq = (PBMap\Zoom << 8) | (tilex << 16) | (tiley << 36)
|
kq = (PBMap\Zoom << 8) | (tilex << 16) | (tiley << 36)
|
||||||
key = PBMap\Layers()\Name + Str(kq)
|
key = PBMap\Layers()\Name + Str(kq)
|
||||||
; Creates the cache tree based on the OSM tree+Layer : layer/zoom/x/y.png
|
; Creates the cache tree based on the OSM tree+Layer : layer/zoom/x/y.png
|
||||||
|
Protected DirName.s = PBMap\Options\HDDCachePath + PBMap\Layers()\Name
|
||||||
|
If FileSize(DirName) <> -2
|
||||||
|
If CreateDirectory(DirName) = #False ; Creates a directory based on the layer name
|
||||||
|
Error("Can't create the following layer directory : " + DirName)
|
||||||
|
Else
|
||||||
|
MyDebug(DirName + " successfully created", 4)
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
; Creates the sub-directory based on the zoom
|
; Creates the sub-directory based on the zoom
|
||||||
Protected DirName.s = PBMap\Options\HDDCachePath + PBMap\Layers()\Name + "\" + Str(PBMap\Zoom)
|
DirName + slash + Str(PBMap\Zoom)
|
||||||
If FileSize(DirName) <> -2
|
If FileSize(DirName) <> -2
|
||||||
If CreateDirectory(DirName) = #False
|
If CreateDirectory(DirName) = #False
|
||||||
Error("Can't create the following cache directory : " + DirName)
|
Error("Can't create the following zoom directory : " + DirName)
|
||||||
|
Else
|
||||||
|
MyDebug(DirName + " successfully created", 4)
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
; Creates the sub-directory based on x
|
; Creates the sub-directory based on x
|
||||||
DirName.s + "\" + Str(tilex)
|
DirName.s + slash + Str(tilex)
|
||||||
If FileSize(DirName) <> -2
|
If FileSize(DirName) <> -2
|
||||||
If CreateDirectory(DirName) = #False
|
If CreateDirectory(DirName) = #False
|
||||||
Error("Can't create the following cache directory : " + DirName)
|
Error("Can't create the following x directory : " + DirName)
|
||||||
|
Else
|
||||||
|
MyDebug(DirName + " successfully created", 4)
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
; Tile cache name based on y
|
; Tile cache name based on y
|
||||||
URL = PBMap\Layers()\ServerURL + Str(PBMap\Zoom) + "/" + Str(tilex) + "/" + Str(tiley) + ".png"
|
URL = PBMap\Layers()\ServerURL + Str(PBMap\Zoom) + "/" + Str(tilex) + "/" + Str(tiley) + ".png"
|
||||||
CacheFile = DirName + "\" + Str(tiley) + ".png"
|
CacheFile = DirName + slash + Str(tiley) + ".png"
|
||||||
*timg = GetTile(key, URL, CacheFile)
|
*timg = GetTile(key, URL, CacheFile)
|
||||||
If *timg\nImage <> -1
|
If *timg\nImage <> -1
|
||||||
MovePathCursor(px, py)
|
MovePathCursor(px, py)
|
||||||
@@ -1882,6 +1899,7 @@ Module PBMap
|
|||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure NominatimGeoLocationQuery(Address.s, *ReturnPosition.GeographicCoordinates = 0)
|
Procedure NominatimGeoLocationQuery(Address.s, *ReturnPosition.GeographicCoordinates = 0)
|
||||||
|
Protected Size.i
|
||||||
Protected Query.s = "http://nominatim.openstreetmap.org/search/" +
|
Protected Query.s = "http://nominatim.openstreetmap.org/search/" +
|
||||||
URLEncoder(Address) +
|
URLEncoder(Address) +
|
||||||
;"Unter%20den%20Linden%201%20Berlin" +
|
;"Unter%20den%20Linden%201%20Berlin" +
|
||||||
@@ -1891,7 +1909,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)
|
||||||
Protected Size.i = CurlReceiveHTTPToFile(Query, JSONFileName, PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
If PBMap\Options\UseCurl
|
||||||
|
Size = CurlReceiveHTTPToFile(Query, JSONFileName, PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
||||||
|
Else
|
||||||
|
HTTPProxy(PBMap\Options\ProxyURL + ":" + PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
|
||||||
|
Size = CurlReceiveHTTPToFile(Query, JSONFileName)
|
||||||
|
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 " +
|
||||||
@@ -1918,6 +1941,67 @@ Module PBMap
|
|||||||
EndIf
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
;(c) ts-soft http://www.purebasic.fr/english/viewtopic.php?f=12&t=58657&hilit=createdirectory&view=unread#unread
|
||||||
|
CompilerSelect #PB_Compiler_OS
|
||||||
|
CompilerCase #PB_OS_Windows
|
||||||
|
#FILE_ATTRIBUTE_DEVICE = 64 ;(0x40)
|
||||||
|
#FILE_ATTRIBUTE_INTEGRITY_STREAM = 32768 ;(0x8000)
|
||||||
|
#FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 8192;(0x2000)
|
||||||
|
#FILE_ATTRIBUTE_NO_SCRUB_DATA = 131072;(0x20000)
|
||||||
|
#FILE_ATTRIBUTE_VIRTUAL = 65536;(0x10000)
|
||||||
|
#FILE_ATTRIBUTE_DONTSETFLAGS = ~(#FILE_ATTRIBUTE_DIRECTORY|
|
||||||
|
#FILE_ATTRIBUTE_SPARSE_FILE|
|
||||||
|
#FILE_ATTRIBUTE_OFFLINE|
|
||||||
|
#FILE_ATTRIBUTE_NOT_CONTENT_INDEXED|
|
||||||
|
#FILE_ATTRIBUTE_VIRTUAL|
|
||||||
|
0)
|
||||||
|
Macro SetFileAttributesEx(Name, Attribs)
|
||||||
|
SetFileAttributes(Name, Attribs & #FILE_ATTRIBUTE_DONTSETFLAGS)
|
||||||
|
EndMacro
|
||||||
|
CompilerDefault
|
||||||
|
Macro SetFileAttributesEx(Name, Attribs)
|
||||||
|
SetFileAttributes(Name, Attribs)
|
||||||
|
EndMacro
|
||||||
|
CompilerEndSelect
|
||||||
|
|
||||||
|
Procedure CreateDirectoryEx(DirectoryName.s, FileAttribute = #PB_Default)
|
||||||
|
Protected i, c, tmp.s
|
||||||
|
If Right(DirectoryName, 1) = slash
|
||||||
|
DirectoryName = Left(DirectoryName, Len(DirectoryName) -1)
|
||||||
|
EndIf
|
||||||
|
c = CountString(DirectoryName, slash) + 1
|
||||||
|
For i = 1 To c
|
||||||
|
tmp + StringField(DirectoryName, i, slash)
|
||||||
|
If FileSize(tmp) <> -2
|
||||||
|
CreateDirectory(tmp)
|
||||||
|
EndIf
|
||||||
|
tmp + slash
|
||||||
|
Next
|
||||||
|
If FileAttribute <> #PB_Default
|
||||||
|
SetFileAttributesEx(DirectoryName, FileAttribute)
|
||||||
|
EndIf
|
||||||
|
If FileSize(DirectoryName) = -2
|
||||||
|
ProcedureReturn #True
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure.i CleanCache()
|
||||||
|
If PBMap\Options\Warning
|
||||||
|
Protected Result.i = MessageRequester("Warning", "You will clear all cache content in " + PBMap\Options\HDDCachePath + ". Are you sure ?",#PB_MessageRequester_YesNo)
|
||||||
|
If Result = #PB_MessageRequester_No ; Quit if "no" selected
|
||||||
|
ProcedureReturn #False
|
||||||
|
EndIf
|
||||||
|
EndIf
|
||||||
|
If DeleteDirectory(PBMap\Options\HDDCachePath, "", #PB_FileSystem_Recursive)
|
||||||
|
MyDebug("Cache in : " + PBMap\Options\HDDCachePath + " cleaned")
|
||||||
|
CreateDirectoryEx(PBMap\Options\HDDCachePath)
|
||||||
|
ProcedureReturn #True
|
||||||
|
Else
|
||||||
|
MyDebug("Can't clean cache in " + PBMap\Options\HDDCachePath)
|
||||||
|
ProcedureReturn #False
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Procedure CanvasEvents()
|
Procedure CanvasEvents()
|
||||||
Protected CanvasMouseX.d, CanvasMouseY.d, MouseX.d, MouseY.d
|
Protected CanvasMouseX.d, CanvasMouseY.d, MouseX.d, MouseY.d
|
||||||
Protected MarkerCoords.PixelCoordinates, *Tile.Tile, MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize
|
Protected MarkerCoords.PixelCoordinates, *Tile.Tile, MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize
|
||||||
@@ -2179,9 +2263,6 @@ Module PBMap
|
|||||||
|
|
||||||
Procedure InitPBMap(Window)
|
Procedure InitPBMap(Window)
|
||||||
Protected Result.i
|
Protected Result.i
|
||||||
If Verbose
|
|
||||||
OpenConsole()
|
|
||||||
EndIf
|
|
||||||
PBMap\ZoomMin = 0
|
PBMap\ZoomMin = 0
|
||||||
PBMap\ZoomMax = 18
|
PBMap\ZoomMax = 18
|
||||||
PBMap\MoveStartingPoint\x = - 1
|
PBMap\MoveStartingPoint\x = - 1
|
||||||
@@ -2193,10 +2274,16 @@ Module PBMap
|
|||||||
PBMap\Timer = 1
|
PBMap\Timer = 1
|
||||||
PBMap\Mode = #MODE_DEFAULT
|
PBMap\Mode = #MODE_DEFAULT
|
||||||
LoadOptions()
|
LoadOptions()
|
||||||
|
If PBMap\Options\Verbose
|
||||||
|
OpenConsole()
|
||||||
|
EndIf
|
||||||
|
CreateDirectoryEx(PBMap\Options\HDDCachePath)
|
||||||
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
|
||||||
curl_global_init(#CURL_GLOBAL_WIN32)
|
curl_global_init(#CURL_GLOBAL_WIN32)
|
||||||
|
EndIf
|
||||||
TechnicalImagesCreation()
|
TechnicalImagesCreation()
|
||||||
SetLocation(0, 0)
|
SetLocation(0, 0)
|
||||||
EndProcedure
|
EndProcedure
|
||||||
@@ -2354,7 +2441,9 @@ 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("ColourFocus", "$FFFF00AA")
|
PBMap::SetOption("ColourFocus", "$FFFF00AA")
|
||||||
|
;PBMap::CleanCache()
|
||||||
PBMap::MapGadget(#Map, 10, 10, 512, 512)
|
PBMap::MapGadget(#Map, 10, 10, 512, 512)
|
||||||
PBMap::SetCallBackMainPointer(@MainPointer()) ; To change the main pointer (center of the view)
|
PBMap::SetCallBackMainPointer(@MainPointer()) ; To change the main pointer (center of the view)
|
||||||
PBMap::SetCallBackLocation(@UpdateLocation()) ; To obtain realtime coordinates
|
PBMap::SetCallBackLocation(@UpdateLocation()) ; To obtain realtime coordinates
|
||||||
@@ -2457,9 +2546,9 @@ CompilerEndIf
|
|||||||
|
|
||||||
|
|
||||||
; IDE Options = PureBasic 5.60 beta 7 (Windows - x64)
|
; IDE Options = PureBasic 5.60 beta 7 (Windows - x64)
|
||||||
; CursorPosition = 2191
|
; CursorPosition = 908
|
||||||
; FirstLine = 2173
|
; FirstLine = 898
|
||||||
; Folding = -----------------
|
; Folding = ------------------
|
||||||
; EnableThread
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
||||||
; EnableUnicode
|
; EnableUnicode
|
Reference in New Issue
Block a user