use of org.locationtech.geogig.osm.internal.history.HistoryDownloader in project GeoGig by boundlessgeo.
the class OSMHistoryImport method runInternal.
@Override
protected void runInternal(GeogigCLI cli) throws IOException {
checkParameter(args.numThreads > 0 && args.numThreads < 7, "numthreads must be between 1 and 6");
ConsoleReader console = cli.getConsole();
final String osmAPIUrl = resolveAPIURL();
final long startIndex;
final long endIndex = args.endIndex;
if (args.resume) {
GeoGIG geogig = cli.getGeogig();
long lastChangeset = getCurrentBranchChangeset(geogig);
startIndex = 1 + lastChangeset;
} else {
startIndex = args.startIndex;
}
console.println(String.format("Obtaining OSM changesets %,d to %,d from %s", startIndex, args.endIndex, osmAPIUrl));
final ThreadFactory threadFactory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("osm-history-fetch-thread-%d").build();
final ExecutorService executor = Executors.newFixedThreadPool(args.numThreads, threadFactory);
final File targetDir = resolveTargetDir();
console.println("Downloading to " + targetDir.getAbsolutePath());
console.flush();
HistoryDownloader downloader;
downloader = new HistoryDownloader(osmAPIUrl, targetDir, startIndex, endIndex, executor);
Envelope env = parseBbox();
Predicate<Changeset> filter = parseFilter(env);
downloader.setChangesetFilter(filter);
try {
importOsmHistory(cli, console, downloader, env);
} finally {
executor.shutdownNow();
try {
executor.awaitTermination(30, TimeUnit.SECONDS);
} catch (InterruptedException e) {
throw new CommandFailedException(e);
}
}
}
Aggregations