From 0b53dcbb172b815694a4790762e8e87f592e6ef8 Mon Sep 17 00:00:00 2001
From: Thomas NOEL <tnoel@entrouvert.com>
Date: Tue, 19 Feb 2019 15:54:27 +0100
Subject: [PATCH] use entrouvert.org GIS instead of openstreetmap.org (#13241)

---
 tests/test_api.py              | 10 +++++-----
 tests/test_backoffice_pages.py |  2 +-
 tests/test_workflows.py        |  4 ++--
 wcs/qommon/publisher.py        |  6 +++---
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/tests/test_api.py b/tests/test_api.py
index dd84dfed..8fa8c1fc 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -2471,18 +2471,18 @@ def test_reverse_geocoding(pub):
         resp = get_app(pub).get('/api/reverse-geocoding?lat=0&lon=0')
         assert resp.content_type == 'application/json'
         assert resp.body == json.dumps({'address': 'xxx'})
-        assert urlopen.call_args[0][0] == 'http://nominatim.openstreetmap.org/reverse?zoom=18&format=json&addressdetails=1&lat=0&lon=0&accept-language=en'
+        assert urlopen.call_args[0][0] == 'https://nominatim.entrouvert.org/reverse?zoom=18&format=json&addressdetails=1&lat=0&lon=0&accept-language=en'
 
         pub.site_options.add_section('options')
         pub.site_options.set('options', 'nominatim_reverse_zoom_level', '16')
         pub.site_options.write(open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w'))
         resp = get_app(pub).get('/api/reverse-geocoding?lat=0&lon=0')
-        assert urlopen.call_args[0][0] == 'http://nominatim.openstreetmap.org/reverse?zoom=16&format=json&addressdetails=1&lat=0&lon=0&accept-language=en'
+        assert urlopen.call_args[0][0] == 'https://nominatim.entrouvert.org/reverse?zoom=16&format=json&addressdetails=1&lat=0&lon=0&accept-language=en'
 
         pub.site_options.set('options', 'nominatim_key', 'KEY')
         pub.site_options.write(open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w'))
         resp = get_app(pub).get('/api/reverse-geocoding?lat=0&lon=0')
-        assert urlopen.call_args[0][0] == 'http://nominatim.openstreetmap.org/reverse?zoom=16&key=KEY&format=json&addressdetails=1&lat=0&lon=0&accept-language=en'
+        assert urlopen.call_args[0][0] == 'https://nominatim.entrouvert.org/reverse?zoom=16&key=KEY&format=json&addressdetails=1&lat=0&lon=0&accept-language=en'
 
         pub.site_options.set('options', 'reverse_geocoding_service_url', 'http://reverse.example.net/?param=value')
         pub.site_options.write(open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w'))
@@ -2558,13 +2558,13 @@ def test_geocoding(pub):
         resp = get_app(pub).get('/api/geocoding?q=test')
         assert resp.content_type == 'application/json'
         assert resp.body == json.dumps([{'lat': 0, 'lon': 0}])
-        assert urlopen.call_args[0][0] == 'http://nominatim.openstreetmap.org/search?format=json&q=test&accept-language=en'
+        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', 'nominatim_key', 'KEY')
         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] == 'http://nominatim.openstreetmap.org/search?key=KEY&format=json&q=test&accept-language=en'
+        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', 'geocoding_service_url', 'http://reverse.example.net/?param=value')
         pub.site_options.write(open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w'))
diff --git a/tests/test_backoffice_pages.py b/tests/test_backoffice_pages.py
index 2b028743..285fc48e 100644
--- a/tests/test_backoffice_pages.py
+++ b/tests/test_backoffice_pages.py
@@ -1092,7 +1092,7 @@ def test_backoffice_map(pub):
     assert 'Plot on a Map' in resp.body
     resp = resp.click('Plot on a Map')
     assert 'data-geojson-url' in resp.body
-    assert 'tile.openstreetmap.org/' in resp.body
+    assert 'tiles.entrouvert.org/' in resp.body
 
     if not pub.site_options.has_section('options'):
         pub.site_options.add_section('options')
diff --git a/tests/test_workflows.py b/tests/test_workflows.py
index 710f79d9..5b658202 100644
--- a/tests/test_workflows.py
+++ b/tests/test_workflows.py
@@ -2564,7 +2564,7 @@ def test_geolocate_address(pub):
         http_get_page.return_value = (None, 200,
                 json.dumps([{'lat':'48.8337085','lon':'2.3233693'}]), None)
         item.perform(formdata)
-        assert 'http://nominatim.openstreetmap.org/search' in http_get_page.call_args[0][0]
+        assert 'https://nominatim.entrouvert.org/search' in http_get_page.call_args[0][0]
         assert urllib2.quote('169 rue du chateau, paris') in http_get_page.call_args[0][0]
         assert int(formdata.geolocations['base']['lat']) == 48
         assert int(formdata.geolocations['base']['lon']) == 2
@@ -2575,7 +2575,7 @@ def test_geolocate_address(pub):
         http_get_page.return_value = (None, 200,
                 json.dumps([{'lat':'48.8337085', 'lon':'2.3233693'}]), None)
         item.perform(formdata)
-        assert 'http://nominatim.openstreetmap.org/search' in http_get_page.call_args[0][0]
+        assert 'https://nominatim.entrouvert.org/search' in http_get_page.call_args[0][0]
         assert urllib2.quote('169 rue du chateau, paris') in http_get_page.call_args[0][0]
         assert 'key=KEY' in http_get_page.call_args[0][0]
         assert int(formdata.geolocations['base']['lat']) == 48
diff --git a/wcs/qommon/publisher.py b/wcs/qommon/publisher.py
index 82531a87..8b95a01d 100644
--- a/wcs/qommon/publisher.py
+++ b/wcs/qommon/publisher.py
@@ -938,14 +938,14 @@ class QommonPublisher(Publisher, object):
                   "<a href='https://openstreetmap.org'>OpenStreetMap</a> contributors, "\
                   "<a href='http://creativecommons.org/licenses/by-sa/2.0/'>CC-BY-SA</a>")
         attrs['data-tile-urltemplate'] = self.get_site_option('map-tile-urltemplate') or \
-                'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'
+                'https://tiles.entrouvert.org/hdm/{z}/{x}/{y}.png'
         return attrs
 
     def get_reverse_geocoding_service_url(self):
         url = self.get_site_option('reverse_geocoding_service_url')
         if url:
             return url
-        url = self.get_site_option('nominatim_url') or 'http://nominatim.openstreetmap.org'
+        url = self.get_site_option('nominatim_url') or 'https://nominatim.entrouvert.org'
         url += '/reverse'
         reverse_zoom_level = self.get_site_option('nominatim_reverse_zoom_level') or 18
         url += '?zoom=%s' % reverse_zoom_level
@@ -958,7 +958,7 @@ class QommonPublisher(Publisher, object):
         url = self.get_site_option('geocoding_service_url')
         if url:
             return url
-        url = self.get_site_option('nominatim_url') or 'http://nominatim.openstreetmap.org'
+        url = self.get_site_option('nominatim_url') or 'https://nominatim.entrouvert.org'
         url += '/search'
         key = self.get_site_option('nominatim_key')
         if key:
-- 
2.20.1

