org.geotools.process.Processors Java Examples

The following examples show how to use org.geotools.process.Processors. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DistributedRenderProcessUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static Expression getRenderingProcess() {
  if (SINGLETON_RENDER_PROCESS == null) {
    final ProcessFactory processFactory =
        new AnnotatedBeanProcessFactory(
            Text.text("Internal GeoWave Process Factory"),
            "internal",
            InternalDistributedRenderProcess.class);
    final Name processName = new NameImpl("internal", "InternalDistributedRender");
    final RenderingProcess process = (RenderingProcess) processFactory.create(processName);
    final Map<String, Parameter<?>> parameters = processFactory.getParameterInfo(processName);
    final InternalProcessFactory factory = new InternalProcessFactory();
    // this is kinda a hack, but the only way to instantiate a process
    // is
    // for it to have a registered process factory, so temporarily
    // register
    // the process factory
    Processors.addProcessFactory(factory);

    SINGLETON_RENDER_PROCESS =
        new RenderingProcessFunction(
            processName,
            Collections.singletonList(
                new ParameterFunction(
                    null,
                    Collections.singletonList(new LiteralExpressionImpl("data")))),
            parameters,
            process,
            null);
    Processors.removeProcessFactory(factory);
  }
  return SINGLETON_RENDER_PROCESS;
}
 
Example #2
Source File: DistributedRenderCallback.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public Layer beforeLayer(final WMSMapContent mapContent, final Layer layer) {
  // sanity check the style
  if ((layer instanceof FeatureLayer)
      && (layer.getStyle() != null)
      && (layer.getStyle().featureTypeStyles() != null)
      && !layer.getStyle().featureTypeStyles().isEmpty()) {

    final Style layerStyle = layer.getStyle();
    final FeatureTypeStyle style = layerStyle.featureTypeStyles().get(0);
    // check if their is a DistributedRender rendering
    // transformation
    if ((style instanceof ProcessFunction)
        && (style.getTransformation() != null)
        && (((ProcessFunction) style.getTransformation()).getName() != null)
        && ((ProcessFunction) style.getTransformation()).getName().equals(
            DistributedRenderProcess.PROCESS_NAME)) {
      // if their is a DistributedRender transformation, we need
      // to provide more information that can only be found
      final DuplicatingStyleVisitor cloner = new DuplicatingStyleVisitor();
      layerStyle.accept(cloner);
      layer.getQuery().getHints().put(
          DistributedRenderProcess.OPTIONS,
          new DistributedRenderOptions(wms, mapContent, layerStyle));
      // now that the options with the distributed render style
      // have been set the original style will be used with
      // distributed rendering

      // now, replace the style with a direct raster symbolizer,
      // so the GridCoverage result of the distributed rendering
      // process is directly rendered to the map in place of the
      // original style

      final Style directRasterStyle = (Style) cloner.getCopy();
      directRasterStyle.featureTypeStyles().clear();
      Processors.addProcessFactory(new InternalProcessFactory());
      directRasterStyle.featureTypeStyles().add(
          getDirectRasterStyle(
              layer.getFeatureSource().getSchema().getGeometryDescriptor().getLocalName(),
              DistributedRenderProcessUtils.getRenderingProcess()));
      ((FeatureLayer) layer).setStyle(directRasterStyle);
    }
  }
  return layer;
}