Skip to content

Commit

Permalink
Merge pull request #1018 from EnMAP-Box/1017-location-browser-request…
Browse files Browse the repository at this point in the history
…sexceptionsjsondecodeerror-expecting-value-line-1-column-1-char-0

resolved #1017
  • Loading branch information
janzandr authored Nov 7, 2024
2 parents ef59afa + f570025 commit ee5854b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,12 @@ def onRequestNominatimClicked(self):
url = 'https://nominatim.openstreetmap.org/search?q=' \
f'{urllib.parse.quote(text)}' \
'&limit=50&extratags=1&polygon_geojson=1&format=json'
nominatimResults = requests.get(url).json()
headers = {'User-Agent': 'EnMAP-Box QGIS Plugin ([email protected])'} # Required user agent
nominatimResults = requests.get(url, headers=headers).json()
# find additional results
if len(nominatimResults) == 1:
url += f'&exclude_place_ids={nominatimResults[0]["place_id"]}'
nominatimResults.extend(requests.get(url).json())
nominatimResults.extend(requests.get(url, headers=headers).json())

self.mResult.mList.clear()
item = QListWidgetItem('')
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import requests
from enmapboxprocessing.testcase import TestCase

class LocationBrowserApp(TestCase):

def test_nominatim(self):
url = 'https://nominatim.openstreetmap.org/search?q=berlin&limit=50&extratags=1&polygon_geojson=1&format=json'
headers = {"User-Agent": "EnMAP-Box QGIS Plugin ([email protected])"} # Required user agent
nominatimResults = requests.get(url, headers=headers)
self.assertEqual(nominatimResults.status_code, 200)

0 comments on commit ee5854b

Please sign in to comment.