org.geotools.data.wms
Class WebMapServer

java.lang.Object
  extended byorg.geotools.data.wms.WebMapServer
Direct Known Subclasses:
WMSService.CustomWMS

public class WebMapServer
extends java.lang.Object

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

Field Summary
protected  Specification[] specs
          Contains the specifications that are to be used with this WMS
 
Constructor Summary
WebMapServer(java.net.URL serverURL)
          Creates a new WebMapServer instance and attempts to retrieve the Capabilities document specified by serverURL.
 
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()
           
 PutStylesRequest createPutStylesRequest()
           
 WMSCapabilities getCapabilities()
          Get the getCapabilities document.
 GeneralEnvelope getEnvelope(Layer layer, org.opengis.referencing.crs.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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

specs

protected Specification[] specs
Contains the specifications that are to be used with this WMS

Constructor Detail

WebMapServer

public WebMapServer(java.net.URL serverURL)
             throws java.io.IOException,
                    ServiceException,
                    org.xml.sax.SAXException
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:
java.io.IOException - if there is an error communicating with the server
ServiceException - if the server responds with an error
org.xml.sax.SAXException - if there is an error while parsing the capabilities, such as bad XML
Method Detail

setupSpecifications

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


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

issueRequest

public GetCapabilitiesResponse issueRequest(GetCapabilitiesRequest request)
                                     throws java.io.IOException,
                                            ServiceException,
                                            org.xml.sax.SAXException
Throws:
java.io.IOException
ServiceException
org.xml.sax.SAXException

issueRequest

public GetMapResponse issueRequest(GetMapRequest request)
                            throws java.io.IOException,
                                   ServiceException,
                                   org.xml.sax.SAXException
Throws:
java.io.IOException
ServiceException
org.xml.sax.SAXException

issueRequest

public GetFeatureInfoResponse issueRequest(GetFeatureInfoRequest request)
                                    throws java.io.IOException,
                                           ServiceException,
                                           org.xml.sax.SAXException
Throws:
java.io.IOException
ServiceException
org.xml.sax.SAXException

issueRequest

public DescribeLayerResponse issueRequest(DescribeLayerRequest request)
                                   throws java.io.IOException,
                                          ServiceException,
                                          org.xml.sax.SAXException
Throws:
java.io.IOException
ServiceException
org.xml.sax.SAXException

issueRequest

public GetLegendGraphicResponse issueRequest(GetLegendGraphicRequest request)
                                      throws java.io.IOException,
                                             ServiceException,
                                             org.xml.sax.SAXException
Throws:
java.io.IOException
ServiceException
org.xml.sax.SAXException

issueRequest

public GetStylesResponse issueRequest(GetStylesRequest request)
                               throws java.io.IOException,
                                      ServiceException,
                                      org.xml.sax.SAXException
Throws:
java.io.IOException
ServiceException
org.xml.sax.SAXException

issueRequest

public PutStylesResponse issueRequest(PutStylesRequest request)
                               throws java.io.IOException,
                                      ServiceException,
                                      org.xml.sax.SAXException
Throws:
java.io.IOException
ServiceException
org.xml.sax.SAXException

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:
java.lang.UnsupportedOperationException - if the server does not support GetFeatureInfo

createDescribeLayerRequest

public DescribeLayerRequest createDescribeLayerRequest()
                                                throws java.lang.UnsupportedOperationException
Throws:
java.lang.UnsupportedOperationException

createGetLegendGraphicRequest

public GetLegendGraphicRequest createGetLegendGraphicRequest()
                                                      throws java.lang.UnsupportedOperationException
Throws:
java.lang.UnsupportedOperationException

createGetStylesRequest

public GetStylesRequest createGetStylesRequest()
                                        throws java.lang.UnsupportedOperationException
Throws:
java.lang.UnsupportedOperationException

createPutStylesRequest

public PutStylesRequest createPutStylesRequest()
                                        throws java.lang.UnsupportedOperationException
Throws:
java.lang.UnsupportedOperationException

getEnvelope

public GeneralEnvelope getEnvelope(Layer layer,
                                   org.opengis.referencing.crs.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 © GeoTools. All Rights Reserved.