Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Jan 14, 2025
1 parent 36e2507 commit 79443a9
Show file tree
Hide file tree
Showing 27 changed files with 191 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import de.blau.android.dialogs.DateRangeDialog;
import de.blau.android.layer.LayerDialogTest;
import de.blau.android.layer.LayerType;
import de.blau.android.layer.streetlevel.mapillary.MapillaryOverlay;
import de.blau.android.photos.MapillaryViewerActivity;
import de.blau.android.prefs.AdvancedPrefDatabase;
import de.blau.android.prefs.Preferences;
Expand Down Expand Up @@ -81,7 +82,7 @@ public void setup() {
TestUtils.grantPermissons(device);
LayerUtils.removeLayer(main, LayerType.MAPILLARY);
tileServer = MockTileServer.setupTileServer(main, "mapillary.mbt", true, LayerType.MAPILLARY, TileType.MVT,
de.blau.android.layer.mapillary.MapillaryOverlay.MAPILLARY_TILES_ID);
de.blau.android.layer.streetlevel.mapillary.MapillaryOverlay.MAPILLARY_TILES_ID);

mockApiServer = new MockWebServerPlus();
HttpUrl mockApiBaseUrl = mockApiServer.server().url("/");
Expand Down Expand Up @@ -120,7 +121,7 @@ public void teardown() {
}
LayerUtils.removeLayer(main, LayerType.MAPILLARY);
try (TileLayerDatabase tlDb = new TileLayerDatabase(main); SQLiteDatabase db = tlDb.getWritableDatabase()) {
TileLayerDatabase.deleteLayerWithId(db, de.blau.android.layer.mapillary.MapillaryOverlay.MAPILLARY_TILES_ID);
TileLayerDatabase.deleteLayerWithId(db, de.blau.android.layer.streetlevel.mapillary.MapillaryOverlay.MAPILLARY_TILES_ID);
}
instrumentation.waitForIdleSync();
}
Expand All @@ -135,7 +136,7 @@ public void mapillaryLayer() {
imageResponse.setResponseCode(200);
imageResponse.setBody("{\"thumb_2048_url\": \"" + mockImagesBaseUrl.toString() + "\",\"computed_geometry\": {\"type\": \"Point\",\"coordinates\": ["
+ "8.407748800863,47.412813485744]" + "},\"id\": \"178993950747668\"}");
de.blau.android.layer.mapillary.MapillaryOverlay layer = (MapillaryOverlay) map.getLayer(LayerType.MAPILLARY);
de.blau.android.layer.streetlevel.mapillary.MapillaryOverlay layer = (MapillaryOverlay) map.getLayer(LayerType.MAPILLARY);
assertNotNull(layer);
layer.flushCaches(main); // forces the layer to retrieve everything

Expand Down
32 changes: 28 additions & 4 deletions src/main/assets/panoramax-style.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@
"id": "sequences",
"type": "line",
"source-layer": "sequences",

"filter": [
"all",
[
">=",
"date",
0
],
[
"<=",
"date",
0
]
],
"minzoom": 14,
"paint": {
"line-opacity": 1,
Expand Down Expand Up @@ -34,12 +46,24 @@
"id": "pictures",
"type": "symbol",
"source-layer": "pictures",

"filter": [
"all",
[
">=",
"ts",
0
],
[
"<=",
"ts",
0
]
],
"minzoom": 19,
"layout": {
"icon-image": "arrow",
"icon-rotate": {
"property": "compass_angle",
"property": "heading",
"type": "identity"
}
},
Expand All @@ -60,7 +84,7 @@
"layout": {
"icon-image": "arrow",
"icon-rotate": {
"property": "compass_angle",
"property": "heading",
"type": "identity"
}
},
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/blau/android/DisambiguationMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ private Type typeFromObject(@NonNull ClickedObject<?> clicked) {
return Type.GPX;
}
if (object instanceof de.blau.android.util.mvt.VectorTileDecoder.Feature) {
if (clicked.getLayer() instanceof de.blau.android.layer.mapillary.MapillaryOverlay) {
if (clicked.getLayer() instanceof de.blau.android.layer.streetlevel.mapillary.MapillaryOverlay) {
return Type.MAPILLARY;
} else if (clicked.getLayer() instanceof de.blau.android.layer.panoramax.PanoramaxOverlay) {
} else if (clicked.getLayer() instanceof de.blau.android.layer.streetlevel.panoramax.PanoramaxOverlay) {
return Type.PANORAMAX;
}
return Type.MVT;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/blau/android/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@
import de.blau.android.layer.DownloadInterface;
import de.blau.android.layer.LayerType;
import de.blau.android.layer.MapViewLayer;
import de.blau.android.layer.NetworkImageLoader;
import de.blau.android.layer.SelectImageInterface;
import de.blau.android.layer.geojson.MapOverlay;
import de.blau.android.layer.streetlevel.NetworkImageLoader;
import de.blau.android.layer.streetlevel.SelectImageInterface;
import de.blau.android.listener.UpdateViewListener;
import de.blau.android.osm.BoundingBox;
import de.blau.android.osm.Node;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/blau/android/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,10 @@ public void setUpLayers(@NonNull Context ctx) {
}
break;
case MAPILLARY:
layer = new de.blau.android.layer.mapillary.MapillaryOverlay(this);
layer = new de.blau.android.layer.streetlevel.mapillary.MapillaryOverlay(this);
break;
case PANORAMAX:
layer = new de.blau.android.layer.panoramax.PanoramaxOverlay(this);
layer = new de.blau.android.layer.streetlevel.panoramax.PanoramaxOverlay(this);
break;
case BOOKMARKS:
layer = new de.blau.android.layer.bookmarks.MapOverlay(this);
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/de/blau/android/contract/Urls.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ private Urls() {
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/";
public static final String DEFAULT_PANORAMAX_API_URL = "https://panoramax.xyz/";

// 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,computed_compass_angle,captured_at";
Expand All @@ -51,7 +52,4 @@ private Urls() {
public static final String GITHUB = "https://github.com/";

public static final String REMOTE_ICON_LOCATION = "https://simonpoole.github.io/beautified-JOSM-preset/icons/png/";

public static final String PANORAMAX_SEQUENCES = "https://panoramax.openstreetmap.fr/api/collections/%s/items";
public static final String PANORAMAX_PICTURES = "https://panoramax.openstreetmap.fr/api/pictures/%s/hd.jpg";
}
2 changes: 1 addition & 1 deletion src/main/java/de/blau/android/dialogs/DateRangeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import androidx.fragment.app.FragmentManager;
import de.blau.android.App;
import de.blau.android.R;
import de.blau.android.layer.DateRangeInterface;
import de.blau.android.layer.streetlevel.DateRangeInterface;
import de.blau.android.listener.DoNothingListener;
import de.blau.android.util.ACRAHelper;
import de.blau.android.util.ImmersiveDialogFragment;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/de/blau/android/dialogs/ImageInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import de.blau.android.util.InfoDialogFragment;

/**
* Very simple dialog fragment to display some info on a GeoJSON element
* Very simple dialog fragment to display some info on an image
*
* @author simon
*
Expand All @@ -40,7 +40,7 @@ public class ImageInfo extends InfoDialogFragment {
private static final String TAG = "fragment_image_info";

private Uri uri = null;
private SimpleDateFormat dateFormat = DateFormatter.getUtcFormat("yyyy-MM-dd HH:mm:ssZ");
private SimpleDateFormat dateFormat = DateFormatter.getUtcFormat("yyyy-MM-dd HH:mm:ssZZ");

/**
* Show an info dialog for an image
Expand Down Expand Up @@ -69,11 +69,11 @@ private static void dismissDialog(@NonNull FragmentActivity activity) {
}

/**
* Create a new instance of the FeatureInfo dialog
* Create a new instance of the ImageInfo dialog
*
* @param feature Feature to display the info on
*
* @return an instance of ElementInfo
* @return an instance of ImageInfo
*/
@NonNull
private static ImageInfo newInstance(@NonNull String uriString) {
Expand Down
29 changes: 13 additions & 16 deletions src/main/java/de/blau/android/dialogs/Layers.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
import de.blau.android.layer.StyleableInterface;
import de.blau.android.layer.StyleableLayer;
import de.blau.android.layer.mvt.MapOverlay;
import de.blau.android.layer.streetlevel.DateRangeInterface;
import de.blau.android.osm.BoundingBox;
import de.blau.android.osm.GpxFile;
import de.blau.android.osm.OsmGpxApi;
Expand Down Expand Up @@ -264,7 +265,7 @@ public AppCompatDialog onCreateDialog(Bundle savedInstanceState) {

if (map.getLayer(LayerType.MAPILLARY) == null) {
try (KeyDatabaseHelper keys = new KeyDatabaseHelper(activity); SQLiteDatabase db = keys.getReadableDatabase()) {
if (KeyDatabaseHelper.getKey(db, de.blau.android.layer.mapillary.MapillaryOverlay.APIKEY_KEY, EntryType.API_KEY) != null) {
if (KeyDatabaseHelper.getKey(db, de.blau.android.layer.streetlevel.mapillary.MapillaryOverlay.APIKEY_KEY, EntryType.API_KEY) != null) {
item = popup.getMenu().add(R.string.menu_layers_enable_mapillary_layer);
item.setOnMenuItemClickListener(unused -> {
de.blau.android.layer.Util.addLayer(activity, LayerType.MAPILLARY);
Expand All @@ -277,17 +278,13 @@ public AppCompatDialog onCreateDialog(Bundle savedInstanceState) {
}

if (map.getLayer(LayerType.PANORAMAX) == null) {
try (KeyDatabaseHelper keys = new KeyDatabaseHelper(activity); SQLiteDatabase db = keys.getReadableDatabase()) {
if (KeyDatabaseHelper.getKey(db, de.blau.android.layer.mapillary.MapillaryOverlay.APIKEY_KEY, EntryType.API_KEY) != null) {
item = popup.getMenu().add("PANORAMAX");
item.setOnMenuItemClickListener(unused -> {
de.blau.android.layer.Util.addLayer(activity, LayerType.PANORAMAX);
updateDialogAndPrefs(activity, prefs, map);
Tip.showDialog(activity, R.string.tip_mapillary_privacy_key, R.string.tip_mapillary_privacy);
return true;
});
}
}
item = popup.getMenu().add(R.string.menu_layers_enable_panoramax_layer);
item.setOnMenuItemClickListener(unused -> {
de.blau.android.layer.Util.addLayer(activity, LayerType.PANORAMAX);
updateDialogAndPrefs(activity, prefs, map);
Tip.showDialog(activity, R.string.tip_panoramax_privacy_key, R.string.tip_panoramax_privacy);
return true;
});
}

item = popup.getMenu().add(R.string.layer_add_gpx);
Expand Down Expand Up @@ -938,14 +935,14 @@ public void onClick(View arg0) {
final Map map = App.getLogic().getMap();

// maybe we should use an interface here
if (layer instanceof MapTilesLayer && !(layer instanceof de.blau.android.layer.mapillary.MapillaryOverlay)) {
if (layer instanceof MapTilesLayer && !(layer instanceof de.blau.android.layer.streetlevel.mapillary.MapillaryOverlay ||
layer instanceof de.blau.android.layer.streetlevel.panoramax.PanoramaxOverlay)) {
// get MRU list from layer
final String[] tileServerIds = ((MapTilesLayer<?>) layer).getMRU();
final TileLayerSource tileLayerConfiguration = ((MapTilesLayer<?>) layer).getTileLayerConfiguration();
final String currentServerId = tileLayerConfiguration.getId();
for (int i = 0; i < tileServerIds.length; i++) {
final String id = tileServerIds[i];

if (!currentServerId.equals(id)) {
final TileLayerSource tileServer = TileLayerSource.get(activity, id, true);
if (tileServer != null) {
Expand Down Expand Up @@ -1040,11 +1037,11 @@ public void onClick(View arg0) {
item.setEnabled(stylingEnabled);
}

if (layer instanceof de.blau.android.layer.mapillary.MapillaryOverlay) {
if (layer instanceof DateRangeInterface) {
MenuItem item = menu.add(R.string.layer_set_date_range);
item.setOnMenuItemClickListener(unused -> {
if (layer != null) {
((de.blau.android.layer.mapillary.MapillaryOverlay) layer).selectDateRange(getActivity(), layer.getIndex());
((DateRangeInterface) layer).selectDateRange(getActivity(), layer.getIndex());
}
return true;
});
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/de/blau/android/layer/DateRangeInterface.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package de.blau.android.layer.streetlevel;

import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentActivity;

public interface DateRangeInterface {
/**
* Set a date range to display
*
* @param start the lower bound for the capture date in ms since the epoch
* @param end the upper bound for the capture date in ms since the epoch
*/
public void setDateRange(long start, long end);

/**
* Show a modal to select the date range
*
* @param activity the current activity
* @param layerIndex the index of the layer
*/
public void selectDateRange(@NonNull FragmentActivity activity, int layerIndex);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.blau.android.layer;
package de.blau.android.layer.streetlevel;

import static de.blau.android.contract.Constants.LOG_TAG_LEN;

Expand All @@ -23,6 +23,7 @@
import de.blau.android.contract.MimeTypes;
import de.blau.android.contract.Schemes;
import de.blau.android.dialogs.ImageInfo;
import de.blau.android.layer.LayerType;
import de.blau.android.util.ExecutorTask;
import de.blau.android.util.FileUtil;
import de.blau.android.util.ImageLoader;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.blau.android.layer;
package de.blau.android.layer.streetlevel;

public interface SelectImageInterface {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.blau.android.layer.mapillary;
package de.blau.android.layer.streetlevel.mapillary;

import static de.blau.android.contract.Constants.LOG_TAG_LEN;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.blau.android.layer.mapillary;
package de.blau.android.layer.streetlevel.mapillary;

import static de.blau.android.contract.Constants.LOG_TAG_LEN;

Expand Down Expand Up @@ -29,7 +29,7 @@
import androidx.exifinterface.media.ExifInterface;
import de.blau.android.App;
import de.blau.android.layer.LayerType;
import de.blau.android.layer.NetworkImageLoader;
import de.blau.android.layer.streetlevel.NetworkImageLoader;
import okhttp3.Call;
import okhttp3.OkHttpClient;
import okhttp3.Request;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.blau.android.layer.mapillary;
package de.blau.android.layer.streetlevel.mapillary;

import static de.blau.android.contract.Constants.LOG_TAG_LEN;

Expand Down Expand Up @@ -31,9 +31,9 @@
import de.blau.android.contract.FileExtensions;
import de.blau.android.contract.Urls;
import de.blau.android.dialogs.DateRangeDialog;
import de.blau.android.layer.DateRangeInterface;
import de.blau.android.layer.LayerType;
import de.blau.android.layer.SelectImageInterface;
import de.blau.android.layer.streetlevel.DateRangeInterface;
import de.blau.android.layer.streetlevel.SelectImageInterface;
import de.blau.android.osm.OsmParser;
import de.blau.android.osm.ViewBox;
import de.blau.android.photos.MapillaryViewerActivity;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* Vector tile based streetlevel imagery layers
*/
package de.blau.android.layer.streetlevel;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.blau.android.layer.panoramax;
package de.blau.android.layer.streetlevel.panoramax;

import static de.blau.android.contract.Constants.LOG_TAG_LEN;

Expand All @@ -20,7 +20,7 @@
import androidx.exifinterface.media.ExifInterface;
import de.blau.android.App;
import de.blau.android.layer.LayerType;
import de.blau.android.layer.NetworkImageLoader;
import de.blau.android.layer.streetlevel.NetworkImageLoader;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
Expand Down
Loading

0 comments on commit 79443a9

Please sign in to comment.