public void testTimeKVPNow() throws Exception { String queryString ="request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff" + "&bbox=0.237,40.562,14.593,44.558&crs=EPSG:4326&width=25&height=25&time=now" + "&coverage=" + getLayerId(WATTEMP); MockHttpServletResponse response = getAsServletResponse("wcs?" + queryString); checkTimeCurrent(response); }
@Test public void testDeferredLoading() throws Exception { Map<String, Object> raw = baseMap(); final String getLayerId = getLayerId(SPATIO_TEMPORAL); raw.put("sourcecoverage", getLayerId); raw.put("format", "image/tiff"); raw.put("BBox", "-90,-180,90,180"); raw.put("crs", "EPSG:4326"); raw.put("resx", "0.001"); raw.put("resy", "0.001"); GridCoverage[] coverages = executeGetCoverageKvp(raw); assertEquals(1, coverages.length); assertDeferredLoading(coverages[0].getRenderedImage()); }
@Test public void testDeferredLoading() throws Exception { Map<String, Object> raw = baseMap(); final String getLayerId = getLayerId(SPATIO_TEMPORAL); raw.put("identifier", getLayerId); raw.put("format", "image/tiff"); raw.put("BoundingBox", "-90,-180,90,180,urn:ogc:def:crs:EPSG:6.6:4326"); raw.put("store", "false"); raw.put("GridBaseCRS", "urn:ogc:def:crs:EPSG:6.6:4326"); GridCoverage[] coverages = executeGetCoverageKvp(raw); assertEquals(1, coverages.length); assertDeferredLoading(coverages[0].getRenderedImage()); }
@Test public void testTimeKVPNow() throws Exception { String queryString = "request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff" + "&bbox=0.237,40.562,14.593,44.558&crs=EPSG:4326&width=25&height=25&time=now" + "&coverage=" + getLayerId(WATTEMP); MockHttpServletResponse response = getAsServletResponse("wcs?" + queryString); checkPixelValue(response, 10, 10, 18.2849999185419); }
@Test public void testTimeFirstKVP() throws Exception { String queryString = "request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff" + "&bbox=0.237,40.562,14.593,44.558&crs=EPSG:4326&width=25&height=25&time=2008-10-31T00:00:00.000Z" + "&coverage=" + getLayerId(WATTEMP); MockHttpServletResponse response = getAsServletResponse("wcs?" + queryString); checkPixelValue(response, 10, 10, 18.2659999176394); }
@Test public void testTimeInputLimitsDefault() throws Exception { String queryString = "&request=getcoverage&service=wcs&version=1.1.1&&format=image/geotiff" + "&BoundingBox=-45,146,-42,147,urn:ogc:def:crs:EPSG:6.6:4326&timeSequence=2010-01-01/2011-01-01/P1D"; Document dom = getAsDOM("wcs/BlueMarble/wcs?identifier=" + getLayerId(TASMANIA_BM) + queryString); // print(dom); String text = checkOws11Exception(dom, ServiceException.INVALID_PARAMETER_VALUE, "time"); assertThat(text, containsString("More than 100 times")); }
@Test public void testKvpBasic() throws Exception { Map<String, Object> raw = baseMap(); final String getLayerId = getLayerId(TASMANIA_BM); raw.put("identifier", getLayerId); raw.put("format", "image/tiff"); raw.put("BoundingBox", "-90,-180,90,180,urn:ogc:def:crs:EPSG:6.6:4326"); raw.put("store", "false"); raw.put("GridBaseCRS", "urn:ogc:def:crs:EPSG:6.6:4326"); GridCoverage[] coverages = executeGetCoverageKvp(raw); assertEquals(1, coverages.length); GridCoverage2D coverage = (GridCoverage2D) coverages[0]; assertEquals( CRS.decode("urn:ogc:def:crs:EPSG:6.6:4326"), coverage.getEnvelope().getCoordinateReferenceSystem()); }
@Test public void testAntimeridianWorld() throws Exception { // for the moment, just make sure we don't die and return something, see Map<String, Object> raw = baseMap(); final String getLayerId = getLayerId(WORLD); raw.put("identifier", getLayerId); raw.put("format", "image/geotiff"); raw.put("BoundingBox", "175,10,-175,20,urn:ogc:def:crs:OGC:1.3:CRS84"); raw.put("store", "false"); // raw.put("GridBaseCRS", "urn:ogc:def:crs:EPSG:6.6:4326"); GridCoverage[] coverages = executeGetCoverageKvp(raw); assertEquals(1, coverages.length); GridCoverage2D coverage = (GridCoverage2D) coverages[0]; assertEquals( CRS.decode("urn:ogc:def:crs:EPSG:6.6:4326"), coverage.getEnvelope().getCoordinateReferenceSystem()); }
public void testTimeFirstKVP() throws Exception { setupRasterDimension(ResourceInfo.ELEVATION, DimensionPresentation.LIST, null); setupRasterDimension(ResourceInfo.ELEVATION, DimensionPresentation.LIST, null); String queryString ="request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff" + "&bbox=0.237,40.562,14.593,44.558&crs=EPSG:4326&width=25&height=25&time=2008-10-31T00:00:00.000Z" + "&coverage=" + getLayerId(WATTEMP); MockHttpServletResponse response = getAsServletResponse("wcs?" + queryString); checkTimeFirst(response); }
@Test public void testWrongGridOrigin() throws Exception { Map<String, Object> raw = baseMap(); final String getLayerId = getLayerId(TASMANIA_BM); raw.put("identifier", getLayerId); raw.put("format", "image/geotiff"); raw.put("BoundingBox", "-45,146,-42,147,urn:ogc:def:crs:EPSG:6.6:4326"); raw.put("GridOrigin", "12,13,14"); try { executeGetCoverageKvp(raw); fail("We should have had a WcsException here?"); } catch (WcsException e) { assertEquals(InvalidParameterValue.name(), e.getCode()); assertEquals("GridOrigin", e.getLocator()); } }
@Test public void testGEOS6540_2() throws Exception { String queryString = "wcs?sourcecoverage=" + getLayerId(MOSAIC) + "&request=getcoverage" + "&service=wcs&version=1.0.0&format=ARCGRID&crs=EPSG:4326" + "&bbox=0,0,1,1&width=50&height=60"; MockHttpServletResponse response = getAsServletResponse(queryString); String content = response.getContentAsString(); assertEquals("text/plain", response.getContentType()); assertTrue( content.startsWith( "NCOLS 50" + System.lineSeparator() + "NROWS 60" + System.lineSeparator())); assertEquals( "inline; filename=sf:rasterFilter.asc", response.getHeader("Content-Disposition")); }
@Test public void testDefaultGridOrigin() throws Exception { Map<String, Object> raw = new HashMap<String, Object>(baseMap()); final String getLayerId = getLayerId(TASMANIA_BM); raw.put("identifier", getLayerId); raw.put("format", "image/geotiff"); // use a bbox larger than the source raw.put("BoundingBox", "-45,146,-42,149,urn:ogc:def:crs:EPSG:6.6:4326"); GridCoverage[] coverages = executeGetCoverageKvp(raw); AffineTransform2D tx = (AffineTransform2D) coverages[0].getGridGeometry().getGridToCRS(); // take into account the "pixel is area" convention assertEquals(0.0, tx.getTranslateX() + tx.getScaleX() / 2, 1e-9); assertEquals(0.0, tx.getTranslateY() + tx.getScaleY() / 2, 1e-9); }
@Test public void testWrongFormatParams() throws Exception { Map<String, Object> raw = baseMap(); final String getLayerId = getLayerId(TASMANIA_BM); raw.put("identifier", getLayerId); raw.put("format", "SuperCoolFormat"); raw.put("BoundingBox", "-45,146,-42,147,urn:ogc:def:crs:EPSG:6.6:4326"); try { executeGetCoverageKvp(raw); fail("When did we learn to encode SuperCoolFormat?"); } catch (WcsException e) { assertEquals(InvalidParameterValue.toString(), e.getCode()); assertEquals("format", e.getLocator()); } }
@Test public void testGEOS6540_1() throws Exception { String queryString = "wcs?sourcecoverage=" + getLayerId(MOSAIC) + "&request=getcoverage" + "&service=wcs&version=1.0.0&format=ArcGrid&crs=EPSG:4326" + "&bbox=0,0,1,1&width=50&height=60"; MockHttpServletResponse response = getAsServletResponse(queryString); assertEquals("text/plain", response.getContentType()); String content = response.getContentAsString(); assertTrue(content.startsWith("NCOLS 50" + System.lineSeparator() + "NROWS 60")); assertEquals( "inline; filename=sf:rasterFilter.asc", response.getHeader("Content-Disposition")); }
@Test public void testSpatialSubsetOnePixel() throws Exception { Map<String, Object> raw = new HashMap<String, Object>(baseMap()); final String getLayerId = getLayerId(RAIN); raw.put("identifier", getLayerId); raw.put("format", "image/geotiff"); // this bbox is inside, and smaller than a single pixel raw.put("BoundingBox", "-45,146,-42,149,urn:ogc:def:crs:EPSG:6.6:4326"); GridCoverage[] coverages = executeGetCoverageKvp(raw); Envelope envelope = coverages[0].getEnvelope(); assertEquals(-45d, envelope.getMinimum(0), 1e-6); assertEquals(-42d, envelope.getMaximum(0), 1e-6); assertEquals(146d, envelope.getMinimum(1), 1e-6); assertEquals(149d, envelope.getMaximum(1), 1e-6); }
public void testRasterFilterRed() throws Exception { String queryString = "wcs?sourcecoverage=" + getLayerId(MOSAIC) + "&request=getcoverage" + "&service=wcs&version=1.0.0&format=image/tiff&crs=EPSG:4326" + "&bbox=0,0,1,1&CQL_FILTER=location like 'red%25'&width=150&height=150"; MockHttpServletResponse response = getAsServletResponse(queryString); RenderedImage image = readTiff(response); // check the pixel int[] pixel = new int[3]; image.getData().getPixel(0, 0, pixel); assertEquals(255, pixel[0]); assertEquals(0, pixel[1]); assertEquals(0, pixel[2]); }
private void testInterpolationMethods(String method) throws Exception { String queryString = "wcs?identifier=" + getLayerId(MOSAIC) + "&request=getcoverage" + "&service=wcs&version=1.1.1&&format=image/tiff" + "&BoundingBox=0,0,1,1,urn:ogc:def:crs:EPSG:6.6:4326" + "&RangeSubset=contents:" + method; MockHttpServletResponse response = getAsServletResponse(queryString); try { this.getMultipart(response); assertEquals(response.getStatus(), 200); } catch (ClassCastException e) { assertEquals("application/xml", response.getContentType()); } } }
public void testRasterFilterGreen() throws Exception { String queryString = "wcs?sourcecoverage=" + getLayerId(MOSAIC) + "&request=getcoverage" + "&service=wcs&version=1.0.0&&format=image/tiff&crs=EPSG:4326" + "&bbox=0,0,1,1&CQL_FILTER=location like 'green%25'&width=150&height=150"; MockHttpServletResponse response = getAsServletResponse(queryString); // make sure we can read the coverage back RenderedImage image = readTiff(response); // check the pixel int[] pixel = new int[3]; image.getData().getPixel(0, 0, pixel); assertEquals(0, pixel[0]); assertEquals(255, pixel[1]); assertEquals(0, pixel[2]); }
@Test public void testRasterFilterRed() throws Exception { String queryString = "wcs?sourcecoverage=" + getLayerId(MOSAIC) + "&request=getcoverage" + "&service=wcs&version=1.0.0&format=image/tiff&crs=EPSG:4326" + "&bbox=0,0,1,1&CQL_FILTER=location like 'red%25'&width=150&height=150"; MockHttpServletResponse response = getAsServletResponse(queryString); RenderedImage image = readTiff(response); // check the pixel int[] pixel = new int[3]; image.getData().getPixel(0, 0, pixel); assertEquals(255, pixel[0]); assertEquals(0, pixel[1]); assertEquals(0, pixel[2]); }
@Test public void testRasterFilterGreen() throws Exception { String queryString = "wcs?sourcecoverage=" + getLayerId(MOSAIC) + "&request=getcoverage" + "&service=wcs&version=1.0.0&&format=image/tiff&crs=EPSG:4326" + "&bbox=0,0,1,1&CQL_FILTER=location like 'green%25'&width=150&height=150"; MockHttpServletResponse response = getAsServletResponse(queryString); // make sure we can read the coverage back RenderedImage image = readTiff(response); // check the pixel int[] pixel = new int[3]; image.getData().getPixel(0, 0, pixel); assertEquals(0, pixel[0]); assertEquals(255, pixel[1]); assertEquals(0, pixel[2]); }