Cleaning and add

This commit is contained in:
djes
2016-07-25 12:30:33 +02:00
parent f7c7f0c02b
commit 90ce841007
2 changed files with 9821 additions and 113 deletions

9706
Roller.gpx Normal file

File diff suppressed because it is too large Load Diff

66
osm.pb
View File

@@ -90,7 +90,7 @@ Module OSM
Gadget.i ; Canvas Gadget Id Gadget.i ; Canvas Gadget Id
TargetLocation.Location ; Latitude and Longitude from focus point TargetLocation.Location ; Latitude and Longitude from focus point
*Drawing.DrawingParameters ; Focus Tile coord *Drawing.DrawingParameters ; Drawing parameters based on focus point
CallBackLocation.i ; @Procedure(latitude.d,lontitude.d) CallBackLocation.i ; @Procedure(latitude.d,lontitude.d)
@@ -245,17 +245,17 @@ Module OSM
Global Proxy = #True Global Proxy = #True
;- => Use this to customise your preferences ;- => Use this to customise your preferences
; Result = CreatePreferences(GetHomeDirectory() + "OSM.prefs") ; Result = CreatePreferences(GetHomeDirectory() + "OSM.prefs")
; If Proxy ; If Proxy
; PreferenceGroup("PROXY") ; PreferenceGroup("PROXY")
; WritePreferenceString("ProxyURL", "myproxy.fr") ; WritePreferenceString("ProxyURL", "myproxy.fr")
; WritePreferenceString("ProxyPort", "myproxyport") ; WritePreferenceString("ProxyPort", "myproxyport")
; WritePreferenceString("ProxyUser", "myproxyname") ; WritePreferenceString("ProxyUser", "myproxyname")
; EndIf ; EndIf
; If Result ; If Result
; ClosePreferences() ; ClosePreferences()
; EndIf ; EndIf
Result = OpenPreferences(GetHomeDirectory() + "OSM.prefs") Result = OpenPreferences(GetHomeDirectory() + "OSM.prefs")
If Proxy If Proxy
@@ -512,7 +512,7 @@ Module OSM
EndProcedure EndProcedure
Procedure DrawTiles() Procedure DrawTiles(*Drawing.DrawingParameters)
Protected x.i, y.i Protected x.i, y.i
@@ -538,22 +538,25 @@ Module OSM
If *NewTile If *NewTile
With *NewTile With *NewTile
;Keep a track of tiles (especially to free memory)
AddElement(OSM\TilesThreads()) AddElement(OSM\TilesThreads())
OSM\TilesThreads()\Tile = *NewTile OSM\TilesThreads()\Tile = *NewTile
;New tile parameters
\x = CenterX + x * OSM\TileSize \x = CenterX + x * OSM\TileSize
\y = CenterY + y * OSM\TileSize \y = CenterY + y * OSM\TileSize
\OSMTileX = tx + x \OSMTileX = tx + x
\OSMTileY = ty + y \OSMTileY = ty + y
\OSMZoom = OSM\Zoom \OSMZoom = OSM\Zoom
;Check if the image exists, if not, load it in the background ;Check if the image exists
\nImage = GetTileFromMem(\OSMZoom, \OSMTileX, \OSMTileY) \nImage = GetTileFromMem(\OSMZoom, \OSMTileX, \OSMTileY)
If \nImage = -1 If \nImage = -1
;If not, load it in the background
\GetImageThread = CreateThread(@GetImageThread(), *NewTile) \GetImageThread = CreateThread(@GetImageThread(), *NewTile)
OSM\TilesThreads()\GetImageThread = \GetImageThread OSM\TilesThreads()\GetImageThread = \GetImageThread
EndIf
Debug " Creating get image thread nb " + Str(\GetImageThread) Debug " Creating get image thread nb " + Str(\GetImageThread)
EndIf
DrawTile(*NewTile) DrawTile(*NewTile)
EndWith EndWith
@@ -565,6 +568,8 @@ Module OSM
Next Next
Next Next
;Free tile memory when the loading thread has finished
;TODO : exit this proc from drawtiles in a special "free ressources" task
ForEach OSM\TilesThreads() ForEach OSM\TilesThreads()
If IsThread(OSM\TilesThreads()\GetImageThread) = 0 If IsThread(OSM\TilesThreads()\GetImageThread) = 0
FreeMemory(OSM\TilesThreads()\Tile) FreeMemory(OSM\TilesThreads()\Tile)
@@ -621,7 +626,7 @@ Module OSM
Protected CenterX = GadgetWidth(OSM\Gadget) / 2 Protected CenterX = GadgetWidth(OSM\Gadget) / 2
Protected CenterY = GadgetHeight(OSM\Gadget) / 2 Protected CenterY = GadgetHeight(OSM\Gadget) / 2
DrawTiles() DrawTiles(*Drawing)
LockMutex(OSM\DrawingMutex) LockMutex(OSM\DrawingMutex)
StartVectorDrawing(CanvasVectorOutput(OSM\Gadget)) StartVectorDrawing(CanvasVectorOutput(OSM\Gadget))
@@ -634,7 +639,7 @@ Module OSM
;- Redraw ;- Redraw
;If something was not correctly drawn, redraw after a while ;If something was not correctly drawn, redraw after a while
If OSM\Dirty If OSM\Dirty And OSM\EmergencyQuit = #False
Debug "Something was dirty ! We try again to redraw" Debug "Something was dirty ! We try again to redraw"
;Delay(250) ;Delay(250)
@@ -770,7 +775,7 @@ EndModule
;Demonstration ;Demonstration
CompilerIf #PB_Compiler_IsMainFile CompilerIf #PB_Compiler_IsMainFile
Enumeration Enumeration
#Window_0 #Window_0
#Map #Map
#Button_0 #Button_0
@@ -788,20 +793,20 @@ Enumeration
#String_0 #String_0
#String_1 #String_1
#Gdt_LoadGpx #Gdt_LoadGpx
EndEnumeration EndEnumeration
Structure Location Structure Location
Longitude.d Longitude.d
Latitude.d Latitude.d
EndStructure EndStructure
Procedure UpdateLocation(*Location.Location) Procedure UpdateLocation(*Location.Location)
SetGadgetText(#String_0,StrD(*Location\Latitude)) SetGadgetText(#String_0,StrD(*Location\Latitude))
SetGadgetText(#String_1,StrD(*Location\Longitude)) SetGadgetText(#String_1,StrD(*Location\Longitude))
ProcedureReturn 0 ProcedureReturn 0
EndProcedure EndProcedure
;- Main ;- Main
If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered ) If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
OSM::InitOSM() OSM::InitOSM()
LoadFont(0, "Wingdings", 12) LoadFont(0, "Wingdings", 12)
@@ -846,15 +851,12 @@ If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_System
EndSelect EndSelect
EndSelect EndSelect
Until Quit = #True Until Quit = #True
EndIf EndIf
<<<<<<< HEAD
=======
CompilerEndIf CompilerEndIf
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
; CursorPosition = 726 ; IDE Options = PureBasic 5.42 LTS (Windows - x64)
; FirstLine = 683 ; CursorPosition = 831
; FirstLine = 803
; Folding = ----- ; Folding = -----
; EnableUnicode ; EnableUnicode
; EnableThread
; EnableXP ; EnableXP
>>>>>>> refs/remotes/origin/master