org.geotools.data.wms
Class WebMapServer

Object
  extended by AbstractOpenWebService<WMSCapabilities,Layer>
      extended by 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
Module:
modules/extension/wms (gt-wms.jar)

Nested Class Summary
 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, info, requestTimeout, resourceInfo, serverURL, specification, specs
 
Constructor Summary
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(WMSCapabilities capabilities)
          Creates a new WebMapServer from a WMSCapablitiles document.
 
Method Summary
 DescribeLayerRequest createDescribeLayerRequest()
           
 GetFeatureInfoRequest createGetFeatureInfoRequest(GetMapRequest getMapRequest)
          Creates a GetFeatureInfoRequest that can be configured and then passed to issueRequest().
 GetLegendGraphicRequest createGetLegendGraphicRequest()
           
 GetMapRequest createGetMapRequest()
          Creates a GetMapRequest that can be configured and then passed to issueRequest().
 GetStylesRequest createGetStylesRequest()
           
protected  ServiceInfo createInfo()
          Implemented by a subclass to describe service
protected  ResourceInfo createInfo(Layer layer)
           
 PutStylesRequest createPutStylesRequest()
           
 WMSCapabilities getCapabilities()
          Get the getCapabilities document.
 GeneralEnvelope getEnvelope(Layer layer, CoordinateReferenceSystem crs)
          Given a layer and a coordinate reference system, will locate an envelope for that layer in that CRS.
 DescribeLayerResponse issueRequest(DescribeLayerRequest request)
           
 GetCapabilitiesResponse issueRequest(GetCapabilitiesRequest request)
           
 GetFeatureInfoResponse issueRequest(GetFeatureInfoRequest request)
           
 GetLegendGraphicResponse issueRequest(GetLegendGraphicRequest request)
           
 GetMapResponse issueRequest(GetMapRequest request)
           
 GetStylesResponse issueRequest(GetStylesRequest request)
           
 PutStylesResponse issueRequest(PutStylesRequest request)
           
protected  void setupSpecifications()
          Sets up the specifications/versions that this server is capable of communicating with.
 
Methods inherited from class AbstractOpenWebService
getInfo, getInfo, internalIssueRequest, negotiateVersion, setLoggingLevel
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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()

Parameters:
capabilities -
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 server
ServiceException - 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 server
timeout - a time to be wait a server response
Throws:
IOException - if there is an error communicating with the server
ServiceException - if the server responds with an error
Method Detail

setupSpecifications

protected void setupSpecifications()
Sets up the specifications/versions that this server is capable of communicating with.

Specified by:
setupSpecifications in class AbstractOpenWebService<WMSCapabilities,Layer>

createInfo

protected ServiceInfo createInfo()
Description copied from class: AbstractOpenWebService
Implemented by a subclass to describe service

Specified by:
createInfo in class AbstractOpenWebService<WMSCapabilities,Layer>
Returns:
ServiceInfo

createInfo

protected ResourceInfo createInfo(Layer layer)
Specified by:
createInfo in class AbstractOpenWebService<WMSCapabilities,Layer>

issueRequest

public GetCapabilitiesResponse issueRequest(GetCapabilitiesRequest request)
                                     throws IOException,
                                            ServiceException
Overrides:
issueRequest in class AbstractOpenWebService<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).

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 GeneralEnvelope 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.

Parameters:
layer -
crs -
Returns:
an Envelope containing a valid bounding box, or null if none are found


Copyright © 1996-2009 Geotools. All Rights Reserved.