Rotation wip
This commit is contained in:
93
PBMap.pb
93
PBMap.pb
@@ -112,6 +112,8 @@ Module PBMap
|
||||
Structure BoundingBox
|
||||
NorthWest.GeographicCoordinates
|
||||
SouthEast.GeographicCoordinates
|
||||
BottomLeft.PixelCoordinates
|
||||
TopRight.PixelCoordinates
|
||||
EndStructure
|
||||
|
||||
Structure DrawingParameters
|
||||
@@ -800,6 +802,7 @@ Module PBMap
|
||||
ProcedureReturn (1000 * HaversineInKM(@*posA,@*posB));
|
||||
EndProcedure
|
||||
|
||||
; No more used, see LatLon2PixelRel
|
||||
Procedure GetPixelCoordFromLocation(*Location.GeographicCoordinates, *Pixel.PixelCoordinates, Zoom) ; TODO to Optimize
|
||||
Protected mapWidth.l = Pow(2, Zoom + 8)
|
||||
Protected mapHeight.l = Pow(2, Zoom + 8)
|
||||
@@ -819,6 +822,17 @@ Module PBMap
|
||||
*Pixel\y=GadgetHeight(PBMap\Gadget)/2 - (y2-y1)
|
||||
EndProcedure
|
||||
|
||||
Procedure IsInDrawingPixelBoundaries(*Drawing.DrawingParameters, *Position.GeographicCoordinates)
|
||||
Protected Pixel.PixelCoordinates
|
||||
LatLon2Pixel(*Position, @Pixel, PBMap\Zoom)
|
||||
If Pixel\x >= *Drawing\Bounds\BottomLeft\x And Pixel\y <= *Drawing\Bounds\BottomLeft\y And Pixel\x <= *Drawing\Bounds\TopRight\x And Pixel\y >= *Drawing\Bounds\TopRight\y
|
||||
ProcedureReturn #True
|
||||
Else
|
||||
ProcedureReturn #False
|
||||
EndIf
|
||||
EndProcedure
|
||||
|
||||
;TODO : rotation fix
|
||||
Procedure IsInDrawingBoundaries(*Drawing.DrawingParameters, *Position.GeographicCoordinates)
|
||||
Protected Lat.d = *Position\Latitude, Lon.d = *Position\Longitude
|
||||
Protected LatNW.d = *Drawing\Bounds\NorthWest\Latitude, LonNW.d = *Drawing\Bounds\NorthWest\Longitude
|
||||
@@ -1246,7 +1260,7 @@ Module PBMap
|
||||
;Check visibility
|
||||
\Visible = #False
|
||||
ForEach \Track()
|
||||
If IsInDrawingBoundaries(*Drawing, @PBMap\TracksList()\Track())
|
||||
If IsInDrawingPixelBoundaries(*Drawing, @PBMap\TracksList()\Track())
|
||||
\Visible = #True
|
||||
Break
|
||||
EndIf
|
||||
@@ -1482,17 +1496,15 @@ Module PBMap
|
||||
Procedure DrawMarkers(*Drawing.DrawingParameters)
|
||||
Protected Pixel.PixelCoordinates
|
||||
ForEach PBMap\Markers()
|
||||
If IsInDrawingBoundaries(*Drawing, @PBMap\Markers()\GeographicCoordinates)
|
||||
LatLon2PixelRel(PBMap\Markers()\GeographicCoordinates, @Pixel, PBMap\Zoom)
|
||||
If Pixel\x >= 0 And Pixel\y >= 0 And Pixel\x < GadgetWidth(PBMap\Gadget) And Pixel\y < GadgetHeight(PBMap\Gadget) ; Only if visible ^_^
|
||||
RotateCoordinates(Pixel\x, Pixel\y, -PBMap\Angle)
|
||||
If PBMap\Markers()\CallBackPointer > 0
|
||||
CallFunctionFast(PBMap\Markers()\CallBackPointer, Pixel\x, Pixel\y, PBMap\Markers()\Focus, PBMap\Markers()\Selected)
|
||||
Else
|
||||
DrawMarker(Pixel\x, Pixel\y, ListIndex(PBMap\Markers()), @PBMap\Markers())
|
||||
EndIf
|
||||
RotateCoordinates(Pixel\x, Pixel\y, PBMap\Angle)
|
||||
If IsInDrawingPixelBoundaries(*Drawing, @PBMap\Markers()\GeographicCoordinates)
|
||||
LatLon2PixelRel(@PBMap\Markers()\GeographicCoordinates, @Pixel, PBMap\Zoom)
|
||||
RotateCoordinates(Pixel\x, Pixel\y, -PBMap\Angle)
|
||||
If PBMap\Markers()\CallBackPointer > 0
|
||||
CallFunctionFast(PBMap\Markers()\CallBackPointer, Pixel\x, Pixel\y, PBMap\Markers()\Focus, PBMap\Markers()\Selected)
|
||||
Else
|
||||
DrawMarker(Pixel\x, Pixel\y, ListIndex(PBMap\Markers()), @PBMap\Markers())
|
||||
EndIf
|
||||
RotateCoordinates(Pixel\x, Pixel\y, PBMap\Angle)
|
||||
EndIf
|
||||
Next
|
||||
EndProcedure
|
||||
@@ -1550,33 +1562,34 @@ Module PBMap
|
||||
*Drawing\DeltaX = Px * ts - (Int(Px) * ts) ;Don't forget the Int() !
|
||||
*Drawing\DeltaY = Py * ts - (Int(Py) * ts)
|
||||
;Drawing boundaries
|
||||
nx = *Drawing\CenterX / ts ;How many tiles around the point
|
||||
ny = *Drawing\CenterY / ts
|
||||
NW\x = Px - nx - 1
|
||||
NW\y = Py - ny - 1
|
||||
SE\x = Px + nx + 2
|
||||
SE\y = Py + ny + 2
|
||||
TileXY2LatLon(@NW, *Drawing\Bounds\NorthWest, PBMap\Zoom)
|
||||
TileXY2LatLon(@SE, *Drawing\Bounds\SouthEast, PBMap\Zoom)
|
||||
; nx = PixelCenter\x - *Drawing\CenterX
|
||||
; ny = PixelCenter\y - *Drawing\CenterY
|
||||
; StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
||||
; RotateCoordinates(PixelCenter\x, PixelCenter\y, PBMap\Angle)
|
||||
; NW\x = ConvertCoordinateX(nx, ny, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||
; NW\y = ConvertCoordinateY(nx, ny, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||
; nx + GadgetWidth(PBMap\Gadget)
|
||||
; ny + GadgetHeight(PBMap\Gadget)
|
||||
; SE\x = ConvertCoordinateX(nx, ny, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||
; SE\y = ConvertCoordinateY(nx, ny, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||
; StopVectorDrawing()
|
||||
; Pixel2LatLon(@NW, *Drawing\Bounds\NorthWest, PBMap\Zoom)
|
||||
; Pixel2LatLon(@SE, *Drawing\Bounds\SouthEast, PBMap\Zoom)
|
||||
; Debug *Drawing\Bounds\NorthWest\Latitude
|
||||
; Debug *Drawing\Bounds\NorthWest\Longitude
|
||||
; Debug *Drawing\Bounds\SouthEast\Latitude
|
||||
; Debug *Drawing\Bounds\SouthEast\Longitude
|
||||
*Drawing\Width = (SE\x / Pow(2, PBMap\Zoom) * 360.0) - (NW\x / Pow(2, PBMap\Zoom) * 360.0) ;Calculus without clipping
|
||||
*Drawing\Height = *Drawing\Bounds\NorthWest\Latitude - *Drawing\Bounds\SouthEast\Latitude
|
||||
; nx = *Drawing\CenterX / ts ;How many tiles around the point
|
||||
; ny = *Drawing\CenterY / ts
|
||||
; NW\x = Px - nx - 1
|
||||
; NW\y = Py - ny - 1
|
||||
; SE\x = Px + nx + 2
|
||||
; SE\y = Py + ny + 2
|
||||
; TileXY2LatLon(@NW, *Drawing\Bounds\NorthWest, PBMap\Zoom)
|
||||
; TileXY2LatLon(@SE, *Drawing\Bounds\SouthEast, PBMap\Zoom)
|
||||
;TODO : rotation fix
|
||||
nx = PixelCenter\x - *Drawing\CenterX
|
||||
ny = PixelCenter\y + *Drawing\CenterY
|
||||
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
||||
RotateCoordinates(PixelCenter\x, PixelCenter\y, PBMap\Angle)
|
||||
*Drawing\Bounds\BottomLeft\x = ConvertCoordinateX(nx, ny, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||
*Drawing\Bounds\BottomLeft\y = ConvertCoordinateY(nx, ny, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||
nx + GadgetWidth(PBMap\Gadget)
|
||||
ny - GadgetHeight(PBMap\Gadget)
|
||||
*Drawing\Bounds\TopRight\x = ConvertCoordinateX(nx, ny, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||
*Drawing\Bounds\TopRight\y = ConvertCoordinateY(nx, ny, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||
StopVectorDrawing()
|
||||
Pixel2LatLon(*Drawing\Bounds\BottomLeft, *Drawing\Bounds\SouthEast, PBMap\Zoom)
|
||||
Pixel2LatLon(*Drawing\Bounds\TopRight, *Drawing\Bounds\NorthWest, PBMap\Zoom)
|
||||
; Debug *Drawing\Bounds\NorthWest\Latitude
|
||||
; Debug *Drawing\Bounds\NorthWest\Longitude
|
||||
; Debug *Drawing\Bounds\SouthEast\Latitude
|
||||
; Debug *Drawing\Bounds\SouthEast\Longitude
|
||||
;*Drawing\Width = (SE\x / Pow(2, PBMap\Zoom) * 360.0) - (NW\x / Pow(2, PBMap\Zoom) * 360.0) ;Calculus without clipping
|
||||
;*Drawing\Height = *Drawing\Bounds\NorthWest\Latitude - *Drawing\Bounds\SouthEast\Latitude
|
||||
;***
|
||||
; Main drawing stuff
|
||||
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
||||
@@ -2443,8 +2456,8 @@ CompilerEndIf
|
||||
|
||||
|
||||
; IDE Options = PureBasic 5.50 (Windows - x64)
|
||||
; CursorPosition = 766
|
||||
; FirstLine = 670
|
||||
; CursorPosition = 1523
|
||||
; FirstLine = 1495
|
||||
; Folding = -----------------
|
||||
; EnableThread
|
||||
; EnableXP
|
||||
|
Reference in New Issue
Block a user