Skip to content
Commits on Source (2)
......@@ -11,6 +11,7 @@ Component=gb.net
Component=gb.net.curl
Description="Map viewer"
Authors="Fabien Bodard"
Environment="GB_GUI=gb.qt5"
TabSize=2
Language=fr
Type=Component
......
......@@ -9,7 +9,7 @@ Property Selected As Boolean '' Returns or sets if this Item is sel
'Property Color As Integer
Property Bounds As MapBounds
Private $sKey As String
Private $bSelected As Boolean
Private $bSelected As Boolean = False
Private $hBounds As MapBounds
'Private $fLineStyle As Integer
Public Type As Integer '' Returns or sets this Item's type (Point, MultiPoint, Polyline, Polygon, Circle)
......
......@@ -21,6 +21,9 @@ Dim hbound As MapBounds
'MapView1.Map.DefaultCache = "/home/tmp"
MapView1.Map.AddTile("OpenStreetMap", "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", Null, "OpenStreetMap1").Copyright = "© OpenStreetMap contributors"
MapView1.Map.AddTile("NOAA", "https://tileservice.charts.noaa.gov/tiles/50000_1/{z}/{x}/{y}.png",, "NOAA") ', ["projection": "EPSG:3857"])
'MapView1.Map.AddTile("NOAA", "https://tileservice.charts.noaa.gov/tiles/13003_1/{z}/{x}/{y}.png", ["projection": "EPSG:3857", "displayProjection": " EPSG: 4326 "])
'" http: / / tileservice.charts.noaa.gov / tiles / 50000 _1 / {z} / {x} / {y}.png ").SubDomains = [" 0 ", " 1 ", " 2 "]"
MapView1.Map.GetTile("OpenStreetMap").Opacity = 0.3
MapView1.Map.Center = MapPoint(48.866667, 2.333333)
......@@ -33,6 +36,7 @@ Dim hbound As MapBounds
MapView1.Map.GetShape("Shape").AddPoint("point 1", MapPoint(48.866667, 2.333333))
MapView1.Map.GetShape("Shape").AddPoint("point 2", MapPoint(48.866667, 2.533333)).Selected = False
MapView1.Map.GetShape("Shape").AddPoint("point 3", MapPoint(48.866667, 2.533333), Color.Yellow, Image.Load("plus.png"))
Dim tmp1 As New MapPoint[]
Dim tmp2 As New MapPoint
......@@ -40,7 +44,7 @@ Dim hbound As MapBounds
tmp2 = MapPoint.GetCenter(tmp1)
MapView1.Map.GetShape("Shape").AddMultipoint("multipoint1", tmp1, Color.green, Image.Load("plus.png"))
'
MapView1.Map.GetShape("Shape").AddPolyLine("poly1", tmp1, Color.Yellow, 4, Line.DashDotDot)
MapView1.Map.GetShape("Shape").AddCircle("cir1", tmp2, 5000, Color.green, 4, Line.dot, Color.Transparent)
MapView1.Map.GetShape("Shape").AddCircle("cir2", tmp2, 2500, Color.red, 4, Line.dash, Color.Transparent)
......
......@@ -21,34 +21,34 @@ End
Public Function MapPointToPixel(hMapPoint As MapPoint, Zoom As Integer) As Point
Dim Res As Float = $initialResolution / (2 ^ zoom)
Dim X, Y As Float
Dim fRes As Float = $initialResolution / (2 ^ Zoom)
Dim fX, fY As Float
'Convert in Meters
X = hMapPoint.lon * $OriginShift / 180.0
Y = - (Log(Tan((90 + hMapPoint.lat) * Pi / 360.0)) / (Pi / 180.0)) * $OriginShift / 180.0
fX = hMapPoint.lon * $OriginShift / 180.0
fY = -(Log(Tan((90 + hMapPoint.lat) * Pi / 360.0)) / (Pi / 180.0)) * $OriginShift / 180.0
'Convert in Pixels
X = (X + $originShift) / res
Y = (Y + $originShift) / res
Return Point(X, Y)
fX = (fX + $originShift) / fRes
fY = (fY + $originShift) / fRes
Return Point(fX, fY)
End
Public Function PixelToMapPoint(hPoint As Point, Zoom As Integer) As MapPoint
Dim X, Y As Float
Dim Res As Float = $initialResolution / (2 ^ zoom)
Dim fX, fY As Float
Dim fRes As Float = $initialResolution / (2 ^ Zoom)
Dim mpPoint As New MapPoint
'Convert in Meters
X = hPoint.x * res - $originShift
Y = hPoint.y * res - $originShift
fX = hPoint.x * fRes - $originShift
fY = hPoint.y * fRes - $originShift
'Convert in Latlon mappoint
mpPoint.Lon = (X / $originShift) * 180.0
mpPoint.Lat = (Y / $originShift) * 180.0
mpPoint.Lon = (fX / $originShift) * 180.0
mpPoint.Lat = (fY / $originShift) * 180.0
mpPoint.Lat = - (180 / Pi * (2 * ATan(Exp(mpPoint.Lat * Pi / 180.0)) - Pi / 2.0))
mpPoint.Lat = -(180 / Pi * (2 * ATan(Exp(mpPoint.Lat * Pi / 180.0)) - Pi / 2.0))
Return mpPoint
End
......@@ -74,7 +74,7 @@ Public Function SexToDec(Value As String) As Float
Case "N", "E"
Return fRet
Case "S", "W", "O"
Return - fRet
Return -fRet
End Select
Endif
Return fRet
......@@ -106,7 +106,7 @@ Public Function DecToSex(Value As Float, Type As Integer) As String
fSec = Frac(fSec) * 60
sret = Subst("&1°&2'&3''", iDeg, iMin, Format(fSec, "0.##")) & sRet
Return sret
Return sRet
End
......
......@@ -3,17 +3,14 @@
'Export
Static Public Sub Polygone(Pt As Integer[])
Dim i As Integer
If pt.Count < 2 Then Return
Paint.MoveTo(pt[0], pt[1])
For i = 2 To pt.Max Step 2
For i As Integer = 2 To pt.Max Step 2
Paint.LineTo(pt[i], pt[i + 1])
Next
Paint.LineTo(pt[0], pt[1])
End
Static Public Sub RectangleRectF(hFbox As RectF)
Paint.Rectangle(hFbox.x, hFbox.Y, hFbox.Right - hFbox.X, hFbox.Bottom - hFbox.Y)
......
......@@ -20,8 +20,6 @@ Static Public Function _call(sInit As String) As Proj
End
Public Function TransformPF(ProjTo As Proj, PF As PointF) As PointF
Dim sCom, sRes As String
Dim a As String[]
......@@ -45,7 +43,6 @@ Public Function TransformMPoint(ProjTo As Proj, MP As MapPoint) As MapPoint
If ProjTo._strProj <> LastTransformString Then
LastTransformString = ProjTo._strProj
Endif
sCom = Subst("cs2cs -f \"%f\" +init=&1 +to +init=&2<<EOF\n", $strProj, ProjTo._strProj)
......@@ -84,4 +81,4 @@ Private Function _strProj_Read() As String
Return $strProj
End
End
\ No newline at end of file
......@@ -166,7 +166,7 @@ End
'fillcolor should come after color, but i dont want to break anything...
Public Sub AddCircle(Key As String, Center As MapPoint, Radius As Float, Optional {Color} As Integer, Optional {LineWidth} As Integer, Optional {LineStyle} As Integer, Optional {FillColor} As Integer) As _ShapeItem
If $aShapeNames.Exist(Key) Then Error.Raise("Key already exist: " & Key)
'If $aShapeNames.Exist(Key) Then Error.Raise("Key already exist: " & Key)
Dim P1, P2, P3, P4 As MapPoint
Dim hItem As New _ShapeItem(Key) As "Item"
......@@ -254,7 +254,8 @@ Public Sub Draw()
pt = Geo.MapPointToPixel(hShape.Points, hMap.zoom)
If hShape.Image Then
'Draws centralized
Paint.DrawImage(IIf(hShape.Color, hShape.Image.Colorize(hShape.Color), hShape.Image), pt.X - hMap.PixelBox.X - hShape.Image.Height / 2, pt.Y - hMap.PixelBox.Y - hShape.Image.width / 2)
If hShape.Color <> -1 Then hShape.Image.Colorize(hShape.Color)
Paint.DrawImage(hShape.Image, pt.X - hMap.PixelBox.X - hShape.Image.Height / 2, pt.Y - hMap.PixelBox.Y - hShape.Image.width / 2)
Else
'Draws with default "red point" icon offset
Paint.DrawImage(Me.Image, pt.X - hMap.PixelBox.X - 16, pt.Y - hMap.PixelBox.Y - 32)
......@@ -270,7 +271,9 @@ Public Sub Draw()
' Endif
If hShape.Image Then
'Draws centralized
Paint.DrawImage(IIf(hShape.Color, hShape.Image.Colorize(hShape.Color), hShape.Image), pt.X - hMap.PixelBox.X - hShape.Image.Height / 2, pt.Y - hMap.PixelBox.Y - hShape.Image.width / 2)
If hShape.Color <> -1 Then hShape.Image.Colorize(hShape.Color)
Paint.DrawImage(hShape.Image, pt.X - hMap.PixelBox.X - hShape.Image.Height / 2, pt.Y - hMap.PixelBox.Y - hShape.Image.width / 2)
'Paint.DrawImage(IIf(hShape.Color, hShape.Image.Colorize(hShape.Color), hShape.Image), pt.X - hMap.PixelBox.X - hShape.Image.Height / 2, pt.Y - hMap.PixelBox.Y - hShape.Image.width / 2)
Else
'Draws with default "red point" icon offset
Paint.DrawImage(Me.Image, pt.X - hMap.PixelBox.X - 16, pt.Y - hMap.PixelBox.Y - 32)
......@@ -388,20 +391,20 @@ End
Private Function GetPointBounds(hMapPoints As MapPoint[]) As MapBounds
Dim X, Y, X2, Y2 As Float
Dim fX, fY, fX2, fY2 As Float
X = hMapPoints[0].Lon
Y = hMapPoints[0].Lat
X2 = X
Y2 = Y
fX = hMapPoints[0].Lon
fY = hMapPoints[0].Lat
fX2 = fX
fY2 = fY
For Each hPoint As MapPoint In hMapPoints
X = Min(hPoint.lon, X)
Y2 = Min(hPoint.lat, Y2)
X2 = Max(hPoint.lon, X2)
Y = Max(hPoint.lat, Y)
fX = Min(hPoint.lon, fX)
fY2 = Min(hPoint.lat, fY2)
fX2 = Max(hPoint.lon, fX2)
fY = Max(hPoint.lat, fY)
Next
Return MapBounds(MapPoint(Y, X), MapPoint(Y2, X2))
Return MapBounds(MapPoint(fY, fX), MapPoint(fY2, fX2))
End
......
......@@ -589,14 +589,12 @@ End
Public Sub SetPattern(sPattern As String, Optional cArgs As Collection)
Dim s As Variant
$sPattern = sPattern
If InStr($sPattern, "{q}") Then $bIsQuadKey = True Else $bIsQuadKey = False
If cArgs Then
For Each s In cArgs
For Each s As Variant In cArgs
$sPattern = Replace($sPattern, "{" & cArgs.Key & "}", s)
Next
Endif
......@@ -629,18 +627,18 @@ End
Private Function TileToQuadKey(X As Integer, Y As Integer, Z As Integer) As String
Dim quadKey As String
Dim i, digit, mask As Integer
Dim sQuadKey As String
Dim iDigit, iMask As Integer
For i = z To 1 Step -1
digit = 0
mask = Lsl(1, (i - 1))
If (x And mask) <> 0 Then digit += 1
If (y And mask) <> 0 Then digit += 2
quadKey &= digit
For i As Integer = z To 1 Step -1
iDigit = 0
iMask = Lsl(1, (i - 1))
If (x And iMask) <> 0 Then iDigit += 1
If (y And iMask) <> 0 Then iDigit += 2
sQuadKey &= iDigit
Next
Return quadKey
Return sQuadKey
End
......@@ -680,17 +678,17 @@ End
'' Usefull for using with some server that query a session.
Public Function SetCoockieFile(sFile As String) As Object
Dim hc As HttpClient
Dim hClient As HttpClient
If Not sFile Then
For Each hc In $aClients
hc.UpdateCookies = False
hc.CookiesFile = ""
For Each hClient In $aClients
hClient.UpdateCookies = False
hClient.CookiesFile = ""
Next
Else
For Each hc In $aClients
hc.UpdateCookies = True
hc.CookiesFile = sFile
For Each hClient In $aClients
hClient.UpdateCookies = True
hClient.CookiesFile = sFile
Next
Endif
......