org.geotools.process.ProcessException Java Examples

The following examples show how to use org.geotools.process.ProcessException. 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: DecimationProcess.java    From geowave with Apache License 2.0 6 votes vote down vote up
@DescribeResult(
    name = "result",
    description = "This is just a pass-through, the key is to provide enough information within invertQuery to perform a map to screen transform")
public SimpleFeatureCollection execute(
    @DescribeParameter(
        name = "data",
        description = "Feature collection containing the data") final SimpleFeatureCollection features,
    @DescribeParameter(
        name = "outputBBOX",
        description = "Georeferenced bounding box of the output") final ReferencedEnvelope argOutputEnv,
    @DescribeParameter(
        name = "outputWidth",
        description = "Width of the output raster") final Integer argOutputWidth,
    @DescribeParameter(
        name = "outputHeight",
        description = "Height of the output raster") final Integer argOutputHeight,
    @DescribeParameter(
        name = "pixelSize",
        description = "The pixel size to decimate by") final Double pixelSize)
    throws ProcessException {
  // vector-to-vector render transform that is just a pass through - the
  // key is to add map to screen transform within invertQuery
  return features;
}
 
Example #2
Source File: DecimationProcess.java    From geowave with Apache License 2.0 6 votes vote down vote up
public Query invertQuery(
    @DescribeParameter(
        name = "outputBBOX",
        description = "Georeferenced bounding box of the output") final ReferencedEnvelope argOutputEnv,
    @DescribeParameter(
        name = "outputWidth",
        description = "Width of the output raster") final Integer argOutputWidth,
    @DescribeParameter(
        name = "outputHeight",
        description = "Height of the output raster") final Integer argOutputHeight,
    @DescribeParameter(
        name = "pixelSize",
        description = "The pixel size to decimate by") final Double pixelSize,
    final Query targetQuery,
    final GridGeometry targetGridGeometry) throws ProcessException {

  // add to the query hints
  targetQuery.getHints().put(OUTPUT_WIDTH, argOutputWidth);
  targetQuery.getHints().put(OUTPUT_HEIGHT, argOutputHeight);
  targetQuery.getHints().put(OUTPUT_BBOX, argOutputEnv);
  if (pixelSize != null) {
    targetQuery.getHints().put(PIXEL_SIZE, pixelSize);
  }
  return targetQuery;
}
 
Example #3
Source File: SubsampleProcess.java    From geowave with Apache License 2.0 6 votes vote down vote up
@DescribeResult(
    name = "result",
    description = "This is just a pass-through, the key is to provide enough information within invertQuery to perform a map to screen transform")
public SimpleFeatureCollection execute(
    @DescribeParameter(
        name = "data",
        description = "Feature collection containing the data") final SimpleFeatureCollection features,
    @DescribeParameter(
        name = "outputBBOX",
        description = "Georeferenced bounding box of the output") final ReferencedEnvelope argOutputEnv,
    @DescribeParameter(
        name = "outputWidth",
        description = "Width of the output raster") final Integer argOutputWidth,
    @DescribeParameter(
        name = "outputHeight",
        description = "Height of the output raster") final Integer argOutputHeight,
    @DescribeParameter(
        name = "pixelSize",
        description = "The pixel size to base subsampling on") final Double pixelSize)
    throws ProcessException {
  // vector-to-vector render transform that is just a pass through - the
  // key is to add map to screen transform within invertQuery
  return features;
}
 
Example #4
Source File: SubsampleProcess.java    From geowave with Apache License 2.0 6 votes vote down vote up
public Query invertQuery(
    @DescribeParameter(
        name = "outputBBOX",
        description = "Georeferenced bounding box of the output") final ReferencedEnvelope argOutputEnv,
    @DescribeParameter(
        name = "outputWidth",
        description = "Width of the output raster") final Integer argOutputWidth,
    @DescribeParameter(
        name = "outputHeight",
        description = "Height of the output raster") final Integer argOutputHeight,
    @DescribeParameter(
        name = "pixelSize",
        description = "The pixel size to base subsampling on") final Double pixelSize,
    final Query targetQuery,
    final GridGeometry targetGridGeometry) throws ProcessException {

  // add to the query hints
  targetQuery.getHints().put(SUBSAMPLE_ENABLED, true);
  targetQuery.getHints().put(OUTPUT_WIDTH, argOutputWidth);
  targetQuery.getHints().put(OUTPUT_HEIGHT, argOutputHeight);
  targetQuery.getHints().put(OUTPUT_BBOX, argOutputEnv);
  if (pixelSize != null) {
    targetQuery.getHints().put(PIXEL_SIZE, pixelSize);
  }
  return targetQuery;
}
 
Example #5
Source File: DistributedRenderProcess.java    From geowave with Apache License 2.0 6 votes vote down vote up
@DescribeResult(
    name = "result",
    description = "This is just a pass-through, the key is to provide enough information within invertQuery to perform a map to screen transform")
public SimpleFeatureCollection execute(
    @DescribeParameter(
        name = "data",
        description = "Feature collection containing the rendered image") final SimpleFeatureCollection features)
    throws ProcessException {
  // this is a pass through, only used so that legend rendering works
  // appropriately

  // InternalDistributedRenderProcess is what actually can be used as a
  // render transformation to perform distributed rendering, within WMS
  // map request callbacks this transformation will be replaced with
  // InternalDistributedRenderProcess

  // therefore all other calls outside of WMS map requests, such as
  // requesting the legend will behave as expected

  return features;
}
 
