Package org.openstreetmap.osmosis.core.container.v0_6

Examples of org.openstreetmap.osmosis.core.container.v0_6.DatasetContext


  /**
   * {@inheritDoc}
   */
  @Override
  public void process(Dataset dataset) {
    DatasetContext dsCtx = dataset.createReader();
   
    try {
      EntityManager<Node> nodeManager = dsCtx.getNodeManager();
      OsmUser user;
      Node node;
     
      // Create the user for edits to be performed under. This is an existing user with an
      // updated name.
      user = new OsmUser(10, "user10b");
     
      // Modify node 1 to add a new tag.
      node = nodeManager.getEntity(1).getWriteableInstance();
      node.setUser(user);
      node.getTags().add(new Tag("change", "new tag"));
      nodeManager.modifyEntity(node);
     
      // Delete node 6.
      nodeManager.removeEntity(6);
     
      // Add node 7 using the NONE user.
      node = new Node(new CommonEntityData(7, 16, buildDate("2008-01-02 18:19:20"), OsmUser.NONE, 93), -11, -12);
      node.getTags().addAll(
          Arrays.asList(new Tag[]{new Tag("created_by", "Me7"), new Tag("change", "new node")}));
      nodeManager.addEntity(node);
     
      dsCtx.complete();
     
    } finally {
      dsCtx.release();
    }
  }
View Full Code Here


  @Override
  public DatasetContext createReader() {
    ReleasableContainer releasableContainer = new ReleasableContainer();
   
    try {
      DatasetContext reader;
     
      reader = new DatasetStoreReader(
          new NodeStorageContainer(
              releasableContainer.add(nodeObjectStore.createReader()),
              releasableContainer.add(nodeObjectOffsetIndexWriter.createReader()),
View Full Code Here

        public void process(ChangeContainer container) {
            if (progressListener.isCanceled()) {
                target.cancel();
                throw new OsmosisRuntimeException("Cancelled by user");
            }
            final EntityContainer entityContainer = container.getEntityContainer();
            final Entity entity = entityContainer.getEntity();
            final ChangeAction changeAction = container.getAction();
            if (changeAction.equals(ChangeAction.Delete)) {
                SimpleFeatureType ft = entity instanceof Node ? OSMUtils.nodeType() : OSMUtils
                        .wayType();
                String id = Long.toString(entity.getId());
View Full Code Here

                    Optional<Object> value = values.get(i);
                    featureBuilder.set(descriptor.getName(), value.orNull());
                }
                SimpleFeature feature = featureBuilder.buildFeature(ref.name());
                Entity entity = converter.toEntity(feature, id);
                EntityContainer container;
                if (entity instanceof Node) {
                    container = new NodeContainer((Node) entity);
                } else {
                    container = new WayContainer((Way) entity);
                }
View Full Code Here

        Iterator<EntityContainer> iterator = Iterators.concat(nodes, ways);
        if (file.getName().endsWith(".pbf")) {
            BlockOutputStream output = new BlockOutputStream(new FileOutputStream(file));
            OsmosisSerializer serializer = new OsmosisSerializer(output);
            while (iterator.hasNext()) {
                EntityContainer entity = iterator.next();
                serializer.process(entity);
            }
            serializer.complete();
        } else {
            XmlWriter writer = new XmlWriter(file, CompressionMethod.None);
            while (iterator.hasNext()) {
                EntityContainer entity = iterator.next();
                writer.process(entity);
            }
            writer.complete();
        }
View Full Code Here

                    Optional<Object> value = values.get(i);
                    featureBuilder.set(descriptor.getName(), value.orNull());
                }
                SimpleFeature feature = featureBuilder.buildFeature(ref.name());
                Entity entity = converter.toEntity(feature, null);
                EntityContainer container;
                if (entity instanceof Node) {
                    container = new NodeContainer((Node) entity);
                } else {
                    container = new WayContainer((Way) entity);
                }
View Full Code Here

  public void process() {
    // Setup
    Entity entityMocked = mock(Entity.class);
    when(entityMocked.getType()).thenReturn(EntityType.Node);

    EntityContainer entityContainerMocked = mock(EntityContainer.class);
    when(entityContainerMocked.getEntity()).thenReturn(entityMocked);

    // Action
    elasticSearchWriterTask.process(entityContainerMocked);
    elasticSearchWriterTask.complete();
View Full Code Here

   */
  @Override
  public ChangeContainer next() {
    EntityHistory<T> entityHistory;
    T entity;
    EntityContainer entityContainer;
    boolean createdPreviously;
   
    // Get the entity from the underlying source.
    entityHistory = source.next();
    entity = entityHistory.getEntity();
View Full Code Here

    bc.process(new NodeContainer(new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1)));
    bc.process(new NodeContainer(new Node(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 1), 2, 2)));
    bc.complete();
    bc.release();

    EntityContainer ec = inspector.getProcessedEntities().iterator().next();
    Assert.assertEquals(new Bound(2, 1, 2, 1, "NewBound"), ec.getEntity());
  }
View Full Code Here

    bc.process(new NodeContainer(new Node(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 1), 2, 2)));
    bc.complete();
    bc.release();

    Iterator<EntityContainer> iterator = inspector.getProcessedEntities().iterator();
    EntityContainer ec = iterator.next();
    Assert.assertEquals(new Bound(2, 1, 2, 1, "NewBound"), ec.getEntity());

    // Ensure there is no second bound.
    ec = iterator.next();
    Assert.assertEquals(EntityType.Node, ec.getEntity().getType());
  }
View Full Code Here

TOP

Related Classes of org.openstreetmap.osmosis.core.container.v0_6.DatasetContext

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.