Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[GEOS-5279][Backport] Cumulative patch for: #45

Merged
merged 1 commit into from

2 participants

@ccancellieri
Collaborator
  • Added check for null readParameters and fix format
    • documentation update
    • GEOS-5279
@ccancellieri ccancellieri Cumulative patch for:
 - Added check for null readParameters and fix format
 - documentation update
 - GEOS-5279
edc6fc3
@simboss simboss merged commit 72ea22d into geoserver:2.2.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 24, 2012
  1. @ccancellieri

    Cumulative patch for:

    ccancellieri authored
     - Added check for null readParameters and fix format
     - documentation update
     - GEOS-5279
This page is out of date. Refresh to see the latest.
View
5 doc/en/user/source/tutorials/image_mosaic_plugin/imagemosaic.rst
@@ -165,6 +165,11 @@ The Coverage Editor gives users the possibility to set a few control parameters
- Set the maximum number of the tiles that can be load simulatenously for a request. In case of a large mosaic this parameter should be opportunely set to not saturating the server with too many granules loaded at the same time.
* - *BackgroundValues*
- Set the value of the mosaic background. Depending on the nature of the mosaic it is wise to set a value for the 'no data' area (usually -9999). This value is repeated on all the mosaic bands.
+ * - *Filter*
+ - Set the default mosaic filter. It should be a valid ECQL query which will be used as default if no 'cql_filter' are specified (instead of Filter.INCLUDE). If the cql_filter is specified in the request it will be overriden.
+
+.. note:: Do not use this filter to change time or elevation dimensions defaults. It will be added as AND condition with CURRENT for 'time' and LOWER for 'elevation'.
+
* - *OutputTransparentColor*
- Set the transparent color for the created mosaic. See below for an example:
View
17 src/main/src/main/java/org/geoserver/data/util/CoverageUtils.java
@@ -18,10 +18,12 @@
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.coverage.grid.io.AbstractGridFormat;
+import org.geotools.filter.text.ecql.ECQL;
import org.geotools.geometry.GeneralEnvelope;
import org.geotools.parameter.DefaultParameterDescriptor;
import org.geotools.referencing.CRS;
import org.geotools.util.Converters;
+import org.opengis.filter.Filter;
import org.opengis.parameter.GeneralParameterDescriptor;
import org.opengis.parameter.GeneralParameterValue;
import org.opengis.parameter.ParameterDescriptor;
@@ -345,13 +347,24 @@ public static Object getCvParamValue(final String key, ParameterValue param, fin
value=backgroundValues;
}
- }
- else if (key.equalsIgnoreCase("InputImageThresholdValue")) {
+ } else if (key.equalsIgnoreCase("InputImageThresholdValue")) {
if (params.get(key) != null) {
String temp = (String) params.get(key);
value=Double.valueOf(temp);
}
+ } else if (key.equalsIgnoreCase("Filter")) {
+ Object sfilter=params.get(key);
+ if (sfilter!=null){
+ if (sfilter instanceof String){
+ value=ECQL.toFilter((String)sfilter);
+ } else if (sfilter instanceof Filter){
+ value=(Filter)sfilter;
+ }
+ } else {
+ value=param.getValue();
+ }
+
} else {
value = params.get(key);
if(value != null) {
View
8 src/wms/src/main/java/org/geoserver/wms/GetMap.java
@@ -47,7 +47,6 @@
import org.geotools.renderer.lite.MetaBufferEstimator;
import org.geotools.renderer.lite.RendererUtilities;
import org.geotools.renderer.lite.StreamingRenderer;
-import org.geotools.resources.CRSUtilities;
import org.geotools.styling.FeatureTypeConstraint;
import org.geotools.styling.FeatureTypeStyle;
import org.geotools.styling.Rule;
@@ -135,12 +134,6 @@ public WebMap run(final GetMapRequest request, WMSMapContent mapContent)
GetMapOutputFormat delegate = getDelegate(outputFormat);
- // if there's a crs in the request, use that. If not, assume its 4326
- final CoordinateReferenceSystem mapcrs = request.getCrs();
-
- final List<MapLayerInfo> layers = request.getLayers();
- final Style[] styles = request.getStyles().toArray(new Style[] {});
- final Filter[] filters = buildLayersFilters(request.getFilter(), layers);
final boolean isTiled = MetatileMapOutputFormat.isRequestTiled(request, delegate);
//
@@ -634,6 +627,7 @@ private void assertMandatory(GetMapRequest request) throws ServiceException {
*/
private Filter[] buildLayersFilters(List<Filter> requestFilters, List<MapLayerInfo> layers) {
final int nLayers = layers.size();
+
if (requestFilters == null || requestFilters.size() == 0) {
requestFilters = Collections.nCopies(layers.size(), (Filter) Filter.INCLUDE);
} else if (requestFilters.size() != nLayers) {
View
41 src/wms/src/main/java/org/geoserver/wms/WMS.java
@@ -4,11 +4,7 @@
*/
package org.geoserver.wms;
-import static org.geoserver.ows.util.ResponseUtils.buildURL;
-
import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
@@ -16,7 +12,6 @@
import java.util.Date;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.ExecutorService;
@@ -30,7 +25,6 @@
import org.geoserver.catalog.FeatureTypeInfo;
import org.geoserver.catalog.LayerGroupInfo;
import org.geoserver.catalog.LayerInfo;
-import org.geoserver.catalog.MetadataLinkInfo;
import org.geoserver.catalog.MetadataMap;
import org.geoserver.catalog.NamespaceInfo;
import org.geoserver.catalog.ResourceInfo;
@@ -41,8 +35,6 @@
import org.geoserver.config.GeoServerInfo;
import org.geoserver.config.JAIInfo;
import org.geoserver.data.util.CoverageUtils;
-import org.geoserver.ows.URLMangler.URLType;
-import org.geoserver.ows.util.KvpUtils;
import org.geoserver.platform.GeoServerExtensions;
import org.geoserver.platform.ServiceException;
import org.geoserver.wms.WMSInfo.WMSInterpolation;
@@ -52,10 +44,8 @@
import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
import org.geotools.data.FeatureSource;
import org.geotools.data.Query;
-import org.geotools.data.QueryCapabilities;
import org.geotools.data.ows.Layer;
import org.geotools.data.ows.WMSCapabilities;
-import org.geotools.data.simple.SimpleFeatureCollection;
import org.geotools.factory.CommonFactoryFinder;
import org.geotools.factory.GeoTools;
import org.geotools.feature.FeatureCollection;
@@ -64,20 +54,19 @@
import org.geotools.feature.visitor.MinVisitor;
import org.geotools.feature.visitor.UniqueVisitor;
import org.geotools.filter.Filters;
-import org.geotools.filter.SortByImpl;
-import org.geotools.resources.coverage.FeatureUtilities;
import org.geotools.styling.Style;
-import org.geotools.util.*;
+import org.geotools.util.Converters;
+import org.geotools.util.Range;
+import org.geotools.util.Version;
import org.geotools.util.logging.Logging;
import org.opengis.feature.type.Name;
import org.opengis.filter.Filter;
import org.opengis.filter.FilterFactory;
import org.opengis.filter.expression.Literal;
import org.opengis.filter.expression.PropertyName;
-import org.opengis.filter.sort.SortBy;
-import org.opengis.filter.sort.SortOrder;
import org.opengis.parameter.GeneralParameterDescriptor;
import org.opengis.parameter.GeneralParameterValue;
+import org.opengis.parameter.ParameterValue;
import org.opengis.parameter.ParameterValueGroup;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
@@ -801,7 +790,6 @@ public boolean isQueryable(LayerGroupInfo layerGroup) {
GeneralParameterValue[] readParameters = CoverageUtils.getParameters(
readParametersDescriptor, coverage.getParameters(), readGeom);
ReaderDimensionsAccessor dimensions = new ReaderDimensionsAccessor(reader);
-
// pass down time
final DimensionInfo timeInfo = metadata.get(ResourceInfo.TIME, DimensionInfo.class);
final List<GeneralParameterDescriptor> parameterDescriptors = readParametersDescriptor
@@ -834,9 +822,24 @@ public boolean isQueryable(LayerGroupInfo layerGroup) {
fixedElevations, "ELEVATION", "Elevation");
}
- if (layerFilter != null) {
- readParameters = CoverageUtils.mergeParameter(parameterDescriptors, readParameters,
- layerFilter, "FILTER", "Filter");
+ if (layerFilter != null && readParameters != null) {
+ // test for default [empty is replaced with INCLUDE filter] ]filter
+ for (int i = 0; i < readParameters.length; i++) {
+
+ GeneralParameterValue param = readParameters[i];
+ GeneralParameterDescriptor pd = param.getDescriptor();
+
+ if (pd.getName().getCode().equalsIgnoreCase("FILTER")) {
+ final ParameterValue pv = (ParameterValue) pd.createValue();
+ // if something different from the default INCLUDE filter is specified
+ if (layerFilter != Filter.INCLUDE) {
+ // override the default filter
+ pv.setValue(layerFilter);
+ readParameters[i] = pv;
+ }
+ break;
+ }
+ }
}
return readParameters;
}
View
31 src/wms/src/test/java/org/geoserver/wms/WMSFilterMosaicTestSupport.java
@@ -0,0 +1,31 @@
+package org.geoserver.wms;
+
+import org.geoserver.catalog.CoverageInfo;
+import org.geoserver.wms.wms_1_1_1.FilterMosaicGetMapTest;
+
+/**
+ * The following will provide data to test the default ImageMosaic cql filter
+ * The added mosaic is used WITHOUT dimensions which are instead used as attributes.
+ *
+ * @see {@link FilterMosaicGetMapTest}
+ *
+ * @author carlo cancellieri
+ *
+ */
+public class WMSFilterMosaicTestSupport extends WMSDimensionsTestSupport {
+
+ /**
+ * Here we setup the default mosaic filter to the layer
+ * @param metadata
+ * @param presentation
+ * @param resolution
+ */
+ protected void setupMosaicFilter(String filter, String layer) {
+ CoverageInfo info = getCatalog().getCoverageByName(layer);
+
+ info.getParameters().put("Filter", filter);
+
+ getCatalog().save(info);
+ }
+
+}
View
6 src/wms/src/test/java/org/geoserver/wms/wms_1_1_1/DimensionsRasterGetMapTest.java
@@ -71,12 +71,6 @@ public void testTimeTwice() throws Exception {
// should be similar to the default, but with different shades of color
assertPixel(image, 36, 31, new Color(246, 246, 255));
assertPixel(image, 68, 72, new Color(255, 182, 182));
-
- image = getAsImage(BASE_URL + "&time=2008-10-31T00:00:00.000Z", "image/png");
-
- // should be similar to the default, but with different shades of color
- assertPixel(image, 36, 31, new Color(246, 246, 255));
- assertPixel(image, 68, 72, new Color(255, 182, 182));
}
View
127 src/wms/src/test/java/org/geoserver/wms/wms_1_1_1/FilterMosaicGetMapTest.java
@@ -0,0 +1,127 @@
+/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
+ * This code is licensed under the GPL 2.0 license, availible at the root
+ * application directory.
+ */
+package org.geoserver.wms.wms_1_1_1;
+
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+
+import org.geoserver.wms.WMSFilterMosaicTestSupport;
+
+/**
+ * Class to test ImageMosaic cql filter
+ *
+ * @see {@link WMSFilterMosaicTestSupport}
+ *
+ * @author carlo cancellieri
+ *
+ */
+public class FilterMosaicGetMapTest extends WMSFilterMosaicTestSupport {
+
+ final static String layer = WATTEMP.getLocalPart();
+
+ final static String BASE_URL = "wms?service=WMS&version=1.1.0" + "&request=GetMap&layers="
+ + layer + "&styles=" + "&bbox=0.237,40.562,14.593,44.558&width=200&height=80"
+ + "&srs=EPSG:4326&format=image/png";
+
+ final static String MIME = "image/png";
+
+ // specifying default filter
+ final static String cql_filter = "elevation=100 AND ingestion=\'2008-10-31T00:00:00.000Z\'";
+
+ public void testAsCQL() throws Exception {
+ // CASE 'MOSAIC WITH DEFAULT FILTERS'
+
+ // setting the default filter
+ super.setupMosaicFilter(cql_filter, layer);
+
+ // get mosaic using the default filter
+ BufferedImage image = getAsImage(BASE_URL, "image/png");
+
+ // at this elevation the pixel is black
+ assertPixel(image, 36, 31, new Color(0, 0, 0));
+ assertPixel(image, 68, 72, new Color(240, 240, 255));
+
+ }
+
+ public void testCaseDefault() throws Exception {
+ // CASE 'MOSAIC WITHOUT FILTERS'
+
+ // disable the default filter
+ super.setupMosaicFilter("", layer);
+
+ // get mosaic without the default filter
+ BufferedImage image = getAsImage(BASE_URL, "image/png");
+
+ // at this elevation the pixel is black
+ assertPixel(image, 36, 31, new Color(246, 246, 255));
+ assertPixel(image, 68, 72, new Color(255, 182, 182));
+ }
+
+ public void testCaseElev100andIngestion31Oct() throws Exception {
+ // CASE 'MOSAIC WITH FILTERS'
+
+ // overriding the default filter using cql_filter parameter
+ BufferedImage image = getAsImage(BASE_URL
+ + "&cql_filter=elevation=100 AND ingestion=\'2008-10-31T00:00:00.000Z\'",
+ "image/png");
+
+ // setting the default filter
+ super.setupMosaicFilter(cql_filter, layer);
+
+ // at this elevation the pixel is black
+ assertPixel(image, 36, 31, new Color(0, 0, 0));
+ assertPixel(image, 68, 72, new Color(240, 240, 255));
+ }
+
+ public void testCaseElev100andIngestion01Nov() throws Exception {
+
+ // CASE 'MOSAIC WITH FILTERS'
+
+ // overriding the default filter using cql_filter parameter
+ BufferedImage image = getAsImage(BASE_URL
+ + "&cql_filter=elevation=100 AND ingestion=\'2008-11-01T00:00:00.000Z\'",
+ "image/png");
+
+ // setting the default filter
+ super.setupMosaicFilter(cql_filter, layer);
+
+ // at this elevation the pixel is black
+ assertPixel(image, 36, 31, new Color(0, 0, 0));
+ assertPixel(image, 68, 72, new Color(246, 246, 255));
+
+ }
+
+ public void testCaseElev0andIngestion31Oct() throws Exception {
+ // CASE 'MOSAIC WITH FILTERS'
+
+ // overriding the default filter using cql_filter parameter
+ BufferedImage image = getAsImage(BASE_URL
+ + "&cql_filter=elevation=0 AND ingestion=\'2008-10-31T00:00:00.000Z\'", "image/png");
+
+ // setting the default filter
+ super.setupMosaicFilter(cql_filter, layer);
+
+ // should be similar to the default, but with different shades of color
+ assertPixel(image, 36, 31, new Color(246, 246, 255));
+ assertPixel(image, 68, 72, new Color(255, 182, 182));
+ }
+
+ public void testCaseElev0andIngestion01Nov() throws Exception {
+ // CASE 'MOSAIC WITH FILTERS'
+
+ // overriding the default filter using cql_filter parameter
+ BufferedImage image = getAsImage(BASE_URL
+ + "&cql_filter=elevation=0 AND ingestion=\'2008-11-01T00:00:00.000Z\'", "image/png");
+
+ // setting the default filter
+ super.setupMosaicFilter(cql_filter, layer);
+
+ assertPixel(image, 36, 31, new Color(246, 246, 255));
+ // and this one a light blue, but slightly darker than before
+ assertPixel(image, 68, 72, new Color(255, 185, 185));
+
+ }
+
+}
Something went wrong with that request. Please try again.