예제 #1
0
  public void rollback(IProgressMonitor monitor) throws Exception {
    editBlackboard.removeGeometries(Collections.singleton(first));

    EditGeom newGeom =
        editBlackboard.newGeom(
            oldshape.getEditGeom().getFeatureIDRef().get(), oldshape.getEditGeom().getShapeType());

    for (int i = 0; i < oldshape.getNumCoords(); i++) {
      editBlackboard.addCoordinate(oldshape.getCoord(i), newGeom.getShell());
    }

    if (currentShapeSet) setCurrentShape(newGeom.getShell());

    FeatureStore<SimpleFeatureType, SimpleFeature> store =
        layer.getResource(FeatureStore.class, new SubProgressMonitor(monitor, 1));

    FilterFactory factory = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    Set<FeatureId> ids = new HashSet<FeatureId>();
    for (FeatureId id : newFids) {
      ids.add(id);
    }
    Id filter = factory.id(ids);

    store.removeFeatures(filter);
    Geometry oldType = (Geometry) oldFeature.getDefaultGeometry();
    GeometryDescriptor newType = store.getSchema().getGeometryDescriptor();
    store.modifyFeatures(
        newType, oldType, factory.id(FeatureUtils.stringToId(factory, oldFeature.getID())));
    oldFeature.setDefaultGeometry(oldGeometry);
    newFids.clear();
  }
예제 #2
0
  @SuppressWarnings({"unchecked"})
  private void modifyOldFeature(final FeatureStore<SimpleFeatureType, SimpleFeature> store)
      throws IOException, IllegalAttributeException {
    FilterFactory fac = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    Filter filter = fac.id(FeatureUtils.stringToId(fac, oldFeature.getID()));

    Geometry g = GeometryCreationUtil.createGeom(LineString.class, first.getShell(), true);
    if (store
        .getSchema()
        .getGeometryDescriptor()
        .getType()
        .getBinding()
        .isAssignableFrom(MultiLineString.class))
      g = new GeometryFactory().createMultiLineString(new LineString[] {(LineString) g});

    store.modifyFeatures(store.getSchema().getGeometryDescriptor(), g, filter);
    oldFeature.setDefaultGeometry(g);
  }
  private void selectFeature(final int index, boolean reveal) throws Exception {

    final Table tree = table.getViewer().getTable();

    FilterFactory fac = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    final String fid = "feature" + (index + 1); // $NON-NLS-1$
    Set<Identifier> ids = FeatureUtils.stringToId(fac, fid);
    Id selection = fac.id(ids);
    table.setSelection(new StructuredSelection(selection), reveal);
    UDIGTestUtil.inDisplayThreadWait(
        3000,
        new WaitCondition() {

          public boolean isTrue() {
            TableItem item = tree.getItem(index);
            if (item.getData() == null) return false;
            return fid.equals(((SimpleFeature) item.getData()).getID());
          }
        },
        false);
  }