commit
69bdb9926a
4 changed files with 43 additions and 18 deletions
|
@ -67,6 +67,7 @@ public class TileSourceManager {
|
|||
private String randoms;
|
||||
private String[] randomsArray;
|
||||
private String rule;
|
||||
private String referer;
|
||||
private boolean hidden; // if hidden in configure map settings, for example mapillary sources
|
||||
|
||||
private boolean isRuleAcceptable = true;
|
||||
|
@ -253,7 +254,11 @@ public class TileSourceManager {
|
|||
}
|
||||
|
||||
public String getReferer() {
|
||||
return null;
|
||||
return referer;
|
||||
}
|
||||
|
||||
public void setReferer(String referer) {
|
||||
this.referer = referer;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -469,12 +474,16 @@ public class TileSourceManager {
|
|||
public static void createMetaInfoFile(File dir, TileSourceTemplate tm, boolean override) throws IOException {
|
||||
File metainfo = new File(dir, ".metainfo"); //$NON-NLS-1$
|
||||
Map<String, String> properties = new LinkedHashMap<String, String>();
|
||||
if (tm.getRule() != null && tm.getRule().length() > 0) {
|
||||
|
||||
if (!Algorithms.isEmpty(tm.getRule())) {
|
||||
properties.put("rule", tm.getRule());
|
||||
}
|
||||
if(tm.getUrlTemplate() != null) {
|
||||
properties.put("url_template", tm.getUrlTemplate());
|
||||
}
|
||||
if (!Algorithms.isEmpty(tm.getReferer())) {
|
||||
properties.put("referer", tm.getReferer());
|
||||
}
|
||||
|
||||
properties.put("ext", tm.getTileFormat());
|
||||
properties.put("min_zoom", tm.getMinimumZoomSupported() + "");
|
||||
|
|
|
@ -14,7 +14,6 @@ import net.osmand.JsonUtils;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager;
|
||||
import net.osmand.map.WorldRegion;
|
||||
import net.osmand.plus.SettingsHelper.AvoidRoadsSettingsItem;
|
||||
import net.osmand.plus.SettingsHelper.MapSourcesSettingsItem;
|
||||
|
@ -266,17 +265,20 @@ public class CustomOsmandPlugin extends OsmandPlugin {
|
|||
List<ITileSource> mapSources = mapSourcesSettingsItem.getItems();
|
||||
|
||||
for (ITileSource tileSource : mapSources) {
|
||||
if (tileSource instanceof TileSourceManager.TileSourceTemplate) {
|
||||
TileSourceManager.TileSourceTemplate sourceTemplate = (TileSourceManager.TileSourceTemplate) tileSource;
|
||||
File tPath = app.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||
File dir = new File(tPath, sourceTemplate.getName());
|
||||
Algorithms.removeAllFiles(dir);
|
||||
} else if (tileSource instanceof SQLiteTileSource) {
|
||||
SQLiteTileSource sqLiteTileSource = ((SQLiteTileSource) tileSource);
|
||||
sqLiteTileSource.closeDB();
|
||||
String tileSourceName = tileSource.getName();
|
||||
if (tileSource instanceof SQLiteTileSource) {
|
||||
tileSourceName += SQLITE_EXT;
|
||||
}
|
||||
|
||||
ITileSource savedTileSource = app.getSettings().getTileSourceByName(tileSourceName, false);
|
||||
if (savedTileSource != null) {
|
||||
if (savedTileSource instanceof SQLiteTileSource) {
|
||||
SQLiteTileSource sqLiteTileSource = ((SQLiteTileSource) savedTileSource);
|
||||
sqLiteTileSource.closeDB();
|
||||
}
|
||||
|
||||
File tPath = app.getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||
File dir = new File(tPath, sqLiteTileSource.getName() + SQLITE_EXT);
|
||||
File dir = new File(tPath, tileSourceName);
|
||||
Algorithms.removeAllFiles(dir);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
|
||||
public SQLiteTileSource(OsmandApplication ctx, String name, int minZoom, int maxZoom, String urlTemplate,
|
||||
String randoms, boolean isEllipsoid, boolean invertedY, String referer,
|
||||
boolean timeSupported, long expirationTimeMillis, boolean inversiveZoom) {
|
||||
boolean timeSupported, long expirationTimeMillis, boolean inversiveZoom, String rule) {
|
||||
this.ctx = ctx;
|
||||
this.name = name;
|
||||
this.urlTemplate = urlTemplate;
|
||||
|
@ -102,6 +102,7 @@ public class SQLiteTileSource implements ITileSource {
|
|||
this.expirationTimeMillis = expirationTimeMillis;
|
||||
this.randoms = randoms;
|
||||
this.referer = referer;
|
||||
this.rule = rule;
|
||||
this.invertedY = invertedY;
|
||||
this.timeSupported = timeSupported;
|
||||
this.inversiveZoom = inversiveZoom;
|
||||
|
|
|
@ -16,6 +16,7 @@ import net.osmand.PlatformUtil;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager;
|
||||
import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
||||
import net.osmand.map.WorldRegion;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
|
@ -2005,8 +2006,8 @@ public class SettingsHelper {
|
|||
boolean ellipsoid = object.optBoolean("ellipsoid", false);
|
||||
boolean invertedY = object.optBoolean("inverted_y", false);
|
||||
String referer = object.optString("referer");
|
||||
boolean timesupported = object.optBoolean("timesupported", false);
|
||||
long expire = object.optLong("expire");
|
||||
boolean timeSupported = object.optBoolean("timesupported", false);
|
||||
long expire = object.optLong("expire", -1);
|
||||
boolean inversiveZoom = object.optBoolean("inversiveZoom", false);
|
||||
String ext = object.optString("ext");
|
||||
int tileSize = object.optInt("tileSize");
|
||||
|
@ -2014,11 +2015,23 @@ public class SettingsHelper {
|
|||
int avgSize = object.optInt("avgSize");
|
||||
String rule = object.optString("rule");
|
||||
|
||||
if (expire > 0 && expire < 3600000) {
|
||||
expire = expire * 60 * 1000L;
|
||||
}
|
||||
|
||||
ITileSource template;
|
||||
if (!sql) {
|
||||
template = new TileSourceManager.TileSourceTemplate(name, url, ext, maxZoom, minZoom, tileSize, bitDensity, avgSize);
|
||||
TileSourceTemplate tileSourceTemplate = new TileSourceTemplate(name, url, ext, maxZoom, minZoom, tileSize, bitDensity, avgSize);
|
||||
tileSourceTemplate.setRule(rule);
|
||||
tileSourceTemplate.setRandoms(randoms);
|
||||
tileSourceTemplate.setReferer(referer);
|
||||
tileSourceTemplate.setEllipticYTile(ellipsoid);
|
||||
tileSourceTemplate.setInvertedYTile(invertedY);
|
||||
tileSourceTemplate.setExpirationTimeMillis(timeSupported ? expire : -1);
|
||||
|
||||
template = tileSourceTemplate;
|
||||
} else {
|
||||
template = new SQLiteTileSource(app, name, minZoom, maxZoom, url, randoms, ellipsoid, invertedY, referer, timesupported, expire, inversiveZoom);
|
||||
template = new SQLiteTileSource(app, name, minZoom, maxZoom, url, randoms, ellipsoid, invertedY, referer, timeSupported, expire, inversiveZoom, rule);
|
||||
}
|
||||
items.add(template);
|
||||
}
|
||||
|
@ -2046,7 +2059,7 @@ public class SettingsHelper {
|
|||
jsonObject.put("inverted_y", template.isInvertedYTile());
|
||||
jsonObject.put("referer", template.getReferer());
|
||||
jsonObject.put("timesupported", template.isTimeSupported());
|
||||
jsonObject.put("expire", template.getExpirationTimeMillis());
|
||||
jsonObject.put("expire", template.getExpirationTimeMinutes());
|
||||
jsonObject.put("inversiveZoom", template.getInversiveZoom());
|
||||
jsonObject.put("ext", template.getTileFormat());
|
||||
jsonObject.put("tileSize", template.getTileSize());
|
||||
|
|
Loading…
Reference in a new issue