kopia lustrzana https://github.com/onthegomap/planetiler
omit() feature collector api and --refresh-sources arg
rodzic
4d52507baa
commit
aa28d25dab
|
@ -797,6 +797,12 @@ public class FeatureCollector implements Iterable<FeatureCollector.Feature> {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Omit this feature from the output */
|
||||||
|
public Feature omit() {
|
||||||
|
output.remove(this);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Feature{" +
|
return "Feature{" +
|
||||||
|
|
|
@ -83,6 +83,7 @@ public class Planetiler {
|
||||||
private final Path multipolygonPath;
|
private final Path multipolygonPath;
|
||||||
private final Path featureDbPath;
|
private final Path featureDbPath;
|
||||||
private final boolean downloadSources;
|
private final boolean downloadSources;
|
||||||
|
private final boolean refreshSources;
|
||||||
private final boolean onlyDownloadSources;
|
private final boolean onlyDownloadSources;
|
||||||
private final boolean parseNodeBounds;
|
private final boolean parseNodeBounds;
|
||||||
private Profile profile = null;
|
private Profile profile = null;
|
||||||
|
@ -117,6 +118,8 @@ public class Planetiler {
|
||||||
tmpDir = config.tmpDir();
|
tmpDir = config.tmpDir();
|
||||||
onlyDownloadSources = arguments.getBoolean("only_download", "download source data then exit", false);
|
onlyDownloadSources = arguments.getBoolean("only_download", "download source data then exit", false);
|
||||||
downloadSources = onlyDownloadSources || arguments.getBoolean("download", "download sources", false);
|
downloadSources = onlyDownloadSources || arguments.getBoolean("download", "download sources", false);
|
||||||
|
refreshSources =
|
||||||
|
arguments.getBoolean("refresh_sources", "download new version of source files if they have changed", false);
|
||||||
fetchOsmTileStats =
|
fetchOsmTileStats =
|
||||||
arguments.getBoolean("download_osm_tile_weights", "download OSM tile weights file", downloadSources);
|
arguments.getBoolean("download_osm_tile_weights", "download OSM tile weights file", downloadSources);
|
||||||
nodeDbPath = arguments.file("temp_nodes", "temp node db location", tmpDir.resolve("node.db"));
|
nodeDbPath = arguments.file("temp_nodes", "temp node db location", tmpDir.resolve("node.db"));
|
||||||
|
@ -891,11 +894,13 @@ public class Planetiler {
|
||||||
|
|
||||||
private Path getPath(String name, String type, Path defaultPath, String defaultUrl) {
|
private Path getPath(String name, String type, Path defaultPath, String defaultUrl) {
|
||||||
Path path = arguments.file(name + "_path", name + " " + type + " path", defaultPath);
|
Path path = arguments.file(name + "_path", name + " " + type + " path", defaultPath);
|
||||||
|
boolean refresh =
|
||||||
|
arguments.getBoolean("refresh_" + name, "Download new version of " + name + " if changed", refreshSources);
|
||||||
boolean freeAfterReading = arguments.getBoolean("free_" + name + "_after_read",
|
boolean freeAfterReading = arguments.getBoolean("free_" + name + "_after_read",
|
||||||
"delete " + name + " input file after reading to make space for output (reduces peak disk usage)", false);
|
"delete " + name + " input file after reading to make space for output (reduces peak disk usage)", false);
|
||||||
if (downloadSources) {
|
if (downloadSources || refresh) {
|
||||||
String url = arguments.getString(name + "_url", name + " " + type + " url", defaultUrl);
|
String url = arguments.getString(name + "_url", name + " " + type + " url", defaultUrl);
|
||||||
if (!Files.exists(path) && url != null) {
|
if ((!Files.exists(path) || refresh) && url != null) {
|
||||||
toDownload.add(new ToDownload(name, url, path));
|
toDownload.add(new ToDownload(name, url, path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,6 +85,17 @@ class FeatureCollectorTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testOmit() {
|
||||||
|
var collector = factory.get(newReaderFeature(newPoint(0, 0), Map.of(
|
||||||
|
"key", "val"
|
||||||
|
)));
|
||||||
|
var point = collector.point("layername");
|
||||||
|
assertFeatures(14, List.of(Map.of("_layer", "layername")), collector);
|
||||||
|
point.omit();
|
||||||
|
assertFeatures(14, List.of(), collector);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testAttrWithMinzoom() {
|
void testAttrWithMinzoom() {
|
||||||
var collector = factory.get(newReaderFeature(newPoint(0, 0), Map.of(
|
var collector = factory.get(newReaderFeature(newPoint(0, 0), Map.of(
|
||||||
|
|
Ładowanie…
Reference in New Issue