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 Error(msg.s)
Declare Refresh()
Declare.d GetLatitude()
Declare.d GetLongitude()
Declare.i GetZoom()
EndDeclareModule
Module OSM
@@ -601,7 +604,7 @@ Module OSM
Next
;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()
If IsThread(OSM\TilesThreads()\GetImageThread) = 0
FreeMemory(OSM\TilesThreads()\Tile)
@@ -645,6 +648,7 @@ Procedure TrackPointer(x.i, y.i,dist.l)
VectorSourceColor(RGBA(0, 0, 0, 255))
DrawVectorText(Str(dist))
EndProcedure
Procedure DrawTrack(*Drawing.DrawingParameters)
Protected Pixel.PixelPosition
Protected Location.Location
@@ -807,7 +811,6 @@ EndProcedure
EndProcedure
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
;bounding box in long/lat coords (x=long, y=lat)
@@ -887,6 +890,30 @@ EndProcedure
OSM\CallBackLocation = CallBackLocation
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)
Protected Gadget.i
@@ -1086,13 +1113,13 @@ CompilerIf #PB_Compiler_IsMainFile
Gadget = EventGadget()
Select Gadget
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
OSM::SetLocation(-0.0001, 0, 0, #PB_Relative)
OSM::SetLocation(10* -360 / Pow(2, OSM::GetZoom() + 8), 0, 0, #PB_Relative)
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
OSM::SetLocation(0, 0.0001, 0, #PB_Relative)
OSM::SetLocation(0, 10* 360 / Pow(2, OSM::GetZoom() + 8), 0, #PB_Relative)
Case #Button_4
OSM::SetZoom(1)
Case #Button_5
@@ -1114,8 +1141,8 @@ CompilerEndIf
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
; ExecutableFormat = Console
; CursorPosition = 273
; FirstLine = 237
; CursorPosition = 1115
; FirstLine = 1083
; Folding = --------
; EnableUnicode
; EnableThread