Package mil.nga.grid
Class GridUtils
- java.lang.Object
-
- mil.nga.grid.GridUtils
-
public class GridUtils extends Object
Grid utilities- Author:
- osbornb
-
-
Constructor Summary
Constructors Constructor Description GridUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Bounds
getBounds(int x, int y, int zoom)
Get the tile bounds from the XYZ tile coordinates and zoom levelstatic Pixel
getPixel(int width, int height, Bounds bounds, Point point)
Get the pixel where the point fits into the boundsstatic float
getXPixel(int width, Bounds bounds, double longitude)
Get the X pixel for where the longitude in meters fits into the boundsstatic float
getYPixel(int height, Bounds bounds, double latitude)
Get the Y pixel for where the latitude in meters fits into the boundsstatic double
getZoomLevel(Bounds bounds)
Get the zoom level of the bounds using the shortest bounds side lengthstatic Point
intersection(Line line1, Line line2)
Get the point intersection between two linesstatic Point
intersection(Point line1Point1, Point line1Point2, Point line2Point1, Point line2Point2)
Get the point intersection between end points of two linesstatic boolean
isOmittedBandLetter(char letter)
Is the band letter an omitted letterGridConstants.BAND_LETTER_OMIT_I
orGridConstants.BAND_LETTER_OMIT_O
static double
precisionAfter(double value, double precision)
Get the precision value after the valuestatic double
precisionBefore(double value, double precision)
Get the precision value before the valuestatic double
tileSize(int tilesPerSide)
Get the tile size in metersstatic int
tilesPerSide(int zoom)
Get the tiles per side, width and height, at the zoom levelstatic Point
toUnit(double longitude, double latitude, Unit unit)
Convert a coordinate to the unit, assumes the coordinate is in the opposite unitstatic Point
toUnit(Unit fromUnit, double longitude, double latitude, Unit toUnit)
Convert a coordinate from a unit to another unit
-
-
-
Method Detail
-
getPixel
public static Pixel getPixel(int width, int height, Bounds bounds, Point point)
Get the pixel where the point fits into the bounds- Parameters:
width
- widthheight
- heightbounds
- boundspoint
- point- Returns:
- pixel
-
getXPixel
public static float getXPixel(int width, Bounds bounds, double longitude)
Get the X pixel for where the longitude in meters fits into the bounds- Parameters:
width
- widthbounds
- boundslongitude
- longitude in meters- Returns:
- x pixel
-
getYPixel
public static float getYPixel(int height, Bounds bounds, double latitude)
Get the Y pixel for where the latitude in meters fits into the bounds- Parameters:
height
- heightbounds
- boundslatitude
- latitude- Returns:
- y pixel
-
getBounds
public static Bounds getBounds(int x, int y, int zoom)
Get the tile bounds from the XYZ tile coordinates and zoom level- Parameters:
x
- x coordinatey
- y coordinatezoom
- zoom level- Returns:
- bounds
-
tilesPerSide
public static int tilesPerSide(int zoom)
Get the tiles per side, width and height, at the zoom level- Parameters:
zoom
- zoom level- Returns:
- tiles per side
-
tileSize
public static double tileSize(int tilesPerSide)
Get the tile size in meters- Parameters:
tilesPerSide
- tiles per side- Returns:
- tile size
-
getZoomLevel
public static double getZoomLevel(Bounds bounds)
Get the zoom level of the bounds using the shortest bounds side length- Parameters:
bounds
- bounds- Returns:
- zoom level
-
toUnit
public static Point toUnit(Unit fromUnit, double longitude, double latitude, Unit toUnit)
Convert a coordinate from a unit to another unit- Parameters:
fromUnit
- unit of provided coordinatelongitude
- longitudelatitude
- latitudetoUnit
- desired unit- Returns:
- point in unit
-
toUnit
public static Point toUnit(double longitude, double latitude, Unit unit)
Convert a coordinate to the unit, assumes the coordinate is in the opposite unit- Parameters:
longitude
- longitudelatitude
- latitudeunit
- desired unit- Returns:
- point in unit
-
isOmittedBandLetter
public static boolean isOmittedBandLetter(char letter)
Is the band letter an omitted letterGridConstants.BAND_LETTER_OMIT_I
orGridConstants.BAND_LETTER_OMIT_O
- Parameters:
letter
- band letter- Returns:
- true if omitted
-
precisionBefore
public static double precisionBefore(double value, double precision)
Get the precision value before the value- Parameters:
value
- valueprecision
- precision- Returns:
- precision value
-
precisionAfter
public static double precisionAfter(double value, double precision)
Get the precision value after the value- Parameters:
value
- valueprecision
- precision- Returns:
- precision value
-
intersection
public static Point intersection(Line line1, Line line2)
Get the point intersection between two lines- Parameters:
line1
- first lineline2
- second line- Returns:
- intersection point or null if no intersection
-
intersection
public static Point intersection(Point line1Point1, Point line1Point2, Point line2Point1, Point line2Point2)
Get the point intersection between end points of two lines- Parameters:
line1Point1
- first point of the first lineline1Point2
- second point of the first lineline2Point1
- first point of the second lineline2Point2
- second point of the second line- Returns:
- intersection point or null if no intersection
-
-