wip
This commit is contained in:
41
PBMap.pb
41
PBMap.pb
@@ -419,7 +419,7 @@ Module PBMap
|
|||||||
Protected LatRad.d = Radian(*Location\Latitude)
|
Protected LatRad.d = Radian(*Location\Latitude)
|
||||||
*Pixel\x = tilemax * (Mod( *Location\Longitude + 180.0, 360) / 360.0 )
|
*Pixel\x = tilemax * (Mod( *Location\Longitude + 180.0, 360) / 360.0 )
|
||||||
*Pixel\y = tilemax * ( 1.0 - Log(Tan(LatRad) + (1.0/Cos(LatRad))) / #PI ) / 2.0
|
*Pixel\y = tilemax * ( 1.0 - Log(Tan(LatRad) + (1.0/Cos(LatRad))) / #PI ) / 2.0
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
;Lat Lon coordinates 2 pixel relative to the center of view
|
;Lat Lon coordinates 2 pixel relative to the center of view
|
||||||
Procedure LatLon2PixelRel(*Location.GeographicCoordinates, *Pixel.PixelCoordinates, Zoom)
|
Procedure LatLon2PixelRel(*Location.GeographicCoordinates, *Pixel.PixelCoordinates, Zoom)
|
||||||
@@ -430,7 +430,7 @@ Module PBMap
|
|||||||
Protected px = tilemax * (Mod( *Location\Longitude + 180.0, 360) / 360.0 )
|
Protected px = tilemax * (Mod( *Location\Longitude + 180.0, 360) / 360.0 )
|
||||||
Protected py = tilemax * ( 1.0 - Log(Tan(LatRad) + (1.0/Cos(LatRad))) / #PI ) / 2.0
|
Protected py = tilemax * ( 1.0 - Log(Tan(LatRad) + (1.0/Cos(LatRad))) / #PI ) / 2.0
|
||||||
;check the x boundaries of the map to adjust the position (coz of the longitude wrapping)
|
;check the x boundaries of the map to adjust the position (coz of the longitude wrapping)
|
||||||
If dpx - px > tilemax / 2
|
If dpx - px >= tilemax / 2
|
||||||
;Debug "c1"
|
;Debug "c1"
|
||||||
*Pixel\x = cx + (px - dpx + tilemax)
|
*Pixel\x = cx + (px - dpx + tilemax)
|
||||||
ElseIf px - dpx > tilemax / 2
|
ElseIf px - dpx > tilemax / 2
|
||||||
@@ -1116,34 +1116,27 @@ Module PBMap
|
|||||||
Protected MouseX.d, MouseY.d
|
Protected MouseX.d, MouseY.d
|
||||||
Protected OldPx.d, OldPy.d, OldMx.d, OldMy.d, Px.d, Py.d
|
Protected OldPx.d, OldPy.d, OldMx.d, OldMy.d, Px.d, Py.d
|
||||||
Protected CenterX = GadgetWidth(PBMap\Gadget) / 2, CenterY = GadgetHeight(PBMap\Gadget) / 2
|
Protected CenterX = GadgetWidth(PBMap\Gadget) / 2, CenterY = GadgetHeight(PBMap\Gadget) / 2
|
||||||
;Fast and dirty code
|
Protected MapWidth = Pow(2.0, PBMap\Zoom) * PBMap\TileSize
|
||||||
|
LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom)
|
||||||
OldPx = PBMap\PixelCoordinates\x : OldPy = PBMap\PixelCoordinates\y
|
OldPx = PBMap\PixelCoordinates\x : OldPy = PBMap\PixelCoordinates\y
|
||||||
OldMx = OldPx + CenterX - x
|
OldMx = OldPx + CenterX - x
|
||||||
OldMy = OldPy + CenterY - y
|
OldMy = OldPy + CenterY - y
|
||||||
|
;*** First : Zoom
|
||||||
PBMap\Zoom = PBMap\Zoom + zoom
|
PBMap\Zoom = PBMap\Zoom + zoom
|
||||||
If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : EndIf
|
If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : EndIf
|
||||||
If PBMap\Zoom < PBMap\ZoomMin : PBMap\Zoom = PBMap\ZoomMin : EndIf
|
If PBMap\Zoom < PBMap\ZoomMin : PBMap\Zoom = PBMap\ZoomMin : EndIf
|
||||||
LatLon2TileXY(@PBMap\GeographicCoordinates, @PBMap\Drawing\TileCoordinates, PBMap\Zoom)
|
LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom)
|
||||||
;Convert X, Y in tile.decimal into real pixels
|
;***
|
||||||
PBMap\PixelCoordinates\X = PBMap\Drawing\TileCoordinates\x * PBMap\TileSize
|
Debug OldMx - OldPx
|
||||||
PBMap\PixelCoordinates\Y = PBMap\Drawing\TileCoordinates\y * PBMap\TileSize
|
MouseX = PBMap\PixelCoordinates\X + CenterX - x
|
||||||
;Convert X, Y in tile.decimal into real pixels
|
MouseY = PBMap\PixelCoordinates\Y + CenterY - y
|
||||||
Px = PBMap\Drawing\TileCoordinates\x * PBMap\TileSize
|
;Cross-multiply to get the new view center
|
||||||
Py = PBMap\Drawing\TileCoordinates\y * PBMap\TileSize
|
PBMap\PixelCoordinates\x = (OldPx * MouseX) / OldMx
|
||||||
MouseX = Px + CenterX - x
|
PBMap\PixelCoordinates\y = (OldPy * MouseY) / OldMy
|
||||||
MouseY = Py + CenterY - y
|
Pixel2LatLon(@PBMap\PixelCoordinates, @PBMap\GeographicCoordinates, PBMap\Zoom)
|
||||||
;Cross-multiply to get the new center
|
|
||||||
PBMap\PixelCoordinates\x = (OldPx * MouseX) / OldMx
|
|
||||||
PBMap\PixelCoordinates\y = (OldPy * MouseY) / OldMy
|
|
||||||
;PBMap tile position in tile.decimal
|
|
||||||
PBMap\Drawing\TileCoordinates\x = PBMap\PixelCoordinates\x / PBMap\TileSize
|
|
||||||
PBMap\Drawing\TileCoordinates\y = PBMap\PixelCoordinates\y / PBMap\TileSize
|
|
||||||
PBMap\Drawing\PassNb = 1
|
|
||||||
TileXY2LatLon(@PBMap\Drawing\TileCoordinates, @PBMap\GeographicCoordinates, PBMap\Zoom)
|
|
||||||
;LatLon2PixelRel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom)
|
|
||||||
;Start drawing
|
;Start drawing
|
||||||
|
PBMap\Drawing\PassNb = 1
|
||||||
PBMap\Redraw = #True
|
PBMap\Redraw = #True
|
||||||
;Drawing()
|
|
||||||
;If CallBackLocation send Location to function
|
;If CallBackLocation send Location to function
|
||||||
If PBMap\CallBackLocation > 0
|
If PBMap\CallBackLocation > 0
|
||||||
CallFunctionFast(PBMap\CallBackLocation, @PBMap\GeographicCoordinates)
|
CallFunctionFast(PBMap\CallBackLocation, @PBMap\GeographicCoordinates)
|
||||||
@@ -1423,8 +1416,8 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
|
|
||||||
CompilerEndIf
|
CompilerEndIf
|
||||||
; IDE Options = PureBasic 5.50 (Windows - x64)
|
; IDE Options = PureBasic 5.50 (Windows - x64)
|
||||||
; CursorPosition = 1117
|
; CursorPosition = 1129
|
||||||
; FirstLine = 1108
|
; FirstLine = 1115
|
||||||
; Folding = -----------
|
; Folding = -----------
|
||||||
; EnableThread
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
||||||
|
Reference in New Issue
Block a user