Class WebMapServer
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 ClassesModifier and TypeClassDescriptionclass
Quickly describe a layer.protected class
Class quickly describing Web Map Service. -
Field Summary
Fields inherited from class AbstractOpenWebService
capabilities, headers, hints, info, LOGGER, resourceInfo, serverURL, specification, specs
-
Constructor Summary
ConstructorsConstructorDescriptionWebMapServer
(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
Modifier and TypeMethodDescriptioncreateGetFeatureInfoRequest
(GetMapRequest getMapRequest) Creates a GetFeatureInfoRequest that can be configured and then passed to issueRequest().Creates a GetMapRequest that can be configured and then passed to issueRequest().protected ServiceInfo
Implemented by a subclass to describe serviceprotected ResourceInfo
createInfo
(Layer layer) Get the getCapabilities document.getEnvelope
(Layer layer, CoordinateReferenceSystem crs) Given a layer and a coordinate reference system, will locate an envelope for that layer in that CRS.static HTTPClient
getHttpClient
(int timeout) issueRequest
(GetCapabilitiesRequest request) issueRequest
(DescribeLayerRequest request) issueRequest
(GetFeatureInfoRequest request) issueRequest
(GetLegendGraphicRequest request) issueRequest
(GetMapRequest request) issueRequest
(GetStylesRequest request) issueRequest
(PutStylesRequest request) protected void
Sets up the specifications/versions that this server is capable of communicating with.Methods inherited from class AbstractOpenWebService
getHints, getHTTPClient, getInfo, getInfo, internalIssueRequest, negotiateVersion, setHints, setHttpClient, setLoggingLevel
-
Constructor Details
-
WebMapServer
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
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
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, ServiceExceptionCreates 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, throws IOException, ServiceExceptionString> headers) 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
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 Details
-
getHttpClient
-
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
Description copied from class:AbstractOpenWebService
Implemented by a subclass to describe service- Specified by:
createInfo
in classAbstractOpenWebService<WMSCapabilities,
Layer> - Returns:
- ServiceInfo
-
createInfo
- 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
- 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
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
Creates a GetMapRequest that can be configured and then passed to issueRequest().- Returns:
- a configureable GetMapRequest object
-
createGetFeatureInfoRequest
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
- Throws:
UnsupportedOperationException
-
createGetLegendGraphicRequest
- Throws:
UnsupportedOperationException
-
createGetStylesRequest
- Throws:
UnsupportedOperationException
-
createPutStylesRequest
- Throws:
UnsupportedOperationException
-
getEnvelope
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
-