Package uk.ac.rdg.resc.edal.wms.util
Class WmsUtils
- java.lang.Object
-
- uk.ac.rdg.resc.edal.wms.util.WmsUtils
-
public class WmsUtils extends Object
Collection of static utility methods that are useful in the WMS application.
Through the taglib definition /WEB-INF/taglib/wmsUtils.tld, some of these functions are also available as JSP2.0 functions. For example:
<%@taglib uri="/WEB-INF/taglib/wmsUtils" prefix="utils"%>- Author:
- Jon Blower, Guy Griffiths
-
-
Field Summary
Fields Modifier and Type Field Description static Set<String>SUPPORTED_VERSIONSThe versions of the WMS standard that this server supports
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcreateDirectory(File dir)Creates a directory, throwing an Exception if it could not be created and it does not already exist.static DatasetgetDatasetFromLayerName(String layerName, WmsCatalogue catalogue)Given aWmsCatalogue, returns theDatasetwhich corresponds to a given layer namestatic EnhancedVariableMetadatagetLayerMetadata(String layerName, WmsCatalogue catalogue)Given a named layer and aWmsCataloguewhich contains it, returns the associatedEnhancedVariableMetadatastatic Collection<String>getSupportedStylesForLayer(String layerName, WmsCatalogue catalogue)Given aWmsCatalogue, returns aListof styles supported by the given layer namestatic StringgetTimeAxisUnits(org.joda.time.Chronology chronology)Returns the string to be used to display units for the TIME dimension in Capabilities documents.static VariableMetadatagetVariableMetadataFromLayerName(String layerName, WmsCatalogue catalogue)Given aWmsCatalogue, returns theVariableMetadatawhich corresponds to a given layer namestatic booleanisNcmlAggregation(String location)static booleanisOpendapLocation(String location)static voidproxyRequest(String url, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)Forwards the request to a third party.
-
-
-
Method Detail
-
createDirectory
public static void createDirectory(File dir) throws Exception
Creates a directory, throwing an Exception if it could not be created and it does not already exist.- Throws:
Exception
-
isOpendapLocation
public static boolean isOpendapLocation(String location)
- Returns:
- true if the given location represents an OPeNDAP dataset. This method simply checks to see if the location string starts with "http://", "https://" or "dods://".
-
isNcmlAggregation
public static boolean isNcmlAggregation(String location)
- Returns:
- true if the given location represents an NcML aggregation. dataset. This method simply checks to see if the location string ends with ".xml" or ".ncml", following the same procedure as the Java NetCDF library.
-
proxyRequest
public static void proxyRequest(String url, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Forwards the request to a third party. In this case this server is acting as a proxy.- Parameters:
url- The URL to the third party server (e.g. "http://myhost.com/ncWMS/wms")request- Http request object. All query string parameters (except "&url=") will be copied from this request object to the request to the third party server.response- Http response object
-
getTimeAxisUnits
public static String getTimeAxisUnits(org.joda.time.Chronology chronology)
Returns the string to be used to display units for the TIME dimension in Capabilities documents. For standard (ISO) chronologies, this will return "ISO8601". Some other chronologies (Julian, 360 day, no leap years, all leap years) will an appropriate string. For other chronologies this will return "unknown".
-
getDatasetFromLayerName
public static Dataset getDatasetFromLayerName(String layerName, WmsCatalogue catalogue) throws EdalLayerNotFoundException
Given aWmsCatalogue, returns theDatasetwhich corresponds to a given layer name- Parameters:
layerName- The name of the layercatalogue- TheWmsCataloguewhich holds theDataset- Returns:
- The requested
Dataset - Throws:
EdalLayerNotFoundException- If the given layer name doesn't map to an availableDataset
-
getVariableMetadataFromLayerName
public static VariableMetadata getVariableMetadataFromLayerName(String layerName, WmsCatalogue catalogue) throws EdalLayerNotFoundException
Given aWmsCatalogue, returns theVariableMetadatawhich corresponds to a given layer name- Parameters:
layerName- The name of the layercatalogue- TheWmsCataloguewhich holds the variable- Returns:
- The requested
VariableMetadata - Throws:
EdalLayerNotFoundException- If the given layer name doesn't map to an availableDatasetand Variable combination
-
getSupportedStylesForLayer
public static Collection<String> getSupportedStylesForLayer(String layerName, WmsCatalogue catalogue) throws EdalLayerNotFoundException
Given aWmsCatalogue, returns aListof styles supported by the given layer name- Parameters:
layerName- The name of the layercatalogue- TheWmsCataloguewhich holds the variable- Returns:
- A
Collectionof the names of the supported styles - Throws:
EdalLayerNotFoundException- If the given layer name doesn't map to an availableDatasetand Variable combination
-
getLayerMetadata
public static EnhancedVariableMetadata getLayerMetadata(String layerName, WmsCatalogue catalogue) throws EdalLayerNotFoundException
Given a named layer and aWmsCataloguewhich contains it, returns the associatedEnhancedVariableMetadata- Parameters:
layerName- The name of the layer to getEnhancedVariableMetadataaboutcatalogue- TheWmsCataloguecontaining the layer- Returns:
- The corresponding
EnhancedVariableMetadata - Throws:
EdalLayerNotFoundException- If the given layer name doesn't map to an availableDatasetand Variable combination
-
-