forked from geoserver/geoserver
/
FilterMosaicGetMapTest.java
127 lines (91 loc) · 4.33 KB
/
FilterMosaicGetMapTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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));
}
}