misc: limit geocoding to bounding box (#46410)
This commit is contained in:
parent
1bee5d7de8
commit
65a54ff5da
|
@ -3375,11 +3375,27 @@ def test_geocoding(pub):
|
|||
assert urlopen.call_args[0][0] == 'https://nominatim.entrouvert.org/search?format=json&q=test&accept-language=en'
|
||||
|
||||
pub.site_options.add_section('options')
|
||||
pub.site_options.set('options', 'map-bounds-top-left', '1.23;2.34')
|
||||
pub.site_options.set('options', 'map-bounds-bottom-right', '2.34;3.45')
|
||||
pub.site_options.write(open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w'))
|
||||
resp = get_app(pub).get('/api/geocoding?q=test')
|
||||
assert urlopen.call_args[0][0] == ('https://nominatim.entrouvert.org/search?viewbox=2.34,1.23,3.45,2.34&bounded=1&'
|
||||
'format=json&q=test&accept-language=en')
|
||||
|
||||
pub.site_options.set('options', 'nominatim_key', 'KEY')
|
||||
pub.site_options.set('options', 'map-bounds-top-left', '')
|
||||
pub.site_options.set('options', 'map-bounds-bottom-right', '')
|
||||
pub.site_options.write(open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w'))
|
||||
resp = get_app(pub).get('/api/geocoding?q=test')
|
||||
assert urlopen.call_args[0][0] == 'https://nominatim.entrouvert.org/search?key=KEY&format=json&q=test&accept-language=en'
|
||||
|
||||
pub.site_options.set('options', 'map-bounds-top-left', '1.23;2.34')
|
||||
pub.site_options.set('options', 'map-bounds-bottom-right', '2.34;3.45')
|
||||
pub.site_options.write(open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w'))
|
||||
resp = get_app(pub).get('/api/geocoding?q=test')
|
||||
assert urlopen.call_args[0][0] == ('https://nominatim.entrouvert.org/search?key=KEY&viewbox=2.34,1.23,3.45,2.34&bounded=1&'
|
||||
'format=json&q=test&accept-language=en')
|
||||
|
||||
pub.site_options.set('options', 'geocoding_service_url', 'http://reverse.example.net/?param=value')
|
||||
pub.site_options.write(open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w'))
|
||||
resp = get_app(pub).get('/api/geocoding?q=test')
|
||||
|
|
|
@ -789,6 +789,11 @@ class QommonPublisher(Publisher, object):
|
|||
key = self.get_site_option('nominatim_key')
|
||||
if key:
|
||||
url += '?key=%s' % key
|
||||
if self.get_site_option('map-bounds-top-left'):
|
||||
url += '&' if '?' in url else '?'
|
||||
top, left = self.get_site_option('map-bounds-top-left').split(';')
|
||||
bottom, right = self.get_site_option('map-bounds-bottom-right').split(';')
|
||||
url += 'viewbox=%s,%s,%s,%s&bounded=1' % (left, top, right, bottom)
|
||||
return url
|
||||
|
||||
def get_working_day_calendar(self):
|
||||
|
|
Loading…
Reference in New Issue