Class WebMapServer
- Object
-
- AbstractOpenWebService<WMSCapabilities,Layer>
-
- WebMapServer
-
public class WebMapServer extends AbstractOpenWebService<WMSCapabilities,Layer>
WebMapServer is a class representing a WMS. It is used to access the Capabilities document and perform requests. It supports multiple versions and will perform version negotiation automatically and use the highest known version that the server can communicate.If restriction of versions to be used is desired, this class should be subclassed and it's setupSpecifications() method over-ridden. It should add which version/specifications are to be used to the specs array. See the current implementation for an example.
Example usage:
WebMapServer wms = new WebMapServer("http://some.example.com/wms"); WMSCapabilities capabilities = wms.getCapabilities(); GetMapRequest request = wms.getMapRequest(); ... //configure request GetMapResponse response = (GetMapResponse) wms.issueRequest(request); ... //extract image from the response
- Author:
- Richard Gould, Refractions Research
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
WebMapServer.LayerInfo
Quickly describe a layer.protected class
WebMapServer.WMSInfo
Class quickly describing Web Map Service.
-
Field Summary
-
Fields inherited from class AbstractOpenWebService
capabilities, headers, hints, info, LOGGER, resourceInfo, serverURL, specification, specs
-
-
Constructor Summary
Constructors Constructor Description WebMapServer(URL serverURL)
Creates a new WebMapServer instance and attempts to retrieve the Capabilities document specified by serverURL.WebMapServer(URL serverURL, int timeout)
Creates a new WebMapServer instance and attempts to retrieve the Capabilities document specified by serverURL.WebMapServer(URL serverURL, HTTPClient httpClient)
Creates a new WebMapServer instance and attempts to retrieve the Capabilities document specified by serverURL.WebMapServer(URL serverURL, HTTPClient httpClient, Map<String,Object> hints)
Creates a new WebMapServer instance and attempts to retrieve the Capabilities document specified by serverURL.WebMapServer(URL serverURL, HTTPClient httpClient, Map<String,Object> hints, Map<String,String> headers)
Creates a new WebMapServer instance and retrieve the Capabilities document specified by serverURL.WebMapServer(WMSCapabilities capabilities)
Creates a new WebMapServer from a WMSCapablitiles document.
-
Method Summary
-
Methods inherited from class AbstractOpenWebService
getHints, getHTTPClient, getInfo, getInfo, internalIssueRequest, negotiateVersion, setHints, setHttpClient, setLoggingLevel
-
-
-
-
Constructor Detail
-
WebMapServer
public WebMapServer(WMSCapabilities capabilities) throws IOException, ServiceException
Creates a new WebMapServer from a WMSCapablitiles document.The implementation assumes that the server is located at: capabilities.getRequest().getGetCapabilities().getGet()
- Throws:
IOException
ServiceException
-
WebMapServer
public WebMapServer(URL serverURL) throws IOException, ServiceException
Creates a new WebMapServer instance and attempts to retrieve the Capabilities document specified by serverURL.- Parameters:
serverURL
- a URL that points to the capabilities document of a server- Throws:
IOException
- if there is an error communicating with the serverServiceException
- if the server responds with an error
-
WebMapServer
public WebMapServer(URL serverURL, HTTPClient httpClient) throws IOException, ServiceException
Creates a new WebMapServer instance and attempts to retrieve the Capabilities document specified by serverURL.- Parameters:
serverURL
- a URL that points to the capabilities document of a server- Throws:
IOException
- if there is an error communicating with the serverServiceException
- if the server responds with an error
-
WebMapServer
public WebMapServer(URL serverURL, HTTPClient httpClient, Map<String,Object> hints) throws IOException, ServiceException
Creates a new WebMapServer instance and attempts to retrieve the Capabilities document specified by serverURL.- Parameters:
serverURL
- a URL that points to the capabilities document of a serverhttpClient
- The client to be used when performing HTTP requestshints
- A map of hints. Can be used to control some aspects of the XML parsing, seeXMLHandlerHints
for a reference- Throws:
IOException
- if there is an error communicating with the serverServiceException
- if the server responds with an error
-
WebMapServer
public WebMapServer(URL serverURL, HTTPClient httpClient, Map<String,Object> hints, Map<String,String> headers) throws IOException, ServiceException
Creates a new WebMapServer instance and retrieve the Capabilities document specified by serverURL.- Parameters:
serverURL
- a URL that points to the capabilities document of a serverhttpClient
- The client to be used when performing HTTP requestshints
- A map of hints. Can be used to control some aspects of the XML parsing, seeXMLHandlerHints
for a referenceheaders
- A map of headers. These will be added when making the HTTP request- Throws:
IOException
- if there is an error communicating with the serverServiceException
- if the server responds with an error
-
WebMapServer
public WebMapServer(URL serverURL, int timeout) throws IOException, ServiceException
Creates a new WebMapServer instance and attempts to retrieve the Capabilities document specified by serverURL.- Parameters:
serverURL
- a URL that points to the capabilities document of a servertimeout
- a time to be wait a server response- Throws:
IOException
- if there is an error communicating with the serverServiceException
- if the server responds with an error
-
-
Method Detail
-
getHttpClient
public static HTTPClient getHttpClient(int timeout)
-
setupSpecifications
protected void setupSpecifications()
Sets up the specifications/versions that this server is capable of communicating with.- Specified by:
setupSpecifications
in classAbstractOpenWebService<WMSCapabilities,Layer>
-
createInfo
protected ServiceInfo createInfo()
Description copied from class:AbstractOpenWebService
Implemented by a subclass to describe service- Specified by:
createInfo
in classAbstractOpenWebService<WMSCapabilities,Layer>
- Returns:
- ServiceInfo
-
createInfo
protected ResourceInfo createInfo(Layer layer)
- Specified by:
createInfo
in classAbstractOpenWebService<WMSCapabilities,Layer>
-
issueRequest
public GetCapabilitiesResponse issueRequest(GetCapabilitiesRequest request) throws IOException, ServiceException
- Overrides:
issueRequest
in classAbstractOpenWebService<WMSCapabilities,Layer>
- Throws:
IOException
ServiceException
-
issueRequest
public GetMapResponse issueRequest(GetMapRequest request) throws IOException, ServiceException
- Throws:
IOException
ServiceException
-
issueRequest
public GetFeatureInfoResponse issueRequest(GetFeatureInfoRequest request) throws IOException, ServiceException
- Throws:
IOException
ServiceException
-
issueRequest
public DescribeLayerResponse issueRequest(DescribeLayerRequest request) throws IOException, ServiceException
- Throws:
IOException
ServiceException
-
issueRequest
public GetLegendGraphicResponse issueRequest(GetLegendGraphicRequest request) throws IOException, ServiceException
- Throws:
IOException
ServiceException
-
issueRequest
public GetStylesResponse issueRequest(GetStylesRequest request) throws IOException, ServiceException
- Throws:
IOException
ServiceException
-
issueRequest
public PutStylesResponse issueRequest(PutStylesRequest request) throws IOException, ServiceException
- Throws:
IOException
ServiceException
-
getCapabilities
public WMSCapabilities getCapabilities()
Get the getCapabilities document. If there was an error parsing it during creation, it will return null (and it should have thrown an exception during creation).- Specified by:
getCapabilities
in classAbstractOpenWebService<WMSCapabilities,Layer>
- Returns:
- a WMSCapabilities object, representing the Capabilities of the server
-
createGetMapRequest
public GetMapRequest createGetMapRequest()
Creates a GetMapRequest that can be configured and then passed to issueRequest().- Returns:
- a configureable GetMapRequest object
-
createGetFeatureInfoRequest
public GetFeatureInfoRequest createGetFeatureInfoRequest(GetMapRequest getMapRequest)
Creates a GetFeatureInfoRequest that can be configured and then passed to issueRequest().- Parameters:
getMapRequest
- a previous configured GetMapRequest- Returns:
- a GetFeatureInfoRequest
- Throws:
UnsupportedOperationException
- if the server does not support GetFeatureInfo
-
createDescribeLayerRequest
public DescribeLayerRequest createDescribeLayerRequest() throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
-
createGetLegendGraphicRequest
public GetLegendGraphicRequest createGetLegendGraphicRequest() throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
-
createGetStylesRequest
public GetStylesRequest createGetStylesRequest() throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
-
createPutStylesRequest
public PutStylesRequest createPutStylesRequest() throws UnsupportedOperationException
- Throws:
UnsupportedOperationException
-
getEnvelope
public GeneralBounds getEnvelope(Layer layer, CoordinateReferenceSystem crs)
Given a layer and a coordinate reference system, will locate an envelope for that layer in that CRS. If the layer is declared to support that CRS, but no envelope can be found, it will try to calculate an appropriate bounding box.If null is returned, no valid bounding box could be found and one couldn't be transformed from another.
- Returns:
- an Envelope containing a valid bounding box, or null if none are found
-
-