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 ' 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 # Gambas Form File 3.0
{ Form Form { Form Form
MoveScaled(0,0,64,64) MoveScaled(0,0,111,64)
Arrangement = Arrange.Fill
{ MapView1 MapView { MapView1 MapView
MoveScaled(0,2,64,61) MoveScaled(0,2,64,61)
} }

View file

@ -15,7 +15,7 @@ Property Opacity As Float
Property Header As String[] Use $aHeader Property Header As String[] Use $aHeader
Private $aStack As New String[] Private $aStack As New String[]
Private $aClients As New HttpClient[] 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 $sCachePath As String ' = User.Home &/ ".cache/gb.map"
Private $tmrGet As New Timer As "tmrGet" Private $tmrGet As New Timer As "tmrGet"
Private $aTiles As New String[] Private $aTiles As New String[]
@ -72,27 +72,18 @@ Public Sub _new(Optional CacheName As String)
$sCachePath = sTempPath $sCachePath = sTempPath
$aClients.Resize($iClientCount) 'Init httpClient Array
For i = 0 To $aClients.Max For i = 0 To $iClientCount - 1
hClient = New HttpClient As "Client" hClient = New HttpClient As "Client"
hClient.Async = True $aClients.Add(hClient)
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
Next Next
End End
' svn checkout --username=gambix svn+ssh://gambas@svn.code.sf.net/p/gambas/code/gambas/trunk ' svn checkout --username=gambix svn+ssh://gambas@svn.code.sf.net/p/gambas/code/gambas/trunk
' '
'' Draws the Maptile Layer '' Draws the Maptile Layer
Public Sub Draw() Public Sub Draw()
Dim s As String Dim s As String
@ -166,7 +157,6 @@ Public Sub _Load()
' Dim sExec As String ' Dim sExec As String
' Dim bFirst As Boolean ' Dim bFirst As Boolean
'*********************************** '***********************************
mpFirst = Geo.PixelToMapPoint(Point(hMap.PixelBox.x, hMap.PixelBox.y), hmap.Zoom) mpFirst = Geo.PixelToMapPoint(Point(hMap.PixelBox.x, hMap.PixelBox.y), hmap.Zoom)
@ -377,8 +367,27 @@ End
Private Sub GetClient() As HttpClient Private Sub GetClient() As HttpClient
Dim hClient As HttpClient
For i As Integer = 0 To $aClients.max 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 Next
End End
@ -760,11 +769,12 @@ End
'' - iLastUse defines file age in days '' - iLastUse defines file age in days
Public Sub ClearCache(Optional iLastUse As Integer) Public Sub ClearCache(Optional iLastUse As Integer)
'needs some testing... 'needs some testing...
If $sCachePath = Null Or Len($sCachePath) < 5 Then Return If $sCachePath = Null Or Len($sCachePath) < 5 Then Return
If iLastUse Then If iLastUse Then
Exec ["find", $sCachePath, "-mtime", "+" & Str(iLastUse), "-delete"] With ["PWD", $sCachePath] Exec ["find", $sCachePath, "-mtime", "+" & Str(iLastUse), "-delete"] With ["PWD", $sCachePath]
Else Else
Exec ["rm", $sCachePath &/ "*"] Exec ["rm", $sCachePath &/ "*"]
Endif Endif
End
End