Package mil.nga.mgrs.features
Class Point
- java.lang.Object
-
- mil.nga.mgrs.features.Point
-
public class Point extends Object
Point- Author:
- wnewman, osbornb
-
-
Constructor Summary
Constructors Constructor Description Point(double longitude, double latitude)Constructor, inUnit.DEGREEunitsPoint(double longitude, double latitude, Unit unit)Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Pointcreate(double longitude, double latitude)Create a point with default degree unitstatic Pointcreate(double longitude, double latitude, Unit unit)Create a pointstatic Pointcreate(int zoneNumber, Hemisphere hemisphere, double easting, double northing)Create a point from UTM valuesstatic Pointdegrees(double longitude, double latitude)Create a point in degreesstatic PointdegreesToMeters(double longitude, double latitude)Create a point converting the degrees coordinate to metersstatic Pointfrom(MGRS mgrs)Parse a MGRS value to a coordinatestatic Pointfrom(UTM utm)Create from a Universal Transverse Mercator ProjectionchargetBandLetter()Get the point band letterHemispheregetHemisphere()Get the point hemispheredoublegetLatitude()Get the latitudedoublegetLongitude()Get the longitudePixelgetPixel(int width, int height, Bounds bounds)Get the pixel where the point fits into the boundsPixelgetPixel(MGRSTile tile)Get the pixel where the point fits into tileUnitgetUnit()Get the unitintgetZoneNumber()Get the point zone numberbooleanisDegrees()Is this point in degreesbooleanisMeters()Is this point in metersbooleanisUnit(Unit unit)Is in the provided unit typestatic Pointmeters(double longitude, double latitude)Create a point in metersstatic PointmetersToDegrees(double longitude, double latitude)Create a point converting the meters coordinate to degreesstatic Pointparse(String mgrs)Parse a MGRS string value to a coordinatevoidsetLatitude(double latitude)Set the latitudevoidsetLongitude(double longitude)Set the longitudevoidsetUnit(Unit unit)Set the unitPointtoDegrees()Convert to degreesPointtoMeters()Convert to metersMGRStoMGRS()Convert to a MGRS coordinatestatic PointtoUnit(double longitude, double latitude, Unit unit)Create a point from a coordinate in an opposite unit to another unitPointtoUnit(Unit unit)Convert to the unitstatic PointtoUnit(Unit fromUnit, double longitude, double latitude, Unit toUnit)Create a point from a coordinate in a unit to another unitUTMtoUTM()Convert to UTM coordinate
-
-
-
Constructor Detail
-
Point
public Point(double longitude, double latitude)Constructor, inUnit.DEGREEunits- Parameters:
longitude- longitudelatitude- latitude
-
Point
public Point(double longitude, double latitude, Unit unit)Constructor- Parameters:
longitude- longitudelatitude- latitudeunit- unit
-
-
Method Detail
-
create
public static Point create(double longitude, double latitude)
Create a point with default degree unit- Parameters:
longitude- longitudelatitude- latitude- Returns:
- point
-
create
public static Point create(double longitude, double latitude, Unit unit)
Create a point- Parameters:
longitude- longitudelatitude- latitudeunit- unit- Returns:
- point
-
degrees
public static Point degrees(double longitude, double latitude)
Create a point in degrees- Parameters:
longitude- longitude in degreeslatitude- latitude in degrees- Returns:
- point in degrees
-
meters
public static Point meters(double longitude, double latitude)
Create a point in meters- Parameters:
longitude- longitude in meterslatitude- latitude in meters- Returns:
- point in meters
-
toUnit
public static Point toUnit(Unit fromUnit, double longitude, double latitude, Unit toUnit)
Create a point from a coordinate in 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)
Create a point from a coordinate in an opposite unit to another unit- Parameters:
longitude- longitudelatitude- latitudeunit- desired unit- Returns:
- point in unit
-
degreesToMeters
public static Point degreesToMeters(double longitude, double latitude)
Create a point converting the degrees coordinate to meters- Parameters:
longitude- longitude in degreeslatitude- latitude in degrees- Returns:
- point in meters
-
metersToDegrees
public static Point metersToDegrees(double longitude, double latitude)
Create a point converting the meters coordinate to degrees- Parameters:
longitude- longitude in meterslatitude- latitude in meters- Returns:
- point in degrees
-
create
public static Point create(int zoneNumber, Hemisphere hemisphere, double easting, double northing)
Create a point from UTM values- Parameters:
zoneNumber- zone numberhemisphere- hemisphereeasting- eastingnorthing- northing- Returns:
- point
-
getLatitude
public double getLatitude()
Get the latitude- Returns:
- latitude
-
setLatitude
public void setLatitude(double latitude)
Set the latitude- Parameters:
latitude- latitude
-
getLongitude
public double getLongitude()
Get the longitude- Returns:
- longitude
-
setLongitude
public void setLongitude(double longitude)
Set the longitude- Parameters:
longitude- longitude
-
getUnit
public Unit getUnit()
Get the unit- Returns:
- unit
-
setUnit
public void setUnit(Unit unit)
Set the unit- Parameters:
unit- unit
-
isUnit
public boolean isUnit(Unit unit)
Is in the provided unit type- Parameters:
unit- unit- Returns:
- true if in the unit
-
isDegrees
public boolean isDegrees()
Is this point in degrees- Returns:
- true if degrees
-
isMeters
public boolean isMeters()
Is this point in meters- Returns:
- true if meters
-
toUnit
public Point toUnit(Unit unit)
Convert to the unit- Parameters:
unit- unit- Returns:
- point in units, same point if equal units
-
toDegrees
public Point toDegrees()
Convert to degrees- Returns:
- point in degrees, same point if already in degrees
-
toMeters
public Point toMeters()
Convert to meters- Returns:
- point in meters, same point if already in meters
-
toMGRS
public MGRS toMGRS()
Convert to a MGRS coordinate- Returns:
- MGRS
-
toUTM
public UTM toUTM()
Convert to UTM coordinate- Returns:
- UTM
-
getPixel
public Pixel getPixel(MGRSTile tile)
Get the pixel where the point fits into tile- Parameters:
tile- tile- Returns:
- pixel
-
getPixel
public Pixel getPixel(int width, int height, Bounds bounds)
Get the pixel where the point fits into the bounds- Parameters:
width- widthheight- heightbounds- bounds- Returns:
- pixel
-
getZoneNumber
public int getZoneNumber()
Get the point zone number- Returns:
- zone number
-
getBandLetter
public char getBandLetter()
Get the point band letter- Returns:
- band letter
-
getHemisphere
public Hemisphere getHemisphere()
Get the point hemisphere- Returns:
- hemisphere
-
from
public static Point from(UTM utm)
Create from a Universal Transverse Mercator Projection- Parameters:
utm- UTM- Returns:
- coordinate
-
from
public static Point from(MGRS mgrs)
Parse a MGRS value to a coordinate- Parameters:
mgrs- MGRS value- Returns:
- coordinate
-
parse
public static Point parse(String mgrs) throws ParseException
Parse a MGRS string value to a coordinate- Parameters:
mgrs- MGRS string value- Returns:
- coordinate
- Throws:
ParseException- upon failure to parse the MGRS value
-
-