/** * Every Layer shall have exactly one <LatLonBoundingBox> element that is either stated * explicitly or inherited from a parent Layer. LatLonBoundingBox states the minimum bounding * rectangle of the map data in the EPSG:4326 geographic coordinate system. The LatLonBoundingBox * attributes minx, miny, maxx, maxy indicate the edges of an enclosing rectangle in decimal * degrees. LatLonBoundingBox shall be supplied regardless of what SRS the map server may support, * but it may be approximate if EPSG:4326 is not supported. Its purpose is to facilitate * geographic searches without requiring coordinate transformations by the search engine. * * @return the bbox */ public Envelope getLatLonBoundingBox() { if ((latLonBoundingBox == null) && (parent != null)) { return parent.getLatLonBoundingBox(); } return latLonBoundingBox; }
/** * returns the layers offered by the WMPS * * @param layerElem * @param parent * @return Layer * @throws XMLParsingException * @throws UnknownCRSException */ protected Layer parseLayers(Element layerElem, Layer parent) throws XMLParsingException, UnknownCRSException { LOG.entering(); boolean queryable = XMLTools.getNodeAsBoolean(layerElem, "./@queryable", nsContext, false); int cascaded = XMLTools.getNodeAsInt(layerElem, "./@cascaded", nsContext, 0); boolean opaque = XMLTools.getNodeAsBoolean(layerElem, "./@opaque", nsContext, false); boolean noSubsets = XMLTools.getNodeAsBoolean(layerElem, "./@noSubsets", nsContext, false); int fixedWidth = XMLTools.getNodeAsInt(layerElem, "./@fixedWidth", nsContext, 0); int fixedHeight = XMLTools.getNodeAsInt(layerElem, "./@fixedHeight", nsContext, 0); String name = XMLTools.getNodeAsString(layerElem, "./Name", nsContext, null); String title = XMLTools.getRequiredNodeAsString(layerElem, "./Title", nsContext); String layerAbstract = XMLTools.getNodeAsString(layerElem, "./Abstract", nsContext, null); String[] keywords = XMLTools.getNodesAsStrings(layerElem, "./KeywordList/Keyword", nsContext); String[] srs = XMLTools.getNodesAsStrings(layerElem, "./SRS", nsContext); List nl = XMLTools.getNodes(layerElem, "./BoundingBox", nsContext); // TODO substitue with Envelope LayerBoundingBox[] bboxes = null; if (nl.size() == 0 && parent != null) { // inherit BoundingBoxes from parent layer bboxes = parent.getBoundingBoxes(); } else { bboxes = parseLayerBoundingBoxes(nl); } Element llBox = (Element) XMLTools.getNode(layerElem, "./LatLonBoundingBox", nsContext); Envelope llBoundingBox = null; if (llBox == null && parent != null) { // inherit LatLonBoundingBox parent layer llBoundingBox = parent.getLatLonBoundingBox(); } else if (llBox != null) { llBoundingBox = parseLatLonBoundingBox(llBox); } else { /** Default crs = EPSG:4326 */ CoordinateSystem crs = CRSFactory.create("EPSG:4326"); llBoundingBox = GeometryFactory.createEnvelope(-180, -90, 180, 90, crs); } Dimension[] dimensions = parseDimensions(layerElem); Extent[] extents = parseExtents(layerElem); Attribution attribution = parseAttribution(layerElem); AuthorityURL[] authorityURLs = parseAuthorityURLs(layerElem); MetadataURL[] metadataURLs = parseMetadataURLs(layerElem); DataURL[] dataURLs = parseDataURL(layerElem); Identifier[] identifiers = parseIdentifiers(layerElem); FeatureListURL[] featureListURLs = parseFeatureListURL(layerElem); Style[] styles = parseStyles(layerElem); ScaleHint scaleHint = parseScaleHint(layerElem); Layer layer = new Layer( queryable, cascaded, opaque, noSubsets, fixedWidth, fixedHeight, name, title, layerAbstract, llBoundingBox, attribution, scaleHint, keywords, srs, bboxes, dimensions, extents, authorityURLs, identifiers, metadataURLs, dataURLs, featureListURLs, styles, null, null, parent); // get Child layers nl = XMLTools.getNodes(layerElem, "./Layer", nsContext); Layer[] layers = new Layer[nl.size()]; for (int i = 0; i < layers.length; i++) { layers[i] = parseLayers((Element) nl.get(i), layer); } // set child layers layer.setLayer(layers); LOG.exiting(); return layer; }