Merge remote-tracking branch 'refs/remotes/origin/thyphoon' into Revision

# Conflicts:
#	PBMap.pb
This commit is contained in:
djes
2017-03-01 10:42:06 +01:00
parent 1b7cf13af7
commit a2eac9192d

View File

@@ -16,15 +16,17 @@ CompilerIf #PB_Compiler_Thread = #False
End End
CompilerEndIf CompilerEndIf
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
#Red = 255
compilerEndif
EnableExplicit EnableExplicit
InitNetwork() InitNetwork()
UsePNGImageDecoder() UsePNGImageDecoder()
UsePNGImageEncoder() UsePNGImageEncoder()
DeclareModule PBMap DeclareModule PBMap
#Red = 255
;-Show debug infos ;-Show debug infos
Global Verbose = 0 Global Verbose = 0
Global MyDebugLevel = 0 Global MyDebugLevel = 0
@@ -164,6 +166,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
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
@@ -243,7 +246,7 @@ Module PBMap
Moving.i Moving.i
Dirty.i ; To signal that drawing need a refresh Dirty.i ; To signal that drawing need a refresh
List TracksList.Tracks() List TracksList.Tracks() ; To display a GPX track
List Markers.Marker() ; To diplay marker List Markers.Marker() ; To diplay marker
EditMarker.l EditMarker.l
@@ -513,6 +516,14 @@ 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"
if DeleteDirectory(PBMap\Options\HDDCachePath, "", #PB_FileSystem_Recursive)
MyDebug("Cache : " + PBMap\Options\HDDCachePath + " cleaned")
else
MyDebug("Can't clean cache in " + PBMap\Options\HDDCachePath)
endif
Case "usecurl"
SelBool(UseCurl)
Case "wheelmouserelative" Case "wheelmouserelative"
SelBool(WheelMouseRelative) SelBool(WheelMouseRelative)
Case "showdegrees" Case "showdegrees"
@@ -564,6 +575,7 @@ Module PBMap
PreferenceGroup("OPTIONS") PreferenceGroup("OPTIONS")
WritePreferenceInteger("WheelMouseRelative", \WheelMouseRelative) WritePreferenceInteger("WheelMouseRelative", \WheelMouseRelative)
WritePreferenceInteger("MaxMemCache", \MaxMemCache) WritePreferenceInteger("MaxMemCache", \MaxMemCache)
WritePreferenceInteger("UseCurl", \UseCurl)
WritePreferenceInteger("ShowDegrees", \ShowDegrees) WritePreferenceInteger("ShowDegrees", \ShowDegrees)
WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos) WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos)
WritePreferenceInteger("ShowScale", \ShowScale) WritePreferenceInteger("ShowScale", \ShowScale)
@@ -619,6 +631,7 @@ Module PBMap
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
\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)
@@ -689,8 +702,10 @@ Module PBMap
EndIf EndIf
Next Next
Delay(10) Delay(10)
Until MapSize(PBMap\MemCache\Images()) = 0 Until MapSize(PBMap\MemCache\Images()) = 0
curl_global_cleanup() If PBMap\Options\Curl
curl_global_cleanup()
endif
EndProcedure EndProcedure
Macro Min(a,b) Macro Min(a,b)
@@ -880,14 +895,25 @@ Module PBMap
Procedure.i GetTileFromWeb(TileURL.s, CacheFile.s) Procedure.i GetTileFromWeb(TileURL.s, CacheFile.s)
Protected *Buffer Protected *Buffer
Protected nImage.i = -1 Protected nImage.i = -1
Protected FileSize.i, timg Protected FileSize.i, timg
FileSize = CurlReceiveHTTPToFile(TileURL, CacheFile, PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword) If PBMap\Options\Curl
If FileSize > 0 FileSize = CurlReceiveHTTPToFile(TileURL, CacheFile, PBMap\Options\ProxyURL, PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
MyDebug("Loaded from web " + TileURL + " as CacheFile " + CacheFile, 3) If FileSize > 0
nImage = GetTileFromHDD(CacheFile) MyDebug("Loaded from web " + TileURL + " as CacheFile " + CacheFile, 3)
nImage = GetTileFromHDD(CacheFile)
Else
MyDebug("Problem loading from web " + TileURL, 3)
EndIf
Else Else
MyDebug("Problem loading from web " + TileURL, 3) HTTPProxy(PBMap\Options\ProxyURL+":"+PBMap\Options\ProxyPort, PBMap\Options\ProxyUser, PBMap\Options\ProxyPassword)
EndIf FileSize = ReceiveHTTPFile(TileURL, CacheFile)
If FileSize > 0
MyDebug("Loaded from web " + TileURL + " as CacheFile " + CacheFile, 3)
nImage = GetTileFromHDD(CacheFile)
Else
MyDebug("Problem loading from web " + TileURL, 3)
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)
@@ -922,7 +948,7 @@ Module PBMap
*Tile\RetryNb = 0 *Tile\RetryNb = 0
Else Else
MyDebug("Image key : " + *Tile\key + " web image not correctly loaded", 3) MyDebug("Image key : " + *Tile\key + " web image not correctly loaded", 3)
Delay(5000) Delay(2000)
*Tile\RetryNb - 1 *Tile\RetryNb - 1
EndIf EndIf
Until *Tile\RetryNb <= 0 Until *Tile\RetryNb <= 0
@@ -1310,13 +1336,11 @@ Module PBMap
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom) LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
If Int(km) <> memKm If Int(km) <> memKm
memKm = Int(km) memKm = Int(km)
RotateCoordinates(Pixel\x, Pixel\y, -PBMap\Angle)
If Int(km) = 0 If Int(km) = 0
DrawTrackPointerFirst(Pixel\x , Pixel\y, Int(km)) DrawTrackPointerFirst(Pixel\x , Pixel\y, Int(km))
Else Else
DrawTrackPointer(Pixel\x , Pixel\y, Int(km)) DrawTrackPointer(Pixel\x , Pixel\y, Int(km))
EndIf EndIf
RotateCoordinates(Pixel\x, Pixel\y, PBMap\Angle)
EndIf EndIf
Next Next
EndIf EndIf
@@ -1498,13 +1522,11 @@ Module PBMap
ForEach PBMap\Markers() ForEach PBMap\Markers()
If IsInDrawingPixelBoundaries(*Drawing, @PBMap\Markers()\GeographicCoordinates) If IsInDrawingPixelBoundaries(*Drawing, @PBMap\Markers()\GeographicCoordinates)
LatLon2PixelRel(@PBMap\Markers()\GeographicCoordinates, @Pixel, PBMap\Zoom) LatLon2PixelRel(@PBMap\Markers()\GeographicCoordinates, @Pixel, PBMap\Zoom)
RotateCoordinates(Pixel\x, Pixel\y, -PBMap\Angle)
If PBMap\Markers()\CallBackPointer > 0 If PBMap\Markers()\CallBackPointer > 0
CallFunctionFast(PBMap\Markers()\CallBackPointer, Pixel\x, Pixel\y, PBMap\Markers()\Focus, PBMap\Markers()\Selected) CallFunctionFast(PBMap\Markers()\CallBackPointer, Pixel\x, Pixel\y, PBMap\Markers()\Focus, PBMap\Markers()\Selected)
Else Else
DrawMarker(Pixel\x, Pixel\y, ListIndex(PBMap\Markers()), @PBMap\Markers()) DrawMarker(Pixel\x, Pixel\y, ListIndex(PBMap\Markers()), @PBMap\Markers())
EndIf EndIf
RotateCoordinates(Pixel\x, Pixel\y, PBMap\Angle)
EndIf EndIf
Next Next
EndProcedure EndProcedure
@@ -1513,9 +1535,9 @@ Module PBMap
; Display how many images in cache ; Display how many images in cache
VectorFont(FontID(PBMap\Font), 16) VectorFont(FontID(PBMap\Font), 16)
VectorSourceColor(RGBA(0, 0, 0, 80)) VectorSourceColor(RGBA(0, 0, 0, 80))
MovePathCursor(50,50) MovePathCursor(50, 50)
DrawVectorText(Str(MapSize(PBMap\MemCache\Images()))) DrawVectorText(Str(MapSize(PBMap\MemCache\Images())))
MovePathCursor(50,70) MovePathCursor(50, 70)
Protected ThreadCounter = 0 Protected ThreadCounter = 0
ForEach PBMap\MemCache\Images() ForEach PBMap\MemCache\Images()
If PBMap\MemCache\Images()\Tile <> 0 If PBMap\MemCache\Images()\Tile <> 0
@@ -1525,11 +1547,11 @@ Module PBMap
EndIf EndIf
Next Next
DrawVectorText(Str(ThreadCounter)) DrawVectorText(Str(ThreadCounter))
MovePathCursor(50,90) MovePathCursor(50, 90)
DrawVectorText(Str(PBMap\Zoom)) DrawVectorText(Str(PBMap\Zoom))
MovePathCursor(50,110) MovePathCursor(50, 110)
DrawVectorText(StrD(*Drawing\Bounds\NorthWest\Latitude) + "," + StrD(*Drawing\Bounds\NorthWest\Longitude)) DrawVectorText(StrD(*Drawing\Bounds\NorthWest\Latitude) + "," + StrD(*Drawing\Bounds\NorthWest\Longitude))
MovePathCursor(50,130) MovePathCursor(50, 130)
DrawVectorText(StrD(*Drawing\Bounds\SouthEast\Latitude) + "," + StrD(*Drawing\Bounds\SouthEast\Longitude)) DrawVectorText(StrD(*Drawing\Bounds\SouthEast\Latitude) + "," + StrD(*Drawing\Bounds\SouthEast\Longitude))
EndProcedure EndProcedure