Skip to content

Commit

Permalink
Initial PMTiles support for remote sources
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Sep 4, 2023
1 parent 63f470d commit 5662be6
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 106 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,7 @@ dependencies {
implementation 'ch.poole.android:sprites:0.0.4'
implementation 'ch.poole.android:indeterminate-checkbox:1.1.0@aar'
implementation 'ch.poole.misc:bentley-ottmann:0.1.1'
implementation 'ch.poole.geo.pmtiles-reader:Reader:0.3.0'

// for temp stuff during dev
// implementation(name:'alibrary', ext:'jar')
Expand Down
16 changes: 9 additions & 7 deletions src/main/java/de/blau/android/resources/TileLayerSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public class TileLayerSource implements Serializable {
public static final String TYPE_WMS_ENDPOINT = "wms_endpoint";
static final String TYPE_BING = "bing";
static final String TYPE_SCANEX = "scanex"; // no longer used
static final String TYPE_WMTS = "wmts";
public static final String TYPE_PMT_3 = "pmt3";

public static final String LAYER_MAPNIK = "MAPNIK";
public static final String LAYER_NONE = "NONE";
Expand Down Expand Up @@ -479,8 +481,8 @@ public enum Category {
private TileType tileType;
private List<Header> headers;

private boolean readOnly = false;
private String imageryOffsetId; // cached id for offset DB
private boolean localFile = false;
private String imageryOffsetId; // cached id for offset DB
private Offset[] offsets;

private static Map<String, TileLayerSource> backgroundServerList = null;
Expand Down Expand Up @@ -677,8 +679,8 @@ public TileLayerSource(@NonNull final Context ctx, @Nullable final String id, @N
// generate id from name if necessary
this.id = (id != null ? id : nameToId(this.name)).toUpperCase(Locale.US);

if (originalUrl.startsWith(FileUtil.FILE_SCHEME_PREFIX)) { // mbtiles no further processing needed
readOnly = true;
if (originalUrl.startsWith(FileUtil.FILE_SCHEME_PREFIX)) { // mbtiles and pmtiles no further processing needed
localFile = true;
}

// extract switch values
Expand Down Expand Up @@ -1353,12 +1355,12 @@ public void setName(@NonNull String name) {
}

/**
* Check if this layer is "read only" aka a mbtiles file
* Check if this layer is a local file
*
* @return true if read only
*/
public boolean isReadOnly() {
return readOnly;
public boolean isLocalFile() {
return localFile;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/blau/android/resources/eli/Eli.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public static TileLayerSource geojsonToServer(@NonNull Context ctx, @NonNull Fea
TileLayerSource.DEFAULT_MAX_OVERZOOM, tileWidth, tileHeight, proj, preference, startDate, endDate, noTileHeader, noTileValues, description,
privacyPolicyUrl, async);
osmts.setNoTileTile(noTileTile);
if (TileLayerSource.TYPE_TMS.equals(osmts.getType())) {
if (TileLayerSource.TYPE_TMS.equals(osmts.getType()) || TileLayerSource.TYPE_PMT_3.equals(osmts.getType())) {
osmts.setTileType(MVT_VALUE.equals(getJsonString(properties, TILE_TYPE_KEY)) ? TileType.MVT : TileType.BITMAP);
}
// we currently only support a single header object
Expand Down
Loading

0 comments on commit 5662be6

Please sign in to comment.