fix: UrlTileSource.Builder was hiding zoom values from TileSource.Builder
- values set thorugh builder.minZoom()/maxZoom() were ignored should fix: #120
This commit is contained in:
@@ -23,16 +23,16 @@ import org.oscim.layers.tile.bitmap.BitmapTileLayer.FadeStep;
|
||||
public abstract class TileSource {
|
||||
|
||||
public abstract static class Builder<T extends Builder<T>> {
|
||||
int minZoom, maxZoom;
|
||||
FadeStep[] fadeSteps;
|
||||
protected int zoomMin, zoomMax;
|
||||
protected FadeStep[] fadeSteps;
|
||||
|
||||
public T zoomMin(int zoom) {
|
||||
minZoom = zoom;
|
||||
zoomMin = zoom;
|
||||
return self();
|
||||
}
|
||||
|
||||
public T zoomMax(int zoom) {
|
||||
maxZoom = zoom;
|
||||
zoomMax = zoom;
|
||||
return self();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,12 @@ public abstract class TileSource {
|
||||
mZoomMax = zoomMax;
|
||||
}
|
||||
|
||||
public TileSource(Builder<?> builder) {
|
||||
mZoomMin = builder.zoomMin;
|
||||
mZoomMax = builder.zoomMax;
|
||||
mFadeSteps = builder.fadeSteps;
|
||||
}
|
||||
|
||||
public abstract ITileDataSource getDataSource();
|
||||
|
||||
public abstract OpenResult open();
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.oscim.tiling.source.LwHttp.LwHttpFactory;
|
||||
public abstract class UrlTileSource extends TileSource {
|
||||
|
||||
public abstract static class Builder<T extends Builder<T>> extends TileSource.Builder<T> {
|
||||
protected int zoomMin, zoomMax;
|
||||
protected String tilePath;
|
||||
protected String url;
|
||||
private HttpEngine.Factory engineFactory;
|
||||
@@ -74,7 +73,9 @@ public abstract class UrlTileSource extends TileSource {
|
||||
}
|
||||
|
||||
protected UrlTileSource(Builder<?> builder) {
|
||||
this(builder.url, builder.tilePath, builder.zoomMin, builder.zoomMax);
|
||||
super(builder);
|
||||
mUrl = makeUrl(builder.url);
|
||||
mTilePath = builder.tilePath.split("\\{|\\}");
|
||||
mHttpFactory = builder.engineFactory;
|
||||
}
|
||||
|
||||
@@ -84,17 +85,25 @@ public abstract class UrlTileSource extends TileSource {
|
||||
|
||||
protected UrlTileSource(String urlString, String tilePath, int zoomMin, int zoomMax) {
|
||||
super(zoomMin, zoomMax);
|
||||
mUrl = makeUrl(urlString);
|
||||
mTilePath = makeTilePath(tilePath);
|
||||
}
|
||||
|
||||
private String[] makeTilePath(String tilePath) {
|
||||
if (tilePath == null)
|
||||
throw new IllegalArgumentException("tilePath cannot be null.");
|
||||
|
||||
return tilePath.split("\\{|\\}");
|
||||
}
|
||||
|
||||
private URL makeUrl(String urlString) {
|
||||
URL url = null;
|
||||
try {
|
||||
url = new URL(urlString);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
mUrl = url;
|
||||
mTilePath = tilePath.split("\\{|\\}");
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user