public class ATAKUtilities
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
ATAKUtilities.BitmapDecoder
Allow for application registration of decoders.
|
Constructor and Description |
---|
ATAKUtilities() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
bytesToHex(byte[] arr)
Turn a byte array into a hex string representation
|
static double |
computeDistanceOfRayToSegment(GeoPoint p,
double azimuth,
GeoPoint seg1,
GeoPoint seg0) |
static double |
computeGridConvergence(GeoPoint sPoint,
double angle,
double distance)
Obtains the grid convergence used for a specific line of bearing.
|
static double |
computeGridConvergence(GeoPoint sPoint,
GeoPoint ePoint)
Obtains the grid convergence used for a specific line of bearing.
|
static double |
convertFromMagneticToTrue(GeoPoint point,
double angle)
Convert a bearing from Magnetic North to True North
|
static double |
convertFromTrueToMagnetic(GeoPoint point,
double angle)
Convert a bearing from True North to Magnetic North
|
static void |
copyClipboard(java.lang.String label,
java.lang.String text,
boolean bToast)
Method to assist in the copying of text data to the clipboard supporting cut and paste.
|
static MapItem |
findAssocShape(MapItem mi)
Find the shape, if any, associated with this map item
|
static Marker |
findSelf(MapView mapView)
Finds self marker but only if it has been placed on the map
|
static Marker |
findSelfUnplaced(MapView mapView)
Finds self marker even if it has not been placed on the map.
|
static java.util.List<java.lang.String> |
fromJSON(java.lang.String json)
Convert JSON string into a list of strings
|
static Vector2D |
geo2Vector(GeoPoint p)
Deprecated.
UTM-based vectors can't handle intersection/contains
checks across different UTM zones.
Use
FOVFilter.geo2Vector(GeoPoint) instead |
static android.graphics.Bitmap |
getBitmap(android.graphics.drawable.Drawable drawable)
Create a Bitmap from the specified drawable
|
static android.graphics.drawable.Drawable |
getContentIcon(java.lang.String contentType)
Get an icon for a given file content type
|
static double |
getCurrentMagneticVariation(GeoPoint point)
For a specific GeoPoint, derive the actual magnetic declination that should be used as
double offset.
|
static java.lang.String |
getDisplayName(MapItem item)
Uses logic to obtain the best display name for a specific MapItem in the system.
|
static android.graphics.drawable.Drawable |
getFileIcon(java.io.File f)
Get an icon for a file
Note: If the file does not exist it's recommended to use
getContentIcon(String) provided you have the content type |
static android.graphics.Bitmap |
getIconBitmap(MapItem item)
Generate a bitmap for this map item's icon
|
static int |
getIconColor(MapItem mi)
Get color from a map item icon
|
static java.lang.String |
getIconUri(MapItem mi)
Get the Icon URI based on marker icon or 'iconUri' meta string
Meant to be used when displaying the map item in UI (not in MapView)
|
static double |
getMaximumFocusResolution(GeoPoint location) |
static double |
getMaximumFocusResolution(GeoPoint location,
double localElevation,
double vfov,
int heightPx)
Computes the maximum GSD that should be specified when focusing on a
point.
|
static double |
getMetersPerPixel()
Get the estimated meters per pixel at the default focus point
|
static double |
getMetersPerPixel(float x,
float y)
Get the estimated meters per pixel at a given point on the screen
|
static double |
getMetersPerPixel(GeoPoint point)
Get the estimated meters per pixel at a given point on the map
|
static double |
getMetersPerPixel(android.graphics.PointF point)
Get the estimated meters per pixel at a given point on the screen
|
static java.lang.String |
getNonDuplicateName(java.lang.String newName,
java.util.List<java.lang.String> names,
java.lang.String format)
Given a list of names, find the next non-duplicate name based on newName
|
static java.lang.String |
getResourceUri(android.content.Context context,
int resId)
Convert resource ID to URI string
|
static java.lang.String |
getResourceUri(int resId)
Provided a resource identifier, return the full resource URI describing
the resource.
|
static java.lang.String |
getStartDirectory(android.content.Context sharedPrefContext)
Returns the appropriate starting directory for file dialogs.
|
static android.graphics.Bitmap |
getUriBitmap(android.content.Context ctx,
java.lang.String uriStr)
Decode URI to its matching bitmap
|
static android.graphics.Bitmap |
getUriBitmap(java.lang.String uriStr)
Decode URI to its matching bitmap
|
static java.lang.String |
getUriPath(java.lang.String uriStr)
Convert a uriStr into a path keeping legacy behavior.
|
static byte[] |
hexToBytes(java.lang.String hex)
Given a hex string, decode it into a byte array.
|
static boolean |
isSelf(MapView mapView,
PointMapItem item)
Method that will return true if the map item provided is the self marker.
|
static boolean |
isSelf(MapView mapView,
java.lang.String uid)
Method that will return true if the map item provided is the self marker.
|
static boolean |
isUUID(java.lang.String string)
Determine if a string supplied is a valid UUID.
|
static boolean |
pointInsidePolygon(GeoPoint point,
GeoPoint[] polygon)
Check if a GeoPoint resides within a polygon represented by a GeoPoint Array The polygon does
not have to convex in order for this function to work, but the first and last GeoPoint must
be equivalent
|
static void |
registerBitmapDecoder(java.lang.String scheme,
ATAKUtilities.BitmapDecoder uriBitmapDecoder)
Register a bitmap decoder with the system that will be called when the uri scheme is encountered.
|
static void |
scaleToFit(ILocation loc)
Given a location, scale to fit the bounds provided by the location
|
static void |
scaleToFit(MapItem item)
Scales map to fit item.
|
static boolean |
scaleToFit(MapView mv,
GeoBounds bounds,
double altitude,
int widthPad,
int heightPad) |
static boolean |
scaleToFit(MapView mv,
GeoBounds bounds,
int widthPad,
int heightPad) |
static boolean |
scaleToFit(MapView mv,
GeoBounds bounds,
int widthPad,
int heightPad,
boolean terrainAdj)
Deprecated.
"terrainAdj" parameter no longer supported
|
static boolean |
scaleToFit(MapView mv,
GeoPoint[] points,
double altitude,
int widthPad,
int heightPad)
Scales map to fit item and, if includeself is true, the self marker, within a space width by
height around the focus point.
|
static boolean |
scaleToFit(MapView mv,
GeoPoint[] points,
int width,
int height) |
static boolean |
scaleToFit(MapView mv,
GeoPoint[] points,
int widthPad,
int heightPad,
boolean terrainAdj)
Deprecated.
"terrainAdj" parameter no longer supported
|
static void |
scaleToFit(MapView _mapView,
MapItem[] items,
int widthPad,
int heightPad)
Scales map to fit items within a space width by height around the focus point.
|
static void |
scaleToFit(MapView _mapView,
MapItem item,
boolean includeSelf,
int widthPad,
int heightPad)
Scales map to fit item and, if includeself is true, the self marker, within a space width by
height around the focus point.
|
static void |
scaleToFit(MapView _mapView,
PointMapItem target,
PointMapItem friendly)
Scales map to fit items within a space width by height around the focus point.
|
static java.util.ArrayList<GeoPoint> |
segmentArrayIntersectionsWithPolygon(GeoPoint[] segments,
GeoPoint[] polygon) |
static boolean |
segmentArrayIntersectsOrContainedByPolygon(GeoPoint[] segments,
GeoPoint[] polygon) |
static boolean |
segmentInsidePolygon(GeoPoint point0,
GeoPoint point1,
GeoPoint[] polygon) |
static void |
SetIcon(android.content.Context context,
android.widget.ImageView view,
MapItem mi)
Set the icon based on the iconUriStr
Parses all the support uri formats
|
static android.graphics.Bitmap |
SetIcon(android.content.Context context,
android.widget.ImageView icon,
java.lang.String iconUriStr,
int color)
Set the icon based on the iconUriStr, must be run on the ui thread
since it directly manipulates the passed in ImageView
Parses all the support uri formats
|
static void |
setIcon(android.widget.ImageView view,
MapItem mi)
Set the icon based on the map item's icon drawable
|
static android.graphics.Bitmap |
setIconFromFile(android.widget.ImageView icon,
java.io.File iconFile)
Given a file and a imageview, set the image from the file as part of the icon and then if
sucessful, return the bitmap constructed from the file.
|
static void |
SetUserIcon(MapView context,
android.widget.ImageView icon,
PointMapItem item) |
static void |
SetUserIcon(MapView context,
android.widget.ImageView icon,
PointMapItem item,
int defaultResource)
Set the icon for the user
Use current marker's icon
Use specified default
|
static void |
SetUserIcon(MapView view,
android.widget.ImageView icon,
java.lang.String uid)
Set the icon for the user.
|
static void |
SetUserIcon(MapView view,
android.widget.ImageView icon,
java.lang.String uid,
int defaultResource)
Set the icon for the user
Use current marker's icon
Use self icon if item is 'self'
Use specified default
|
static java.util.List<GeoPoint> |
simplifyPoints(SpatialCalculator calc,
java.util.Collection<GeoPoint> points)
Helper method for
SpatialCalculator#simplify(Collection, double, boolean)
Automatically calculates degree threshold using the current DPI |
static java.lang.String |
toJSON(java.util.List<java.lang.String> strings)
Convert list of strings to a JSON array
|
static void |
unregisterBitmapDecoder(java.lang.String scheme)
Unregister the uriBitmapDecoder for a specified scheme.
|
static GeoPoint |
vector2Geo(Vector2D v,
java.lang.String zone)
Given a vector from the start of the zone and a zone - utilize UTM to generate a geopoint.
|
public static java.lang.String getDisplayName(MapItem item)
item
- The map item to get the display name from.public static boolean isUUID(java.lang.String string)
string
- the unknown stringpublic static Marker findSelfUnplaced(MapView mapView)
mapView
- the mapView to usepublic static Marker findSelf(MapView mapView)
mapView
- the mapView to usepublic static boolean isSelf(MapView mapView, PointMapItem item)
mapView
- the mapView useditem
- the item passed inpublic static boolean isSelf(MapView mapView, java.lang.String uid)
mapView
- the mapView useduid
- the uid of the item to checkpublic static void scaleToFit(MapView _mapView, MapItem item, boolean includeSelf, int widthPad, int heightPad)
_mapView
- the mapview to use when scaling to fit around the item.item
- the item to useincludeSelf
- if the scaleToFit should also make use of the self markerwidthPad
- the padding to be used for the width around the best fit.heightPad
- the padding to be used for the height of the bet fit.public static void scaleToFit(MapView _mapView, MapItem[] items, int widthPad, int heightPad)
_mapView
- the mapview to use when scaling to fit around the items.items
- the array of items to provide a best fit forwidthPad
- the padding to be used for the width around the best fit.heightPad
- the padding to be used for the height of the bet fit.public static void scaleToFit(MapView _mapView, PointMapItem target, PointMapItem friendly)
_mapView
- the mapview to use when scaling to fit around the items.target
- the target point to includefriendly
- the friendly point to includepublic static boolean scaleToFit(MapView mv, GeoPoint[] points, double altitude, int widthPad, int heightPad)
mv
- the mapview to use when scaling to fit.points
- the array of geopoints to usealtitude
- Altitude to zoom to (perspective mode only; NaN to ignore)widthPad
- the padding to be used for the width around the best fit.heightPad
- the padding to be used for the height of the bet fit.public static boolean scaleToFit(MapView mv, GeoPoint[] points, int width, int height)
public static boolean scaleToFit(MapView mv, GeoBounds bounds, int widthPad, int heightPad)
public static boolean scaleToFit(MapView mv, GeoBounds bounds, double altitude, int widthPad, int heightPad)
public static void scaleToFit(MapItem item)
item
- the item to usepublic static void scaleToFit(ILocation loc)
loc
- the location@Deprecated public static boolean scaleToFit(MapView mv, GeoBounds bounds, int widthPad, int heightPad, boolean terrainAdj)
@Deprecated public static boolean scaleToFit(MapView mv, GeoPoint[] points, int widthPad, int heightPad, boolean terrainAdj)
public static double getMaximumFocusResolution(GeoPoint location, double localElevation, double vfov, int heightPx)
NOTE: this is NOT a recommended focus distance.
location
- The focus locationlocalElevation
- The local elevation at the point locationvfov
- The vertical FOV of the cameraheightPx
- The height of the display viewport, in pixelspublic static double getMaximumFocusResolution(GeoPoint location)
public static double getCurrentMagneticVariation(GeoPoint point)
public static double computeGridConvergence(GeoPoint sPoint, GeoPoint ePoint)
sPoint
- the starting point for the line of bearing.ePoint
- the end point for the line of bearing.public static double computeGridConvergence(GeoPoint sPoint, double angle, double distance)
sPoint
- the starting point for the line of bearing.angle
- the angle of the line of bearing.distance
- the length of the line of bearing.public static double convertFromMagneticToTrue(GeoPoint point, double angle)
point
- GeoPoint for the location of the Compass.angle
- Bearing in degrees (Magnetic North)public static double convertFromTrueToMagnetic(GeoPoint point, double angle)
point
- GeoPoint for the location of the Compass.angle
- Bearing in degrees (True North)public static boolean pointInsidePolygon(GeoPoint point, GeoPoint[] polygon)
point
- GeoPoint to be testedpolygon
- Array of GeoPoint that represents the polygon (does not have to be convex)public static boolean segmentInsidePolygon(GeoPoint point0, GeoPoint point1, GeoPoint[] polygon)
public static boolean segmentArrayIntersectsOrContainedByPolygon(GeoPoint[] segments, GeoPoint[] polygon)
public static java.util.ArrayList<GeoPoint> segmentArrayIntersectionsWithPolygon(GeoPoint[] segments, GeoPoint[] polygon)
public static double computeDistanceOfRayToSegment(GeoPoint p, double azimuth, GeoPoint seg1, GeoPoint seg0)
@Deprecated public static Vector2D geo2Vector(GeoPoint p)
FOVFilter.geo2Vector(GeoPoint)
insteadp
- the geopoint to usepublic static GeoPoint vector2Geo(Vector2D v, java.lang.String zone)
v
- the vector offset from the zone described by easting (x) and northing (y).zone
- the zone descriptorpublic static MapItem findAssocShape(MapItem mi)
mi
- Map item to searchpublic static java.lang.String getIconUri(MapItem mi)
mi
- Map itempublic static java.lang.String getResourceUri(android.content.Context context, int resId)
context
- Resource contextresId
- Resource IDpublic static java.lang.String getResourceUri(int resId)
public static int getIconColor(MapItem mi)
mi
- the map item to use for finding the currently set icon color.public static void SetUserIcon(MapView view, android.widget.ImageView icon, java.lang.String uid)
view
- the map view to use when searching or the user.icon
- the view to populate with the found icon.uid
- the uid of the user to be found.public static void SetUserIcon(MapView view, android.widget.ImageView icon, java.lang.String uid, int defaultResource)
view
- the mapView to use to find the online users.icon
- the view to set with the found default icon.uid
- the uid of the user.defaultResource
- if the user is not online or on the map, use the defaultResource to represent the user.public static void SetUserIcon(MapView context, android.widget.ImageView icon, PointMapItem item)
public static void SetUserIcon(MapView context, android.widget.ImageView icon, PointMapItem item, int defaultResource)
context
- the context to use when setting the iconicon
- the icon to useitem
- the item to set the icon fordefaultResource
- the default resourcepublic static void setIcon(android.widget.ImageView view, MapItem mi)
view
- The ImageView to display the iconmi
- The Map Item to load the icon frompublic static void SetIcon(android.content.Context context, android.widget.ImageView view, MapItem mi)
context
- the context to useview
- The ImageView to display the iconmi
- The Map Item to load the icon frompublic static android.graphics.Bitmap SetIcon(android.content.Context context, android.widget.ImageView icon, java.lang.String iconUriStr, int color)
context
- icon
- The ImageView to display the iconiconUriStr
- The URI to load the icon fromcolor
- The color to be applied to the iconpublic static android.graphics.Bitmap getIconBitmap(MapItem item)
item
- Map itempublic static java.lang.String getUriPath(java.lang.String uriStr)
uriStr
- the uri string { file, android, android.resource, base64 or
no scheme at all}public static void registerBitmapDecoder(java.lang.String scheme, ATAKUtilities.BitmapDecoder uriBitmapDecoder)
scheme
- the uri scheme supported.uriBitmapDecoder
- the decoder used to process the uri.public static void unregisterBitmapDecoder(java.lang.String scheme)
scheme
- the uri scheme for the bitmap decoder to remove.public static android.graphics.Bitmap getUriBitmap(java.lang.String uriStr)
uriStr
- URI string to decodepublic static android.graphics.Bitmap getUriBitmap(android.content.Context ctx, java.lang.String uriStr)
uriStr
- URI string to decodectx
- The application contextpublic static java.lang.String toJSON(java.util.List<java.lang.String> strings)
strings
- the list of stringpublic static java.util.List<java.lang.String> fromJSON(java.lang.String json)
json
- the original encoded json document.public static java.lang.String bytesToHex(byte[] arr)
arr
- the byte arraypublic static byte[] hexToBytes(java.lang.String hex)
hex
- a hex string containing characters [0-F]java.lang.IllegalArgumentException
- if the string contains a non hex characterpublic static java.lang.String getNonDuplicateName(java.lang.String newName, java.util.List<java.lang.String> names, java.lang.String format)
newName
- New name - i.e. ItemNamenames
- List of names - i.e. ItemName, ItemName (1), ItemName (2)format
- Format where '#' is replaced by the dupe number - i.e. " (#)"public static android.graphics.Bitmap setIconFromFile(android.widget.ImageView icon, java.io.File iconFile)
icon
- the imageview used for the bitmap from the file.iconFile
- the file containing the image.public static android.graphics.Bitmap getBitmap(android.graphics.drawable.Drawable drawable)
drawable
- the drawable to turn into a bitmap.public static void copyClipboard(java.lang.String label, java.lang.String text, boolean bToast)
label
- the label defining the datatext
- the actual data to be copiedbToast
- if true, displays a toast.public static android.graphics.drawable.Drawable getContentIcon(java.lang.String contentType)
contentType
- Content typepublic static android.graphics.drawable.Drawable getFileIcon(java.io.File f)
getContentIcon(String)
provided you have the content typef
- Filepublic static java.lang.String getStartDirectory(android.content.Context sharedPrefContext)
sharedPrefContext
- The context of the shared preferences to usepublic static double getMetersPerPixel(float x, float y)
x
- X coordinate on the screeny
- Y coordinate on the screenDouble.NaN
if could not be calculatedpublic static double getMetersPerPixel(android.graphics.PointF point)
point
- Point on the screen (x, y)Double.NaN
if could not be calculatedpublic static double getMetersPerPixel(GeoPoint point)
point
- Point on the mapDouble.NaN
if could not be calculatedpublic static double getMetersPerPixel()
Double.NaN
if could not be calculatedpublic static java.util.List<GeoPoint> simplifyPoints(SpatialCalculator calc, java.util.Collection<GeoPoint> points)
SpatialCalculator#simplify(Collection, double, boolean)
Automatically calculates degree threshold using the current DPIcalc
- Spatial calcualtorpoints
- List of points