Class AerisAmp


  • public class AerisAmp
    extends Object
    Created by sshie on 1/6/2017.
    • Constructor Detail

      • AerisAmp

        public AerisAmp()
        Constructor Create AerisAmp class with default refreshPermissions to false
      • AerisAmp

        public AerisAmp​(String clientId,
                        String clientSecret)
        Constructor Create AerisAmp class with default refreshPermissions to false
        Parameters:
        clientId - The AerisWeather client id
        clientSecret - The AerisWeather client key
      • AerisAmp

        public AerisAmp​(String clientId,
                        String clientSecret,
                        boolean refreshPermissions)
        Constructor Create AerisAmp class allowing permissions to be refreshed if needed
        Parameters:
        clientId - The AerisWeather client id
        clientSecret - The AerisWeather client key
      • AerisAmp

        public AerisAmp​(String clientId,
                        String clientSecret,
                        float lat,
                        float lon,
                        int zoom,
                        int width,
                        int height)
        Constructor Create AerisAmp class passing in user defined values for lat, lon, zoom etc. Refresh permissions is defaulted to false.
        Parameters:
        clientId - The AerisWeather client id
        clientSecret - The AerisWeather client key
      • AerisAmp

        public AerisAmp​(String clientId,
                        String clientSecret,
                        float lat,
                        float lon,
                        int zoom,
                        int width,
                        int height,
                        boolean refreshPermissions)
        Constructor Create AerisAmp class passing in user defined values for lat, lon, zoom etc as well as allowing user to specify if permissions is refresh or not.
        Parameters:
        clientId - The AerisWeather client id
        clientSecret - The AerisWeather client key
      • AerisAmp

        public AerisAmp​(String clientId,
                        String clientSecret,
                        int width,
                        int height,
                        double south,
                        double west,
                        double north,
                        double east)
        Constructor for creating an AMP layer from a bounding box
        Parameters:
        clientId - The AerisWeather client id
        clientSecret - The AerisWeather client key
        width - The width of the map area
        height - The height of the map area
        south - The southern most longitude
        west - The western most latitude
        north - The northern most longitude
        east - The eastern most latitude
    • Method Detail

      • setClientId

        public void setClientId​(String id)
        Set the AerisEngine client id
        Parameters:
        id - The AerisWeather client id
      • setClientSecret

        public void setClientSecret​(String secret)
        Set the AerisEngine client secret
        Parameters:
        secret - The AerisWeather client key
      • setSouth

        public void setSouth​(double south)
        Set the southern most (bottom) latitude coordinate of the bounding box, in degrees.
        Parameters:
        south - southern most (bottom) latitude
      • setWest

        public void setWest​(double west)
        Set the western most (left) longitude coordinate of the bounding box, in degrees.
        Parameters:
        west - western most (left) longitude
      • setNorth

        public void setNorth​(double north)
        Set the northern most (top) latitude coordinate of the bounding box, in degrees.
        Parameters:
        north - northern most (top) latitude
      • setEast

        public void setEast​(double east)
        Set the eastern most (right) longitude coordinate of the bounding box, in degrees.
        Parameters:
        east - eastern most (right) longitude
      • setBoundingBox

        public void setBoundingBox​(com.google.android.gms.maps.model.LatLngBounds latLngBounds)
        Used when creating an AMP layer from a bounding box
        Parameters:
        latLngBounds - latitude and longitude boundaries
      • getPermissions

        public com.aerisweather.aeris.model.AerisPermissions getPermissions​(Boolean refresh)
        Return an AerisPermissions object with the current Aeris API permissions. Will pull permissions from the API if the member permissions object is null or if the user specifies to force a refresh.
        Parameters:
        refresh - boolean
        Returns:
        AerisPermissions
      • getClientId

        public String getClientId()
      • getClientSecret

        public String getClientSecret()
      • setLatitude

        public void setLatitude​(float lat)
      • setLongitude

        public void setLongitude​(float lon)
      • setZoom

        public void setZoom​(float zoom)
      • getZoom

        public int getZoom()
      • setMapWidth

        public void setMapWidth​(int width)
      • setMapHeight

        public void setMapHeight​(int height)
      • setLatLng

        public void setLatLng​(com.google.android.gms.maps.model.LatLng latLng)
      • getLatLng

        public com.google.android.gms.maps.model.LatLng getLatLng()
      • setOpacity

        public void setOpacity​(int height)
      • setTimeOffset

        public void setTimeOffset​(String offset)
      • setDefaultLayers

        public boolean setDefaultLayers()
        setDefaultLayers() - Clears any layers that have been added previously, and adds the default layers of - Radar, opacity 80% - Flat, opacity 100% - Admin, opacity 100%
        Returns:
        boolean True if successful, false if failed
      • removeLayer

        public void removeLayer​(String aerisLayerId)
        removeLayer() Remove a layer from the AMP layer array using the layer ID.
        Parameters:
        aerisLayerId - layerId
      • removeLayer

        public void removeLayer​(AerisAmpLayer removeLayer)
        removeLayer() Remove a layer from the AMP layer array.
        Parameters:
        removeLayer - AerisAmpLayer
      • setLayer

        public void setLayer​(AerisAmpLayer layer)
        addLayer() Add an existing layer to the AMP layer array.
        Parameters:
        layer - AerisAmpLayer
      • setLayerFromName

        public int setLayerFromName​(String layerName)
        addLayer() Add a layer to the AMP layer array, based on the layer name.
        Parameters:
        layerName - The string name of the layer to add
        Returns:
        int Returns an int indicating the success or fail code. 0 = success 1 = failed - invalid layer name 2 = failed - no permissions for layer 3 = failed - error or exception
      • setLayerFromId

        public int setLayerFromId​(String layerId)
        addLayer() Add a layer to the AMP layer array, based on the layer id.
        Parameters:
        layerId - The string id of the layer to add
        Returns:
        int Returns an int indicating the success or fail code. 0 = success 1 = failed - invalid layer id 2 = failed - no permissions for layer 3 = failed - error or exception
      • buildStaticMapUrl

        public String buildStaticMapUrl()
        Create a static map URL to get a layer image from AMP using a center latlon and zoom
        Returns:
        String AMP url
      • buildStaticMapUrlWithBoundingBox

        public String buildStaticMapUrlWithBoundingBox()
        Create a static map URL to get a layer image from AMP using a bounding box
        Returns:
        String AMP url
      • getStaticMapUrl

        public String getStaticMapUrl()
        Returns the last static map url created. To create a new static map url, call buildStaticMapUrl()
        Returns:
        String The static map url created from the current amp properties.
      • buildTileUrl

        public String buildTileUrl​(int x,
                                   int y,
                                   int zoom)
      • getFutureLayerId

        public String getFutureLayerId​(String layerId)
      • getStaticMapImage

        public android.graphics.Bitmap getStaticMapImage()
        Get the map bitmap from AMP. If a bitmap has already been created it will be returned, if not a call will be made to the AerisWeather AMP API.
        Returns:
        Bitmap
      • getBitmapFromAMP

        public android.graphics.Bitmap getBitmapFromAMP​(String urlString)
        Get the map bitmap from AMP. The url passed in must include a valid AerisWeather client id and secret. This call will directly hit the AerisWeather API. To check if a bitmap has been generated previously, call getStaticMapImage()
        Parameters:
        urlString -
        Returns:
        Bitmap
      • getAllPossibleLayers

        public ArrayList<AerisAmpLayer> getAllPossibleLayers()
        Returns a list of all AMP layers available to the user.
        Returns:
        ArrayList All AMP layers defined in the layers.json
      • getPermissibleLayers

        public ArrayList<AerisAmpLayer> getPermissibleLayers()
        Returns a list of all AMP layers available to the user. If the array is already populated, it will return it as such. To force a refresh and recheck the layers, call the overloaded method with the forceRefresh parameter set to true.
        Returns:
        ArrayList The list of AMP layer objects available to the user
      • getPermissibleLayers

        public ArrayList<AerisAmpLayer> getPermissibleLayers​(boolean forceRefresh)
        Overload used to manually force a refresh of the array.
        Parameters:
        forceRefresh - boolean - pass true to manually force a recheck of allowed layers
        Returns:
        ArrayList The list of AMP layer objects available to the user
      • getActiveMapLayers

        public ArrayList<AerisAmpLayer> getActiveMapLayers()
        Returns a list of AerisAmpLayer currently selected/active.
        Returns:
        ArrayList The active layers.
      • getActiveLayer

        public AerisAmpLayer getActiveLayer​(String layerId)
        Returns a specific AerisAmpLayer. Returns null if the layer is not currently selected/active.
        Returns:
        AerisAmpLayer The requested active layer, or null if the layer is not active.
      • getActiveLayerFromId

        public AerisAmpLayer getActiveLayerFromId​(String layerId)
        Returns a specific AerisAmpLayer. Returns null if the layer is not currently selected/active.
        Returns:
        AerisAmpLayer The requested active layer, or null if the layer is not active.
      • getActiveLayerFromName

        public AerisAmpLayer getActiveLayerFromName​(String layerName)
        Returns a specific AerisAmpLayer. Returns null if the layer is not currently selected/active.
        Returns:
        AerisAmpLayer The requested active layer, or null if the layer is not active.
      • getLayerFromId

        public AerisAmpLayer getLayerFromId​(String layerId)
        Returns a specific AerisAmpLayer. Returns null if the layer is not currently selected/active.
        Returns:
        AerisAmpLayer The requested active layer, or null if the layer is not active.
      • getLayerFromName

        public AerisAmpLayer getLayerFromName​(String layerName)
        Returns a specific AerisAmpLayer. Returns null if the layer is not currently selected/active.
        Returns:
        AerisAmpLayer The requested active layer, or null if the layer is not active.
      • getLayerModifiersFromId

        public ArrayList getLayerModifiersFromId​(String layerId)
        Returns the available modifiers for a specific layer.
        Parameters:
        layerId - String
      • getLayerModifiersFromName

        public ArrayList getLayerModifiersFromName​(String layerName)
        Returns the available modifiers for a specific layer.
        Parameters:
        layerName - String
      • setTileValidTime

        public void setTileValidTime​(long tileValidTime)
        Use this method to set the overall valid time for the Amp layer. Most useful when loading or reloading tiles, since GoogleMap doesn't allow us to get at the data when it is drawing tiles.
        Parameters:
        tileValidTime - long
      • getTileValidTime

        public long getTileValidTime()