Package org.openstreetmap.osmosis.pbf2.v0_6

Examples of org.openstreetmap.osmosis.pbf2.v0_6.PbfReader


  @Override
  public Map<String, TaskManagerFactory> loadTaskFactories() {
    Map<String, TaskManagerFactory> factoryMap;

    PbfReaderFactory reader = new PbfReaderFactory();

    factoryMap = new HashMap<String, TaskManagerFactory>();
    factoryMap.put("read-pbf-fast", reader);
    factoryMap.put("rbf", reader);
View Full Code Here


      // executor service. We allow the decoder to issue an extra blob
      // than there are workers to ensure there is another blob
      // immediately ready for processing when a worker thread completes.
      // The main thread is responsible for splitting blobs from the
      // request stream, and sending decoded entities to the sink.
      PbfDecoder pbfDecoder = new PbfDecoder(streamSplitter, executorService, workers + 1, sink);
      pbfDecoder.run();

      sink.complete();

    } catch (IOException e) {
      throw new OsmosisRuntimeException("Unable to read PBF file " + file + ".", e);
View Full Code Here

  }


  @Override
  public void run() {
    PbfStreamSplitter streamSplitter = null;
    ExecutorService executorService = Executors.newFixedThreadPool(workers);

    try {
      InputStream inputStream;

      sink.initialize(Collections.<String, Object>emptyMap());

      // make "-" an alias for /dev/stdin
      if (file.getName().equals("-")) {
        inputStream = System.in;
      } else {
        inputStream = new FileInputStream(file);
      }

      // Create a stream splitter to break the PBF stream into blobs.
      streamSplitter = new PbfStreamSplitter(new DataInputStream(inputStream));

      // Process all blobs of data in the stream using threads from the
      // executor service. We allow the decoder to issue an extra blob
      // than there are workers to ensure there is another blob
      // immediately ready for processing when a worker thread completes.
      // The main thread is responsible for splitting blobs from the
      // request stream, and sending decoded entities to the sink.
      PbfDecoder pbfDecoder = new PbfDecoder(streamSplitter, executorService, workers + 1, sink);
      pbfDecoder.run();

      sink.complete();

    } catch (IOException e) {
      throw new OsmosisRuntimeException("Unable to read PBF file " + file + ".", e);
    } finally {
      sink.release();

      executorService.shutdownNow();

      if (streamSplitter != null) {
        streamSplitter.release();
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.openstreetmap.osmosis.pbf2.v0_6.PbfReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.