Cleaning and add
This commit is contained in:
9706
Roller.gpx
Normal file
9706
Roller.gpx
Normal file
File diff suppressed because it is too large
Load Diff
228
osm.pb
228
osm.pb
@@ -90,12 +90,12 @@ Module OSM
|
||||
Gadget.i ; Canvas Gadget Id
|
||||
|
||||
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)
|
||||
|
||||
Position.Pixel ; Actual focus Point coords in pixels
|
||||
MoveStartingPoint.Pixel ; Start mouse position coords when dragging the map
|
||||
MoveStartingPoint.Pixel ; Start mouse position coords when dragging the map
|
||||
|
||||
ServerURL.s ; Web URL ex: http://tile.openstreetmap.org/
|
||||
ZoomMin.i ; Min Zoom supported by server
|
||||
@@ -123,7 +123,7 @@ Module OSM
|
||||
|
||||
Global OSM.OSM, Null.i
|
||||
|
||||
;- *** CURL specific ***
|
||||
;- *** CURL specific ***
|
||||
|
||||
Global *ReceiveHTTPToMemoryBuffer, ReceiveHTTPToMemoryBufferPtr.i, ReceivedData.s
|
||||
IncludeFile "libcurl.pbi" ; https://github.com/deseven/pbsamples/tree/master/crossplatform/libcurl
|
||||
@@ -222,7 +222,7 @@ Module OSM
|
||||
|
||||
EndProcedure
|
||||
;- ***
|
||||
|
||||
|
||||
Procedure InitOSM()
|
||||
|
||||
Protected Result.i
|
||||
@@ -245,17 +245,17 @@ Module OSM
|
||||
|
||||
Global Proxy = #True
|
||||
|
||||
;- => Use this to customise your preferences
|
||||
; Result = CreatePreferences(GetHomeDirectory() + "OSM.prefs")
|
||||
; If Proxy
|
||||
; PreferenceGroup("PROXY")
|
||||
; WritePreferenceString("ProxyURL", "myproxy.fr")
|
||||
; WritePreferenceString("ProxyPort", "myproxyport")
|
||||
; WritePreferenceString("ProxyUser", "myproxyname")
|
||||
; EndIf
|
||||
; If Result
|
||||
; ClosePreferences()
|
||||
; EndIf
|
||||
;- => Use this to customise your preferences
|
||||
; Result = CreatePreferences(GetHomeDirectory() + "OSM.prefs")
|
||||
; If Proxy
|
||||
; PreferenceGroup("PROXY")
|
||||
; WritePreferenceString("ProxyURL", "myproxy.fr")
|
||||
; WritePreferenceString("ProxyPort", "myproxyport")
|
||||
; WritePreferenceString("ProxyUser", "myproxyname")
|
||||
; EndIf
|
||||
; If Result
|
||||
; ClosePreferences()
|
||||
; EndIf
|
||||
|
||||
Result = OpenPreferences(GetHomeDirectory() + "OSM.prefs")
|
||||
If Proxy
|
||||
@@ -498,10 +498,10 @@ Module OSM
|
||||
If OSM\EmergencyQuit = 0 ;Quit before drawing
|
||||
StartVectorDrawing(CanvasVectorOutput(OSM\Gadget))
|
||||
If IsImage(*Tile\nImage)
|
||||
MovePathCursor(x,y)
|
||||
DrawVectorImage(ImageID(*Tile\nImage))
|
||||
MovePathCursor(x,y)
|
||||
DrawVectorText(Str(x) + ", " + Str(y))
|
||||
MovePathCursor(x,y)
|
||||
DrawVectorImage(ImageID(*Tile\nImage))
|
||||
MovePathCursor(x,y)
|
||||
DrawVectorText(Str(x) + ", " + Str(y))
|
||||
Else
|
||||
Debug "Image missing"
|
||||
OSM\Dirty = #True ;Signal that this image is missing so we should have to redraw
|
||||
@@ -512,7 +512,7 @@ Module OSM
|
||||
|
||||
EndProcedure
|
||||
|
||||
Procedure DrawTiles()
|
||||
Procedure DrawTiles(*Drawing.DrawingParameters)
|
||||
|
||||
Protected x.i, y.i
|
||||
|
||||
@@ -538,22 +538,25 @@ Module OSM
|
||||
If *NewTile
|
||||
With *NewTile
|
||||
|
||||
;Keep a track of tiles (especially to free memory)
|
||||
AddElement(OSM\TilesThreads())
|
||||
OSM\TilesThreads()\Tile = *NewTile
|
||||
|
||||
;New tile parameters
|
||||
\x = CenterX + x * OSM\TileSize
|
||||
\y = CenterY + y * OSM\TileSize
|
||||
\OSMTileX = tx + x
|
||||
\OSMTileY = ty + y
|
||||
\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)
|
||||
If \nImage = -1
|
||||
;If not, load it in the background
|
||||
\GetImageThread = CreateThread(@GetImageThread(), *NewTile)
|
||||
|
||||
OSM\TilesThreads()\GetImageThread = \GetImageThread
|
||||
Debug " Creating get image thread nb " + Str(\GetImageThread)
|
||||
EndIf
|
||||
Debug " Creating get image thread nb " + Str(\GetImageThread)
|
||||
DrawTile(*NewTile)
|
||||
|
||||
EndWith
|
||||
@@ -565,6 +568,8 @@ Module OSM
|
||||
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()
|
||||
If IsThread(OSM\TilesThreads()\GetImageThread) = 0
|
||||
FreeMemory(OSM\TilesThreads()\Tile)
|
||||
@@ -574,10 +579,10 @@ Module OSM
|
||||
|
||||
EndProcedure
|
||||
|
||||
Procedure DrawTrack()
|
||||
Protected Pixel.Pixel
|
||||
Protected Location.Location
|
||||
If ListSize(OSM\track())>0
|
||||
Procedure DrawTrack()
|
||||
Protected Pixel.Pixel
|
||||
Protected Location.Location
|
||||
If ListSize(OSM\track())>0
|
||||
|
||||
ForEach OSM\track()
|
||||
If @OSM\TargetLocation\Latitude<>0 And @OSM\TargetLocation\Longitude<>0
|
||||
@@ -587,14 +592,14 @@ Module OSM
|
||||
Else
|
||||
AddPathLine(Pixel\X,Pixel\Y)
|
||||
EndIf
|
||||
|
||||
|
||||
EndIf
|
||||
|
||||
Next
|
||||
VectorSourceColor(RGBA(0, 255, 0, 150))
|
||||
StrokePath(10, #PB_Path_RoundEnd|#PB_Path_RoundCorner)
|
||||
|
||||
EndIf
|
||||
VectorSourceColor(RGBA(0, 255, 0, 150))
|
||||
StrokePath(10, #PB_Path_RoundEnd|#PB_Path_RoundCorner)
|
||||
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
Procedure Pointer(x.l,y.l,color.l=#Red)
|
||||
@@ -621,7 +626,7 @@ Module OSM
|
||||
Protected CenterX = GadgetWidth(OSM\Gadget) / 2
|
||||
Protected CenterY = GadgetHeight(OSM\Gadget) / 2
|
||||
|
||||
DrawTiles()
|
||||
DrawTiles(*Drawing)
|
||||
|
||||
LockMutex(OSM\DrawingMutex)
|
||||
StartVectorDrawing(CanvasVectorOutput(OSM\Gadget))
|
||||
@@ -634,7 +639,7 @@ Module OSM
|
||||
|
||||
;- Redraw
|
||||
;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"
|
||||
;Delay(250)
|
||||
|
||||
@@ -770,91 +775,88 @@ EndModule
|
||||
|
||||
;Demonstration
|
||||
CompilerIf #PB_Compiler_IsMainFile
|
||||
Enumeration
|
||||
#Window_0
|
||||
#Map
|
||||
#Button_0
|
||||
#Button_1
|
||||
#Button_2
|
||||
#Button_3
|
||||
#Button_4
|
||||
#Button_5
|
||||
#Combo_0
|
||||
#Text_0
|
||||
#Text_1
|
||||
#Text_2
|
||||
#Text_3
|
||||
#Text_4
|
||||
#String_0
|
||||
#String_1
|
||||
#Gdt_LoadGpx
|
||||
EndEnumeration
|
||||
|
||||
Enumeration
|
||||
#Window_0
|
||||
#Map
|
||||
#Button_0
|
||||
#Button_1
|
||||
#Button_2
|
||||
#Button_3
|
||||
#Button_4
|
||||
#Button_5
|
||||
#Combo_0
|
||||
#Text_0
|
||||
#Text_1
|
||||
#Text_2
|
||||
#Text_3
|
||||
#Text_4
|
||||
#String_0
|
||||
#String_1
|
||||
#Gdt_LoadGpx
|
||||
EndEnumeration
|
||||
|
||||
Structure Location
|
||||
Longitude.d
|
||||
Latitude.d
|
||||
EndStructure
|
||||
|
||||
Procedure UpdateLocation(*Location.Location)
|
||||
SetGadgetText(#String_0,StrD(*Location\Latitude))
|
||||
SetGadgetText(#String_1,StrD(*Location\Longitude))
|
||||
ProcedureReturn 0
|
||||
EndProcedure
|
||||
;- Main
|
||||
If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
|
||||
|
||||
OSM::InitOSM()
|
||||
LoadFont(0, "Wingdings", 12)
|
||||
LoadFont(1, "Arial", 12, #PB_Font_Bold)
|
||||
|
||||
OSM::OSMGadget(#Map, 10, 10, 512, 512)
|
||||
|
||||
TextGadget(#Text_1, 530, 50, 60, 15, "Movements : ")
|
||||
ButtonGadget(#Button_0, 550, 100, 30, 30, Chr($E7)) : SetGadgetFont(#Button_0, FontID(0))
|
||||
ButtonGadget(#Button_1, 610, 100, 30, 30, Chr($E8)) : SetGadgetFont(#Button_1, FontID(0))
|
||||
ButtonGadget(#Button_2, 580, 070, 30, 30, Chr($E9)) : SetGadgetFont(#Button_2, FontID(0))
|
||||
ButtonGadget(#Button_3, 580, 130, 30, 30, Chr($EA)) : SetGadgetFont(#Button_3, FontID(0))
|
||||
TextGadget(#Text_2, 530, 160, 60, 15, "Zoom : ")
|
||||
ButtonGadget(#Button_4, 550, 180, 50, 30, " + ") : SetGadgetFont(#Button_4, FontID(1))
|
||||
ButtonGadget(#Button_5, 600, 180, 50, 30, " - ") : SetGadgetFont(#Button_5, FontID(1))
|
||||
TextGadget(#Text_3, 530, 230, 60, 15, "Latitude : ")
|
||||
StringGadget(#String_0, 600, 230, 90, 20, "")
|
||||
TextGadget(#Text_4, 530, 250, 60, 15, "Longitude : ")
|
||||
StringGadget(#String_1, 600, 250, 90, 20, "")
|
||||
ButtonGadget(#Gdt_LoadGpx, 530, 280, 150, 30, "Load GPX")
|
||||
|
||||
Define Event.i, Gadget.i, Quit.b = #False
|
||||
Define pfValue.d
|
||||
OSM::SetLocation(49.04599, 2.03347, 17)
|
||||
OSM::SetCallBackLocation(@UpdateLocation())
|
||||
|
||||
Repeat
|
||||
Event = WaitWindowEvent()
|
||||
Procedure UpdateLocation(*Location.Location)
|
||||
SetGadgetText(#String_0,StrD(*Location\Latitude))
|
||||
SetGadgetText(#String_1,StrD(*Location\Longitude))
|
||||
ProcedureReturn 0
|
||||
EndProcedure
|
||||
;- Main
|
||||
If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered )
|
||||
|
||||
OSM::Event(Event)
|
||||
Select Event
|
||||
Case #PB_Event_CloseWindow : Quit = 1
|
||||
Case #PB_Event_Gadget ;{
|
||||
Gadget = EventGadget()
|
||||
Select Gadget
|
||||
Case #Button_4
|
||||
OSM::SetZoom(1)
|
||||
Case #Button_5
|
||||
OSM::SetZoom( - 1)
|
||||
Case #Gdt_LoadGpx
|
||||
OSM::LoadGpxFile(OpenFileRequester("Choisissez un fichier à charger", "", "*.gpx", 0))
|
||||
EndSelect
|
||||
EndSelect
|
||||
Until Quit = #True
|
||||
EndIf
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
OSM::InitOSM()
|
||||
LoadFont(0, "Wingdings", 12)
|
||||
LoadFont(1, "Arial", 12, #PB_Font_Bold)
|
||||
|
||||
OSM::OSMGadget(#Map, 10, 10, 512, 512)
|
||||
|
||||
TextGadget(#Text_1, 530, 50, 60, 15, "Movements : ")
|
||||
ButtonGadget(#Button_0, 550, 100, 30, 30, Chr($E7)) : SetGadgetFont(#Button_0, FontID(0))
|
||||
ButtonGadget(#Button_1, 610, 100, 30, 30, Chr($E8)) : SetGadgetFont(#Button_1, FontID(0))
|
||||
ButtonGadget(#Button_2, 580, 070, 30, 30, Chr($E9)) : SetGadgetFont(#Button_2, FontID(0))
|
||||
ButtonGadget(#Button_3, 580, 130, 30, 30, Chr($EA)) : SetGadgetFont(#Button_3, FontID(0))
|
||||
TextGadget(#Text_2, 530, 160, 60, 15, "Zoom : ")
|
||||
ButtonGadget(#Button_4, 550, 180, 50, 30, " + ") : SetGadgetFont(#Button_4, FontID(1))
|
||||
ButtonGadget(#Button_5, 600, 180, 50, 30, " - ") : SetGadgetFont(#Button_5, FontID(1))
|
||||
TextGadget(#Text_3, 530, 230, 60, 15, "Latitude : ")
|
||||
StringGadget(#String_0, 600, 230, 90, 20, "")
|
||||
TextGadget(#Text_4, 530, 250, 60, 15, "Longitude : ")
|
||||
StringGadget(#String_1, 600, 250, 90, 20, "")
|
||||
ButtonGadget(#Gdt_LoadGpx, 530, 280, 150, 30, "Load GPX")
|
||||
|
||||
Define Event.i, Gadget.i, Quit.b = #False
|
||||
Define pfValue.d
|
||||
OSM::SetLocation(49.04599, 2.03347, 17)
|
||||
OSM::SetCallBackLocation(@UpdateLocation())
|
||||
|
||||
Repeat
|
||||
Event = WaitWindowEvent()
|
||||
|
||||
OSM::Event(Event)
|
||||
Select Event
|
||||
Case #PB_Event_CloseWindow : Quit = 1
|
||||
Case #PB_Event_Gadget ;{
|
||||
Gadget = EventGadget()
|
||||
Select Gadget
|
||||
Case #Button_4
|
||||
OSM::SetZoom(1)
|
||||
Case #Button_5
|
||||
OSM::SetZoom( - 1)
|
||||
Case #Gdt_LoadGpx
|
||||
OSM::LoadGpxFile(OpenFileRequester("Choisissez un fichier à charger", "", "*.gpx", 0))
|
||||
EndSelect
|
||||
EndSelect
|
||||
Until Quit = #True
|
||||
EndIf
|
||||
CompilerEndIf
|
||||
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
|
||||
; CursorPosition = 726
|
||||
; FirstLine = 683
|
||||
|
||||
; IDE Options = PureBasic 5.42 LTS (Windows - x64)
|
||||
; CursorPosition = 831
|
||||
; FirstLine = 803
|
||||
; Folding = -----
|
||||
; EnableUnicode
|
||||
; EnableThread
|
||||
; EnableXP
|
||||
>>>>>>> refs/remotes/origin/master
|
||||
; EnableXP
|
Reference in New Issue
Block a user