public WMSLayerCapabilities getLayerByName(String name) { if (WWUtil.isEmpty(name)) return null; List<WMSLayerCapabilities> namedLayers = this.getNamedLayers(); for (WMSLayerCapabilities layer : namedLayers) { if (layer.getName().equals(name)) return layer; } return null; }
/** * Returns all named layers in the capabilities document. * * @return an unordered list of the document's named layers. */ public List<WMSLayerCapabilities> getNamedLayers() { if (this.getCapabilityInformation() == null || this.getCapabilityInformation().getLayerCapabilities() == null) return null; List<WMSLayerCapabilities> namedLayers = new ArrayList<WMSLayerCapabilities>(); for (WMSLayerCapabilities layer : this.getCapabilityInformation().getLayerCapabilities()) { namedLayers.addAll(layer.getNamedLayers()); } return namedLayers; }
@Override public String toString() // TODO: Complete this method { StringBuilder sb = new StringBuilder(super.toString()); sb.append("LAYERS\n"); for (WMSLayerCapabilities layerCaps : this.getNamedLayers()) { sb.append(layerCaps.toString()).append("\n"); } return sb.toString(); }
public Double[] getLayerExtremeElevations(WMSCapabilities caps, String[] layerNames) { if (caps == null) { String message = Logging.getMessage("nullValue.WMSCapabilities"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (layerNames == null) { String message = Logging.getMessage("nullValue.WMSLayerNames"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } Double extremeMin = null; Double extremeMax = null; for (String name : layerNames) { WMSLayerCapabilities layer = caps.getLayerByName(name); if (layer == null) continue; Double min = layer.getExtremeElevationMin(); if (min != null && (extremeMin == null || min.compareTo(min) > 0)) extremeMin = min; Double max = layer.getExtremeElevationMax(); if (max != null && (extremeMax == null || max.compareTo(max) > 0)) extremeMax = max; } if (extremeMin != null || extremeMax != null) { Double[] extremes = new Double[] {null, null}; if (extremeMin != null) extremes[0] = extremeMin; if (extremeMax != null) extremes[1] = extremeMax; return extremes; } return null; }
public Long getLayerLatestLastUpdateTime(WMSCapabilities caps, String[] layerNames) { if (caps == null) { String message = Logging.getMessage("nullValue.WMSCapabilities"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } if (layerNames == null) { String message = Logging.getMessage("nullValue.WMSLayerNames"); Logging.logger().severe(message); throw new IllegalArgumentException(message); } String lastUpdate = null; for (String name : layerNames) { WMSLayerCapabilities layer = this.getLayerByName(name); if (layer == null) continue; String update = layer.getLastUpdate(); if (update != null && update.length() > 0 && (lastUpdate == null || update.compareTo(lastUpdate) > 0)) lastUpdate = update; } if (lastUpdate != null) { try { return Long.parseLong(lastUpdate); } catch (NumberFormatException e) { String message = Logging.getMessage("generic.ConversionError", lastUpdate); Logging.logger().warning(message); } } return null; }