Search in sources :

Example 6 with ProcessDescriptor

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

the class AddDemo method main.

public static void main(String[] args) throws ProcessException, NoSuchIdentifierException {
    Demos.init();
    System.out.println("---------------------------------------- Process Addition demo");
    double number1 = 10.0;
    double number2 = 15.3;
    // Find the addition process
    ProcessDescriptor descriptor = ProcessFinder.getProcessDescriptor("geotoolkit", "math:add");
    // fill process input from process descriptor
    ParameterValueGroup in = descriptor.getInputDescriptor().createValue();
    in.parameter("first").setValue(number1);
    in.parameter("second").setValue(number2);
    System.out.println("Addition of " + number1 + "+" + number2);
    // process creation with inputs
    org.geotoolkit.process.Process process = descriptor.createProcess(in);
    // Execute the process and get output results
    ParameterValueGroup output = process.call();
    double result = (Double) output.parameter("result").getValue();
    System.out.println("Result : " + result);
}
Also used : ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor)

Example 7 with ProcessDescriptor

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

the class CachedPatternSymbolizer method computeOld.

private Geometry[] computeOld(GridCoverage coverage, Map<NumberRange, List<Symbolizer>> styles) throws IOException {
    final ProcessDescriptor descriptor = CoverageToVectorDescriptor.INSTANCE;
    final Integer band = (Integer) styleElement.getChannel().apply(null);
    final ParameterValueGroup input = descriptor.getInputDescriptor().createValue();
    input.parameter(CoverageToVectorDescriptor.COVERAGE.getName().getCode()).setValue(coverage);
    final Set<NumberRange> nrs = styles.keySet();
    input.parameter(CoverageToVectorDescriptor.RANGES.getName().getCode()).setValue(nrs.toArray(new NumberRange[nrs.size()]));
    input.parameter(CoverageToVectorDescriptor.BAND.getName().getCode()).setValue(band);
    final Process process = descriptor.createProcess(input);
    final Geometry[] polygons;
    try {
        polygons = (Geometry[]) process.call().parameter(CoverageToVectorDescriptor.GEOMETRIES.getName().getCode()).getValue();
    } catch (ProcessException ex) {
        Logger.getLogger("org.geotoolkit.display2d.ext.pattern").log(Level.WARNING, null, ex);
        throw new IOException(ex.getMessage(), ex);
    }
    return polygons;
}
Also used : NumberRange(org.apache.sis.measure.NumberRange) Geometry(org.locationtech.jts.geom.Geometry) ProcessException(org.geotoolkit.process.ProcessException) ParameterValueGroup(org.opengis.parameter.ParameterValueGroup) ProcessDescriptor(org.geotoolkit.process.ProcessDescriptor) Process(org.geotoolkit.process.Process) IOException(java.io.IOException)

Example 8 with ProcessDescriptor

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

the class IntersectionTest method testIntersection.

@Test
public void testIntersection() throws ProcessException, NoSuchIdentifierException, FactoryException {
    // Inputs
    final FeatureSet featureList = buildFeatureList();
    final FeatureSet featureInterList = buildFeatureInterList();
    // Process
    ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:intersection");
    ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("feature_in").setValue(featureList);
    in.parameter("feature_inter").setValue(featureInterList);
    // in.parameter("geometry_name").setValue("geom1");
    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 : 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 9 with ProcessDescriptor

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

the class MaxLimitTest method testLimit.

@Test
public void testLimit() throws ProcessException, NoSuchIdentifierException, FactoryException {
    // Inputs
    final FeatureCollection featureList = buildFeatureList();
    // Process
    ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, "vector:maxlimit");
    ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("feature_in").setValue(featureList);
    in.parameter("max_in").setValue(5);
    org.geotoolkit.process.Process proc = desc.createProcess(in);
    // Features out
    final FeatureCollection featureListOut = (FeatureCollection) proc.call().parameter("feature_out").getValue();
    assertEquals(5, featureListOut.size());
}
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 10 with ProcessDescriptor

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

the class MergeTest method testMerge.

/**
 * Merge Test with 4 FeatureCollection. 1 - base FeatureCollection 2 - FeatureCollection with same FeatureType as
 * base 3 - FeatureCollection with some attribute like base and with conversion needed 4 - FeatureCollection with
 * none attribute like base
 */
@Test
public void testMerge() throws ProcessException, NoSuchIdentifierException, FactoryException {
    // Inputs
    final FeatureCollection featureList1 = buildFeatureList1();
    final FeatureCollection featureList2 = buildFeatureList2();
    final FeatureCollection featureList3 = buildFeatureList3();
    final FeatureCollection featureList4 = buildFeatureList4();
    FeatureCollection[] FCList = new FeatureCollection[4];
    FCList[0] = featureList1;
    FCList[1] = featureList2;
    FCList[2] = featureList3;
    FCList[3] = featureList4;
    // Process
    ProcessDescriptor desc = ProcessFinder.getProcessDescriptor(GeotkProcessingRegistry.NAME, MergeDescriptor.NAME);
    ParameterValueGroup in = desc.getInputDescriptor().createValue();
    in.parameter("features_in").setValue(FCList);
    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)

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