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));
}
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));
}
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);
}
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);
}
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);
}
Aggregations