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_VERSIONS
The versions of the WMS standard that this server supports
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
createDirectory(File dir)
Creates a directory, throwing an Exception if it could not be created and it does not already exist.static Dataset
getDatasetFromLayerName(String layerName, WmsCatalogue catalogue)
Given aWmsCatalogue
, returns theDataset
which corresponds to a given layer namestatic EnhancedVariableMetadata
getLayerMetadata(String layerName, WmsCatalogue catalogue)
Given a named layer and aWmsCatalogue
which contains it, returns the associatedEnhancedVariableMetadata
static Collection<String>
getSupportedStylesForLayer(String layerName, WmsCatalogue catalogue)
Given aWmsCatalogue
, returns aList
of styles supported by the given layer namestatic String
getTimeAxisUnits(org.joda.time.Chronology chronology)
Returns the string to be used to display units for the TIME dimension in Capabilities documents.static VariableMetadata
getVariableMetadataFromLayerName(String layerName, WmsCatalogue catalogue)
Given aWmsCatalogue
, returns theVariableMetadata
which corresponds to a given layer namestatic boolean
isNcmlAggregation(String location)
static boolean
isOpendapLocation(String location)
static void
proxyRequest(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 theDataset
which corresponds to a given layer name- Parameters:
layerName
- The name of the layercatalogue
- TheWmsCatalogue
which 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 theVariableMetadata
which corresponds to a given layer name- Parameters:
layerName
- The name of the layercatalogue
- TheWmsCatalogue
which holds the variable- Returns:
- The requested
VariableMetadata
- Throws:
EdalLayerNotFoundException
- If the given layer name doesn't map to an availableDataset
and Variable combination
-
getSupportedStylesForLayer
public static Collection<String> getSupportedStylesForLayer(String layerName, WmsCatalogue catalogue) throws EdalLayerNotFoundException
Given aWmsCatalogue
, returns aList
of styles supported by the given layer name- Parameters:
layerName
- The name of the layercatalogue
- TheWmsCatalogue
which holds the variable- Returns:
- A
Collection
of the names of the supported styles - Throws:
EdalLayerNotFoundException
- If the given layer name doesn't map to an availableDataset
and Variable combination
-
getLayerMetadata
public static EnhancedVariableMetadata getLayerMetadata(String layerName, WmsCatalogue catalogue) throws EdalLayerNotFoundException
Given a named layer and aWmsCatalogue
which contains it, returns the associatedEnhancedVariableMetadata
- Parameters:
layerName
- The name of the layer to getEnhancedVariableMetadata
aboutcatalogue
- TheWmsCatalogue
containing the layer- Returns:
- The corresponding
EnhancedVariableMetadata
- Throws:
EdalLayerNotFoundException
- If the given layer name doesn't map to an availableDataset
and Variable combination
-
-