Search in sources :

Example 16 with ProcessDescriptor

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));
}
Also used : FeatureType(org.opengis.feature.FeatureType) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) FeatureSet(org.apache.sis.storage.FeatureSet) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor)

Example 17 with ProcessDescriptor

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);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) AbstractProcessTest(org.geotoolkit.processing.vector.AbstractProcessTest) Test(org.junit.Test)

Example 18 with ProcessDescriptor

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);
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) FeatureSet(org.apache.sis.storage.FeatureSet) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) AbstractProcessTest(org.geotoolkit.processing.vector.AbstractProcessTest) Test(org.junit.Test)

Example 19 with ProcessDescriptor

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);
}
Also used : FeatureCollection(org.geotoolkit.storage.feature.FeatureCollection) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) AbstractProcessTest(org.geotoolkit.processing.vector.AbstractProcessTest) Test(org.junit.Test)

Example 20 with ProcessDescriptor

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));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) MathTransform(org.opengis.referencing.operation.MathTransform) Coordinate(org.locationtech.jts.geom.Coordinate) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) LinearRing(org.locationtech.jts.geom.LinearRing) AbstractProcessTest(org.geotoolkit.processing.AbstractProcessTest) Test(org.junit.Test)

Aggregations

ProcessDescriptor (org.geotoolkit.process.ProcessDescriptor)136 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)121 Test (org.junit.Test)108 AbstractProcessTest (org.geotoolkit.processing.AbstractProcessTest)62 Geometry (org.locationtech.jts.geom.Geometry)43 GeometryFactory (org.locationtech.jts.geom.GeometryFactory)33 Coordinate (org.locationtech.jts.geom.Coordinate)32 LinearRing (org.locationtech.jts.geom.LinearRing)31 Process (org.geotoolkit.process.Process)30 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)20 AbstractProcessTest (org.geotoolkit.processing.vector.AbstractProcessTest)18 GridCoverage (org.apache.sis.coverage.grid.GridCoverage)17 FeatureCollection (org.geotoolkit.storage.feature.FeatureCollection)15 GridCoverageBuilder (org.apache.sis.coverage.grid.GridCoverageBuilder)14 GridGeometry (org.apache.sis.coverage.grid.GridGeometry)14 FeatureSet (org.apache.sis.storage.FeatureSet)14 BufferedImage (java.awt.image.BufferedImage)13 RenderedImage (java.awt.image.RenderedImage)13 SampleDimension (org.apache.sis.coverage.SampleDimension)13 MathTransform (org.opengis.referencing.operation.MathTransform)13