use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class ClusterHullTest method testClusterHullBasic.
private void testClusterHullBasic(String filename_in, String filename_expected, Double tolerance, Double epsilon, Unit<Length> unit) throws URISyntaxException, DataStoreException, NoSuchIdentifierException, ProcessException {
final FeatureSet featureSet = buildFeatureSet(filename_in);
ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:clusterhull");
ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("feature_set_in").setValue(featureSet);
in.parameter("tolerance_value").setValue(tolerance);
in.parameter("smoothing_epsilon").setValue(epsilon);
in.parameter("tolerance_unit").setValue(unit);
org.geotoolkit.process.Process proc = desc.createProcess(in);
// Feature set out
final FeatureSet out = (FeatureSet) proc.call().parameter("feature_set_out").getValue();
// Feature set expected
final FeatureSet expected = buildFeatureSet(filename_expected);
// Test
GeometryCollection gc1 = extractGeometryCollectionFromFeatureSet(out);
GeometryCollection gc2 = extractGeometryCollectionFromFeatureSet(expected);
// is same geometry
assertTrue(gc1.equalsExact(gc2, TOLERANCE));
FeatureType type1 = out.getType();
FeatureType type2 = expected.getType();
// is same feature
assertEquals(FeatureExt.getCRS(type1), FeatureExt.getCRS(type2));
}
use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class ConvexHullTest method testConvexHull.
@Test
public void testConvexHull() throws ProcessException, NoSuchIdentifierException, FactoryException {
// Inputs
final FeatureCollection featureList = buildFeatureList();
// Process
ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:convexhull");
ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("feature_in").setValue(featureList);
org.geotoolkit.process.Process proc = desc.createProcess(in);
// Geometry out
final Geometry resultGeom = (Geometry) proc.call().parameter("geometry_out").getValue();
// Expected Features out
final Geometry geomteryResult1 = buildGeometryResult1();
assertTrue(geomteryResult1.equals(resultGeom));
// assertEquals(geomteryResult1, resultGeom);
// select the second feature geometry
ProcessDescriptor desc2 = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:convexhull");
ParameterValueGroup in2 = desc2.getInputDescriptor().createValue();
in2.parameter("feature_in").setValue(featureList);
in2.parameter("geometry_name").setValue("geom2");
org.geotoolkit.process.Process proc2 = desc.createProcess(in2);
// Geometry out
final Geometry resultGeom2 = (Geometry) proc2.call().parameter("geometry_out").getValue();
// Expected Features out
final Geometry geomteryResult2 = buildGeometryResult2();
assertTrue(geomteryResult2.equals(resultGeom2));
// assertEquals(geomteryResult2, resultGeom2);
}
use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class IntersectTest method testIntersect.
@Test
public void testIntersect() throws ProcessException, NoSuchIdentifierException, FactoryException {
// Inputs
final FeatureSet featureList = buildFeatureList();
final Geometry geom = buildIntersectionGeometry();
// Process
ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:intersect");
ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("feature_in").setValue(featureList);
in.parameter("geometry_in").setValue(geom);
org.geotoolkit.process.Process proc = desc.createProcess(in);
// Features out
final FeatureSet featureListOut = (FeatureSet) proc.call().parameter("feature_out").getValue();
// Expected Features out
final FeatureSet featureListResult = buildResultList();
compare(featureListResult, featureListOut);
}
use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class UnionTest method testUnion.
@Test
public void testUnion() throws ProcessException, NoSuchIdentifierException, FactoryException {
// Inputs
final FeatureCollection featureList = buildFeatureList();
final FeatureCollection featureUnionList = buildFeatureUnionList();
// Process
ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:union");
ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("feature_in").setValue(featureList);
in.parameter("feature_union").setValue(featureUnionList);
in.parameter("input_geometry_name").setValue("geom1");
org.geotoolkit.process.Process proc = desc.createProcess(in);
// Features out
final FeatureCollection featureListOut = (FeatureCollection) proc.call().parameter("feature_out").getValue();
// Expected Features out
final FeatureCollection featureListResult = buildResultList();
compare(featureListResult, featureListOut);
}
use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class CoveredByTest method testCoveredByCRS.
@Test
public void testCoveredByCRS() throws NoSuchIdentifierException, ProcessException, FactoryException, TransformException {
GeometryFactory fact = JTS.getFactory();
// Inputs first
final LinearRing ring = fact.createLinearRing(new Coordinate[] { new Coordinate(0.0, 0.0), new Coordinate(0.0, 10.0), new Coordinate(5.0, 10.0), new Coordinate(5.0, 0.0), new Coordinate(0.0, 0.0) });
final Geometry geom1 = fact.createPolygon(ring, null);
CoordinateReferenceSystem crs1 = CommonCRS.WGS84.geographic();
JTS.setCRS(geom1, crs1);
Geometry geom2 = fact.createPoint(new Coordinate(5, 5));
CoordinateReferenceSystem crs2 = CRS.forCode("EPSG:2154");
JTS.setCRS(geom2, crs2);
// Process
final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "jts:coveredBy");
final ParameterValueGroup in = desc.getInputDescriptor().createValue();
in.parameter("geom1").setValue(geom1);
in.parameter("geom2").setValue(geom2);
final org.geotoolkit.process.Process proc = desc.createProcess(in);
// result
final Boolean result = (Boolean) proc.call().parameter("result").getValue();
final MathTransform mt = CRS.findOperation(crs2, crs1, null).getMathTransform();
geom2 = org.apache.sis.internal.feature.jts.JTS.transform(geom2, mt);
final Boolean expected = geom1.contains(geom2);
assertTrue(expected.equals(result));
}
Aggregations