Class WMSImagery
- java.lang.Object
-
- org.openstreetmap.josm.io.imagery.WMSImagery
-
public class WMSImagery extends java.lang.Object
This class represents the capabilities of a WMS imagery server.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWMSImagery.WMSGetCapabilitiesExceptionAn exception that is thrown if there was an error while getting the capabilities of the WMS server.
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringCAPABILITIES_QUERY_STRINGprivate static javax.xml.namespace.QNameCAPABILITIES_ROOT_111private static javax.xml.namespace.QNameCAPABILITIES_ROOT_130private java.net.URLcapabilitiesUrlprivate java.util.List<java.lang.String>formatsprivate java.lang.StringgetMapUrlprivate java.util.Map<java.lang.String,java.lang.String>headersprivate java.util.List<LayerDetails>layersprivate static javax.xml.namespace.QNameQN_ABSTRACTprivate static javax.xml.namespace.QNameQN_BOUNDINGBOXprivate static javax.xml.namespace.QNameQN_CAPABILITYprivate static javax.xml.namespace.QNameQN_CRSprivate static javax.xml.namespace.QNameQN_DCPTYPEprivate static javax.xml.namespace.QNameQN_EASTBOUNDLONGITUDEprivate static javax.xml.namespace.QNameQN_EX_GEOGRAPHIC_BBOXprivate static javax.xml.namespace.QNameQN_FORMATprivate static javax.xml.namespace.QNameQN_GETprivate static javax.xml.namespace.QNameQN_GETMAPprivate static javax.xml.namespace.QNameQN_HTTPprivate static javax.xml.namespace.QNameQN_LATLONBOUNDINGBOXprivate static javax.xml.namespace.QNameQN_LAYERprivate static javax.xml.namespace.QNameQN_NAMEprivate static javax.xml.namespace.QNameQN_NORTHBOUNDLATITUDEprivate static javax.xml.namespace.QNameQN_ONLINE_RESOURCEprivate static javax.xml.namespace.QNameQN_REQUESTprivate static javax.xml.namespace.QNameQN_SERVICEprivate static javax.xml.namespace.QNameQN_SOUTHBOUNDLATITUDEprivate static javax.xml.namespace.QNameQN_SRSprivate static javax.xml.namespace.QNameQN_STYLEprivate static javax.xml.namespace.QNameQN_TITLEprivate static javax.xml.namespace.QNameQN_WESTBOUNDLONGITUDEprivate static java.lang.StringREQUEST_GET_CAPABILITIESprivate static java.lang.StringSERVICE_WMSprivate java.lang.Stringtitleprivate java.lang.Stringversionstatic java.lang.StringWMS_NS_URLWMS namespace address
-
Constructor Summary
Constructors Constructor Description WMSImagery(java.lang.String url)Make getCapabilities request towards given URLWMSImagery(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers)Make getCapabilities request towards given URL using headersWMSImagery(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, ProgressMonitor monitor)Make getCapabilities request towards given URL using headers
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidattemptGetCapabilities(java.lang.String url)booleanbelowWMS130()Determines if this service operates at protocol level below WMS 1.3.0java.lang.StringbuildGetMapUrl(java.util.List<java.lang.String> selectedLayers, java.util.Collection<java.lang.String> selectedStyles, java.lang.String format, boolean transparent)Returns URL for accessing GetMap service.java.lang.StringbuildGetMapUrl(java.util.List<DefaultLayer> selectedLayers, boolean transparent)Returns URL for accessing GetMap service.java.lang.StringbuildGetMapUrl(java.util.List<LayerDetails> selectedLayers, java.util.List<java.lang.String> selectedStyles, boolean transparent)Returns URL for accessing GetMap service.java.lang.StringbuildGetMapUrl(java.util.List<LayerDetails> selectedLayers, java.util.List<java.lang.String> selectedStyles, java.lang.String format, boolean transparent)Returns URL for accessing GetMap service.java.lang.StringbuildRootUrl()Returns root URL of services in this GetCapabilities.java.lang.StringbuildRootUrlWithoutCapabilities()Returns root URL of services without the GetCapabilities call.private voidcalculateChildren()private static doublegetDecimalDegree(java.lang.String value)java.util.Collection<java.lang.String>getFormats()Returns the list of supported formats.java.util.List<LayerDetails>getLayers()Returns the list of top-level layers.java.util.List<LayerDetails>getLayers(java.util.List<DefaultLayer> defaultLayers)Returns collection of LayerDetails specified by defaultLayers.java.lang.StringgetPreferredFormat()Gets the preferred format for this imagery layer.java.util.Collection<java.lang.String>getServerProjections(java.util.List<LayerDetails> selectedLayers)Returns projections that server supports for provided list of layers.java.lang.StringgetTitle()Returns title of this service.(package private) static booleanimageFormatHasTransparency(java.lang.String format)(package private) static booleanisImageFormatSupported(java.lang.String format)(package private) static booleanisImageFormatSupported(java.lang.String format, java.lang.String... mimeFormats)private static booleanisImageFormatSupportedWarn(java.lang.String format)private static java.lang.StringnormalizeUrl(java.lang.String serviceUrlStr)private voidparseAndAddStyle(javax.xml.stream.XMLStreamReader reader, LayerDetails ld)private static BoundsparseBBox(Projection conv, java.lang.String miny, java.lang.String minx, java.lang.String maxy, java.lang.String maxx)private BoundsparseBoundingBox(javax.xml.stream.XMLStreamReader reader, Projection conv)private voidparseCapability(javax.xml.stream.XMLStreamReader reader)private BoundsparseExGeographic(javax.xml.stream.XMLStreamReader reader)private voidparseLayer(javax.xml.stream.XMLStreamReader reader, LayerDetails parentLayer)private voidparseRequest(javax.xml.stream.XMLStreamReader reader)private voidparseService(javax.xml.stream.XMLStreamReader reader)private booleantagEquals(javax.xml.namespace.QName a, javax.xml.namespace.QName b)ImageryInfotoImageryInfo(java.lang.String name, java.util.List<LayerDetails> selectedLayers, java.util.List<java.lang.String> selectedStyles, java.lang.String format, boolean transparent)Creates ImageryInfo object from this GetCapabilities document
-
-
-
Field Detail
-
SERVICE_WMS
private static final java.lang.String SERVICE_WMS
- See Also:
- Constant Field Values
-
REQUEST_GET_CAPABILITIES
private static final java.lang.String REQUEST_GET_CAPABILITIES
- See Also:
- Constant Field Values
-
CAPABILITIES_QUERY_STRING
private static final java.lang.String CAPABILITIES_QUERY_STRING
- See Also:
- Constant Field Values
-
WMS_NS_URL
public static final java.lang.String WMS_NS_URL
WMS namespace address- See Also:
- Constant Field Values
-
CAPABILITIES_ROOT_130
private static final javax.xml.namespace.QName CAPABILITIES_ROOT_130
-
QN_ABSTRACT
private static final javax.xml.namespace.QName QN_ABSTRACT
-
QN_CAPABILITY
private static final javax.xml.namespace.QName QN_CAPABILITY
-
QN_CRS
private static final javax.xml.namespace.QName QN_CRS
-
QN_DCPTYPE
private static final javax.xml.namespace.QName QN_DCPTYPE
-
QN_FORMAT
private static final javax.xml.namespace.QName QN_FORMAT
-
QN_GET
private static final javax.xml.namespace.QName QN_GET
-
QN_GETMAP
private static final javax.xml.namespace.QName QN_GETMAP
-
QN_HTTP
private static final javax.xml.namespace.QName QN_HTTP
-
QN_LAYER
private static final javax.xml.namespace.QName QN_LAYER
-
QN_NAME
private static final javax.xml.namespace.QName QN_NAME
-
QN_REQUEST
private static final javax.xml.namespace.QName QN_REQUEST
-
QN_SERVICE
private static final javax.xml.namespace.QName QN_SERVICE
-
QN_STYLE
private static final javax.xml.namespace.QName QN_STYLE
-
QN_TITLE
private static final javax.xml.namespace.QName QN_TITLE
-
QN_BOUNDINGBOX
private static final javax.xml.namespace.QName QN_BOUNDINGBOX
-
QN_EX_GEOGRAPHIC_BBOX
private static final javax.xml.namespace.QName QN_EX_GEOGRAPHIC_BBOX
-
QN_WESTBOUNDLONGITUDE
private static final javax.xml.namespace.QName QN_WESTBOUNDLONGITUDE
-
QN_EASTBOUNDLONGITUDE
private static final javax.xml.namespace.QName QN_EASTBOUNDLONGITUDE
-
QN_SOUTHBOUNDLATITUDE
private static final javax.xml.namespace.QName QN_SOUTHBOUNDLATITUDE
-
QN_NORTHBOUNDLATITUDE
private static final javax.xml.namespace.QName QN_NORTHBOUNDLATITUDE
-
QN_ONLINE_RESOURCE
private static final javax.xml.namespace.QName QN_ONLINE_RESOURCE
-
CAPABILITIES_ROOT_111
private static final javax.xml.namespace.QName CAPABILITIES_ROOT_111
-
QN_SRS
private static final javax.xml.namespace.QName QN_SRS
-
QN_LATLONBOUNDINGBOX
private static final javax.xml.namespace.QName QN_LATLONBOUNDINGBOX
-
headers
private final java.util.Map<java.lang.String,java.lang.String> headers
-
version
private java.lang.String version
-
getMapUrl
private java.lang.String getMapUrl
-
capabilitiesUrl
private java.net.URL capabilitiesUrl
-
formats
private final java.util.List<java.lang.String> formats
-
layers
private java.util.List<LayerDetails> layers
-
title
private java.lang.String title
-
-
Constructor Detail
-
WMSImagery
public WMSImagery(java.lang.String url) throws java.io.IOException, WMSImagery.WMSGetCapabilitiesException
Make getCapabilities request towards given URL- Parameters:
url- service url- Throws:
java.io.IOException- when connection error when fetching get capabilities documentWMSImagery.WMSGetCapabilitiesException- when there are errors when parsing get capabilities documentjava.nio.file.InvalidPathException- if a Path object cannot be constructed for the capabilities cached file
-
WMSImagery
public WMSImagery(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers) throws java.io.IOException, WMSImagery.WMSGetCapabilitiesException
Make getCapabilities request towards given URL using headers- Parameters:
url- service urlheaders- HTTP headers to be sent with request- Throws:
java.io.IOException- when connection error when fetching get capabilities documentWMSImagery.WMSGetCapabilitiesException- when there are errors when parsing get capabilities documentjava.nio.file.InvalidPathException- if a Path object cannot be constructed for the capabilities cached file
-
WMSImagery
public WMSImagery(java.lang.String url, java.util.Map<java.lang.String,java.lang.String> headers, ProgressMonitor monitor) throws java.io.IOException, WMSImagery.WMSGetCapabilitiesException
Make getCapabilities request towards given URL using headers- Parameters:
url- service urlheaders- HTTP headers to be sent with requestmonitor- Feedback for which URL we are currently trying, the integer is the total number of urls we are going to try- Throws:
java.io.IOException- when connection error when fetching get capabilities documentWMSImagery.WMSGetCapabilitiesException- when there are errors when parsing get capabilities documentjava.nio.file.InvalidPathException- if a Path object cannot be constructed for the capabilities cached file- Since:
- 18780
-
-
Method Detail
-
calculateChildren
private void calculateChildren()
-
getLayers
public java.util.List<LayerDetails> getLayers()
Returns the list of top-level layers.- Returns:
- the list of top-level layers
-
getFormats
public java.util.Collection<java.lang.String> getFormats()
Returns the list of supported formats.- Returns:
- the list of supported formats
-
getPreferredFormat
public java.lang.String getPreferredFormat()
Gets the preferred format for this imagery layer.- Returns:
- The preferred format as mime type.
-
buildRootUrl
public java.lang.String buildRootUrl()
Returns root URL of services in this GetCapabilities.- Returns:
- root URL of services in this GetCapabilities
-
buildRootUrlWithoutCapabilities
public java.lang.String buildRootUrlWithoutCapabilities()
Returns root URL of services without the GetCapabilities call.- Returns:
- root URL of services without the GetCapabilities call
- Since:
- 15209
-
buildGetMapUrl
public java.lang.String buildGetMapUrl(java.util.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 of
getServerProjections(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)
getPreferredFormat()- 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
- {proj} - that needs to be replaced with projection (one of
-
buildGetMapUrl
public java.lang.String buildGetMapUrl(java.util.List<LayerDetails> selectedLayers, java.util.List<java.lang.String> selectedStyles, boolean transparent)
Returns URL for accessing GetMap service. String will contain following parameters:- {proj} - that needs to be replaced with projection (one of
getServerProjections(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)
getPreferredFormat()- 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)
- {proj} - that needs to be replaced with projection (one of
-
buildGetMapUrl
public java.lang.String buildGetMapUrl(java.util.List<LayerDetails> selectedLayers, java.util.List<java.lang.String> selectedStyles, java.lang.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 java.lang.String buildGetMapUrl(java.util.List<java.lang.String> selectedLayers, java.util.Collection<java.lang.String> selectedStyles, java.lang.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)
-
tagEquals
private boolean tagEquals(javax.xml.namespace.QName a, javax.xml.namespace.QName b)
-
attemptGetCapabilities
private void attemptGetCapabilities(java.lang.String url) throws java.io.IOException, WMSImagery.WMSGetCapabilitiesException
- Throws:
java.io.IOExceptionWMSImagery.WMSGetCapabilitiesException
-
parseService
private void parseService(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
parseCapability
private void parseCapability(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
parseRequest
private void parseRequest(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
parseLayer
private void parseLayer(javax.xml.stream.XMLStreamReader reader, LayerDetails parentLayer) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.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(javax.xml.stream.XMLStreamReader reader, LayerDetails ld) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
parseExGeographic
private Bounds parseExGeographic(javax.xml.stream.XMLStreamReader reader) throws javax.xml.stream.XMLStreamException
- Throws:
javax.xml.stream.XMLStreamException
-
parseBoundingBox
private Bounds parseBoundingBox(javax.xml.stream.XMLStreamReader reader, Projection conv)
-
parseBBox
private static Bounds parseBBox(Projection conv, java.lang.String miny, java.lang.String minx, java.lang.String maxy, java.lang.String maxx)
-
getDecimalDegree
private static double getDecimalDegree(java.lang.String value)
-
normalizeUrl
private static java.lang.String normalizeUrl(java.lang.String serviceUrlStr) throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException
-
isImageFormatSupportedWarn
private static boolean isImageFormatSupportedWarn(java.lang.String format)
-
isImageFormatSupported
static boolean isImageFormatSupported(java.lang.String format)
-
isImageFormatSupported
static boolean isImageFormatSupported(java.lang.String format, java.lang.String... mimeFormats)
-
imageFormatHasTransparency
static boolean imageFormatHasTransparency(java.lang.String format)
-
toImageryInfo
public ImageryInfo toImageryInfo(java.lang.String name, java.util.List<LayerDetails> selectedLayers, java.util.List<java.lang.String> selectedStyles, java.lang.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 java.util.Collection<java.lang.String> getServerProjections(java.util.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 java.util.List<LayerDetails> getLayers(java.util.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
-
getTitle
public java.lang.String getTitle()
Returns title of this service.- Returns:
- title of this service
-
-