Java Code Examples for org.geotools.geometry.jts.ReferencedEnvelope#include()

The following examples show how to use org.geotools.geometry.jts.ReferencedEnvelope#include() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoWaveEmptyTransaction.java    From geowave with Apache License 2.0 6 votes vote down vote up
/**
 * Record a modification to the indicated fid
 *
 * @param fid
 * @param original the original feature(prior state)
 * @param updated the update feature replacement feature; null to indicate remove
 */
@Override
public void modify(final String fid, final SimpleFeature original, final SimpleFeature updated)
    throws IOException {
  // point move?
  if (!updated.getBounds().equals(original.getBounds())) {
    components.remove(original, this);
    components.writeCommit(updated, new GeoWaveEmptyTransaction(components));
  } else {
    components.writeCommit(updated, new GeoWaveEmptyTransaction(components));
  }

  final ReferencedEnvelope bounds = new ReferencedEnvelope();
  bounds.include(updated.getBounds());
  bounds.include(original.getBounds());
  components.getGTstore().getListenerManager().fireFeaturesChanged(
      updated.getFeatureType().getTypeName(),
      Transaction.AUTO_COMMIT,
      bounds,
      true);
}
 
Example 2
Source File: ElasticFeatureSource.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Implementation that generates the total bounds
 */
@Override
protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException {
    LOGGER.fine("getBoundsInternal");
    final CoordinateReferenceSystem crs = getSchema().getCoordinateReferenceSystem();
    final ReferencedEnvelope bounds = new ReferencedEnvelope(crs);

    try (FeatureReader<SimpleFeatureType, SimpleFeature> featureReader = getReaderInternal(query)) {
        while (featureReader.hasNext()) {
            final SimpleFeature feature = featureReader.next();
            bounds.include(feature.getBounds());
        }
    }
    return bounds;
}
 
Example 3
Source File: GeoWaveTransactionManagement.java    From geowave with Apache License 2.0 4 votes vote down vote up
/**
 * Record a modification to the indicated feature ID.
 *
 * @param fid the feature ID
 * @param original original feature
 * @param updated replacement feature; null to indicate remove
 */
@Override
public void modify(final String fid, final SimpleFeature original, final SimpleFeature updated)
    throws IOException {

  lockingManager.lock(transaction, fid);
  // assumptions: (1) will not get a modification to a deleted feature
  // thus, only contents of the removed features collection for this
  // feature relate to moving bounds.
  // @see {@link #interweaveTransaction(CloseableIterator<SimpleFeature>)}
  //
  // Cannot assume that a modification occurs for a newly added fid

  // TODO: skipping this for now. creates a problem because
  // the row IDs may or maynot change. If they change completely, then
  // it is not an issue. However, a mix of changed or unchanged means
  // that the original rows become invisible for the duration of the
  // transaction

  // The problem now is that the bounded query may not return the moved
  // record, if it has moved outside
  // the query space. oh well!

  final ModifiedFeature modRecord = modifiedFeatures.get(fid);

  if (!updated.getBounds().equals(original.getBounds())) {

    // retain original--original position is removed later.
    // The original feature needs to be excluded in a query
    // and removed at commit
    removedFeatures.put(fid, original);
  }
  if (((modRecord != null) && modRecord.alreadyWritten) || addedFidList.contains(fid)) {
    components.writeCommit(updated, this);
    synchronized (mutex) {
      if (modRecord != null) {
        modifiedFeatures.put(fid, new ModifiedFeature(modRecord.oldFeature, updated, true));
      } else {
        LOGGER.error("modRecord was set to null in another thread; synchronization issue");
      }
    }
  } else {
    synchronized (mutex) {
      modifiedFeatures.put(
          fid,
          new ModifiedFeature(
              modRecord == null ? original : modRecord.oldFeature,
              updated,
              false));
    }
  }
  final ReferencedEnvelope bounds = new ReferencedEnvelope((CoordinateReferenceSystem) null);
  bounds.include(original.getBounds());
  bounds.include(updated.getBounds());
  components.getGTstore().getListenerManager().fireFeaturesChanged(
      components.getAdapter().getFeatureType().getTypeName(),
      transaction,
      bounds,
      false);
}
 
Example 4
Source File: GeoWaveTransactionManagement.java    From geowave with Apache License 2.0 4 votes vote down vote up
public void commit() throws IOException {

    flushAddsToStore(true);

    final Iterator<Pair<SimpleFeature, SimpleFeature>> updateIt = getUpdates();

    // if (addedFidList.size() > 0) {
    // final String transId = "\\(?" + txID + "\\)?";
    // final VisibilityTransformer visibilityTransformer = new
    // VisibilityTransformer(
    // "&?" + transId,
    // "");
    // for (final Collection<ByteArrayId> rowIDs : addedFidList.values()) {
    // components.replaceDataVisibility(
    // this,
    // rowIDs,
    // visibilityTransformer);
    // }
    //
    // components.replaceStatsVisibility(
    // this,
    // visibilityTransformer);
    // }

    final Iterator<SimpleFeature> removeIt = removedFeatures.values().iterator();

    while (removeIt.hasNext()) {
      final SimpleFeature delFeatured = removeIt.next();
      components.remove(delFeatured, this);
      final ModifiedFeature modFeature = modifiedFeatures.get(delFeatured.getID());
      // only want notify updates to existing (not new) features
      if ((modFeature == null) || modFeature.alreadyWritten) {
        components.getGTstore().getListenerManager().fireFeaturesRemoved(
            typeName,
            transaction,
            ReferencedEnvelope.reference(delFeatured.getBounds()),
            true);
      }
    }

    while (updateIt.hasNext()) {
      final Pair<SimpleFeature, SimpleFeature> pair = updateIt.next();
      components.writeCommit(pair.getRight(), new GeoWaveEmptyTransaction(components));
      final ReferencedEnvelope bounds = new ReferencedEnvelope((CoordinateReferenceSystem) null);
      bounds.include(pair.getLeft().getBounds());
      bounds.include(pair.getRight().getBounds());
      components.getGTstore().getListenerManager().fireFeaturesChanged(
          typeName,
          transaction,
          ReferencedEnvelope.reference(pair.getRight().getBounds()),
          true);
    }

    statsCache = null;
  }