Package org.openstreetmap.osmosis.core.task.v0_6

Examples of org.openstreetmap.osmosis.core.task.v0_6.ChangeSink


  public void connect(PipeTasks pipeTasks) {
    // A multi sink receives multiple streams of data, so we must connect
    // them up one by one.
    for (int i = 0; i < task.getChangeSinkCount(); i++) {
      ChangeSink sink;
      ChangeSource source;
     
      // Retrieve the next sink.
      sink = task.getChangeSink(i);
     
      // Retrieve the appropriate source.
      source = (ChangeSource) getInputTask(pipeTasks, i, ChangeSource.class);
     
      // Connect the tasks.
      source.setChangeSink(sink);
    }
   
    // Register the source as an output task.
    setOutputTask(pipeTasks, task, 0);
  }
View Full Code Here


  /**
   * {@inheritDoc}
   */
  @Override
  public void connect(PipeTasks pipeTasks) {
    DatasetSource source;
   
    // Get the input task. A sink only has one input, this corresponds to
    // pipe index 0.
    source = (DatasetSource) getInputTask(pipeTasks, 0, DatasetSource.class);
   
    // Cast the input feed to the correct type.
    // Connect the tasks.
    source.setDatasetSink(task);
   
    // Register the task as an output. A source only has one output, this
    // corresponds to pipe index 0.
    setOutputTask(pipeTasks, task, 0);
  }
View Full Code Here

  /**
   * {@inheritDoc}
   */
  @Override
  public void connect(PipeTasks pipeTasks) {
    DatasetSource source;
   
    // Get the input task. A sink only has one input, this corresponds to
    // pipe index 0.
    source = (DatasetSource) getInputTask(pipeTasks, 0, DatasetSource.class);
   
    // Connect the tasks.
    source.setDatasetSink(task);
  }
View Full Code Here

    sinkInitInvoked = false;
   
    // Send the replication data downstream but don't call any lifecycle
    // methods on the change sink because we're managing those separately.
    if (chunkFile != null) {
      RunnableChangeSource changeReader = new XmlChangeReader(chunkFile, true, CompressionMethod.GZip);
      changeReader.setChangeSink(noLifecycleChangeSink);
      changeReader.run();
    }
   
    changeSink.complete();
  }
View Full Code Here

    }
  };
 
  public OsmosisReader(File file) throws IOException {
   
    RunnableSource reader = createReaderForFile(file);
   
    reader.setSink(sinkImplementation);
   
    Thread readerThread = new Thread(reader);
    readerThread.start();
   
    while (readerThread.isAlive()) {
View Full Code Here

      compression = CompressionMethod.GZip;
    } else if (file.getName().endsWith(".bz2")) {
      compression = CompressionMethod.BZip2;
    }
   
    RunnableSource reader;
   
    if (pbf) {
      reader = new crosby.binary.osmosis.OsmosisReader(
          new FileInputStream(file));
    } else {
View Full Code Here

        } 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>() {
View Full Code Here

    // change contains deletes which have a current timestamp
    // that cannot be reliably predicted.
    // Therefore, check all relevant attributes manually.
   
    ChangeDeriver deriver = new ChangeDeriver(1);
    RunnableSource left = new XmlReader(dataUtils.createDataFile(
        "v0_6/derive_change/simple.osm"), true, CompressionMethod.None);
    RunnableSource right = new EmptyReader();
   
    SinkChangeInspector result = RunTaskUtilities.run(deriver, left, right);
    List<ChangeContainer> changes = result.getProcessedChanges();
   
    Assert.assertEquals(3, changes.size());
View Full Code Here

   *
   * @throws Exception if something goes wrong
   */
  @Test
  public void testNeitherHasBound() throws Exception {
    RunnableSource source0 = new BoundSource(new Bound(1, 2, 4, 3, "source0"), false);
    RunnableSource source1 = new BoundSource(new Bound(5, 6, 8, 7, "source1"), false);

    EntityMerger merger = new EntityMerger(ConflictResolutionMethod.LatestSource, 1,
        BoundRemovedAction.Ignore);
   
    SinkEntityInspector merged = RunTaskUtilities.run(merger, source0, source1);
View Full Code Here

   *
   * @throws Exception if something goes wrong
   */
  @Test
  public void testSource0HasBound() throws Exception {
    RunnableSource source0 = new BoundSource(new Bound(1, 2, 4, 3, "source0"), true);
    RunnableSource source1 = new BoundSource(new Bound(5, 6, 8, 7, "source1"), false);

    EntityMerger merger = new EntityMerger(ConflictResolutionMethod.LatestSource, 1,
        BoundRemovedAction.Ignore);
   
    SinkEntityInspector merged = RunTaskUtilities.run(merger, source0, source1);
View Full Code Here

TOP

Related Classes of org.openstreetmap.osmosis.core.task.v0_6.ChangeSink

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.