Skip to content

Commit

Permalink
Merge branch 'oam_selection_test'
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Sep 17, 2023
2 parents c4d36e4 + 60ad5c0 commit 91df4a3
Show file tree
Hide file tree
Showing 12 changed files with 97 additions and 5 deletions.
8 changes: 8 additions & 0 deletions documentation/docs/help/en/Advanced preferences.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
35 changes: 34 additions & 1 deletion src/androidTest/java/de/blau/android/layer/LayerDialogTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down
4 changes: 4 additions & 0 deletions src/main/assets/help/en/Advanced preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ <h3>Configure geocoders</h3>
<p>Geocoding service providers. Currently Photon and Nominatim servers are supported.</p>
<h3>Taginfo server</h3>
<p>Configure the taginfo server used for the &quot;online&quot; preset search/construction.</p>
<h3>Overpass server</h3>
<p>Configure the overpass API server used online object search.</p>
<h3>OpenAerialMap server</h3>
<p>Configure the OpenAerialMap server used for providing additional imagery for backgrounds.</p>
<h2>Layer download and storage</h2>
<p>Download and storage configuration for the tiled imagery layers.</p>
<h3>Max. number of download threads</h3>
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/de/blau/android/contract/Urls.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/de/blau/android/prefs/Preferences.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
*
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/de/blau/android/resources/OAMCatalogView.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -137,7 +136,7 @@ protected List<LayerEntry> doInBackground(Void param) {
OAMCatalog catalog = new OAMCatalog();
List<LayerEntry> 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) {
Expand Down
1 change: 1 addition & 0 deletions src/main/res/values/prefkeys.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<string name="config_maprouletteServer_key">maprouletteServer</string>
<string name="config_taginfoServer_key">taginfoServer</string>
<string name="config_overpassServer_key">overpassServer</string>
<string name="config_oamServer_key">oamServer</string>
<string name="config_mapillarySequencesUrlV4_key">mapillarySequencesUrlV4</string>
<string name="config_mapillaryApi_key">mapillaryApi</string> <!-- no longer used -->
<string name="config_mapillaryImagesUrlV4_key">mapillaryImagesUrlV4</string>
Expand Down
2 changes: 2 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,8 @@
<string name="config_taginfoServer_summary">Taginfo server to use for preset generation</string>
<string name="config_overpassServer_title">Overpass server</string>
<string name="config_overpassServer_summary">Overpass server used for queries</string>
<string name="config_oamServer_title">OpenAerialMap server</string>
<string name="config_oamServer_summary">OpenAerialMap server used for serving imagery</string>

<!-- Layer download and storage -->
<string name="config_category_layers">Layer download and storage</string>
Expand Down
6 changes: 6 additions & 0 deletions src/main/res/xml-v19/advancedpreferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@
android:summary="@string/config_overpassServer_summary"
android:dialogMessage="@string/config_overpassServer_summary"
android:title="@string/config_overpassServer_title" />
<androidx.preference.EditTextPreference
android:defaultValue="https://api.openaerialmap.org/"
android:key="@string/config_oamServer_key"
android:summary="@string/config_oamServer_summary"
android:dialogMessage="@string/config_oamServer_summary"
android:title="@string/config_oamServer_title" />
</androidx.preference.PreferenceScreen>
<androidx.preference.PreferenceScreen
android:key="config_category_layers"
Expand Down
6 changes: 6 additions & 0 deletions src/main/res/xml-v24/advancedpreferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,12 @@
android:summary="@string/config_overpassServer_summary"
android:dialogMessage="@string/config_overpassServer_summary"
android:title="@string/config_overpassServer_title" />
<androidx.preference.EditTextPreference
android:defaultValue="https://api.openaerialmap.org/"
android:key="@string/config_oamServer_key"
android:summary="@string/config_oamServer_summary"
android:dialogMessage="@string/config_oamServer_summary"
android:title="@string/config_oamServer_title" />
</androidx.preference.PreferenceScreen>
<androidx.preference.PreferenceScreen
android:key="config_category_layers"
Expand Down
6 changes: 6 additions & 0 deletions src/main/res/xml-v29/advancedpreferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,12 @@
android:summary="@string/config_overpassServer_summary"
android:dialogMessage="@string/config_overpassServer_summary"
android:title="@string/config_overpassServer_title" />
<androidx.preference.EditTextPreference
android:defaultValue="https://api.openaerialmap.org/"
android:key="@string/config_oamServer_key"
android:summary="@string/config_oamServer_summary"
android:dialogMessage="@string/config_oamServer_summary"
android:title="@string/config_oamServer_title" />
</androidx.preference.PreferenceScreen>
<androidx.preference.PreferenceScreen
android:key="config_category_layers"
Expand Down
6 changes: 6 additions & 0 deletions src/main/res/xml/advancedpreferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@
android:summary="@string/config_overpassServer_summary"
android:dialogMessage="@string/config_overpassServer_summary"
android:title="@string/config_overpassServer_title" />
<androidx.preference.EditTextPreference
android:defaultValue="https://api.openaerialmap.org/"
android:key="@string/config_oamServer_key"
android:summary="@string/config_oamServer_summary"
android:dialogMessage="@string/config_oamServer_summary"
android:title="@string/config_oamServer_title" />
</androidx.preference.PreferenceScreen>
<androidx.preference.PreferenceScreen
android:key="config_category_layers"
Expand Down

0 comments on commit 91df4a3

Please sign in to comment.