Class 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 class  WMSImagery.WMSGetCapabilitiesException
      An exception that is thrown if there was an error while getting the capabilities of the WMS server.
    • Constructor Summary

      Constructors 
      Constructor Description
      WMSImagery​(java.lang.String url)
      Make getCapabilities request towards given URL
      WMSImagery​(java.lang.String url, java.util.Map<java.lang.String,​java.lang.String> headers)
      Make getCapabilities request towards given URL using headers
      WMSImagery​(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 void attemptGetCapabilities​(java.lang.String url)  
      boolean belowWMS130()
      Determines if this service operates at protocol level below WMS 1.3.0
      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.
      java.lang.String buildGetMapUrl​(java.util.List<DefaultLayer> selectedLayers, boolean transparent)
      Returns URL for accessing GetMap service.
      java.lang.String buildGetMapUrl​(java.util.List<LayerDetails> selectedLayers, java.util.List<java.lang.String> selectedStyles, boolean transparent)
      Returns URL for accessing GetMap service.
      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.
      java.lang.String buildRootUrl()
      Returns root URL of services in this GetCapabilities.
      java.lang.String buildRootUrlWithoutCapabilities()
      Returns root URL of services without the GetCapabilities call.
      private void calculateChildren()  
      private static double getDecimalDegree​(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.String getPreferredFormat()
      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.String getTitle()
      Returns title of this service.
      (package private) static boolean imageFormatHasTransparency​(java.lang.String format)  
      (package private) static boolean isImageFormatSupported​(java.lang.String format)  
      (package private) static boolean isImageFormatSupported​(java.lang.String format, java.lang.String... mimeFormats)  
      private static boolean isImageFormatSupportedWarn​(java.lang.String format)  
      private static java.lang.String normalizeUrl​(java.lang.String serviceUrlStr)  
      private void parseAndAddStyle​(javax.xml.stream.XMLStreamReader reader, LayerDetails ld)  
      private static Bounds parseBBox​(Projection conv, java.lang.String miny, java.lang.String minx, java.lang.String maxy, java.lang.String maxx)  
      private Bounds parseBoundingBox​(javax.xml.stream.XMLStreamReader reader, Projection conv)  
      private void parseCapability​(javax.xml.stream.XMLStreamReader reader)  
      private Bounds parseExGeographic​(javax.xml.stream.XMLStreamReader reader)  
      private void parseLayer​(javax.xml.stream.XMLStreamReader reader, LayerDetails parentLayer)  
      private void parseRequest​(javax.xml.stream.XMLStreamReader reader)  
      private void parseService​(javax.xml.stream.XMLStreamReader reader)  
      private boolean tagEquals​(javax.xml.namespace.QName a, javax.xml.namespace.QName b)  
      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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 document
        WMSImagery.WMSGetCapabilitiesException - when there are errors when parsing get capabilities document
        java.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 url
        headers - HTTP headers to be sent with request
        Throws:
        java.io.IOException - when connection error when fetching get capabilities document
        WMSImagery.WMSGetCapabilitiesException - when there are errors when parsing get capabilities document
        java.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 url
        headers - HTTP headers to be sent with request
        monitor - 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 document
        WMSImagery.WMSGetCapabilitiesException - when there are errors when parsing get capabilities document
        java.nio.file.InvalidPathException - if a Path object cannot be constructed for the capabilities cached file
        Since:
        18780
    • Method Detail

      • getLayers

        public java.util.List<LayerDetailsgetLayers()
        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)
        Format of the response will be calculated using getPreferredFormat()
        Parameters:
        selectedLayers - list of DefaultLayer selection of layers to be shown
        transparent - whether returned images should contain transparent pixels (if supported by format)
        Returns:
        URL template for GetMap service containing
      • 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)
        Format of the response will be calculated using getPreferredFormat()
        Parameters:
        selectedLayers - selected layers as subset of the tree returned by getLayers()
        selectedStyles - selected styles for all selectedLayers
        transparent - whether returned images should contain transparent pixels (if supported by format)
        Returns:
        URL template for GetMap service
        See Also:
        buildGetMapUrl(List, boolean)
      • 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 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)
        Parameters:
        selectedLayers - selected layers as subset of the tree returned by getLayers()
        selectedStyles - selected styles for all selectedLayers
        format - format of the response - one of getFormats()
        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 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)
        Parameters:
        selectedLayers - selected layers as list of strings
        selectedStyles - selected styles of layers as list of strings
        format - format of the response - one of getFormats()
        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)
      • 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
      • 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
      • isImageFormatSupported

        static boolean isImageFormatSupported​(java.lang.String format,
                                              java.lang.String... mimeFormats)
      • 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 layer
        selectedLayers - layers which are to be used by this imagery layer
        selectedStyles - styles that should be used for selectedLayers
        format - format of the response - one of getFormats()
        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<LayerDetailsgetLayers​(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