attributes.addAttribute("", "crs", "crs", "", "urn:ogc:def:crs:OGC:1.3:CRS84"); } else { String urnIdentifier = urnIdentifier(crs); CoordinateReferenceSystem latlonCrs = CRS.decode(urnIdentifier); encodedEnvelope = new ReferencedEnvelope(CRS.transform(encodedEnvelope, latlonCrs)); "", Integer.toString(crs.getCoordinateSystem().getDimension())); start("ows:BoundingBox", attributes); element( "ows:LowerCorner", new StringBuffer( .append(encodedEnvelope.getLowerCorner().getOrdinate(1)) .toString()); element( "ows:UpperCorner", new StringBuffer( .append(encodedEnvelope.getUpperCorner().getOrdinate(1)) .toString()); end("ows:BoundingBox");
protected void handleInterpolationMethods(CoverageInfo ci) { start("wcs:InterpolationMethods"); for (Iterator it = ci.getInterpolationMethods().iterator(); it.hasNext(); ) { String method = (String) it.next(); String converted = METHOD_NAME_MAP.get(method); if (converted != null) element("wcs:InterpolationMethod", converted); } elementIfNotEmpty("wcs:Default", ci.getDefaultInterpolationMethod()); end("wcs:InterpolationMethods"); }
start("wcs:CoverageDescriptions", attributes); for (Iterator it = request.getIdentifier().iterator(); it.hasNext(); ) { String coverageId = (String) it.next(); handleCoverageDescription(ci); } catch (Exception e) { throw new RuntimeException( end("wcs:CoverageDescriptions");
attributes.addAttribute("", locationAtt, locationAtt, "", locationDef); start("wcs:CoverageDescriptions", attributes); for (Iterator it = request.getIdentifier().iterator(); it.hasNext();) { String coverageId = (String) it.next(); handleCoverageDescription(ci); } catch (Exception e) { throw new RuntimeException( end("wcs:CoverageDescriptions");
private void handleGridCRS(CoverageInfo ci) throws Exception { start("wcs:GridCRS"); element("wcs:GridBaseCRS", urnIdentifier(ci.getCrs())); element("wcs:GridType", GridType.GT2dGridIn2dCrs.getXmlConstant()); // TODO: go back to using the metadata once they can be trusted final LinearTransform tx = (LinearTransform) ci.getGrid().getGridToCRS(); final Matrix matrix = tx.getMatrix(); // origin StringBuffer origins = new StringBuffer(); for (int i = 0; i < matrix.getNumRow() - 1; i++) { origins.append(matrix.getElement(i, matrix.getNumCol() - 1)); if (i < matrix.getNumRow() - 2) origins.append(" "); } element("wcs:GridOrigin", origins.toString()); // offsets StringBuffer offsets = new StringBuffer(); for (int i = 0; i < matrix.getNumRow() - 1; i++) { for (int j = 0; j < matrix.getNumCol() - 1; j++) { offsets.append(matrix.getElement(i, j)); if (j < matrix.getNumCol() - 2) offsets.append(" "); } if (i < matrix.getNumRow() - 2) offsets.append(" "); } element("wcs:GridOffsets", offsets.toString()); element("wcs:GridCS", "urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS"); end("wcs:GridCRS"); }
private void handleRange(CoverageInfo ci) { start("wcs:Range"); // at the moment we only handle single field coverages start("wcs:Field"); CoverageDimension[] dimensions = ci.getDimensions(); element("wcs:Identifier", "contents"); // the output domain of the field start("wcs:Definition"); NumberRange range = getCoverageRange(dimensions); if (range == null || range.isEmpty()) { element("wcs:AnyValue", ""); } else { start("ows:AllowedValues"); start("ows:Range"); element("ows:MinimumValue", Double.toString(range.getMinimum())); element("ows:MaximumValue", Double.toString(range.getMaximum())); end("ows:Range"); end("ows:AllowedValues"); } end("wcs:Definition"); handleNullValues(dimensions); handleInterpolationMethods(ci); handleAxis(ci); end("wcs:Field"); end("wcs:Range"); }
protected void handleGridCRS(CoverageInfo ci) throws Exception { start("wcs:GridCRS"); element("wcs:GridBaseCRS", urnIdentifier(ci.getCRS())); element("wcs:GridType", GridType.GT2dGridIn2dCrs.getXmlConstant()); // TODO: go back to using the metadata once they can be trusted final LinearTransform tx = (LinearTransform) ci.getGrid().getGridToCRS(); final Matrix matrix = tx.getMatrix(); // origin StringBuffer origins = new StringBuffer(); for (int i = 0; i < matrix.getNumRow() - 1; i++) { origins.append(matrix.getElement(i, matrix.getNumCol() - 1)); if (i < matrix.getNumRow() - 2) origins.append(" "); } element("wcs:GridOrigin", origins.toString()); // offsets StringBuffer offsets = new StringBuffer(); for (int i = 0; i < matrix.getNumRow() - 1; i++) { for (int j = 0; j < matrix.getNumCol() - 1; j++) { offsets.append(matrix.getElement(i, j)); if (j < matrix.getNumCol() - 2) offsets.append(" "); } if (i < matrix.getNumRow() - 2) offsets.append(" "); } element("wcs:GridOffsets", offsets.toString()); element("wcs:GridCS", "urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS"); end("wcs:GridCRS"); }
private void handleSupportedFormats(CoverageInfo ci) throws Exception { // gather all the formats for this coverage Set<String> formats = new HashSet<String>(); for (Iterator it = ci.getSupportedFormats().iterator(); it.hasNext();) { String format = (String) it.next(); // wcs 1.1 requires mime types, not format names try { CoverageResponseDelegate delegate = CoverageResponseDelegateFactory .encoderFor(format); String formatMime = delegate.getMimeFormatFor(format); if(formatMime != null) formats.add(formatMime); } catch(Exception e) { // no problem, we just want to avoid people writing HALLABALOOLA in the // supported formats section of the coverage config and then break the // describe response } } // sort them List<String> sortedFormats = new ArrayList<String>(formats); Collections.sort(sortedFormats); for (String format : sortedFormats) { element("wcs:SupportedFormat", format); } }
private void handleBoundingBox(GeneralEnvelope envelope, boolean wgsLonLat) throws Exception { final AttributesImpl attributes = new AttributesImpl(); final CoordinateReferenceSystem crs = envelope.getCoordinateReferenceSystem(); GeneralEnvelope encodedEnvelope = envelope; if (wgsLonLat) { attributes.addAttribute("", "crs", "crs", "", "urn:ogc:def:crs:OGC:1.3:CRS84"); } else { String urnIdentifier = urnIdentifier(crs); CoordinateReferenceSystem latlonCrs = CRS.decode(urnIdentifier); encodedEnvelope = CRS.transform(CRS.findMathTransform(crs, latlonCrs, true), envelope); attributes.addAttribute("", "crs", "crs", "", urnIdentifier); } attributes.addAttribute("", "dimensions", "dimensions", "", Integer.toString(crs .getCoordinateSystem().getDimension())); start("ows:BoundingBox", attributes); element("ows:LowerCorner", new StringBuffer(Double.toString(encodedEnvelope .getLowerCorner().getOrdinate(0))).append(" ").append( encodedEnvelope.getLowerCorner().getOrdinate(1)).toString()); element("ows:UpperCorner", new StringBuffer(Double.toString(encodedEnvelope .getUpperCorner().getOrdinate(0))).append(" ").append( encodedEnvelope.getUpperCorner().getOrdinate(1)).toString()); end("ows:BoundingBox"); }
protected void handleRange(CoverageInfo ci) { start("wcs:Range"); // at the moment we only handle single field coverages start("wcs:Field"); List<CoverageDimensionInfo> dimensions = ci.getDimensions(); element("wcs:Identifier", "contents"); // the output domain of the field start("wcs:Definition"); NumberRange range = getCoverageRange(dimensions); if (range == null || range.isEmpty()) { element("ows:AnyValue", ""); } else { start("ows:AllowedValues"); start("ows:Range"); element("ows:MinimumValue", Double.toString(range.getMinimum())); element("ows:MaximumValue", Double.toString(range.getMaximum())); end("ows:Range"); end("ows:AllowedValues"); } end("wcs:Definition"); handleNullValues(dimensions); handleInterpolationMethods(ci); handleAxis(ci); end("wcs:Field"); end("wcs:Range"); }
protected void handleSupportedFormats(CoverageInfo ci) throws Exception { // gather all the formats for this coverage Set<String> formats = new LinkedHashSet<String>(); for (Iterator it = ci.getSupportedFormats().iterator(); it.hasNext(); ) { String format = (String) it.next(); // wcs 1.1 requires mime types, not format names try { CoverageResponseDelegate delegate = responseFactory.encoderFor(format); String formatMime = delegate.getMimeType(format); if (formatMime != null) formats.add(formatMime); } catch (Exception e) { // no problem, we just want to avoid people writing HALLABALOOLA in the // supported formats section of the coverage config and then break the // describe response } } // sort them for (String format : formats) { element("wcs:SupportedFormat", format); } }
protected void handleMetadataLink(MetadataLinkInfo mdl, String linkType) { AttributesImpl attributes = new AttributesImpl(); if ((mdl.getAbout() != null) && (mdl.getAbout() != "")) { attributes.addAttribute("", "about", "about", "", mdl.getAbout()); } if ((mdl.getMetadataType() != null) && (mdl.getMetadataType() != "")) { attributes.addAttribute( "", "metadataType", "metadataType", "", mdl.getMetadataType()); } if ((linkType != null) && (linkType != "")) { attributes.addAttribute("", "xlink:type", "xlink:type", "", linkType); } if ((mdl.getContent() != null) && (mdl.getContent() != "")) { attributes.addAttribute( "", "xlink:href", "xlink:href", "", ResponseUtils.proxifyMetadataLink(mdl, request.getBaseUrl())); } if (attributes.getLength() > 0) { element("ows:Metadata", null, attributes); } }
protected void handleNullValues(List<CoverageDimensionInfo> dimensions) { for (CoverageDimensionInfo cd : dimensions) { List<Double> nulls = cd.getNullValues(); if (nulls == null) return; if (nulls.size() == 1) { element("wcs:NullValue", nulls.get(0).toString()); } else if (nulls.size() >= 1) { // the new specification allows only for a list of values, // Can we assume min and max are two integer numbers and // make up a list out of them? For the moment, just fail throw new IllegalArgumentException( "Cannot encode a range of null values, " + "only single values are handled"); } } }
private void handleNullValues(CoverageDimension[] dimensions) { for (int i = 0; i < dimensions.length; i++) { CoverageDimension cd = dimensions[i]; Double[] nulls = cd.getNullValues(); if(nulls == null) return; if (nulls.length == 1) { element("wcs:NullValue", nulls[0].toString()); } else if (nulls.length >= 1) { // the new specification allows only for a list of values, // Can we assume min and max are two integer numbers and // make up a list out of them? For the moment, just fail throw new IllegalArgumentException("Cannot encode a range of null values, " + "only single values are handled"); } } }
private void handleMetadataLink(MetaDataLink mdl, String linkType) { if (mdl != null) { AttributesImpl attributes = new AttributesImpl(); if ((mdl.getAbout() != null) && (mdl.getAbout() != "")) { attributes.addAttribute("", "about", "about", "", mdl.getAbout()); } if ((mdl.getMetadataType() != null) && (mdl.getMetadataType() != "")) { attributes.addAttribute("", "xlink:type", "xlink:type", "", linkType); } if (attributes.getLength() > 0) { element("ows:Metadata", null, attributes); } } }
public Translator createTranslator(ContentHandler handler) { return new WCS111DescribeCoverageTranslator(handler); }
public Translator createTranslator(ContentHandler handler) { return new WCS111DescribeCoverageTranslator(handler); }
protected void handleSupportedCRSs(CoverageInfo ci) throws Exception { Set supportedCRSs = new LinkedHashSet(); if (ci.getRequestSRS() != null) supportedCRSs.addAll(ci.getRequestSRS()); if (ci.getResponseSRS() != null) supportedCRSs.addAll(ci.getResponseSRS()); for (Iterator it = supportedCRSs.iterator(); it.hasNext(); ) { String crsName = (String) it.next(); CoordinateReferenceSystem crs = CRS.decode(crsName); element("wcs:SupportedCRS", urnIdentifier(crs)); element("wcs:SupportedCRS", crsName); } }
protected void handleCoverageDescription(CoverageInfo ci) throws Exception { start("wcs:CoverageDescription"); element("ows:Title", ci.getTitle()); element("ows:Abstract", ci.getDescription()); handleKeywords(ci.getKeywords()); element("wcs:Identifier", ci.getStore().getWorkspace().getName() + ":" + ci.getName()); handleMetadataLinks(ci.getMetadataLinks(), "simple"); handleDomain(ci); handleRange(ci); handleSupportedCRSs(ci); handleSupportedFormats(ci); end("wcs:CoverageDescription"); }
protected void handleDomain(CoverageInfo ci) throws Exception { start("wcs:Domain"); start("wcs:SpatialDomain"); handleBoundingBox(ci.getLatLonBoundingBox(), true); handleBoundingBox(ci.boundingBox(), false); handleGridCRS(ci); end("wcs:SpatialDomain"); end("wcs:Domain"); }