use of org.openstreetmap.osmosis.xml.common.CompressionMethod in project voltdb by VoltDB.
the class OSMImport method run.
public void run() {
CompressionMethod compressionMethod = CompressionMethod.None;
Sink sink = new VoltDBOsmSink(config.server);
FastXmlReader fxr = new FastXmlReader(input, false, compressionMethod);
fxr.setSink(sink);
fxr.run();
}
use of org.openstreetmap.osmosis.xml.common.CompressionMethod in project GeoGig by boundlessgeo.
the class OSMImportOp method parseDataFileAndInsert.
private OSMReport parseDataFileAndInsert(@Nullable File file, final InputStream dataIn, final EntityConverter converter) {
final boolean pbf;
final CompressionMethod compression;
if (file == null) {
pbf = false;
compression = CompressionMethod.None;
} else {
pbf = file.getName().endsWith(".pbf");
compression = resolveCompressionMethod(file);
}
RunnableSource reader;
if (pbf) {
reader = new OsmosisReader(dataIn);
} else {
reader = new org.locationtech.geogig.osm.internal.XmlReader(dataIn, true, compression);
}
final WorkingTree workTree = workingTree();
if (!add) {
workTree.delete(OSMUtils.NODE_TYPE_NAME);
workTree.delete(OSMUtils.WAY_TYPE_NAME);
}
final int queueCapacity = 100 * 1000;
final int timeout = 1;
final TimeUnit timeoutUnit = TimeUnit.SECONDS;
// With this iterator and the osm parsing happening on a separate thread, we follow a
// producer/consumer approach so that the osm parse thread produces featrures into the
// iterator's queue, and WorkingTree.insert consumes them on this thread
QueueIterator<Feature> iterator = new QueueIterator<Feature>(queueCapacity, timeout, timeoutUnit);
ProgressListener progressListener = getProgressListener();
ConvertAndImportSink sink = new ConvertAndImportSink(converter, iterator, platform(), mapping, noRaw, new SubProgressListener(progressListener, 100));
reader.setSink(sink);
Thread readerThread = new Thread(reader, "osm-import-reader-thread");
readerThread.start();
Function<Feature, String> parentTreePathResolver = new Function<Feature, String>() {
@Override
public String apply(Feature input) {
if (input instanceof MappedFeature) {
return ((MappedFeature) input).getPath();
}
return input.getType().getName().getLocalPart();
}
};
// used to set the task status name, but report no progress so it does not interfere
// with the progress reported by the reader thread
SubProgressListener noPorgressReportingListener = new SubProgressListener(progressListener, 0) {
@Override
public void setProgress(float progress) {
// no-op
}
};
workTree.insert(parentTreePathResolver, iterator, noPorgressReportingListener, null, null);
if (sink.getCount() == 0) {
throw new EmptyOSMDownloadException();
}
OSMReport report = new OSMReport(sink.getCount(), sink.getNodeCount(), sink.getWayCount(), sink.getUnprocessedCount(), sink.getLatestChangeset(), sink.getLatestTimestamp());
return report;
}
Aggregations