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