Class BaseWmsClient

    • Field Detail

      • mapHeight

        protected int mapHeight
      • mapWidth

        protected int mapWidth
      • proxyUrl

        protected String proxyUrl
      • docHref

        protected String docHref
      • nearestTime

        protected String nearestTime
      • mapArea

        protected MapArea mapArea
      • layerDetailsLoaded

        protected boolean layerDetailsLoaded
      • dateTimeDetailsLoaded

        protected boolean dateTimeDetailsLoaded
      • minMaxDetailsLoaded

        protected boolean minMaxDetailsLoaded
    • Constructor Detail

      • BaseWmsClient

        public BaseWmsClient()
    • Method Detail

      • onModuleLoad

        public void onModuleLoad()
        This is the entry point for GWT. Queries a config servlet and sets some global fields. If the config is not present, or there is an error, sets some defaults, and calls the initialisation method.
        Specified by:
        onModuleLoad in interface com.google.gwt.core.client.EntryPoint
      • handleCustomParams

        protected void handleCustomParams​(com.google.gwt.json.client.JSONObject parentObj)
        This is called after all other parameters have been received from a config servlet, and subclasses can use it to handle custom configuration options from the ConfigServlet.
        Parameters:
        parentObj -
      • initWithDefaults

        protected void initWithDefaults()
        Initializes the WMS client with some default settings. Subclasses can override this to define new defaults
      • getMapArea

        protected MapArea getMapArea()
        Returns:
        A new MapArea. This will be called once. Subclasses can override this method to use specialised subclasses of MapArea
      • getWmsRequestUrl

        protected String getWmsRequestUrl​(String wmsUrl,
                                          String request,
                                          Map<String,​String> parameters)
        Builds a URL given the request name and a Map of parameters
        Parameters:
        request - the request name (e.g. GetMap)
        parameters - a Map of parameters and their values
        Returns:
        the URL of the request
      • getUrlFromGetArgs

        protected String getUrlFromGetArgs​(String baseUrl,
                                           String... params)
        Encodes the URL, including proxy and base WMS URL
        Parameters:
        baseUrl - The base URL to encode
        params - A series of key=value arguments to append as GET parameters
        Returns:
        the encoded URL
      • getMapHeight

        protected int getMapHeight()
        Gets the height of the map in the map widget
        Returns:
        the height in pixels
      • getMapWidth

        protected int getMapWidth()
        Gets the width of the map in the map widget
        Returns:
        the width in pixels
      • requestLayerDetails

        protected void requestLayerDetails​(String wmsUrl,
                                           String layerId,
                                           String currentTime,
                                           boolean autoZoomAndPalette)
        Request details about a particular layer. Once loaded, layerDetailsLoaded will be called.
        Parameters:
        wmsUrl - the base URL of the WMS server containing the layer details
        layerId - the ID of the layer whose details are desired
        currentTime - the time we want to know the closest available time to. Can be null
        autoZoomAndPalette - true if we want to zoom to extents and possibly auto-adjust palette once the details have been loaded. Note that this will only auto-adjust the palette if the conditions are right
      • maybeRequestAutoRange

        protected void maybeRequestAutoRange​(String layerId,
                                             boolean force)
        Possibly requests the auto-detected scale range. This will make the request if force is true, or we have a default scale range set on the server
        Parameters:
        layerId - the ID of the layer to request the scale range for
        force - whether to perform even if a scale has been set on the server
      • rangeLoaded

        protected void rangeLoaded​(String layerId,
                                   double min,
                                   double max)
        This is called when an auto scale range has been loaded. It can be assumed that by this point we want to update the scale.
        Parameters:
        layerId - the layer for which the scale range has been loaded
        min - the minimum scale value
        max - the maximum scale value
      • layerDetailsLoaded

        protected void layerDetailsLoaded​(LayerDetails layerDetails)
        This is called once a layer's details have been loaded. By default this will just populate the widgets associated with this layer, but subclasses may want to override this method to implement custom behaviour before/after populating the widgets
        Parameters:
        layerDetails - the details received from the server
      • populateWidgets

        protected void populateWidgets​(LayerDetails layerDetails)
        Populates the set of widgets associated with this layer. The ID of the layer is taken from the LayerDetails and the associated widgets are retrieved and populated
        Parameters:
        layerDetails - a LayerDetails object containing the layer details. This gets returned when layer details are loaded
      • updateMapBase

        protected void updateMapBase​(String layerUpdated)
        Checks that all the required details are loaded (or do not need to be) before calling the subclass method
      • invalidJson

        protected void invalidJson​(Exception e,
                                   String response,
                                   String url,
                                   boolean displayPopup)
        Handles the case where we are unable to parse JSON data returned from the server, or where non-JSON data is returned when we expected JSON data. This covers a number of situations and so needs to be quite a general method.
        Parameters:
        e - The exception which was caught
        response - The message text
        url - The URL which caused the exception
      • layerSelected

        public void layerSelected​(String wmsUrl,
                                  String layerId,
                                  boolean autoZoomAndPalette)
        Description copied from interface: LayerSelectionHandler
        Called when a layer is selected
        Specified by:
        layerSelected in interface LayerSelectionHandler
        Parameters:
        wmsUrl - The WMS URL where the layer is present
        layerId - The ID of the layer on the WMS server
        autoZoomAndPalette - Whether we want to automatically zoom to the layer extents and adjust the palette. Note that the palette will not be adjusted if a range has been set on the server
      • layerDeselected

        public void layerDeselected​(String layerId)
        Description copied from interface: LayerSelectionHandler
        Called when a layer is deselected. This is only likely to happen on multi-layer systems TODO perhaps this will need a wmsUrl to uniquely locate the layer? Currently we have no multi-layer systems on which to test this, so it's not really important. This comment should be removed when one gets implemented
        Specified by:
        layerDeselected in interface LayerSelectionHandler
        Parameters:
        layerId - The ID of the layer which has been deselected
      • paletteChanged

        public void paletteChanged​(String layerId,
                                   String paletteName,
                                   String style,
                                   int nColorBands)
        Description copied from interface: PaletteSelectionHandler
        Called when the palette has changed in some way
        Specified by:
        paletteChanged in interface PaletteSelectionHandler
        Parameters:
        layerId - The layer for which the palette has changed
        paletteName - The name of the palette
        style - The name of the style
        nColorBands - The number of colour bands
      • scaleRangeChanged

        public void scaleRangeChanged​(String layerId,
                                      String scaleRange)
        Description copied from interface: PaletteSelectionHandler
        Called when the scale range has been adjusted
        Specified by:
        scaleRangeChanged in interface PaletteSelectionHandler
        Parameters:
        layerId - The layer for which the scale range has changed
        scaleRange - A string representing the new scale range
      • logScaleChanged

        public void logScaleChanged​(String layerId,
                                    boolean newIsLogScale)
        Description copied from interface: PaletteSelectionHandler
        Called when the linear/log scale setting has been changed
        Specified by:
        logScaleChanged in interface PaletteSelectionHandler
        Parameters:
        layerId - The layer for which the linear/log setting has changed
        newIsLogScale - true if the new state is logarithmic, false if it is linear
      • dateSelected

        public void dateSelected​(String layerId,
                                 String selectedDate)
        Description copied from interface: TimeDateSelectionHandler
        Called when a date is selected
        Specified by:
        dateSelected in interface TimeDateSelectionHandler
        Parameters:
        layerId - The layer on which a date has been chosen
        selectedDate - A string representing the selected date
      • setUnitConverter

        protected void setUnitConverter​(String layerId,
                                        UnitConverter converter)
        Allows the client to use different units to those specified on the server (e.g. convert celcius to kelvin)
        Parameters:
        layerId - The ID of the layer to convert units for
        converter - The UnitConverter to use for conversion
      • setLoading

        public void setLoading​(boolean loading)
        Description copied from interface: GodivaActionsHandler
        Should be called when a component starts or stops loading. This allows implementing classes to keep a count of the number of elements loading and take appropriate action when something starts loading, or when everything has finished loading
        Specified by:
        setLoading in interface GodivaActionsHandler
        Parameters:
        loading - true if the element has started loading, false if it has finished loading
      • onMapMove

        public void onMapMove​(org.gwtopenmaps.openlayers.client.event.MapMoveListener.MapMoveEvent eventObject)
        Specified by:
        onMapMove in interface org.gwtopenmaps.openlayers.client.event.MapMoveListener
      • onMapZoom

        public void onMapZoom​(org.gwtopenmaps.openlayers.client.event.MapZoomListener.MapZoomEvent eventObject)
        Specified by:
        onMapZoom in interface org.gwtopenmaps.openlayers.client.event.MapZoomListener
      • init

        protected abstract void init()
        This gets called once the page has loaded. Subclasses should use for initializing any widgets, and setting the layout. If this is not implemented, a blank page will be displayed
      • getWidgetCollection

        protected abstract GodivaStateInfo getWidgetCollection​(String layerId)
        Gets the GodivaStateInfo for the specified layer
        Parameters:
        layerId - The WMS layer ID
        Returns:
        The state information, usually in the form of widgets
      • requestAndPopulateMenu

        protected abstract void requestAndPopulateMenu()
        This is called at initialisation, and is used to populate the layer selection menu(s). Subclasses should use this to request any data and then populate the appropriate widget(s)
      • availableTimesLoaded

        protected abstract void availableTimesLoaded​(String layerId,
                                                     List<String> availableTimes,
                                                     String nearestTime)
        This is called once a list of available times has been loaded
        Parameters:
        layerId - the layer for which times have been loaded
        availableTimes - a List of available times
        nearestTime - the nearest time to the current time (for e.g. auto selection)
      • updateMap

        protected abstract void updateMap​(MapArea mapArea,
                                          String layerUpdated)
        This is where the map should be updated. It gets called when all details have been loaded and we actually want to update the map. Clients should handle this in the appropriate way, which will almost certainly involve a call to mapArea.addLayer(...)
        Parameters:
        mapArea - The map area which can be updated
        layerUpdated - The ID of the layer which we are viewing
      • loadingStarted

        protected abstract void loadingStarted()
        This is called when a loading process starts
      • loadingFinished

        protected abstract void loadingFinished()
        This is called when all loading processes have finished
      • getCurrentTime

        protected abstract String getCurrentTime()
        Returns the "current" time. The definition of current may depend on exactly what the client does. This is the time used when requesting layer details from the server - i.e. the time to which the "nearestTime" will refer
        Returns:
        A string representation of the current time