-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1018 from EnMAP-Box/1017-location-browser-request…
…sexceptionsjsondecodeerror-expecting-value-line-1-column-1-char-0 resolved #1017
- Loading branch information
Showing
3 changed files
with
13 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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('') | ||
|
Empty file.
10 changes: 10 additions & 0 deletions
10
tests/enmap-box/enmapbox/eo4qapps/locationbrowserapp/test_LocationBrowserApp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |