/**
   * Writes out the current feature.
   *
   * @throws IOException
   * @see org.geotools.data.FeatureWriter#write()
   */
  public void write() throws IOException {
    // DJB: I modified this so it doesnt throw an error if you
    //     do an update and you didnt actually change anything.
    //     (We do the work)
    if ((live != null)) {
      // We have a modification to record!
      diff.modify(live.getID(), current);

      ReferencedEnvelope bounds = new ReferencedEnvelope((CoordinateReferenceSystem) null);
      bounds.include(live.getBounds());
      bounds.include(current.getBounds());
      fireNotification(FeatureEvent.FEATURES_CHANGED, bounds);
      live = null;
      current = null;
    } else if ((live == null) && (current != null)) {
      // We have new content to record
      //
      diff.add(current.getID(), current);
      fireNotification(
          FeatureEvent.FEATURES_ADDED, ReferencedEnvelope.reference(current.getBounds()));
      current = null;
    } else {
      throw new IOException("No feature available to write");
    }
  }
 public void write() throws IOException {
   if (live == null) {
     throw new IOException("No current feature to write");
   }
   if (live.equals(origional)) {
     writeImplementation(origional);
   } else {
     writeImplementation(live);
     if (origional != null) {
       ReferencedEnvelope bounds = new ReferencedEnvelope();
       bounds.include(live.getBounds());
       bounds.include(origional.getBounds());
       store.listenerManager.fireFeaturesChanged(
           live.getFeatureType().getTypeName(), Transaction.AUTO_COMMIT, bounds, false);
     } else {
       store.listenerManager.fireFeaturesAdded(
           live.getFeatureType().getTypeName(),
           Transaction.AUTO_COMMIT,
           ReferencedEnvelope.reference(live.getBounds()),
           false);
     }
   }
   origional = null;
   live = null;
 }
Пример #3
0
 /**
  * Computes the aggregated bounds of {@code features}, assuming all of them are in the same CRS
  */
 public ReferencedEnvelope boundsOf(Feature... features) {
   ReferencedEnvelope bounds = null;
   for (int i = 0; i < features.length; i++) {
     Feature f = features[i];
     if (bounds == null) {
       bounds = (ReferencedEnvelope) f.getBounds();
     } else {
       bounds.include(f.getBounds());
     }
   }
   return bounds;
 }
Пример #4
0
  /** Computes the aggregated bounds of {@code features} in the {@code targetCrs} */
  public ReferencedEnvelope boundsOf(CoordinateReferenceSystem targetCrs, Feature... features)
      throws Exception {
    ReferencedEnvelope bounds = new ReferencedEnvelope(targetCrs);

    for (int i = 0; i < features.length; i++) {
      Feature f = features[i];
      BoundingBox fbounds = f.getBounds();
      if (!CRS.equalsIgnoreMetadata(targetCrs, fbounds)) {
        fbounds = fbounds.toBounds(targetCrs);
      }
      bounds.include(fbounds);
    }
    return bounds;
  }