use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class CoveredByTest method testCoveredBy.
@Test
public void testCoveredBy() 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);
Geometry geom2 = fact.createPoint(new Coordinate(5, 5));
// 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 Boolean expected = geom1.contains(geom2);
assertTrue(expected.equals(result));
}
use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class CoversTest method testCovers.
@Test
public void testCovers() 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:covers");
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.covers(geom2);
assertTrue(expected.equals(result));
}
use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class CrossesTest method testCrossesCRS.
@Test
public void testCrossesCRS() 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);
final CoordinateReferenceSystem crs1 = CommonCRS.WGS84.geographic();
JTS.setCRS(geom1, crs1);
Geometry geom2 = fact.createLineString(new Coordinate[] { new Coordinate(5, 5), new Coordinate(-5, -5) });
final CoordinateReferenceSystem crs2 = CRS.forCode("EPSG:2154");
JTS.setCRS(geom2, crs2);
// Process
final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "jts:crosses");
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.crosses(geom2);
assertTrue(expected.equals(result));
}
use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class DifferenceTest method testDifference.
@Test
public void testDifference() 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 LinearRing ring2 = fact.createLinearRing(new Coordinate[] { new Coordinate(-5.0, 0.0), new Coordinate(-5.0, 10.0), new Coordinate(2.0, 10.0), new Coordinate(2.0, 0.0), new Coordinate(-5.0, 0.0) });
final Geometry geom2 = fact.createPolygon(ring2, null);
// Process
final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "jts:difference");
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 Geometry result = (Geometry) proc.call().parameter("result_geom").getValue();
final Geometry expected = geom1.difference(geom2);
assertTrue(expected.equals(result));
}
use of org.geotoolkit.process.ProcessDescriptor in project geotoolkit by Geomatys.
the class IntersectionSurfaceTest method testIntersection.
@Test
public void testIntersection() 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);
final LinearRing ring2 = fact.createLinearRing(new Coordinate[] { new Coordinate(-5.0, 0.0), new Coordinate(-5.0, 10.0), new Coordinate(2.0, 10.0), new Coordinate(2.0, 0.0), new Coordinate(-5.0, 0.0) });
final Geometry geom2 = fact.createPolygon(ring2, null);
// Process
final ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "jts:intersectionSurface");
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 Double result = (Double) proc.call().parameter("result_surface").getValue();
final Geometry expectedGeom = geom1.intersection(geom2);
final double expected = expectedGeom.getArea();
assertTrue(expected == result);
}
Aggregations