Skip to content

Commit

Permalink
fix up process-feature - no surprises here
Browse files Browse the repository at this point in the history
  • Loading branch information
jodygarnett committed Oct 31, 2012
1 parent 1654950 commit 162bdb9
Show file tree
Hide file tree
Showing 15 changed files with 24 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,6 @@ public SimpleFeatureIterator features() {
return new ClippingFeatureIterator(delegate.features(), clip, getSchema());
}

@Override
public Iterator<SimpleFeature> iterator() {
return new WrappingIterator(features());
}

@Override
public void close(Iterator<SimpleFeature> close) {
if (close instanceof WrappingIterator) {
((WrappingIterator) close).close();
}
}
}

static class ClippingFeatureIterator implements SimpleFeatureIterator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@
*/
package org.geotools.process.vector;

import java.util.Iterator;
import java.util.NoSuchElementException;

import org.geotools.process.factory.DescribeParameter;
import org.geotools.process.factory.DescribeProcess;
import org.geotools.process.factory.DescribeResult;
import org.geotools.process.gs.WrappingIterator;
import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.factory.CommonFactoryFinder;
import org.geotools.feature.collection.DecoratingSimpleFeatureCollection;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.process.factory.DescribeParameter;
import org.geotools.process.factory.DescribeProcess;
import org.geotools.process.factory.DescribeResult;
import org.geotools.process.gs.GSProcess;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import org.opengis.filter.Filter;
Expand Down Expand Up @@ -72,17 +71,6 @@ public SimpleFeatureIterator features() {
return new IncludedFeatureIterator(delegate.features(), delegate, features, getSchema());
}

@Override
public Iterator<SimpleFeature> iterator() {
return new WrappingIterator(features());
}