Example #6
Source File: InternalDistributedRenderProcess.java    From geowave with Apache License 2.0 5 votes vote down vote up
@DescribeResult(
    name = "result",
    description = "This is just a pass-through, the key is to provide enough information within invertQuery to perform a map to screen transform")
public GridCoverage2D execute(
    @DescribeParameter(
        name = "data",
        description = "Feature collection containing the rendered image") final SimpleFeatureCollection features)
    throws ProcessException {
  // vector-to-raster render transform that take a single feature that
  // wraps a distributed render result and converts it to a GridCoverage2D
  if (features != null) {
    final SimpleFeatureIterator it = features.features();
    if (it.hasNext()) {
      final SimpleFeature resultFeature = features.features().next();
      final DistributedRenderResult actualResult =
          (DistributedRenderResult) resultFeature.getAttribute(0);
      final DistributedRenderOptions renderOptions =
          (DistributedRenderOptions) resultFeature.getAttribute(1);
      // convert to the GridCoverage2D required for output
      final GridCoverageFactory gcf =
          CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
      final BufferedImage result = actualResult.renderComposite(renderOptions);
      final GridCoverage2D gridCov =
          gcf.create("Process Results", result, renderOptions.getEnvelope());
      return gridCov;
    }
  }
  return null;
}
 
Example #7
Source File: InternalDistributedRenderProcess.java    From geowave with Apache License 2.0 5 votes vote down vote up
public Query invertQuery(final Query targetQuery, final GridGeometry targetGridGeometry)
    throws ProcessException {
  // it seems that without invertQuery returning the targetQuery, the geom
  // property field does not get set in the filter (line 205 of
  // org.geotools.renderer.lite.RenderingTransformationHelper in geotools
  // v15.1)
  return targetQuery;
}
 
Example #8
Source File: GeoHashGridProcess.java    From elasticgeo with GNU General Public License v3.0 4 votes vote down vote up
@DescribeResult(description = "Output raster")
public GridCoverage2D execute(

        // process data
        @DescribeParameter(name = "data", description = "Input features") SimpleFeatureCollection obsFeatures,

        // process parameters
        @DescribeParameter(name = "pixelsPerCell", description = "Resolution used for upsampling (in pixels)", defaultValue="1", min = 1) Integer argPixelsPerCell,
        @DescribeParameter(name = "gridStrategy", description = "GeoHash grid strategy", defaultValue="Basic", min = 1) String gridStrategy,
        @DescribeParameter(name = "gridStrategyArgs", description = "Grid strategy arguments", min = 0) List<String> gridStrategyArgs,
        @DescribeParameter(name = "emptyCellValue", description = "Default cell value", min = 0) Float emptyCellValue,
        @DescribeParameter(name = "scaleMin", description = "Scale minimum", defaultValue="0") Float scaleMin,
        @DescribeParameter(name = "scaleMax", description = "Scale maximum", min = 0) Float scaleMax,
        @DescribeParameter(name = "useLog", description = "Whether to use log values (default=false)", defaultValue="false") Boolean useLog,

        // output image parameters
        @DescribeParameter(name = "outputBBOX", description = "Bounding box of the output") ReferencedEnvelope argOutputEnv,
        @DescribeParameter(name = "outputWidth", description = "Width of output raster in pixels") Integer argOutputWidth,
        @DescribeParameter(name = "outputHeight", description = "Height of output raster in pixels") Integer argOutputHeight,

        ProgressListener monitor) throws ProcessException {

    try {
        // construct and populate grid
        final GeoHashGrid geoHashGrid = Strategy.valueOf(gridStrategy.toUpperCase()).createNewInstance();
        geoHashGrid.setParams(gridStrategyArgs);
        geoHashGrid.setEmptyCellValue(emptyCellValue);
        geoHashGrid.setScale(new RasterScale(scaleMin, scaleMax, useLog));
        geoHashGrid.initalize(argOutputEnv, obsFeatures);
        // convert to grid coverage
        final GridCoverage2D nativeCoverage = geoHashGrid.toGridCoverage2D();

        // reproject
        final GridCoverage2D transformedCoverage = (GridCoverage2D) Operations.DEFAULT.resample(nativeCoverage, argOutputEnv.getCoordinateReferenceSystem()); 
        // upscale to approximate output resolution
        final GridCoverage2D scaledCoverage = GridCoverageUtil.scale(transformedCoverage, argOutputWidth*argPixelsPerCell, argOutputHeight*argPixelsPerCell);
        // crop (geohash grid envelope will always contain output bbox)
        final GridCoverage2D croppedCoverage = GridCoverageUtil.crop(scaledCoverage, argOutputEnv);
        return GridCoverageUtil.scale(croppedCoverage, argOutputWidth, argOutputHeight);
    } catch (Exception e) {
        throw new ProcessException("Error executing GeoHashGridProcess", e);
    }
}
 
Example #9
Source File: DistributedRenderProcess.java    From geowave with Apache License 2.0 4 votes vote down vote up
public Query invertQuery(final Query targetQuery, final GridGeometry targetGridGeometry)
    throws ProcessException {
  return targetQuery;
}