Class WMSImagery
- java.lang.Object
-
- org.openstreetmap.josm.io.imagery.WMSImagery
-
public class WMSImagery extends Object
This class represents the capabilities of a WMS imagery server.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WMSImagery.WMSGetCapabilitiesException
An exception that is thrown if there was an error while getting the capabilities of the WMS server.
-
Field Summary
-
Constructor Summary
Constructors Constructor Description WMSImagery(String url)
Make getCapabilities request towards given URLWMSImagery(String url, Map<String,String> headers)
Make getCapabilities request towards given URL using headers
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
attemptGetCapabilities(String url)
boolean
belowWMS130()
Determines if this service operates at protocol level below WMS 1.3.0String
buildGetMapUrl(List<String> selectedLayers, Collection<String> selectedStyles, String format, boolean transparent)
Returns URL for accessing GetMap service.String
buildGetMapUrl(List<DefaultLayer> selectedLayers, boolean transparent)
Returns URL for accessing GetMap service.String
buildGetMapUrl(List<LayerDetails> selectedLayers, List<String> selectedStyles, boolean transparent)
Returns URL for accessing GetMap service.String
buildGetMapUrl(List<LayerDetails> selectedLayers, List<String> selectedStyles, String format, boolean transparent)
Returns URL for accessing GetMap service.String
buildRootUrl()
Returns root URL of services in this GetCapabilities.String
buildRootUrlWithoutCapabilities()
Returns root URL of services without the GetCapabilities call.private void
calculateChildren()
private static double
getDecimalDegree(String value)
Collection<String>
getFormats()
Returns the list of supported formats.List<LayerDetails>
getLayers()
Returns the list of top-level layers.List<LayerDetails>
getLayers(List<DefaultLayer> defaultLayers)
Returns collection of LayerDetails specified by defaultLayers.String
getPreferredFormat()
Gets the preferred format for this imagery layer.Collection<String>
getServerProjections(List<LayerDetails> selectedLayers)
Returns projections that server supports for provided list of layers.String
getTitle()
Returns title of this service.(package private) static boolean
imageFormatHasTransparency(String format)
(package private) static boolean
isImageFormatSupported(String format)
(package private) static boolean
isImageFormatSupported(String format, String... mimeFormats)
private static boolean
isImageFormatSupportedWarn(String format)
private static String
normalizeUrl(String serviceUrlStr)
private void
parseAndAddStyle(XMLStreamReader reader, LayerDetails ld)
private static Bounds
parseBBox(Projection conv, String miny, String minx, String maxy, String maxx)
private Bounds
parseBoundingBox(XMLStreamReader reader, Projection conv)
private void
parseCapability(XMLStreamReader reader)
private Bounds
parseExGeographic(XMLStreamReader reader)
private void
parseLayer(XMLStreamReader reader, LayerDetails parentLayer)
private void
parseRequest(XMLStreamReader reader)
private void
parseService(XMLStreamReader reader)
private boolean
tagEquals(QName a, QName b)
ImageryInfo
toImageryInfo(String name, List<LayerDetails> selectedLayers, List<String> selectedStyles, String format, boolean transparent)
Creates ImageryInfo object from this GetCapabilities document
-
-
-
Field Detail
-
SERVICE_WMS
private static final String SERVICE_WMS
- See Also:
- Constant Field Values
-
REQUEST_GET_CAPABILITIES
private static final String REQUEST_GET_CAPABILITIES
- See Also:
- Constant Field Values
-
CAPABILITIES_QUERY_STRING
private static final String CAPABILITIES_QUERY_STRING
- See Also:
- Constant Field Values
-
WMS_NS_URL
public static final String WMS_NS_URL
WMS namespace address- See Also:
- Constant Field Values
-
CAPABILITIES_ROOT_130
private static final QName CAPABILITIES_ROOT_130
-
QN_ABSTRACT
private static final QName QN_ABSTRACT
-
QN_CAPABILITY
private static final QName QN_CAPABILITY
-
QN_DCPTYPE
private static final QName QN_DCPTYPE
-
QN_REQUEST
private static final QName QN_REQUEST
-
QN_SERVICE
private static final QName QN_SERVICE
-
QN_BOUNDINGBOX
private static final QName QN_BOUNDINGBOX
-
QN_EX_GEOGRAPHIC_BBOX
private static final QName QN_EX_GEOGRAPHIC_BBOX
-
QN_WESTBOUNDLONGITUDE
private static final QName QN_WESTBOUNDLONGITUDE
-
QN_EASTBOUNDLONGITUDE
private static final QName QN_EASTBOUNDLONGITUDE
-
QN_SOUTHBOUNDLATITUDE
private static final QName QN_SOUTHBOUNDLATITUDE
-
QN_NORTHBOUNDLATITUDE
private static final QName QN_NORTHBOUNDLATITUDE
-
QN_ONLINE_RESOURCE
private static final QName QN_ONLINE_RESOURCE
-
CAPABILITIES_ROOT_111
private static final QName CAPABILITIES_ROOT_111
-
QN_LATLONBOUNDINGBOX
private static final QName QN_LATLONBOUNDINGBOX
-
capabilitiesUrl
private URL capabilitiesUrl
-
layers
private List<LayerDetails> layers
-
-
Constructor Detail
-
WMSImagery
public WMSImagery(String url) throws IOException, WMSImagery.WMSGetCapabilitiesException
Make getCapabilities request towards given URL- Parameters:
url
- service url- Throws:
IOException
- when connection error when fetching get capabilities documentWMSImagery.WMSGetCapabilitiesException
- when there are errors when parsing get capabilities documentInvalidPathException
- if a Path object cannot be constructed for the capabilities cached file
-
WMSImagery
public WMSImagery(String url, Map<String,String> headers) throws IOException, WMSImagery.WMSGetCapabilitiesException
Make getCapabilities request towards given URL using headers- Parameters:
url
- service urlheaders
- HTTP headers to be sent with request- Throws:
IOException
- when connection error when fetching get capabilities documentWMSImagery.WMSGetCapabilitiesException
- when there are errors when parsing get capabilities documentInvalidPathException
- if a Path object cannot be constructed for the capabilities cached file
-
-
Method Detail
-
calculateChildren
private void calculateChildren()
-
getLayers
public List<LayerDetails> getLayers()
Returns the list of top-level layers.- Returns:
- the list of top-level layers
-
getFormats
public Collection<String> getFormats()
Returns the list of supported formats.- Returns:
- the list of supported formats
-
getPreferredFormat
public String getPreferredFormat()
Gets the preferred format for this imagery layer.- Returns:
- The preferred format as mime type.
-
buildRootUrl
public String buildRootUrl()
Returns root URL of services in this GetCapabilities.- Returns:
- root URL of services in this GetCapabilities
-
buildRootUrlWithoutCapabilities
public String buildRootUrlWithoutCapabilities()
Returns root URL of services without the GetCapabilities call.- Returns:
- root URL of services without the GetCapabilities call
- Since:
- 15209
-
buildGetMapUrl
public String buildGetMapUrl(List<DefaultLayer> selectedLayers, boolean transparent)
Returns URL for accessing GetMap service. String will contain following parameters: * {proj} - that needs to be replaced with projection (one ofgetServerProjections(List)
) * {width} - that needs to be replaced with width of the tile * {height} - that needs to be replaces with height of the tile * {bbox} - that needs to be replaced with area that should be fetched (in {proj} coordinates) Format of the response will be calculated usinggetPreferredFormat()
- Parameters:
selectedLayers
- list of DefaultLayer selection of layers to be showntransparent
- whether returned images should contain transparent pixels (if supported by format)- Returns:
- URL template for GetMap service containing
-
buildGetMapUrl
public String buildGetMapUrl(List<LayerDetails> selectedLayers, List<String> selectedStyles, boolean transparent)
Returns URL for accessing GetMap service. String will contain following parameters: * {proj} - that needs to be replaced with projection (one ofgetServerProjections(List)
) * {width} - that needs to be replaced with width of the tile * {height} - that needs to be replaces with height of the tile * {bbox} - that needs to be replaced with area that should be fetched (in {proj} coordinates) Format of the response will be calculated usinggetPreferredFormat()
- Parameters:
selectedLayers
- selected layers as subset of the tree returned bygetLayers()
selectedStyles
- selected styles for all selectedLayerstransparent
- whether returned images should contain transparent pixels (if supported by format)- Returns:
- URL template for GetMap service
- See Also:
buildGetMapUrl(List, boolean)
-
buildGetMapUrl
public String buildGetMapUrl(List<LayerDetails> selectedLayers, List<String> selectedStyles, String format, boolean transparent)
Returns URL for accessing GetMap service. String will contain following parameters: * {proj} - that needs to be replaced with projection (one ofgetServerProjections(List)
) * {width} - that needs to be replaced with width of the tile * {height} - that needs to be replaces with height of the tile * {bbox} - that needs to be replaced with area that should be fetched (in {proj} coordinates)- Parameters:
selectedLayers
- selected layers as subset of the tree returned bygetLayers()
selectedStyles
- selected styles for all selectedLayersformat
- format of the response - one ofgetFormats()
transparent
- whether returned images should contain transparent pixels (if supported by format)- Returns:
- URL template for GetMap service
- Since:
- 15228
- See Also:
buildGetMapUrl(List, boolean)
-
buildGetMapUrl
public String buildGetMapUrl(List<String> selectedLayers, Collection<String> selectedStyles, String format, boolean transparent)
Returns URL for accessing GetMap service. String will contain following parameters: * {proj} - that needs to be replaced with projection (one ofgetServerProjections(List)
) * {width} - that needs to be replaced with width of the tile * {height} - that needs to be replaces with height of the tile * {bbox} - that needs to be replaced with area that should be fetched (in {proj} coordinates)- Parameters:
selectedLayers
- selected layers as list of stringsselectedStyles
- selected styles of layers as list of stringsformat
- format of the response - one ofgetFormats()
transparent
- whether returned images should contain transparent pixels (if supported by format)- Returns:
- URL template for GetMap service
- See Also:
buildGetMapUrl(List, boolean)
-
attemptGetCapabilities
private void attemptGetCapabilities(String url) throws IOException, WMSImagery.WMSGetCapabilitiesException
-
parseService
private void parseService(XMLStreamReader reader) throws XMLStreamException
- Throws:
XMLStreamException
-
parseCapability
private void parseCapability(XMLStreamReader reader) throws XMLStreamException
- Throws:
XMLStreamException
-
parseRequest
private void parseRequest(XMLStreamReader reader) throws XMLStreamException
- Throws:
XMLStreamException
-
parseLayer
private void parseLayer(XMLStreamReader reader, LayerDetails parentLayer) throws XMLStreamException
- Throws:
XMLStreamException
-
belowWMS130
public boolean belowWMS130()
Determines if this service operates at protocol level below WMS 1.3.0- Returns:
- if this service operates at protocol level below 1.3.0
-
parseAndAddStyle
private void parseAndAddStyle(XMLStreamReader reader, LayerDetails ld) throws XMLStreamException
- Throws:
XMLStreamException
-
parseExGeographic
private Bounds parseExGeographic(XMLStreamReader reader) throws XMLStreamException
- Throws:
XMLStreamException
-
parseBoundingBox
private Bounds parseBoundingBox(XMLStreamReader reader, Projection conv)
-
parseBBox
private static Bounds parseBBox(Projection conv, String miny, String minx, String maxy, String maxx)
-
getDecimalDegree
private static double getDecimalDegree(String value)
-
normalizeUrl
private static String normalizeUrl(String serviceUrlStr) throws MalformedURLException
- Throws:
MalformedURLException
-
isImageFormatSupportedWarn
private static boolean isImageFormatSupportedWarn(String format)
-
isImageFormatSupported
static boolean isImageFormatSupported(String format)
-
isImageFormatSupported
static boolean isImageFormatSupported(String format, String... mimeFormats)
-
imageFormatHasTransparency
static boolean imageFormatHasTransparency(String format)
-
toImageryInfo
public ImageryInfo toImageryInfo(String name, List<LayerDetails> selectedLayers, List<String> selectedStyles, String format, boolean transparent)
Creates ImageryInfo object from this GetCapabilities document- Parameters:
name
- name of imagery layerselectedLayers
- layers which are to be used by this imagery layerselectedStyles
- styles that should be used for selectedLayersformat
- format of the response - one ofgetFormats()
transparent
- if layer should be transparent- Returns:
- ImageryInfo object
- Since:
- 15228
-
getServerProjections
public Collection<String> getServerProjections(List<LayerDetails> selectedLayers)
Returns projections that server supports for provided list of layers. This will be intersection of projections defined for each layer- Parameters:
selectedLayers
- list of layers- Returns:
- projection code
-
getLayers
public List<LayerDetails> getLayers(List<DefaultLayer> defaultLayers)
Returns collection of LayerDetails specified by defaultLayers.- Parameters:
defaultLayers
- default layers that should select layer object- Returns:
- collection of LayerDetails specified by defaultLayers
-
-