Nicer moves

This commit is contained in:
djes
2016-08-03 12:01:14 +02:00
parent 0f1ab83c85
commit 937b620484

43
osm.pb
View File

@@ -34,6 +34,9 @@ DeclareModule OSM
Declare Quit() Declare Quit()
Declare Error(msg.s) Declare Error(msg.s)
Declare Refresh() Declare Refresh()
Declare.d GetLatitude()
Declare.d GetLongitude()
Declare.i GetZoom()
EndDeclareModule EndDeclareModule
Module OSM Module OSM
@@ -601,7 +604,7 @@ Module OSM
Next Next
;Free tile memory when the loading thread has finished ;Free tile memory when the loading thread has finished
;TODO : exit this proc from drawtiles in a special "free ressources" task ;TODO : get out 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)
@@ -645,6 +648,7 @@ Procedure TrackPointer(x.i, y.i,dist.l)
VectorSourceColor(RGBA(0, 0, 0, 255)) VectorSourceColor(RGBA(0, 0, 0, 255))
DrawVectorText(Str(dist)) DrawVectorText(Str(dist))
EndProcedure EndProcedure
Procedure DrawTrack(*Drawing.DrawingParameters) Procedure DrawTrack(*Drawing.DrawingParameters)
Protected Pixel.PixelPosition Protected Pixel.PixelPosition
Protected Location.Location Protected Location.Location
@@ -807,7 +811,6 @@ EndProcedure
EndProcedure EndProcedure
Procedure ZoomToArea() Procedure ZoomToArea()
;Source => http://gis.stackexchange.com/questions/19632/how-to-calculate-the-optimal-zoom-level-to-display-two-or-more-points-on-a-map ;Source => http://gis.stackexchange.com/questions/19632/how-to-calculate-the-optimal-zoom-level-to-display-two-or-more-points-on-a-map
;bounding box in long/lat coords (x=long, y=lat) ;bounding box in long/lat coords (x=long, y=lat)
@@ -887,6 +890,30 @@ EndProcedure
OSM\CallBackLocation = CallBackLocation OSM\CallBackLocation = CallBackLocation
EndProcedure EndProcedure
Procedure.d GetLatitude()
Protected Value.d
LockMutex(OSM\Drawing\Mutex)
Value = OSM\TargetLocation\Latitude
UnlockMutex(OSM\Drawing\Mutex)
ProcedureReturn Value
EndProcedure
Procedure.d GetLongitude()
Protected Value.d
LockMutex(OSM\Drawing\Mutex)
Value = OSM\TargetLocation\Longitude
UnlockMutex(OSM\Drawing\Mutex)
ProcedureReturn Value
EndProcedure
Procedure.i GetZoom()
Protected Value.d
LockMutex(OSM\Drawing\Mutex)
Value = OSM\Zoom
UnlockMutex(OSM\Drawing\Mutex)
ProcedureReturn Value
EndProcedure
Procedure Event(Event.l) Procedure Event(Event.l)
Protected Gadget.i Protected Gadget.i
@@ -1086,13 +1113,13 @@ CompilerIf #PB_Compiler_IsMainFile
Gadget = EventGadget() Gadget = EventGadget()
Select Gadget Select Gadget
Case #Gdt_Up Case #Gdt_Up
OSM::SetLocation(0.0001, 0, 0, #PB_Relative) OSM::SetLocation(10* 360 / Pow(2, OSM::GetZoom() + 8), 0, 0, #PB_Relative)
Case #Gdt_Down Case #Gdt_Down
OSM::SetLocation(-0.0001, 0, 0, #PB_Relative) OSM::SetLocation(10* -360 / Pow(2, OSM::GetZoom() + 8), 0, 0, #PB_Relative)
Case #Gdt_Left Case #Gdt_Left
OSM::SetLocation(0, -0.0001, 0, #PB_Relative) OSM::SetLocation(0, 10* -360 / Pow(2, OSM::GetZoom() + 8), 0, #PB_Relative)
Case #Gdt_Right Case #Gdt_Right
OSM::SetLocation(0, 0.0001, 0, #PB_Relative) OSM::SetLocation(0, 10* 360 / Pow(2, OSM::GetZoom() + 8), 0, #PB_Relative)
Case #Button_4 Case #Button_4
OSM::SetZoom(1) OSM::SetZoom(1)
Case #Button_5 Case #Button_5
@@ -1114,8 +1141,8 @@ CompilerEndIf
; IDE Options = PureBasic 5.42 LTS (Windows - x86) ; IDE Options = PureBasic 5.42 LTS (Windows - x86)
; ExecutableFormat = Console ; ExecutableFormat = Console
; CursorPosition = 273 ; CursorPosition = 1115
; FirstLine = 237 ; FirstLine = 1083
; Folding = -------- ; Folding = --------
; EnableUnicode ; EnableUnicode
; EnableThread ; EnableThread