GeoHashGridProcess implements VectorProcess { public Query invertQuery( @DescribeParameter(name = "outputBBOX", description = "Georeferenced bounding box of the output") ReferencedEnvelope envelope, Query targetQuery, GridGeometry targetGridGeometry ) throws ProcessException { final BBOXRemovingFilterVisitor visitor = new BBOXRemovingFilterVisitor(); Filter filter = (Filter) targetQuery.getFilter().accept(visitor, null); final String geometryName = visitor.getGeometryPropertyName(); if (geometryName != null) { final BBOX bbox; try { if (envelope.getCoordinateReferenceSystem() != null) { envelope = envelope.transform(DefaultGeographicCRS.WGS84,false); } bbox = FILTER_FACTORY.bbox(geometryName, envelope.getMinX(), envelope.getMinY(), envelope.getMaxX(), envelope.getMaxY(), "EPSG:4326"); } catch (Exception e) { throw new ProcessException("Unable to create bbox filter for feature source", e); } filter = (Filter) FILTER_FACTORY.and(filter, bbox).accept(new SimplifyingFilterVisitor(), null); targetQuery.setFilter(filter); } final List<PropertyName> properties = new ArrayList<>(); properties.add(FILTER_FACTORY.property("_aggregation")); targetQuery.setProperties(properties); return targetQuery; }  @DescribeResult(description = "Output raster") 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); Query invertQuery(
            @DescribeParameter(name = "outputBBOX", description = "Georeferenced bounding box of the output") ReferencedEnvelope envelope,
            Query targetQuery, GridGeometry targetGridGeometry
            );  }
@Test public void testInvertQuery() { Filter filter = ff.bbox("geom", 0, 0, 0, 0, "EPSG:4326"); ReferencedEnvelope env = new ReferencedEnvelope(0,1,2,3,DefaultGeographicCRS.WGS84); Query query = new Query(); query.setFilter(filter); Query queryOut = process.invertQuery(env, query, null); assertEquals(ff.bbox("geom", 0, 2, 1, 3, "EPSG:4326"), queryOut.getFilter()); }
@Test public void testInvertQueryAcrossDateline() { Filter filter = ff.bbox("geom", 0, 0, 0, 0, "EPSG:4326"); ReferencedEnvelope env = new ReferencedEnvelope(-179,179,2,3,DefaultGeographicCRS.WGS84); Query query = new Query(); query.setFilter(filter); Query queryOut = process.invertQuery(env, query, null); assertEquals(ff.bbox("geom", -179, 2, 179, 3, "EPSG:4326"), queryOut.getFilter()); }
@Test public void testInvertQueryNorthEastAxisOrder() throws Exception { Filter filter = ff.bbox("geom", 0, 0, 0, 0, "EPSG:4326"); CRSAuthorityFactory factory = CRS.getAuthorityFactory(false); CoordinateReferenceSystem crs = factory.createCoordinateReferenceSystem("EPSG:4326"); ReferencedEnvelope env = new ReferencedEnvelope(2,3,0,1,crs); Query query = new Query(); query.setFilter(filter); Query queryOut = process.invertQuery(env, query, null); assertEquals(ff.bbox("geom", 0, 2, 1, 3, "EPSG:4326"), queryOut.getFilter()); }
@Test public void testInvertQueryWithOtherFilterElement() { Filter filter = ff.and(ff.equals(ff.property("key"), ff.literal("value")), ff.bbox("geom", 0, 0, 0, 0, "EPSG:4326")); ReferencedEnvelope env = new ReferencedEnvelope(0,1,2,3,DefaultGeographicCRS.WGS84); Query query = new Query(); query.setFilter(filter); Query queryOut = process.invertQuery(env, query, null); assertEquals(ff.and(ff.equals(ff.property("key"), ff.literal("value")), ff.bbox("geom", 0, 2, 1, 3, "EPSG:4326")), queryOut.getFilter()); }