Package com.vividsolutions.wms
Class MapRequest
- java.lang.Object
-
- com.vividsolutions.wms.AbstractWMSRequest
-
- com.vividsolutions.wms.MapRequest
-
- All Implemented Interfaces:
WMSRequest
public class MapRequest extends AbstractWMSRequest
Represents all of the parameters of a getMap request from a WMS server.- Author:
- Chris Hodgson chodgson@refractions.net
-
-
Field Summary
-
Fields inherited from class com.vividsolutions.wms.AbstractWMSRequest
con, service, version
-
-
Constructor Summary
Constructors Constructor Description MapRequest(WMService service)Creates a new MapRequest.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BoundingBoxgetBoundingBox()Gets the BoundingBox of the image being requested.StringgetFormat()Returns the format of this request.intgetImageHeight()Gets the height of the requested image, in pixels.intgetImageWidth()Gets the width of the requested image, in pixels.List<String>getLayerNames()Returns the list of layers to be requested.booleangetTransparent()Gets whether or not a transparent image is being requested.URLgetURL()must be implemented according to the specific needsstatic StringlistToString(List<String> list)Returns a String containing the string representations of each item in the list (as provided by toString()), separated by commas.voidsetApiKeyNameAndValue(String apiKeyNameAndValue)voidsetBoundingBox(BoundingBox bbox)Sets the BoundingBox of the image being requested.voidsetFormat(String format)Sets the format of this request.voidsetImageHeight(int imageHeight)Sets the height of the image being requested.voidsetImageSize(int imageWidth, int imageHeight)Sets the width and height of the image being requested.voidsetImageWidth(int imageWidth)Sets the width of the image being requested.voidsetLayerNames(List<String> layerNames)Sets the layers to be requested.voidsetMoreParameters(String moreParameters)voidsetStyle(MapStyle style)voidsetTransparent(boolean transparent)Sets whether or not to request an image with a transparent background.-
Methods inherited from class com.vividsolutions.wms.AbstractWMSRequest
getConnection, getImage, getInputStream, getService, getText, prepareConnection, readConnection, readToError, setWMSVersion
-
-
-
-
Constructor Detail
-
MapRequest
public MapRequest(WMService service)
Creates a new MapRequest.- Parameters:
service- the WMService which this MapRequest will use
-
-
Method Detail
-
getFormat
public String getFormat()
Returns the format of this request. This may be a string such as GIF, JPEG, or PNG for a WMS 1.0 server, or a mime-type string in the case of a WMS 1.1 server. It may also be null if the format has not yet been set.- Returns:
- the string representing the format of this request
-
getImageWidth
public int getImageWidth()
Gets the width of the requested image, in pixels. The default image width is 100.- Returns:
- the width of the requested image
-
getImageHeight
public int getImageHeight()
Gets the height of the requested image, in pixels. The default image height is 100.- Returns:
- the height of the requested image
-
getLayerNames
public List<String> getLayerNames()
Returns the list of layers to be requested. Each item in the list should be a String which is the name of a layer.- Returns:
- the list of layer names to be requested
-
getBoundingBox
public BoundingBox getBoundingBox()
Gets the BoundingBox of the image being requested.- Returns:
- the BoundingBox of the image being requested
-
getTransparent
public boolean getTransparent()
Gets whether or not a transparent image is being requested.- Returns:
- true if a transparent image is being requested, false otherwise
-
setFormat
public void setFormat(String format) throws IllegalArgumentException
Sets the format of this request. The format must be a string which is in the list of supported formats as provided by getSupportedFormatList() (not necessarily the same String object, but the same sequence of characters). This will be an unformatted string for a WMS 1.0 server (GIF, JPEG, PNG) or a mime-type string for a WMS 1.1 server (image/gif, image/jpeg, image/png). If the format specified is not in the list, an IllegalArgumentException will be thrown.- Parameters:
format- a format string which is in the list of supported formats- Throws:
IllegalArgumentException- if the specified format isn't in the list of supported formats- See Also:
MapImageFormatChooser
-
setStyle
public void setStyle(MapStyle style)
-
setMoreParameters
public void setMoreParameters(String moreParameters)
-
setApiKeyNameAndValue
public void setApiKeyNameAndValue(String apiKeyNameAndValue)
-
setImageWidth
public void setImageWidth(int imageWidth)
Sets the width of the image being requested.- Parameters:
imageWidth- the width of the image being requested
-
setImageHeight
public void setImageHeight(int imageHeight)
Sets the height of the image being requested.- Parameters:
imageHeight- the height of the image being requested
-
setImageSize
public void setImageSize(int imageWidth, int imageHeight)Sets the width and height of the image being requested.- Parameters:
imageWidth- the width of the image being requestedimageHeight- the height of the image being requested
-
setLayerNames
public void setLayerNames(List<String> layerNames)
Sets the layers to be requested. Each item in the list should be a string which corresponds to the name of a layer. The order of the list is important as the layers are rendered in the same order they are listed.- Parameters:
layerNames- an ordered List of the names of layers to be displayed
-
setBoundingBox
public void setBoundingBox(BoundingBox bbox)
Sets the BoundingBox of the image being requested.- Parameters:
bbox- the BoundingBox of the image being requested
-
setTransparent
public void setTransparent(boolean transparent)
Sets whether or not to request an image with a transparent background. Requesting a transparent background doesn't guarantee that the resulting image will actually have a transparent background. Not all servers support transparency, and not all formats support transparency.- Parameters:
transparent- true to request a transparent background, false otherwise.
-
listToString
public static String listToString(List<String> list)
Returns a String containing the string representations of each item in the list (as provided by toString()), separated by commas.- Parameters:
list- the list to be returned as a coma-separated String- Returns:
- a comma-separted String of the items in the list
-
getURL
public URL getURL() throws MalformedURLException
Description copied from class:AbstractWMSRequestmust be implemented according to the specific needs- Specified by:
getURLin interfaceWMSRequest- Specified by:
getURLin classAbstractWMSRequest- Returns:
- the URL for this request
- Throws:
MalformedURLException- if there is a problem building the URL for some reason
-
-