Wip
This commit is contained in:
53
osm.pb
53
osm.pb
@@ -1,4 +1,4 @@
|
|||||||
;**************************************************************
|
;**************************************************************
|
||||||
; Program: OSM (OpenStreetMap Module)
|
; Program: OSM (OpenStreetMap Module)
|
||||||
; Author: Thyphoon And Djes
|
; Author: Thyphoon And Djes
|
||||||
; Date: Mai 17, 2016
|
; Date: Mai 17, 2016
|
||||||
@@ -49,6 +49,17 @@ Module OSM
|
|||||||
GetImageThread.i
|
GetImageThread.i
|
||||||
EndStructure
|
EndStructure
|
||||||
|
|
||||||
|
Structure DrawingParameters
|
||||||
|
x.d
|
||||||
|
y.d
|
||||||
|
OSMTileX.i
|
||||||
|
OSMTileY.i
|
||||||
|
OSMZoom.i
|
||||||
|
DeltaX.i
|
||||||
|
DeltaY.i
|
||||||
|
PassNb.i
|
||||||
|
EndStructure
|
||||||
|
|
||||||
Structure TileThread
|
Structure TileThread
|
||||||
GetImageThread.i
|
GetImageThread.i
|
||||||
*Tile.Tile
|
*Tile.Tile
|
||||||
@@ -78,11 +89,9 @@ 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
|
||||||
TargetTile.Tile ; Focus Tile coord
|
*Drawing.DrawingParameters ; Focus Tile coord
|
||||||
|
|
||||||
Position.Pixel ; Actual focus Point coords in pixels
|
Position.Pixel ; Actual focus Point coords in pixels
|
||||||
DeltaX.i
|
|
||||||
DeltaY.i
|
|
||||||
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/
|
ServerURL.s ; Web URL ex: http://tile.openstreetmap.org/
|
||||||
@@ -582,7 +591,7 @@ Module OSM
|
|||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure DrawingThread(Null)
|
Procedure DrawingThread(*Drawing.DrawingParameters)
|
||||||
|
|
||||||
Debug "--------- Main drawing thread ------------"
|
Debug "--------- Main drawing thread ------------"
|
||||||
OSM\Dirty = #False
|
OSM\Dirty = #False
|
||||||
@@ -608,7 +617,14 @@ Module OSM
|
|||||||
If OSM\Dirty
|
If OSM\Dirty
|
||||||
Debug "Something was dirty ! We try again to redraw"
|
Debug "Something was dirty ! We try again to redraw"
|
||||||
;Delay(250)
|
;Delay(250)
|
||||||
CreateThread(@DrawingThread(), Null)
|
|
||||||
|
*Drawing\PassNb + 1
|
||||||
|
CreateThread(@DrawingThread(), *Drawing)
|
||||||
|
EndIf
|
||||||
|
|
||||||
|
*Drawing\PassNb - 1
|
||||||
|
If *Drawing\PassNb = 0
|
||||||
|
FreeMemory(*TargetTile)
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
@@ -655,6 +671,7 @@ Module OSM
|
|||||||
Protected MouseX.i, MouseY.i
|
Protected MouseX.i, MouseY.i
|
||||||
Protected OldX.i, OldY.i
|
Protected OldX.i, OldY.i
|
||||||
Protected TileX.d, TileY.d
|
Protected TileX.d, TileY.d
|
||||||
|
Protected *Drawing.DrawingParameters
|
||||||
|
|
||||||
If IsGadget(OSM\Gadget) And GadgetType(OSM\Gadget) = #PB_GadgetType_Canvas
|
If IsGadget(OSM\Gadget) And GadgetType(OSM\Gadget) = #PB_GadgetType_Canvas
|
||||||
Select Event
|
Select Event
|
||||||
@@ -682,20 +699,22 @@ Module OSM
|
|||||||
;OSM tile position in tile.decimal
|
;OSM tile position in tile.decimal
|
||||||
TileX = OSM\Position\x / OSM\TileSize
|
TileX = OSM\Position\x / OSM\TileSize
|
||||||
TileY = OSM\Position\y / OSM\TileSize
|
TileY = OSM\Position\y / OSM\TileSize
|
||||||
|
*Drawing = AllocateMemory(SizeOf(*DrawingParameters))
|
||||||
;Pixel shift
|
;Pixel shift
|
||||||
OSM\DeltaX = OSM\Position\x - Int(TileX) * OSM\TileSize
|
*Drawing\DeltaX = OSM\Position\x - Int(TileX) * OSM\TileSize
|
||||||
OSM\DeltaY = OSM\Position\y - Int(TileY) * OSM\TileSize
|
*Drawing\DeltaY = OSM\Position\y - Int(TileY) * OSM\TileSize
|
||||||
;Moved to a new tile ?
|
;Moved to a new tile ?
|
||||||
If (Int(OSM\Position\x / OSM\TileSize)) <> (Int(OldX / OSM\TileSize)) Or (Int(OSM\Position\y / OSM\TileSize)) <> (Int(OldY / OSM\TileSize))
|
If (Int(OSM\Position\x / OSM\TileSize)) <> (Int(OldX / OSM\TileSize)) Or (Int(OSM\Position\y / OSM\TileSize)) <> (Int(OldY / OSM\TileSize))
|
||||||
Debug "--- New tile"
|
Debug "--- New tile"
|
||||||
OSM\TargetTile\x = TileX
|
*TargetTile\x = TileX
|
||||||
OSM\TargetTile\y = TileY
|
*TargetTile\y = TileY
|
||||||
Debug "OSM\Position\x " + Str(OSM\Position\x) + " ; OSM\Position\y " + Str(OSM\Position\y)
|
Debug "OSM\Position\x " + Str(OSM\Position\x) + " ; OSM\Position\y " + Str(OSM\Position\y)
|
||||||
XY2LatLon(@OSM\TargetTile, @OSM\TargetLocation)
|
XY2LatLon(*Drawing, @OSM\TargetLocation)
|
||||||
Debug "OSM\TargetTile\x " + StrD(OSM\TargetTile\x) + " ; OSM\TargetTile\y " + StrD(OSM\TargetTile\y)
|
Debug "OSM\TargetTile\x " + StrD(*Drawing\x) + " ; OSM\TargetTile\y " + StrD(*Drawing\y)
|
||||||
EndIf
|
EndIf
|
||||||
OSM\EmergencyQuit = #False
|
OSM\EmergencyQuit = #False
|
||||||
CreateThread(@DrawingThread(), Null)
|
*Drawing\PassNb = 1
|
||||||
|
CreateThread(@DrawingThread(), *Drawing)
|
||||||
OSM\MoveStartingPoint\x = GetGadgetAttribute(OSM\Gadget, #PB_Canvas_MouseX)
|
OSM\MoveStartingPoint\x = GetGadgetAttribute(OSM\Gadget, #PB_Canvas_MouseX)
|
||||||
OSM\MoveStartingPoint\y = GetGadgetAttribute(OSM\Gadget, #PB_Canvas_MouseY)
|
OSM\MoveStartingPoint\y = GetGadgetAttribute(OSM\Gadget, #PB_Canvas_MouseY)
|
||||||
EndIf
|
EndIf
|
||||||
@@ -783,11 +802,3 @@ If OpenWindow(#Window_0, 260, 225, 700, 571, "OpenStreetMap", #PB_Window_System
|
|||||||
EndSelect
|
EndSelect
|
||||||
Until Quit = #True
|
Until Quit = #True
|
||||||
EndIf
|
EndIf
|
||||||
|
|
||||||
; IDE Options = PureBasic 5.42 LTS (Windows - x86)
|
|
||||||
; CursorPosition = 250
|
|
||||||
; FirstLine = 231
|
|
||||||
; Folding = -----
|
|
||||||
; EnableUnicode
|
|
||||||
; EnableThread
|
|
||||||
; EnableXP
|
|
Reference in New Issue
Block a user