String gridBaseCrs = gridCRS.getGridBaseCRS(); if (gridBaseCrs != null) { + " is not among the supported ones for coverage " + meta.getName(), WcsExceptionCode.InvalidParameterValue, "GridBaseCrs"); gridCRS.setGridBaseCRS(gridBaseCrs); } else { String code = GML2EncodingUtils.epsgCode(meta.getCrs()); gridCRS.setGridBaseCRS("urn:x-ogc:def:crs:EPSG:" + code); String gridTypeValue = gridCRS.getGridType(); GridType type = GridType.GT2dGridIn2dCrs; if (gridTypeValue != null) { gridCRS.setGridType(type.getXmlConstant()); String gridCS = gridCRS.getGridCS(); if (gridCS != null) { if (!gridCS.equalsIgnoreCase(GridCS.GCSGrid2dSquare.getXmlConstant())) gridCRS.setGridCS(GridCS.GCSGrid2dSquare.getXmlConstant()); crs = CRS.decode(gridCRS.getGridBaseCRS()); } catch (Exception e) { throw new WcsException("Could not understand crs " + gridCRS.getGridBaseCRS(), WcsExceptionCode.InvalidParameterValue, "GridBaseCRS"); if (!gridCRS.isSetGridOrigin() || gridCRS.getGridOrigin() == null) {
private OutputType parseOutputElement(Map kvp) throws Exception { final OutputType output = Wcs111Factory.eINSTANCE.createOutputType(); output.setGridCRS(Wcs111Factory.eINSTANCE.createGridCrsType()); // check and set store Boolean store = (Boolean) kvp.get("store"); if (store != null) output.setStore(store.booleanValue()); // check and set format String format = (String) kvp.get("format"); if (format == null) throw new WcsException("format parameter is mandatory", MissingParameterValue, "format"); output.setFormat(format); // set the other gridcrs properties final GridCrsType gridCRS = output.getGridCRS(); gridCRS.setGridBaseCRS((String) kvp.get("gridBaseCrs")); gridCRS.setGridType((String) kvp.get("gridType")); gridCRS.setGridCS((String) kvp.get("gridCS")); gridCRS.setGridOrigin((Double[]) kvp.get("GridOrigin")); gridCRS.setGridOffsets((Double[]) kvp.get("GridOffsets")); return output; }
gridCRS.setGridBaseCRS((String) kvp.get("gridBaseCrs")); gridType = gridCRS.getGridType(); gridCRS.setGridType(gridType); gridCS = gridCRS.getGridCS(); gridCRS.setGridCS(gridCS); gridCRS.setGridOrigin((Double[]) kvp.get("GridOrigin")); gridCRS.setGridOffsets((Double[]) kvp.get("GridOffsets"));
assertEquals("urn:ogc:def:crs:EPSG:6.6:4326", gridCRS.getGridBaseCRS()); assertEquals("urn:ogc:def:method:WCS:1.1:2dSimpleGrid", gridCRS.getGridType()); assertEquals("urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS", gridCRS.getGridCS()); System.out.println(gridCRS.getGridOrigin().getClass() + ": " + gridCRS.getGridOrigin()); assertTrue(Arrays.equals(new Double[] {10.0, 20.0}, (Double[]) gridCRS.getGridOrigin())); assertTrue(Arrays.equals(new Double[] {1.0, 2.0}, (Double[]) gridCRS.getGridOffsets()));
if (gridCRS != null) { if (gridToCRS instanceof IdentityTransform) { if (gridCRS.getGridType().equals(GridType.GT2dSimpleGrid.getXmlConstant()) || gridCRS.getGridType() .equals(GridType.GT2dGridIn2dCrs.getXmlConstant())) offsets = new Double[] {1.0, -1.0}; } else { AffineTransform2D affine = (AffineTransform2D) gridToCRS; if (gridCRS.getGridType().equals(GridType.GT2dSimpleGrid.getXmlConstant()) || gridCRS.getGridType() .equals(GridType.GT2dGridIn2dCrs.getXmlConstant())) offsets = new Double[] {affine.getScaleX(), affine.getScaleY()}; || gridCRS.getGridType().equals(GridType.GT2dSimpleGrid.getXmlConstant()) || gridCRS.getGridType().equals(GridType.GT2dGridIn2dCrs.getXmlConstant())) { offsets = new Double[] {scaleX, scaleY}; } else {
@Test public void testBasic() throws Exception { Map<String, Object> raw = baseMap(); final String layerId = getLayerId(TASMANIA_BM); raw.put("identifier", layerId); raw.put("format", "image/tiff"); raw.put("BoundingBox", "-45,146,-42,147"); raw.put("store", "false"); raw.put("GridBaseCRS", "urn:ogc:def:crs:EPSG:6.6:4326"); GetCoverageType getCoverage = (GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw); assertEquals(layerId, getCoverage.getIdentifier().getValue()); assertEquals("image/tiff", getCoverage.getOutput().getFormat()); assertFalse(getCoverage.getOutput().isStore()); assertEquals( "urn:ogc:def:crs:EPSG:6.6:4326", getCoverage.getOutput().getGridCRS().getGridBaseCRS()); }
@Test public void testGridCS() throws Exception { Map<String, Object> raw = baseMap(); final String layerId = getLayerId(TASMANIA_BM); raw.put("identifier", layerId); raw.put("format", "image/tiff"); raw.put("BoundingBox", "-45,146,-42,147"); raw.put("GridCS", GridCS.GCSGrid2dSquare.getXmlConstant()); GetCoverageType getCoverage = (GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw); assertEquals( GridCS.GCSGrid2dSquare.getXmlConstant(), getCoverage.getOutput().getGridCRS().getGridCS()); raw.put("GridCS", GridCS.GCSGrid2dSquare.getXmlConstant().toUpperCase()); getCoverage = (GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw); assertEquals( GridCS.GCSGrid2dSquare.getXmlConstant(), getCoverage.getOutput().getGridCRS().getGridCS()); raw.put("GridCS", "Hoolabaloola"); try { reader.read(reader.createRequest(), parseKvp(raw), raw); fail("We should have had a WcsException here?"); } catch (WcsException e) { assertEquals(InvalidParameterValue.name(), e.getCode()); assertEquals("GridCS", e.getLocator()); } }
GetCoverageType getCoverage = (GetCoverageType) reader.read(reader.createRequest(), parseKvp(raw), raw); Double[] offsets = (Double[]) getCoverage.getOutput().getGridCRS().getGridOffsets(); assertEquals(2, offsets.length); assertEquals(0, Double.compare(10.5, (double) offsets[0]));
Double[] origin = (Double[]) getCoverage.getOutput().getGridCRS().getGridOrigin(); assertEquals(2, origin.length); assertEquals(0, Double.compare(10.5, (double) origin[0]));
targetCRS = reader.getOriginalEnvelope().getCoordinateReferenceSystem(); else targetCRS = CRS.decode(gridCRS.getGridBaseCRS()); Double[] origin = (Double[]) gridCRS.getGridOrigin(); Double[] offsets = (Double[]) gridCRS.getGridOffsets(); if (gridCRS.getGridType().equals(GridType.GT2dSimpleGrid)) offsets = new Double[] { 1.0, 1.0 }; else } else { AffineTransform2D affine = (AffineTransform2D) gridToCRS; if (gridCRS.getGridType().equals(GridType.GT2dSimpleGrid)) offsets = new Double[] { affine.getScaleX(), affine.getScaleY() }; else if (gridCRS.getGridType().equals(GridType.GT2dSimpleGrid.getXmlConstant())) { tx = new AffineTransform(offsets[0], 0, 0, offsets[1], origin[0], origin[1]); } else {
assertEquals( GridType.GT2dGridIn2dCrs.getXmlConstant(), getCoverage.getOutput().getGridCRS().getGridType()); assertEquals( GridType.GT2dSimpleGrid.getXmlConstant(), getCoverage.getOutput().getGridCRS().getGridType()); assertEquals( GridType.GT2dSimpleGrid.getXmlConstant(), getCoverage.getOutput().getGridCRS().getGridType());
String gridBaseCrs = gridCRS.getGridBaseCRS(); if (gridBaseCrs != null) { WcsExceptionCode.InvalidParameterValue, "GridBaseCrs"); gridCRS.setGridBaseCRS(gridBaseCrs); } else { String code = GML2EncodingUtils.epsgCode(meta.getCRS()); gridCRS.setGridBaseCRS("urn:x-ogc:def:crs:EPSG:" + code); String gridTypeValue = gridCRS.getGridType(); GridType type = GridType.GT2dGridIn2dCrs; if (gridTypeValue != null) { gridCRS.setGridType(type.getXmlConstant()); String gridCS = gridCRS.getGridCS(); if (gridCS != null) { if (!gridCS.equalsIgnoreCase(GridCS.GCSGrid2dSquare.getXmlConstant())) gridCRS.setGridCS(GridCS.GCSGrid2dSquare.getXmlConstant()); crs = CRS.decode(gridCRS.getGridBaseCRS()); } catch (Exception e) { throw new WcsException( "Could not understand crs " + gridCRS.getGridBaseCRS(), WcsExceptionCode.InvalidParameterValue, "GridBaseCRS");
targetCRS = reader.getOriginalEnvelope().getCoordinateReferenceSystem(); } else { targetCRS = CRS.decode(gridCRS.getGridBaseCRS()); double pixelSizeY; if (gridCRS != null) { Double[] origin = (Double[]) gridCRS.getGridOrigin(); Double[] offsets = (Double[]) gridCRS.getGridOffsets(); if (gridCRS.getGridType().equals(GridType.GT2dSimpleGrid.getXmlConstant())) { tx = new AffineTransform(offsets[0], 0, 0, offsets[1], origin[0], origin[1]); } else if (gridCRS.getGridType() .equals(GridType.GT2dGridIn2dCrs.getXmlConstant())) { tx =