use of org.opengis.referencing.datum.PixelInCell in project geotoolkit by Geomatys.
the class CoverageToFeatureTest method coverageToFeatureTestPixelCenter.
/**
* Test coverageToFeature process with a PixelInCell.CELL_CENTER coverage
* @throws NoSuchAuthorityCodeException
* @throws FactoryException
*/
@Test
public void coverageToFeatureTestPixelCenter() throws NoSuchAuthorityCodeException, FactoryException, ProcessException {
final PixelInCell pixPos = PixelInCell.CELL_CENTER;
final GridCoverageResource reader = buildResource(pixPos);
// Process
final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, CoverageToFeaturesDescriptor.NAME);
final ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("reader_in").setValue(reader);
final Process proc = desc.createProcess(in);
// Features out
final Collection<Feature> featureListOut = (Collection<Feature>) proc.call().parameter("feature_out").getValue();
final List<Feature> featureListResult = (List<Feature>) buildFCResultPixelCenter();
assertEquals(featureListResult.get(0).getType(), featureListOut.iterator().next().getType());
assertEquals(featureListOut.size(), featureListResult.size());
final Iterator<Feature> iteratorOut = featureListOut.iterator();
final Iterator<Feature> iteratorResult = featureListResult.iterator();
final ArrayList<Geometry> geomsOut = new ArrayList<>();
int itOut = 0;
while (iteratorOut.hasNext()) {
Feature featureOut = iteratorOut.next();
geomsOut.add((Geometry) featureOut.getPropertyValue("cellgeom"));
geomsOut.add((Geometry) featureOut.getPropertyValue("position"));
}
final ArrayList<Geometry> geomsResult = new ArrayList<>();
int itResult = 0;
while (iteratorResult.hasNext()) {
Feature featureResult = iteratorResult.next();
geomsResult.add((Geometry) featureResult.getPropertyValue("cellgeom"));
geomsResult.add((Geometry) featureResult.getPropertyValue("position"));
}
assertEquals(geomsResult.size(), geomsOut.size());
for (int i = 0; i < geomsResult.size(); i++) {
Geometry gOut = geomsOut.get(i);
Geometry gResult = geomsResult.get(i);
assertArrayEquals(gResult.getCoordinates(), gOut.getCoordinates());
}
}
Aggregations