Search in sources :

Example 21 with ProcessDescriptor

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));
}
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 22 with ProcessDescriptor

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));
}
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 23 with ProcessDescriptor

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

Example 24 with ProcessDescriptor

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));
}
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 25 with ProcessDescriptor

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

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