Package org.openstreetmap.osmosis.core.task.common

Examples of org.openstreetmap.osmosis.core.task.common.ChangeAction


                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());
                target.put(new FeatureToDelete(ft, id));
                return;
            }
            if (changeAction.equals(ChangeAction.Modify)) {
                // Check that the feature to modify exist. If so, we will just treat it as an
                // addition, overwriting the previous feature
                SimpleFeatureType ft = entity instanceof Node ? OSMUtils.nodeType() : OSMUtils
                        .wayType();
                String path = ft.getName().getLocalPart();
                Optional<org.locationtech.geogig.api.Node> opt = workTree.findUnstaged(path);
                if (!opt.isPresent()) {
                    return;
                }
            }

            if (++count % 10 == 0) {
                progressListener.setProgress(count);
            }
            latestChangeset = Math.max(latestChangeset, entity.getChangesetId());
            latestTimestamp = Math.max(latestTimestamp, entity.getTimestamp().getTime());
            Geometry geom = null;
            switch (entity.getType()) {
            case Node:
                nodeCount++;
                geom = parsePoint((Node) entity);
                break;
            case Way:
                wayCount++;
                geom = parseLine((Way) entity);
                break;
            default:
                return;
            }
            if (geom != null) {
                System.err.printf("%s within %s? %s\n", geom, bbox, geom.within(bbox));
                if (changeAction.equals(ChangeAction.Create) && geom.within(bbox)
                        || changeAction.equals(ChangeAction.Modify)) {
                    Feature feature = converter.toFeature(entity, geom);
                    target.put(feature);
                }
            }
        }
View Full Code Here


                    container = new NodeContainer((Node) entity);
                } else {
                    container = new WayContainer((Way) entity);
                }

                ChangeAction action = diff.changeType().equals(ChangeType.ADDED) ? ChangeAction.Create
                        : diff.changeType().equals(ChangeType.MODIFIED) ? ChangeAction.Modify
                                : ChangeAction.Delete;

                return new ChangeContainer(container, action);
View Full Code Here

   * @param changeEntity
   *            The change to be analysed.
   * @return The sort weighting.
   */
  private int calculateSortWeight(ChangeContainer changeEntity) {
    ChangeAction action = changeEntity.getAction();
    Entity entity = changeEntity.getEntityContainer().getEntity();
   
    if (entity.getType().equals(EntityType.Bound)) {
      if (action.equals(ChangeAction.Create)) {
        return 1;
      }
      if (action.equals(ChangeAction.Modify)) {
        return 8;
      }
      if (action.equals(ChangeAction.Delete)) {
        return 12;
      }
    } else if (entity.getType().equals(EntityType.Node)) {
      if (action.equals(ChangeAction.Create)) {
        return 2;
      }
      if (action.equals(ChangeAction.Modify)) {
        return 7;
      }
      if (action.equals(ChangeAction.Delete)) {
        return 11;
      }
    } else if (entity.getType().equals(EntityType.Way)) {
      if (action.equals(ChangeAction.Create)) {
        return 3;
      }
      if (action.equals(ChangeAction.Modify)) {
        return 6;
      }
      if (action.equals(ChangeAction.Delete)) {
        return 10;
      }
    } else if (entity.getType().equals(EntityType.Relation)) {
      if (action.equals(ChangeAction.Create)) {
        return 4;
      }
      if (action.equals(ChangeAction.Modify)) {
        return 5;
      }
      if (action.equals(ChangeAction.Delete)) {
        return 9;
      }
    }
   
    throw new OsmosisRuntimeException(
View Full Code Here

  /**
   * {@inheritDoc}
   */
  public void process(ChangeContainer changeContainer) {
    Entity entity;
    ChangeAction action;
   
    entity = changeContainer.getEntityContainer().getEntity();
    action = changeContainer.getAction();
   
    if (progressTracker.updateRequired()) {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void process(ChangeContainer change) {
        ChangeAction action;

        // Verify that the schema version is supported.
        schemaVersionValidator.validateVersion(ApidbVersionConstants.SCHEMA_MIGRATIONS);

        action = change.getAction();
View Full Code Here

 
  /**
   * {@inheritDoc}
   */
  public void process(ChangeContainer change) {
    ChangeAction action;
   
    // Verify that the schema version is supported.
    schemaVersionValidator.validateVersion(PostgreSqlVersionConstants.SCHEMA_VERSION);
   
    action = change.getAction();
View Full Code Here

 
  /**
   * {@inheritDoc}
   */
  public void process(ChangeContainer change) {
    ChangeAction action;
   
    initialize();
   
    // Verify that the schema version is supported.
    schemaVersionValidator.validateVersion(PostgreSqlVersionConstants.SCHEMA_VERSION);
View Full Code Here

    // Send the change data unless this is sequence 0 where no data is
    // allowed. We'll only send a single record for simplicity.
    if (state.getSequenceNumber() > 0) {
      // We'll do a create action on the first replication pass, and modify subsequently.
      ChangeAction action;
      if (state.getSequenceNumber() == 1) {
        action = ChangeAction.Create;
      } else {
        action = ChangeAction.Modify;
      }
View Full Code Here

 
 
  private void flushCurrentChanges() {
    ChangeContainer changeBegin;
    ChangeContainer changeEnd;
    ChangeAction actionBegin;
    ChangeAction actionEnd;
    ChangeAction actionResult;
   
    changeBegin = currentChanges.get(0);
    changeEnd = currentChanges.get(currentChanges.size() - 1);
   
    actionBegin = changeBegin.getAction();
View Full Code Here

TOP

Related Classes of org.openstreetmap.osmosis.core.task.common.ChangeAction

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.