@Override
public void close(Iterator<SimpleFeature> close) {
if (close instanceof WrappingIterator) {
((WrappingIterator) close).close();
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,18 +379,6 @@ public SimpleFeatureIterator features() {
delegate.getSchema(), features.getSchema(), firstAttributes, sndAttributes,
intersectionMode, percentagesEnabled, areasEnabled,fb);
}

@Override
public Iterator<SimpleFeature> iterator() {
return new WrappingIterator(features());
}

@Override
public void close(Iterator<SimpleFeature> close) {
if (close instanceof WrappingIterator) {
((WrappingIterator) close).close();
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.util.logging.Logger;

import org.geotools.feature.DefaultFeatureCollection;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureCollections;
import org.geotools.feature.FeatureIterator;
Expand Down Expand Up @@ -69,7 +70,7 @@ public FeatureCollection execute(
@DescribeParameter(name = "to_measure_attb", description = "Attribute providing end measure of feature") String toMeasureAttb,
@DescribeParameter(name = "measure", description = "Measure of the point along the feature to be computed") Double measure)
throws ProcessException {
FeatureCollection results = FeatureCollections.newCollection();
DefaultFeatureCollection results = new DefaultFeatureCollection();
try {
if (featureCollection == null || featureCollection.size() == 0) {
LOGGER.info("No features provided in request");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import javax.measure.unit.SI;
import javax.measure.unit.Unit;

import org.geotools.feature.DefaultFeatureCollection;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureCollections;
import org.geotools.feature.FeatureIterator;
Expand Down Expand Up @@ -81,7 +82,7 @@ public FeatureCollection execute(
@DescribeParameter(name = "point", description = "Point whose location to measure") Point point,
@DescribeParameter(name = "crs", min = 0, description = "Coordinate reference system to use for input (default is the input collection CRS)") CoordinateReferenceSystem crs)
throws ProcessException {
FeatureCollection results = FeatureCollections.newCollection();
DefaultFeatureCollection results = new DefaultFeatureCollection();
try {
if (featureCollection == null || featureCollection.size() == 0) {
LOGGER.info("No features provided in request");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import java.util.logging.Logger;

import org.geotools.feature.DefaultFeatureCollection;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureCollections;
import org.geotools.feature.FeatureIterator;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.process.ProcessException;
Expand Down Expand Up @@ -68,7 +68,7 @@ public FeatureCollection execute(
@DescribeParameter(name = "from_measure", description = "Measure for start of segment to extract") Double fromMeasure,
@DescribeParameter(name = "to_measure", description = "Measure for end of segment to extract") Double toMeasure)
throws ProcessException {
FeatureCollection results = FeatureCollections.newCollection();
DefaultFeatureCollection results = new DefaultFeatureCollection();
try {
if (featureCollection == null || featureCollection.size() == 0) {
LOGGER.info("No features provided in request");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import javax.measure.unit.SI;
import javax.measure.unit.Unit;

import org.geotools.feature.DefaultFeatureCollection;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureCollections;
import org.geotools.feature.FeatureIterator;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.geotools.measure.Measure;
Expand Down Expand Up @@ -102,17 +104,16 @@ public FeatureCollection execute(
}
MathTransform crsTransform = CRS.findMathTransform(crs, epsg4326);

FeatureCollection results = FeatureCollections.newCollection();
DefaultFeatureCollection results = new DefaultFeatureCollection();
FeatureType targetFeatureType = createTargetFeatureType(featureCollection.getSchema());
Unit fromUnit = SI.METER;
Unit toUnit = Unit.valueOf("mi");
UnitConverter unitConvert = fromUnit.getConverterTo(toUnit);
Feature nearestFeature = null;
double nearestDistance = 9e9;
double nearestBearing = 0;
Iterator featureIterator = null;
FeatureIterator featureIterator = featureCollection.features();
try {
featureIterator = featureCollection.iterator();
while (featureIterator.hasNext()) {
SimpleFeature f = (SimpleFeature) featureIterator.next();
if (f.getDefaultGeometryProperty().getValue() == null)
Expand All @@ -136,8 +137,7 @@ public FeatureCollection execute(
nearestBearing = calcBearing(co);
}
} finally {
if (featureIterator != null)
featureCollection.close(featureIterator);
featureIterator.close();
}
if (nearestFeature != null) {
nearestDistance = unitConvert.convert(nearestDistance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public SimpleFeatureCollection execute(
}

// we don't expect million of directions, so we use a simple in memory collection
SimpleFeatureCollection result = new ListFeatureCollection(schema);
ListFeatureCollection result = new ListFeatureCollection(schema);
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(schema);
for (int i = 0; i < distances.length; i++) {
fb.add(generator.getBuffer(distances[i]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public SimpleFeatureCollection execute(
outputEnv.getMinX(), outputEnv.getMinY());

SimpleFeatureType schema = createType(srcCRS);
SimpleFeatureCollection result = new ListFeatureCollection(schema);
ListFeatureCollection result = new ListFeatureCollection(schema);
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(schema);

GeometryFactory factory = new GeometryFactory(new PackedCoordinateSequenceFactory());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,6 @@ public SimpleFeatureIterator features() {
return new SimplifyingFeatureIterator(delegate.features(), distance, preserveTopology,
getSchema());
}

@Override
public Iterator<SimpleFeature> iterator() {
return new WrappingIterator(features());
}

@Override
public void close(Iterator<SimpleFeature> close) {
if (close instanceof WrappingIterator) {
((WrappingIterator) close).close();
}
}
}

static class SimplifyingFeatureIterator implements SimpleFeatureIterator {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
import javax.measure.unit.Unit;

import org.geotools.data.Parameter;
import org.geotools.feature.DefaultFeatureCollection;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureCollections;
import org.geotools.feature.FeatureIterator;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
import org.geotools.measure.Measure;
Expand Down Expand Up @@ -114,18 +116,17 @@ public FeatureCollection execute(
}
MathTransform crsTransform = CRS.findMathTransform(crs, epsg4326);

FeatureCollection results = FeatureCollections.newCollection();
DefaultFeatureCollection results = new DefaultFeatureCollection();
FeatureType targetFeatureType = createTargetFeatureType(featureCollection.getSchema());
Unit fromUnit = SI.METER;
Unit toUnit = Unit.valueOf("mi");
UnitConverter unitConvert = fromUnit.getConverterTo(toUnit);
Feature nearestFeature = null;
double nearestDistance = 9e9;
double nearestBearing = 0;
Iterator featureIterator = null;
double[] nearestPoint = new double[2];
FeatureIterator featureIterator = featureCollection.features();
try {
featureIterator = featureCollection.iterator();
while (featureIterator.hasNext()) {
SimpleFeature f = (SimpleFeature) featureIterator.next();
if (f.getDefaultGeometryProperty().getValue() == null)
Expand All @@ -151,8 +152,7 @@ public FeatureCollection execute(
nearestPoint[1] = geo1[1];
}
} finally {
if (featureIterator != null)
featureCollection.close(featureIterator);
featureIterator.close();
}
if (nearestFeature != null) {
nearestDistance = unitConvert.convert(nearestDistance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,18 +303,6 @@ public SimpleFeatureType getSchema() {
public SimpleFeatureIterator features() {
return new ReshapeFeatureIterator(delegate.features(), definition, schema);
}

@Override
public Iterator<SimpleFeature> iterator() {
return new WrappingIterator(features());
}

@Override
public void close(Iterator<SimpleFeature> close) {
if (close instanceof WrappingIterator) {
((WrappingIterator) close).close();
}
}
}
/**
* Process one feature at time; obtaining values by evaulating the provided list of definitions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,19 +112,6 @@ public SimpleFeatureIterator features() {
return new UnitedFeatureIterator(delegate.features(), delegate, features.features(),
features, getSchema());
}

@Override
public Iterator<SimpleFeature> iterator() {
return new WrappingIterator(features());
}

@Override
public void close(Iterator<SimpleFeature> close) {
if (close instanceof WrappingIterator) {
((WrappingIterator) close).close();
}
}

@Override
public SimpleFeatureType getSchema() {
return this.schema;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,6 @@ public SimpleFeatureIterator features() {
return new ZonalStatisticsIterator(delegate.features(), dataAttribute, data,
targetSchema);
}

@Override
public Iterator<SimpleFeature> iterator() {
return new WrappingIterator(features());
}

@Override
public void close(Iterator<SimpleFeature> close) {
if (close instanceof WrappingIterator) {
((WrappingIterator) close).close();
}
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.data.simple.SimpleFeatureIterator;
import org.geotools.feature.DefaultFeatureCollection;
import org.geotools.feature.FeatureCollections;
import org.geotools.feature.simple.SimpleFeatureBuilder;
import org.geotools.feature.simple.SimpleFeatureTypeBuilder;
Expand Down Expand Up @@ -182,7 +183,7 @@ private SimpleFeatureCollection createPoints(Coordinate[] pts, ReferencedEnvelop

SimpleFeatureType type = tb.buildFeatureType();
SimpleFeatureBuilder fb = new SimpleFeatureBuilder(type);
SimpleFeatureCollection fc = FeatureCollections.newCollection();
DefaultFeatureCollection fc = new DefaultFeatureCollection();

GeometryFactory factory = new GeometryFactory(new PackedCoordinateSequenceFactory());

Expand Down

0 comments on commit 162bdb9

Please sign in to comment.