Dear All!
I need some guidance ...
What I want to do:
geocoding of a given postal address which results in details like GPS coordinates
A simplified version of my App is as following:
With that I receive following messages in the log:
I did some variations (example: w/ and w/o try/catch - structures) which results some times in a different exception:
(ErrnoException) android.system.ErrnoException: open failed: ENOENT (No such file or directory)
When I type in the query into a browser I receive the excepted result.
It seams to me that the query result should be written to a place on my phone where I don't have access to.
What is wrong with my code?
Android version: 14
Smartphone: Galaxy A16 5G
B4A Version: 13.10
Any help appreciated ...
Wosl
PS: I use a similar code in an older android version ... and it worked. When I compile it on a newer Android version it fails.
I need some guidance ...
What I want to do:
geocoding of a given postal address which results in details like GPS coordinates
A simplified version of my App is as following:
Geocoding example:
Sub Activity_Create(FirstTime As Boolean)
Private cAddress As String ="10117 Berlin, Pariser Platz 5"
Log ("Address: " & cAddress)
Wait for (Geocoding(cAddress)) Complete(Result As Int)
Log ("Return Code: " & Result)
End Sub
Sub Geocoding(aquery As String) As ResumableSub
'#####################################################################
'
' Geocoding a specific postal address (PLZ Stadt, Straße Hausnummer)
'
' aquery String with postal address
'
'#####################################################################
Dim su As StringUtils
Dim q As String=su.EncodeUrl(aquery,"UTF8")
Dim s As String=$"https://nominatim.openstreetmap.org/?addressdetails=1&q=${q}&format=json"$
Dim j As HttpJob
Dim ier As Int
Log ("Geocoding Query = '" & s & "'")
Try
j.Initialize("Geocoding", Me)
j.Download(s)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log ("Geocoding successfully done")
Log ("Result = '" & j.GetString & "'")
'
' ... parse for the GPS coordinates
'
ier = 0
Else
Log ("Geocoding failed (#1)")
ier = 1
End If
Catch
Log ("Geocoding failed (#2): " & LastException.Message)
ier = 2
End Try
If j.IsInitialized Then j.Release
Return ier
End Sub
With that I receive following messages in the log:
Error message:
** Activity (main) Create (first time) **
Address: 10117 Berlin, Pariser Platz 5
Geocoding Query = 'https://nominatim.openstreetmap.org/?addressdetails=1&q=10117+Berlin%2C+Pariser+Platz+5&format=json'
** Activity (main) Resume **
*** Receiver (httputils2service) Receive (first time) ***
ResponseError. Reason: , Response: Access denied. See https://operations.osmfoundation.org/policies/nominatim/
Geocoding failed (#1)
Return Code: 1
** Activity (main) Pause, UserClosed = false **
I did some variations (example: w/ and w/o try/catch - structures) which results some times in a different exception:
(ErrnoException) android.system.ErrnoException: open failed: ENOENT (No such file or directory)
When I type in the query into a browser I receive the excepted result.
It seams to me that the query result should be written to a place on my phone where I don't have access to.
What is wrong with my code?
Android version: 14
Smartphone: Galaxy A16 5G
B4A Version: 13.10
Any help appreciated ...
Wosl
PS: I use a similar code in an older android version ... and it worked. When I compile it on a newer Android version it fails.