Nicer moves
This commit is contained in:
55
osm.pb
55
osm.pb
@@ -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
|
||||||
@@ -355,8 +358,8 @@ Module OSM
|
|||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure GetPixelCoordFromLocation(*Location.Location, *Pixel.PixelPosition) ; TODO to Optimize
|
Procedure GetPixelCoordFromLocation(*Location.Location, *Pixel.PixelPosition) ; TODO to Optimize
|
||||||
Protected mapWidth.l = Pow(2,OSM\Zoom+8)
|
Protected mapWidth.l = Pow(2, OSM\Zoom + 8)
|
||||||
Protected mapHeight.l = Pow(2,OSM\Zoom+8)
|
Protected mapHeight.l = Pow(2, OSM\Zoom + 8)
|
||||||
Protected x1.l,y1.l
|
Protected x1.l,y1.l
|
||||||
|
|
||||||
; get x value
|
; get x value
|
||||||
@@ -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)
|
||||||
@@ -627,7 +630,7 @@ Module OSM
|
|||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure TrackPointer(x.i, y.i,dist.l)
|
Procedure TrackPointer(x.i, y.i,dist.l)
|
||||||
Protected color.l
|
Protected color.l
|
||||||
color=RGBA(0, 0, 0, 255)
|
color=RGBA(0, 0, 0, 255)
|
||||||
MovePathCursor(x,y)
|
MovePathCursor(x,y)
|
||||||
@@ -642,9 +645,10 @@ Procedure TrackPointer(x.i, y.i,dist.l)
|
|||||||
FillPath()
|
FillPath()
|
||||||
VectorFont(FontID(OSM\Font), 13)
|
VectorFont(FontID(OSM\Font), 13)
|
||||||
MovePathCursor(x-VectorTextWidth(Str(dist))/2, y-20-VectorTextHeight(Str(dist))/2)
|
MovePathCursor(x-VectorTextWidth(Str(dist))/2, y-20-VectorTextHeight(Str(dist))/2)
|
||||||
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
|
||||||
@@ -1074,7 +1101,7 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
Define pfValue.d
|
Define pfValue.d
|
||||||
OSM::SetCallBackLocation(@UpdateLocation())
|
OSM::SetCallBackLocation(@UpdateLocation())
|
||||||
OSM::SetLocation(49.04599, 2.03347, 17)
|
OSM::SetLocation(49.04599, 2.03347, 17)
|
||||||
OSM::AddMarker(49.0446828398,2.0349812508,-1,@MyPointer())
|
OSM::AddMarker(49.0446828398, 2.0349812508, -1, @MyPointer())
|
||||||
|
|
||||||
Repeat
|
Repeat
|
||||||
Event = WaitWindowEvent()
|
Event = WaitWindowEvent()
|
||||||
@@ -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
|
||||||
|
Reference in New Issue
Block a user