public void setLatLonBoundingBox(CRSEnvelope latLonBoundingBox) { if (latLonBoundingBox.getSRSName() != null) { String srsName = latLonBoundingBox.getSRSName(); if (!srsName.equals("CRS:84")) { throw new IllegalStateException( "Layer LatLonBoundingBox srsName required to be null or CRS:84"); } } else { latLonBoundingBox.setSRSName("CRS:84", false); } this.latLonBoundingBox = latLonBoundingBox; }
/** * Returns every BoundingBox associated with this layer. The <code>HashMap</code> returned has * each bounding box's SRS Name (usually an EPSG code) value as the key, and the value is the * <code>BoundingBox</code> object itself. * * <p>Implements inheritance: if this layer's bounding box is null, query ancestors until the * first bounding box is found or no more ancestors * * @return a HashMap of all of this layer's bounding boxes or null if no bounding boxes found */ public synchronized Map<String, CRSEnvelope> getBoundingBoxes() { if (allBoundingBoxesCache == null) { allBoundingBoxesCache = new HashMap<String, CRSEnvelope>(); for (CRSEnvelope bbox : getLayerBoundingBoxes()) { allBoundingBoxesCache.put(bbox.getSRSName(), bbox); } Layer parent = this.getParent(); while (parent != null && allBoundingBoxesCache.size() == 0) { for (CRSEnvelope bbox : parent.getLayerBoundingBoxes()) { allBoundingBoxesCache.put(bbox.getSRSName(), bbox); } parent = parent.getParent(); } } // May return empty. But that is OK since spec says 0 or more may be specified return allBoundingBoxesCache; }
@Override public void convertValueToDom(Object value, DomElement parentElement) throws ConversionException { CRSEnvelope crsEnvelope = (CRSEnvelope) value; DomElement srsName = parentElement.createChild(SRS_NAME); srsName.setValue(crsEnvelope.getSRSName()); DomElement minX = parentElement.createChild(MIN_X); minX.setValue(Double.toString(crsEnvelope.getMinX())); DomElement minY = parentElement.createChild(MIN_Y); minY.setValue(Double.toString(crsEnvelope.getMinY())); DomElement maxX = parentElement.createChild(MAX_X); maxX.setValue(Double.toString(crsEnvelope.getMaxX())); DomElement maxY = parentElement.createChild(MAX_Y); maxY.setValue(Double.toString(crsEnvelope.getMaxY())); } }
@Override public void convertValueToDom(Object value, DomElement parentElement) throws ConversionException { CRSEnvelope crsEnvelope = (CRSEnvelope) value; DomElement srsName = parentElement.createChild(SRS_NAME); srsName.setValue(crsEnvelope.getSRSName()); DomElement minX = parentElement.createChild(MIN_X); minX.setValue(Double.toString(crsEnvelope.getMinX())); DomElement minY = parentElement.createChild(MIN_Y); minY.setValue(Double.toString(crsEnvelope.getMinY())); DomElement maxX = parentElement.createChild(MAX_X); maxX.setValue(Double.toString(crsEnvelope.getMaxX())); DomElement maxY = parentElement.createChild(MAX_Y); maxY.setValue(Double.toString(crsEnvelope.getMaxY())); } }
/** * Fix the provided layer's bounding box so that it can be correctly handled. * * <p>Call layer.clearCache() after this method. * * @param layer * @param forceXY true prior to WMS 1.3.0, false after WMS 1.3.0 */ static void fixLayerBoundingBox(Layer layer, boolean forceXY) { if (layer == null) { return; } if (layer.getLayerBoundingBoxes() != null) { for (CRSEnvelope boundingBox : layer.getLayerBoundingBoxes()) { String srsName = boundingBox.getSRSName(); boundingBox.setSRSName(srsName, forceXY); } } for (Layer child : layer.getChildren()) { fixLayerBoundingBox(child, forceXY); } }