@Test public void testAntimeridianTaz() 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(TASMANIA_BM); raw.put("identifier", getLayerId); raw.put("format", "image/geotiff"); raw.put("store", "false"); // complete coverage from left side of request bbox raw.put("BoundingBox", "145,-80,-175,0,urn:ogc:def:crs:OGC:1.3:CRS84"); executeGetCoverageKvp(raw); // partial coverage from left side of request bbox raw.put("BoundingBox", "147,-80,-175,0,urn:ogc:def:crs:OGC:1.3:CRS84"); executeGetCoverageKvp(raw); // partial coverage from both left and right side raw.put("BoundingBox", "147.2,-80,147,0,urn:ogc:def:crs:OGC:1.3:CRS84"); executeGetCoverageKvp(raw); // partial coverage from right side raw.put("BoundingBox", "175,-80,147,0,urn:ogc:def:crs:OGC:1.3:CRS84"); executeGetCoverageKvp(raw); // full coverage from right side raw.put("BoundingBox", "175,-80,150,0,urn:ogc:def:crs:OGC:1.3:CRS84"); executeGetCoverageKvp(raw); }
public void testOutputLimits() throws Exception { try { // ridicolous limit, just one byte setOutputLimit(1); String queryString = "&request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff&bbox=146,-45,147,-42" + "&crs=EPSG:4326&width=150&height=150"; Document dom = getAsDOM("wcs/BlueMarble/wcs?sourcecoverage=" + getLayerId(TASMANIA_BM) + queryString); // print(dom); // check it's an error, check we're getting it because of the output limits assertEquals("ServiceExceptionReport", dom.getDocumentElement().getNodeName()); String error = xpath.evaluate( "/ServiceExceptionReport/ServiceException/text()", dom).trim(); assertTrue(error.matches(".*generate too much data.*")); } finally { setOutputLimit(0); } }
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]); }
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); }
public void testTimeSecond() throws Exception { String request = getWaterTempTimeRequest("2008-11-01T00:00:00.000Z"); MockHttpServletResponse response = postAsServletResponse("wcs", request); checkTimeCurrent(response); }
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 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 testTimeRangeKVP() throws Exception { setupRasterDimension(TIMERANGES, ResourceInfo.TIME, DimensionPresentation.LIST, null); setupRasterDimension(TIMERANGES, ResourceInfo.ELEVATION, DimensionPresentation.LIST, null); String baseUrl = "wcs?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" + "&coverage=" + getLayerId(TIMERANGES); // last range MockHttpServletResponse response = getAsServletResponse( baseUrl + "&TIME=2008-11-05T00:00:00.000Z/2008-11-06T12:00:00.000Z"); assertEquals("image/tiff", response.getContentType()); checkPixelValue(response, 10, 10, 13.337999683572); // middle hole, no data --> we should get back an exception Document dom = getAsDOM(baseUrl + "&TIME=2008-11-04T12:00:00.000Z/2008-11-04T16:00:00.000Z"); // print(dom); XMLAssert.assertXpathEvaluatesTo("1", "count(//ServiceExceptionReport)", dom); // first range response = getAsServletResponse( baseUrl + "&TIME=2008-10-31T12:00:00.000Z/2008-10-31T16:00:00.000Z"); assertEquals("image/tiff", response.getContentType()); checkPixelValue(response, 10, 10, 18.2659999176394); }
public void testInputLimits() throws Exception { try { // ridicolous limit, just one byte setInputLimit(1); String queryString = "&request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff&bbox=146,-45,147,-42" + "&crs=EPSG:4326&width=150&height=150"; Document dom = getAsDOM("wcs/BlueMarble/wcs?sourcecoverage=" + getLayerId(TASMANIA_BM) + queryString); // print(dom); // check it's an error, check we're getting it because of the input limits assertEquals("ServiceExceptionReport", dom.getDocumentElement().getNodeName()); String error = xpath.evaluate( "/ServiceExceptionReport/ServiceException/text()", dom).trim(); assertTrue(error.matches(".*read too much data.*")); } finally { setInputLimit(0); } }
@Test public void testOutputLimits() throws Exception { try { // ridicolous limit, just one byte setOutputLimit(1); 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"; Document dom = getAsDOM("wcs/wcs?identifier=" + getLayerId(TASMANIA_BM) + queryString); // print(dom); // check it's an error, check we're getting it because of the output limits assertEquals("ows:ExceptionReport", dom.getDocumentElement().getNodeName()); String error = xpath.evaluate( "/ows:ExceptionReport/ows:Exception/ows:ExceptionText/text()", dom); assertTrue(error.matches(".*generate too much data.*")); } finally { setOutputLimit(0); } }
@Test public void testInputLimits() throws Exception { try { // ridicolous limit, just one byte setInputLimit(1); String queryString = "&request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff&bbox=146,-45,147,-42" + "&crs=EPSG:4326&width=150&height=150"; Document dom = getAsDOM( "wcs/BlueMarble/wcs?sourcecoverage=" + getLayerId(TASMANIA_BM) + queryString); // print(dom); // check it's an error, check we're getting it because of the input limits assertEquals("ServiceExceptionReport", dom.getDocumentElement().getNodeName()); String error = xpath.evaluate("/ServiceExceptionReport/ServiceException/text()", dom).trim(); assertTrue(error.matches(".*read too much data.*")); } finally { setInputLimit(0); } }
@Test public void testTimeTooMany() throws Exception { GeoServer gs = getGeoServer(); WCSInfo wcs = gs.getService(WCSInfo.class); wcs.setMaxRequestedDimensionValues(2); gs.save(wcs); try { 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-31/2008-11-31/PT1H" + "&coverage=" + getLayerId(WATTEMP); MockHttpServletResponse response = getAsServletResponse("wcs?" + queryString); assertEquals("application/vnd.ogc.se_xml", response.getContentType()); Document dom = dom(response, true); // print(dom); String text = checkLegacyException(dom, ServiceException.INVALID_PARAMETER_VALUE, "time"); assertThat(text, containsString("More than 2 times")); } finally { wcs.setMaxRequestedDimensionValues( DimensionInfo.DEFAULT_MAX_REQUESTED_DIMENSION_VALUES); gs.save(wcs); } }
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()); } } }
@Test public void testWorkspaceQualified() 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"; ServletResponse r = getAsServletResponse("wcs?identifier=" + TASMANIA_BM.getLocalPart() + queryString); assertTrue(r.getContentType().startsWith("multipart/related")); Document dom = getAsDOM("cdf/wcs?identifier=" + TASMANIA_BM.getLocalPart() + queryString); assertEquals("ows:ExceptionReport", dom.getDocumentElement().getNodeName()); }
@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")); }
envelopeBuilder.append(newEnvelope.getMaximum(1)); Map<String, Object> raw = baseMap(); final String layerID = getLayerId(TASMANIA_BM); raw.put("sourcecoverage", layerID); raw.put("version", "1.0.0"); raw.put("resy", Double.toString(Math.abs(expectedTx.getScaleY()))); final GridCoverage[] coverages = executeGetCoverageKvp(raw); final GridCoverage2D result=(GridCoverage2D) coverages[0]; assertTrue(coverages.length==1); final AffineTransform2D tx = (AffineTransform2D) result.getGridGeometry().getGridToCRS(); assertEquals("resx",expectedTx.getScaleX(),tx.getScaleX(),1E-6); assertEquals("resx",Math.abs(expectedTx.getScaleY()),Math.abs(tx.getScaleY()),1E-6); assertEquals("w",180,gridEnvelope.getSpan(0)); assertEquals("h",180,gridEnvelope.getSpan(1)); assertEquals("grid envelope",expectedGridEnvelope, gridEnvelope);
@Test public void testReproject() throws Exception { Catalog catalog = getCatalog(); final String layerId = getLayerId(TASMANIA_BM); CoverageInfo ci = catalog.getCoverageByName(layerId); ci.getResponseSRS().add("EPSG:3857"); Map<String, Object> raw = baseMap(); raw.put("identifier", layerId); raw.put("format", "image/geotiff"); raw.put("BoundingBox", "-80,-180,80,180,urn:ogc:def:crs:EPSG:6.6:4326"); raw.put("GridBaseCRS", "EPSG:3857"); GridCoverage[] coverages = executeGetCoverageKvp(raw);
public void testLayerQualified() throws Exception { String queryString ="&request=getcoverage&service=wcs&version=1.0.0&format=image/geotiff&bbox=146,-45,147,-42"+ "&crs=EPSG:4326&width=150&height=150"; ServletResponse response = getAsServletResponse( "wcs/BlueMarble/wcs?sourcecoverage=BlueMarble"+queryString); assertTrue(response.getContentType().startsWith("image/tiff")); Document dom = getAsDOM( "wcs/DEM/wcs?sourcecoverage=BlueMarble"+queryString); assertEquals("ServiceExceptionReport", dom.getDocumentElement().getNodeName()); }
@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 testTimeInputLimitsCustom() throws Exception { GeoServer gs = getGeoServer(); WCSInfo wcs = gs.getService(WCSInfo.class); wcs.setMaxRequestedDimensionValues(2); gs.save(wcs); try { 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 2 times")); } finally { wcs.setMaxRequestedDimensionValues( DimensionInfo.DEFAULT_MAX_REQUESTED_DIMENSION_VALUES); gs.save(wcs); } }