Exemplo n.º 1
0
  public Function function(Name processName, List<Expression> args, Literal fallback) {
    // if the param function just return it
    if (processName.equals(new NameImpl(ParameterFunction.NAME))) {
      return new ParameterFunction(fallback, args);
    }

    // lookup the process
    if (functionNames == null) {
      init();
    }

    if (!processToFunction.containsKey(processName)) {
      // no such function
      return null;
    } else {
      // wrap the process
      org.geotools.process.Process process = Processors.createProcess(processName);
      Map<String, Parameter<?>> parameters = Processors.getParameterInfo(processName);
      if (process instanceof RenderingProcess) {
        return new RenderingProcessFunction(
            processName.getLocalPart(),
            processName,
            args,
            parameters,
            (RenderingProcess) process,
            fallback);
      } else {
        return new ProcessFunction(
            processName.getLocalPart(), processName, args, parameters, process, fallback);
      }
    }
  }
Exemplo n.º 2
0
  public void testProcess() throws ParseException, InterruptedException, ExecutionException {
    WKTReader wktReader = new WKTReader(new GeometryFactory());
    Geometry geom = wktReader.read("MULTIPOINT (1 1, 5 4, 7 9, 5 5, 2 2)");

    Name name = new NameImpl("spatial", "octagonalEnvelope");
    org.geotools.process.Process process = Processors.createProcess(name);
    System.out.println("Executing process: " + name);
    for (Map.Entry<String, Parameter<?>> entry : Processors.getParameterInfo(name).entrySet()) {
      System.out.println("\t" + entry.getKey() + ":\t" + entry.getValue());
    }

    ProcessExecutor engine = Processors.newProcessExecutor(2);

    // quick map of inputs
    Map<String, Object> input = new KVP("geom", geom);
    Progress working = engine.submit(process, input);

    // you could do other stuff whle working is doing its thing
    if (working.isCancelled()) {
      return;
    }

    Map<String, Object> result = working.get(); // get is BLOCKING
    Geometry octo = (Geometry) result.get("result");

    System.out.println(octo);
  }