Merge branch 'master' of gitlab.com:gambas/gambas

This commit is contained in:
Benoît Minisini 2023-10-20 01:49:34 +02:00
commit 3b9b1d8bfd
4 changed files with 83 additions and 66 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

View file

@ -1 +1,7 @@
' Gambas class file
Public Sub Form_Open()
MapView1.Map.AddTile("OpenStreet", "http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", Null)
End

View file

@ -1,7 +1,8 @@
# Gambas Form File 3.0
{ Form Form
MoveScaled(0,0,64,64)
MoveScaled(0,0,111,64)
Arrangement = Arrange.Fill
{ MapView1 MapView
MoveScaled(0,2,64,61)
}

View file

@ -15,7 +15,7 @@ Property Opacity As Float
Property Header As String[] Use $aHeader
Private $aStack As New String[]
Private $aClients As New HttpClient[]
Private $iClientCount As Integer = 4
Private $iClientCount As Integer = 10
Private $sCachePath As String ' = User.Home &/ ".cache/gb.map"
Private $tmrGet As New Timer As "tmrGet"
Private $aTiles As New String[]
@ -72,27 +72,18 @@ Public Sub _new(Optional CacheName As String)
$sCachePath = sTempPath
$aClients.Resize($iClientCount)
For i = 0 To $aClients.Max
'Init httpClient Array
For i = 0 To $iClientCount - 1
hClient = New HttpClient As "Client"
hClient.Async = True
With Me._GetMap()
If ._Proxy Then
hClient.Proxy.Auth = ._Proxy.Auth
hClient.Proxy.Type = ._Proxy.Type
hClient.Proxy.Host = ._Proxy.Host
hClient.Proxy.User = ._Proxy.User
hClient.Proxy.Password = ._Proxy.Password
Endif
End With
$aClients[i] = hClient
hClient.Timeout = 10
$aClients.Add(hClient)
Next
End
' svn checkout --username=gambix svn+ssh://gambas@svn.code.sf.net/p/gambas/code/gambas/trunk
'
'' Draws the Maptile Layer
Public Sub Draw()
Dim s As String
@ -166,7 +157,6 @@ Public Sub _Load()
' Dim sExec As String
' Dim bFirst As Boolean
'***********************************
mpFirst = Geo.PixelToMapPoint(Point(hMap.PixelBox.x, hMap.PixelBox.y), hmap.Zoom)
@ -377,8 +367,27 @@ End
Private Sub GetClient() As HttpClient
Dim hClient As HttpClient
For i As Integer = 0 To $aClients.max
If $aClients[i].Status = Net.Inactive Then Return $aClients[i]
If $aClients[i].Status = Net.Inactive Then
$aClients[i].Close
hClient = New HttpClient As "Client"
hClient.Async = True
hClient.Timeout = 10
'Setup proxy
With Me._GetMap()
If ._Proxy Then
hClient.Proxy.Auth = ._Proxy.Auth
hClient.Proxy.Type = ._Proxy.Type
hClient.Proxy.Host = ._Proxy.Host
hClient.Proxy.User = ._Proxy.User
hClient.Proxy.Password = ._Proxy.Password
Endif
End With
$aClients[i] = hClient
Return hClient
Endif
Next
End
@ -515,7 +524,7 @@ Private Function GetWMSTilept(X As Integer, Y As Integer, Z As Integer) As Strin
Dim hBound As MapBounds = Geo.TileBounds(X, Y, Z)
' Dim hbound2 As MapBounds = Geo.TileBounds(x + 1, y - 1, z)
' Dim hConv, hConv2 As MapBounds
' Dim hConv, hConv2 As MapBounds
Dim sTemp As String
Dim s As String
@ -759,12 +768,13 @@ End
'' Remove old files from cache.
'' - iLastUse defines file age in days
Public Sub ClearCache(Optional iLastUse As Integer)
'needs some testing...
'needs some testing...
If $sCachePath = Null Or Len($sCachePath) < 5 Then Return
If iLastUse Then
Exec ["find", $sCachePath, "-mtime", "+" & Str(iLastUse), "-delete"] With ["PWD", $sCachePath]
Else
Exec ["rm", $sCachePath &/ "*"]
Endif
End
End