From 0b4a14033750bbb97c808222851d2dec441702f4 Mon Sep 17 00:00:00 2001 From: simonpoole Date: Sun, 17 Sep 2023 09:32:40 +0200 Subject: [PATCH 1/2] Make OAM server configurable and add test of OAM catalog modal --- .../blau/android/layer/LayerDialogTest.java | 35 ++++++++++++++++++- .../java/de/blau/android/contract/Urls.java | 3 +- .../de/blau/android/prefs/Preferences.java | 22 ++++++++++++ .../android/resources/OAMCatalogView.java | 3 +- src/main/res/values/prefkeys.xml | 1 + src/main/res/values/strings.xml | 2 ++ src/main/res/xml-v19/advancedpreferences.xml | 6 ++++ src/main/res/xml-v24/advancedpreferences.xml | 6 ++++ src/main/res/xml-v29/advancedpreferences.xml | 6 ++++ src/main/res/xml/advancedpreferences.xml | 6 ++++ 10 files changed, 85 insertions(+), 5 deletions(-) diff --git a/src/androidTest/java/de/blau/android/layer/LayerDialogTest.java b/src/androidTest/java/de/blau/android/layer/LayerDialogTest.java index c3d53d3ca2..e1e1b124c2 100644 --- a/src/androidTest/java/de/blau/android/layer/LayerDialogTest.java +++ b/src/androidTest/java/de/blau/android/layer/LayerDialogTest.java @@ -38,7 +38,6 @@ import de.blau.android.App; import de.blau.android.JavaResources; import de.blau.android.LayerUtils; -import de.blau.android.Logic; import de.blau.android.Main; import de.blau.android.Map; import de.blau.android.MockTileServer; @@ -484,6 +483,40 @@ public void wmsEndpoint() { } } + /** + * Test querying and adding a layer from OAM + */ + @Test + public void openAerialMap() { + assertTrue(TestUtils.clickResource(device, true, device.getCurrentPackageName() + ":id/layers", true)); + assertTrue(TestUtils.clickResource(device, true, device.getCurrentPackageName() + ":id/add", true)); + TestUtils.scrollToEnd(false); + + MockWebServerPlus oamServer = null; + try { + oamServer = new MockWebServerPlus(); + String urlString = oamServer.url(""); + + App.getLogic().getPrefs().setOAMServer(urlString); + oamServer.url("meta"); + + oamServer.enqueue("oam"); + + assertTrue(TestUtils.clickText(device, false, main.getString(R.string.menu_tools_add_imagery_from_oam), true)); + assertTrue(TestUtils.findText(device, false, main.getString(R.string.oam_layer_title))); + + assertTrue(TestUtils.findText(device, false, "Johnson Valley Soggy Dry Lake Cracks", 5000)); + assertTrue(TestUtils.clickText(device, false, "Johnson Valley Soggy Dry Lake Cracks", true)); + assertTrue(TestUtils.findText(device, false, main.getString(R.string.add_layer_title))); + assertTrue(TestUtils.findText(device, false, "Johnson Valley Soggy Dry Lake Cracks")); + } finally { + try { + oamServer.server().shutdown(); + } catch (IOException e) { + } + } + } + /** * Enable/disable bookmark layer * diff --git a/src/main/java/de/blau/android/contract/Urls.java b/src/main/java/de/blau/android/contract/Urls.java index 55d0d5aadd..2ce902f745 100644 --- a/src/main/java/de/blau/android/contract/Urls.java +++ b/src/main/java/de/blau/android/contract/Urls.java @@ -26,6 +26,7 @@ private Urls() { public static final String DEFAULT_OFFSET_SERVER = "http://offsets.textual.ru/"; public static final String DEFAULT_TAGINFO_SERVER = "https://taginfo.openstreetmap.org/"; public static final String DEFAULT_OVERPASS_SERVER = "https://overpass-api.de/api/interpreter"; + public static final String DEFAULT_OAM_SERVER = "https://api.openaerialmap.org/"; // these are only configurable for testing public static final String DEFAULT_MAPILLARY_IMAGES_V4 = "https://graph.mapillary.com/%s?access_token=%s&fields=thumb_2048_url,computed_geometry"; @@ -43,8 +44,6 @@ private Urls() { public static final String ELI = "https://osmlab.github.io/editor-layer-index/imagery.geojson"; public static final String JOSM_IMAGERY = "https://josm.openstreetmap.de/maps?format=geojson"; - public static final String OAM_SERVER = "https://api.openaerialmap.org/"; - public static final String MSF_SERVER = "https://mapsplit.poole.ch/"; public static final String EGM96 = "https://github.com/simonpoole/egm96/raw/master/src/main/resources/EGM96.dat"; diff --git a/src/main/java/de/blau/android/prefs/Preferences.java b/src/main/java/de/blau/android/prefs/Preferences.java index cd785ee09a..463df07eb6 100755 --- a/src/main/java/de/blau/android/prefs/Preferences.java +++ b/src/main/java/de/blau/android/prefs/Preferences.java @@ -81,6 +81,7 @@ public class Preferences { private final String mapRouletteServer; private String taginfoServer; private String overpassServer; + private String oamServer; private String mapillarySequencesUrlV4; private String mapillaryImagesUrlV4; private final int mapillaryMinZoom; @@ -221,6 +222,8 @@ public Preferences(@NonNull Context ctx) { mapRouletteServer = prefs.getString(r.getString(R.string.config_maprouletteServer_key), Urls.DEFAULT_MAPROULETTE_SERVER); taginfoServer = prefs.getString(r.getString(R.string.config_taginfoServer_key), Urls.DEFAULT_TAGINFO_SERVER); overpassServer = prefs.getString(r.getString(R.string.config_overpassServer_key), Urls.DEFAULT_OVERPASS_SERVER); + oamServer = prefs.getString(r.getString(R.string.config_oamServer_key), Urls.DEFAULT_OAM_SERVER); + mapillarySequencesUrlV4 = prefs.getString(r.getString(R.string.config_mapillarySequencesUrlV4_key), Urls.DEFAULT_MAPILLARY_SEQUENCES_URL_V4); mapillaryImagesUrlV4 = prefs.getString(r.getString(R.string.config_mapillaryImagesUrlV4_key), Urls.DEFAULT_MAPILLARY_IMAGES_V4); mapillaryMinZoom = getIntPref(R.string.config_mapillary_min_zoom_key, de.blau.android.layer.mapillary.MapOverlay.MAPILLARY_DEFAULT_MIN_ZOOM); @@ -814,6 +817,25 @@ public void setOverpassServer(@NonNull String url) { prefs.edit().putString(r.getString(R.string.config_overpassServer_key), url).commit(); } + /** + * Get the configured OpenAerialMap server + * + * @return base url for the server + */ + public String getOAMServer() { + return oamServer; + } + + /** + * Set the configured OpenAerialMap server + * + * @param url base url for the server + */ + public void setOAMServer(@NonNull String url) { + this.oamServer = url; + prefs.edit().putString(r.getString(R.string.config_oamServer_key), url).commit(); + } + /** * Get the configured mapillary sequence url * diff --git a/src/main/java/de/blau/android/resources/OAMCatalogView.java b/src/main/java/de/blau/android/resources/OAMCatalogView.java index b3d7632e24..0540e2cb48 100644 --- a/src/main/java/de/blau/android/resources/OAMCatalogView.java +++ b/src/main/java/de/blau/android/resources/OAMCatalogView.java @@ -21,7 +21,6 @@ import de.blau.android.Logic; import de.blau.android.Main; import de.blau.android.R; -import de.blau.android.contract.Urls; import de.blau.android.dialogs.Progress; import de.blau.android.osm.BoundingBox; import de.blau.android.resources.TileLayerDialog.OnUpdateListener; @@ -137,7 +136,7 @@ protected List doInBackground(Void param) { OAMCatalog catalog = new OAMCatalog(); List list = null; try { - list = catalog.getEntries(activity, Urls.OAM_SERVER, box); + list = catalog.getEntries(activity, App.getLogic().getPrefs().getOAMServer(), box); final int found = catalog.getFound(); final int limit = catalog.getLimit(); if (found > limit) { diff --git a/src/main/res/values/prefkeys.xml b/src/main/res/values/prefkeys.xml index 351846b6f5..7db5f26257 100644 --- a/src/main/res/values/prefkeys.xml +++ b/src/main/res/values/prefkeys.xml @@ -57,6 +57,7 @@ maprouletteServer taginfoServer overpassServer + oamServer mapillarySequencesUrlV4 mapillaryApi mapillaryImagesUrlV4 diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index a0c5e8d8d8..89e455d6bd 100755 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -1331,6 +1331,8 @@ Taginfo server to use for preset generation Overpass server Overpass server used for queries + OpenAerialMap server + OpenAerialMap server used for serving imagery Layer download and storage diff --git a/src/main/res/xml-v19/advancedpreferences.xml b/src/main/res/xml-v19/advancedpreferences.xml index 3f6a12bd6e..57923883b3 100644 --- a/src/main/res/xml-v19/advancedpreferences.xml +++ b/src/main/res/xml-v19/advancedpreferences.xml @@ -551,6 +551,12 @@ android:summary="@string/config_overpassServer_summary" android:dialogMessage="@string/config_overpassServer_summary" android:title="@string/config_overpassServer_title" /> + + + + Date: Sun, 17 Sep 2023 10:58:32 +0200 Subject: [PATCH 2/2] Update preference doc --- documentation/docs/help/en/Advanced preferences.md | 8 ++++++++ src/main/assets/help/en/Advanced preferences.html | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/documentation/docs/help/en/Advanced preferences.md b/documentation/docs/help/en/Advanced preferences.md index 759141cd53..6787a6604b 100644 --- a/documentation/docs/help/en/Advanced preferences.md +++ b/documentation/docs/help/en/Advanced preferences.md @@ -301,6 +301,14 @@ Geocoding service providers. Currently Photon and Nominatim servers are supporte Configure the taginfo server used for the "online" preset search/construction. +### Overpass server + +Configure the overpass API server used online object search. + +### OpenAerialMap server + +Configure the OpenAerialMap server used for providing additional imagery for backgrounds. + ## Layer download and storage Download and storage configuration for the tiled imagery layers. diff --git a/src/main/assets/help/en/Advanced preferences.html b/src/main/assets/help/en/Advanced preferences.html index 31e4ac0494..f23b2ef4b3 100644 --- a/src/main/assets/help/en/Advanced preferences.html +++ b/src/main/assets/help/en/Advanced preferences.html @@ -156,6 +156,10 @@

Configure geocoders

Geocoding service providers. Currently Photon and Nominatim servers are supported.

Taginfo server

Configure the taginfo server used for the "online" preset search/construction.

+

Overpass server

+

Configure the overpass API server used online object search.

+

OpenAerialMap server

+

Configure the OpenAerialMap server used for providing additional imagery for backgrounds.

Layer download and storage

Download and storage configuration for the tiled imagery layers.

Max. number of download threads