/** * reads a deegree WCS configuration file and performs a GetCoverage request Steps: * * <ul> * <li>read configuration file * <li>read a GetCoverage request object * <li>perform the request * </ul> */ public void _testGetCoverage1() { try { WCSConfiguration configuration = WCSConfiguration.create(Configuration.getWCSConfigurationURL()); WCService service = new WCService(configuration); StringBuffer sb = new StringBuffer(); sb.append(Configuration.PROTOCOL + "://" + Configuration.HOST) .append(':') .append(Configuration.PORT) .append(Configuration.WCS_WEB_CONTEXT) .append('/') .append(Configuration.WCS_SERVLET); String req = "<?xml version='1.0' encoding='UTF-8'?><GetCoverage " + "xmlns='http://www.opengis.net/wcs' xmlns:gml='http://www.opengis.net/gml' " + "service='WCS' version='1.0.0'><sourceCoverage>Mapneatline</sourceCoverage>" + "<domainSubset><spatialSubset><gml:Envelope srsName='EPSG:4326'>" + "<gml:pos dimension='2'>-1,-1</gml:pos><gml:pos dimension='2'>1,1" + "</gml:pos></gml:Envelope><gml:Grid dimension='2'><gml:limits>" + "<gml:GridEnvelope><gml:low>0 0</gml:low><gml:high>300 300</gml:high>" + "</gml:GridEnvelope></gml:limits><gml:axisName>x</gml:axisName>" + "<gml:axisName>y</gml:axisName></gml:Grid></spatialSubset></domainSubset>" + "<output><crs>EPSG:4326</crs><format>jpeg</format></output></GetCoverage>"; StringReader reader = new StringReader(req); Document doc = XMLTools.parse(reader); GetCoverage desc = (GetCoverage) OGCRequestFactory.createFromXML(doc); ResultCoverage o = (ResultCoverage) service.doService(desc); BufferedImage bi = ((AbstractGridCoverage) o.getCoverage()).getAsImage(500, 500); FileOutputStream fos = new FileOutputStream(Configuration.getWCSBaseDir().getPath() + "/kannweg1.tif"); ImageUtils.saveImage(bi, fos, "tif", 1); fos.close(); } catch (Exception e) { fail(StringTools.stackTraceToString(e)); } }
/** * reads a deegree WCS configuration file and performs a GetCoverage request Steps: * * <ul> * <li>read configuration file * <li>read a GetCoverage request object * <li>perform the request * </ul> */ public void _testGetCoverage3() { try { WCSConfiguration configuration = WCSConfiguration.create(Configuration.getWCSConfigurationURL()); WCService service = new WCService(configuration); Map<String, String> map = new HashMap<String, String>(); map.put("SERVICE", "WCS"); map.put("REQUEST", "GetCoverage"); map.put("VERSION", "1.0.0"); map.put("COVERAGE", "europe"); map.put("CRS", "EPSG:4326"); map.put("BBOX", "-5,40,20,60"); map.put("WIDTH", "800"); map.put("HEIGHT", "800"); map.put("FORMAT", "jpeg"); // StringBuffer sb = new StringBuffer(); // sb.append(Configuration.PROTOCOL + "://" + Configuration.HOST) // .append(':').append(Configuration.PORT).append('/') // .append(Configuration.WCS_WEB_CONTEXT).append('/') // .append(Configuration.WCS_SERVLET).append("?service=WCS&") // .append("request=GetCoverage&version=1.0.0&coverage=europe&") // .append( "crs=EPSG:4326&BBOX=-5,40,20,60&Width=800&height=800&") // .append("format=jpeg"); GetCoverage desc = GetCoverage.create(map); ResultCoverage o = (ResultCoverage) service.doService(desc); BufferedImage bi = ((AbstractGridCoverage) o.getCoverage()).getAsImage(800, 800); FileOutputStream fos = new FileOutputStream(Configuration.getWCSBaseDir().getPath() + "/kannweg3.tif"); ImageUtils.saveImage(bi, fos, "tif", 1); fos.close(); } catch (Exception e) { fail(StringTools.stackTraceToString(e)); } }
/** * reads a deegree WCS configuration file and performs a GetCoverage request. same as * testGetCoverage1() but uses nameIndexed data source Steps: * * <ul> * <li>read configuration file * <li>read a GetCoverage request object * <li>perform the request * </ul> */ public void _testGetCoverage2() { try { WCSConfiguration configuration = WCSConfiguration.create(Configuration.getWCSConfigurationURL()); WCService service = new WCService(configuration); Map<String, String> map = new HashMap<String, String>(); map.put("SERVICE", "WCS"); map.put("REQUEST", "GetCoverage"); map.put("VERSION", "1.0.0"); map.put("COVERAGE", "dem"); map.put("CRS", "EPSG:4326"); map.put("BBOX", "-122.6261,37.4531,-122.0777,38.0"); map.put("WIDTH", "828"); map.put("HEIGHT", "823"); map.put("FORMAT", "GeoTiff"); // StringBuffer sb = new StringBuffer(); // sb.append(Configuration.PROTOCOL + "://" + Configuration.HOST).append(':').append( // Configuration.PORT).append('/').append(Configuration.WCS_WEB_CONTEXT).append( // '/').append(Configuration.WCS_SERVLET).append("?service=WCS&").append( // "request=GetCoverage&version=1.0.0&coverage=dem&").append( // "crs=EPSG:4326&BBOX=-122.6261,37.4531,-122.0777,38.0&Width=828&height=823&") // .append("format=GeoTiff"); GetCoverage desc = GetCoverage.create(map); ResultCoverage o = (ResultCoverage) service.doService(desc); BufferedImage bi = ((AbstractGridCoverage) o.getCoverage()).getAsImage(828, 823); LOG.logInfo(o.toString()); FileOutputStream fos = new FileOutputStream(new URL(Configuration.getWCSBaseDir(), "/kannweg2.tif").getFile()); ImageUtils.saveImage(bi, fos, "tif", 1); fos.close(); } catch (Exception e) { fail(StringTools.stackTraceToString(e)); } }