Package com.aerisweather.aeris.tiles
Class AerisAmp
- java.lang.Object
-
- com.aerisweather.aeris.tiles.AerisAmp
-
public class AerisAmp extends Object
Created by sshie on 1/6/2017.
-
-
Constructor Summary
Constructors Constructor Description AerisAmp()
Constructor Create AerisAmp class with default refreshPermissions to falseAerisAmp(String clientId, String clientSecret)
Constructor Create AerisAmp class with default refreshPermissions to falseAerisAmp(String clientId, String clientSecret, boolean refreshPermissions)
Constructor Create AerisAmp class allowing permissions to be refreshed if neededAerisAmp(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.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.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
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
buildStaticMapUrl()
Create a static map URL to get a layer image from AMP using a center latlon and zoomString
buildStaticMapUrlWithBoundingBox()
Create a static map URL to get a layer image from AMP using a bounding boxString
buildTileUrl(int x, int y, int zoom)
AerisAmpLayer
createNewLayer(String id, String name, int opacity)
AerisAmpLayer
getActiveLayer(String layerId)
Returns a specific AerisAmpLayer.AerisAmpLayer
getActiveLayerFromId(String layerId)
Returns a specific AerisAmpLayer.AerisAmpLayer
getActiveLayerFromName(String layerName)
Returns a specific AerisAmpLayer.ArrayList<AerisAmpLayer>
getActiveMapLayers()
Returns a list of AerisAmpLayer currently selected/active.ArrayList<AerisAmpLayer>
getAllPossibleLayers()
Returns a list of all AMP layers available to the user.android.graphics.Bitmap
getBitmapFromAMP(String urlString)
Get the map bitmap from AMP.String
getClientId()
String
getClientSecret()
String
getFutureLayerId(AerisAmpLayer ampLayer)
String
getFutureLayerId(String layerId)
com.google.android.gms.maps.model.LatLng
getLatLng()
AerisAmpLayer
getLayerFromId(String layerId)
Returns a specific AerisAmpLayer.AerisAmpLayer
getLayerFromName(String layerName)
Returns a specific AerisAmpLayer.ArrayList
getLayerModifiersFromId(String layerId)
Returns the available modifiers for a specific layer.ArrayList
getLayerModifiersFromName(String layerName)
Returns the available modifiers for a specific layer.ArrayList<AerisAmpLayer>
getPermissibleLayers()
Returns a list of all AMP layers available to the user.ArrayList<AerisAmpLayer>
getPermissibleLayers(boolean forceRefresh)
Overload used to manually force a refresh of the array.com.aerisweather.aeris.model.AerisPermissions
getPermissions(Boolean refresh)
Return an AerisPermissions object with the current Aeris API permissions.android.graphics.Bitmap
getStaticMapImage()
Get the map bitmap from AMP.String
getStaticMapUrl()
Returns the last static map url created.long
getTileValidTime()
int
getZoom()
void
removeLayer(AerisAmpLayer removeLayer)
removeLayer() Remove a layer from the AMP layer array.void
removeLayer(String aerisLayerId)
removeLayer() Remove a layer from the AMP layer array using the layer ID.void
setBoundingBox(com.google.android.gms.maps.model.LatLngBounds latLngBounds)
Used when creating an AMP layer from a bounding boxvoid
setClientId(String id)
Set the AerisEngine client idvoid
setClientSecret(String secret)
Set the AerisEngine client secretboolean
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%void
setEast(double east)
Set the eastern most (right) longitude coordinate of the bounding box, in degrees.void
setLatitude(float lat)
void
setLatLng(com.google.android.gms.maps.model.LatLng latLng)
void
setLayer(AerisAmpLayer layer)
addLayer() Add an existing layer to the AMP layer array.int
setLayerFromId(String layerId)
addLayer() Add a layer to the AMP layer array, based on the layer id.int
setLayerFromName(String layerName)
addLayer() Add a layer to the AMP layer array, based on the layer name.void
setLongitude(float lon)
void
setMapHeight(int height)
void
setMapWidth(int width)
void
setNorth(double north)
Set the northern most (top) latitude coordinate of the bounding box, in degrees.void
setOpacity(int height)
void
setSouth(double south)
Set the southern most (bottom) latitude coordinate of the bounding box, in degrees.void
setTileValidTime(long tileValidTime)
Use this method to set the overall valid time for the Amp layer.void
setTimeOffset(String offset)
void
setWest(double west)
Set the western most (left) longitude coordinate of the bounding box, in degrees.void
setZoom(float zoom)
-
-
-
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 idclientSecret
- 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 idclientSecret
- 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 idclientSecret
- 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 idclientSecret
- 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 idclientSecret
- The AerisWeather client keywidth
- The width of the map areaheight
- The height of the map areasouth
- The southern most longitudewest
- The western most latitudenorth
- The northern most longitudeeast
- 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)
-
createNewLayer
public AerisAmpLayer createNewLayer(String id, String name, int opacity)
-
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(AerisAmpLayer ampLayer)
-
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()
-
-