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 TypeClassDescriptionclassQuickly describe a layer.protected classClass 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 ServiceInfoImplemented by a subclass to describe serviceprotected ResourceInfocreateInfo(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 HTTPClientgetHttpClient(int timeout) issueRequest(GetCapabilitiesRequest request) issueRequest(DescribeLayerRequest request) issueRequest(GetFeatureInfoRequest request) issueRequest(GetLegendGraphicRequest request) issueRequest(GetMapRequest request) issueRequest(GetStylesRequest request) issueRequest(PutStylesRequest request) protected voidSets 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:
IOExceptionServiceException
-
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, seeXMLHandlerHintsfor 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, seeXMLHandlerHintsfor 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:
setupSpecificationsin classAbstractOpenWebService<WMSCapabilities,Layer>
-
createInfo
Description copied from class:AbstractOpenWebServiceImplemented by a subclass to describe service- Specified by:
createInfoin classAbstractOpenWebService<WMSCapabilities,Layer> - Returns:
- ServiceInfo
-
createInfo
- Specified by:
createInfoin classAbstractOpenWebService<WMSCapabilities,Layer>
-
issueRequest
public GetCapabilitiesResponse issueRequest(GetCapabilitiesRequest request) throws IOException, ServiceException - Overrides:
issueRequestin classAbstractOpenWebService<WMSCapabilities,Layer> - Throws:
IOExceptionServiceException
-
issueRequest
- Throws:
IOExceptionServiceException
-
issueRequest
public GetFeatureInfoResponse issueRequest(GetFeatureInfoRequest request) throws IOException, ServiceException - Throws:
IOExceptionServiceException
-
issueRequest
public DescribeLayerResponse issueRequest(DescribeLayerRequest request) throws IOException, ServiceException - Throws:
IOExceptionServiceException
-
issueRequest
public GetLegendGraphicResponse issueRequest(GetLegendGraphicRequest request) throws IOException, ServiceException - Throws:
IOExceptionServiceException
-
issueRequest
public GetStylesResponse issueRequest(GetStylesRequest request) throws IOException, ServiceException - Throws:
IOExceptionServiceException
-
issueRequest
public PutStylesResponse issueRequest(PutStylesRequest request) throws IOException, ServiceException - Throws:
IOExceptionServiceException
-
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:
getCapabilitiesin 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
-