Search in sources :

Example 26 with ProcessDescriptor

use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.

the class IntersectsTest method testIntersects.

@Test
public void testIntersects() throws NoSuchIdentifierException, ProcessException {
    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);
    final Geometry geom2 = fact.createPoint(new Coordinate(5, 5));
    // Process
    final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "jts:intersects");
    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 Boolean expected = geom1.intersects(geom2);
    assertTrue(expected.equals(result));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) LinearRing(org.locationtech.jts.geom.LinearRing) AbstractProcessTest(org.geotoolkit.processing.AbstractProcessTest) Test(org.junit.Test)

Example 27 with ProcessDescriptor

use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.

the class IsEmptyTest method testIsEmpty.

@Test
public void testIsEmpty() throws NoSuchIdentifierException, ProcessException {
    GeometryFactory fact = org.geotoolkit.geometry.jts.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);
    // Process
    final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "jts:isEmpty");
    final ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("geom").setValue(geom1);
    final org.geotoolkit.process.Process proc = desc.createProcess(in);
    // result
    final Boolean result = (Boolean) proc.call().parameter("result").getValue();
    final Boolean expected = geom1.isEmpty();
    assertTrue(expected.equals(result));
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) GeometryFactory(org.locationtech.jts.geom.GeometryFactory) Coordinate(org.locationtech.jts.geom.Coordinate) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) LinearRing(org.locationtech.jts.geom.LinearRing) AbstractProcessTest(org.geotoolkit.processing.AbstractProcessTest) Test(org.junit.Test)

Example 28 with ProcessDescriptor

use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.

the class PowerTest method testPower.

@Test
public void testPower() throws NoSuchIdentifierException, ProcessException {
    // Inputs first
    final double first = 2.6;
    final double second = 4.3;
    // Process
    final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "math:power");
    final ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("first").setValue(first);
    in.parameter("second").setValue(second);
    final org.geotoolkit.process.Process proc = desc.createProcess(in);
    // result
    final Double result = (Double) proc.call().parameter("result").getValue();
    assertEquals(60.867, result.doubleValue(), 0.001);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) AbstractProcessTest(org.geotoolkit.processing.AbstractProcessTest) Test(org.junit.Test)

Example 29 with ProcessDescriptor

use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.

the class RoundTest method testFloor.

@Test
public void testFloor() throws NoSuchIdentifierException, ProcessException {
    // Inputs first
    final double first = 24.64;
    // Process
    final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "math:round");
    final ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("first").setValue(first);
    final org.geotoolkit.process.Process proc = desc.createProcess(in);
    // result
    final Double result = (Double) proc.call().parameter("result").getValue();
    assertEquals(new Double(25.0), result);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) AbstractProcessTest(org.geotoolkit.processing.AbstractProcessTest) Test(org.junit.Test)

Example 30 with ProcessDescriptor

use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.

the class SubstractTest method testSubstract.

@Test
public void testSubstract() throws NoSuchIdentifierException, ProcessException {
    // Inputs first
    final double first = 22.3;
    final double second = 10.5;
    // Process
    final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "math:substract");
    final ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("first").setValue(first);
    in.parameter("second").setValue(second);
    final org.geotoolkit.process.Process proc = desc.createProcess(in);
    // out
    final Double result = (Double) proc.call().parameter("result").getValue();
    // Test
    assertEquals(new Double(11.8), result);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) 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