Package ucar.unidata.geoloc
Class LatLonPoints
- java.lang.Object
-
- ucar.unidata.geoloc.LatLonPoints
-
public class LatLonPoints extends Object
Static utilities for LatLonPoint.
-
-
Constructor Summary
Constructors Constructor Description LatLonPoints()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
betweenLon(double lon, double lonBeg, double lonEnd)
Test if a longitude lies in the interval [lonBeg, lonEnd].static boolean
isInfinite(ProjectionPoint pt)
See if either coordinate inpt
is +/- infinite.static double
latNormal(double lat)
Normalize the latitude to lie between +/-90static String
latToString(double lat, int ndec)
Make a nicely formatted representation of a latitude, eg 40.34N or 12.9S.static double
lonDiff(double lon1, double lon2)
Find difference (lon1 - lon2) normalized so that maximum value is += 180.static double
lonNormal(double lon)
Normalize the longitude to lie between +/-180static double
lonNormal(double lon, double center)
put longitude into the range [center +/- 180] degstatic double
lonNormal360(double lon)
put longitude into the range [0, 360] degstatic double
lonNormalFrom(double lon, double start)
put longitude into the range [start, start+360] degstatic String
lonToString(double lon, int ndec)
Make a nicely formatted representation of a longitude, eg 120.3W or 99.99E.static LatLonPoint
parseLatLonPoint(String source)
The inverse of toString(LatLonPoint), or null if cant parsestatic double
range180(double lon)
put longitude into the range [-180, 180] degstatic String
toString(LatLonPoint pt, int sigDigits)
String representation of LatLonPoint in the form, eg 40.23, -105.1static String
toString(ProjectionPoint pt, int sigDigits)
String representation of ProjectionPoint in the form, eg x, y
-
-
-
Method Detail
-
betweenLon
public static boolean betweenLon(double lon, double lonBeg, double lonEnd)
Test if a longitude lies in the interval [lonBeg, lonEnd]. All points are adjusted to deal with possible longitude wrap. -180 is consider to be east of 180.- Parameters:
lon
- point to testlonBeg
- beginning longitudelonEnd
- ending longitude, always to the east of lonBeg- Returns:
- true if lon is in the interval [lonBeg, lonEnd].
-
lonNormal360
public static double lonNormal360(double lon)
put longitude into the range [0, 360] deg- Parameters:
lon
- lon to normalize- Returns:
- longitude into the range [0, 360] deg
-
lonNormal
public static double lonNormal(double lon, double center)
put longitude into the range [center +/- 180] deg- Parameters:
lon
- lon to normalizecenter
- center point- Returns:
- longitude into the range [center +/- 180] deg
-
lonNormalFrom
public static double lonNormalFrom(double lon, double start)
put longitude into the range [start, start+360] deg- Parameters:
lon
- lon to normalizestart
- starting point- Returns:
- longitude into the [start, start+360] deg
-
lonNormal
public static double lonNormal(double lon)
Normalize the longitude to lie between +/-180- Parameters:
lon
- east latitude in degrees- Returns:
- normalized lon
-
lonDiff
public static double lonDiff(double lon1, double lon2)
Find difference (lon1 - lon2) normalized so that maximum value is += 180.- Parameters:
lon1
- startlon2
- end- Returns:
- normalized difference
-
latNormal
public static double latNormal(double lat)
Normalize the latitude to lie between +/-90- Parameters:
lat
- north latitude in degrees- Returns:
- normalized lat
-
latToString
public static String latToString(double lat, int ndec)
Make a nicely formatted representation of a latitude, eg 40.34N or 12.9S.- Parameters:
lat
- the latitude.ndec
- number of digits to right of decimal point- Returns:
- String representation.
-
lonToString
public static String lonToString(double lon, int ndec)
Make a nicely formatted representation of a longitude, eg 120.3W or 99.99E.- Parameters:
lon
- the longitude.ndec
- number of digits to right of decimal point- Returns:
- String representation.
-
isInfinite
public static boolean isInfinite(ProjectionPoint pt)
See if either coordinate inpt
is +/- infinite. This happens sometimes in projective geometry.- Parameters:
pt
- point to check- Returns:
- true if either coordinate is +/- infinite.
-
range180
public static double range180(double lon)
put longitude into the range [-180, 180] deg- Parameters:
lon
- lon to normalize- Returns:
- longitude in range [-180, 180] deg
-
toString
public static String toString(LatLonPoint pt, int sigDigits)
String representation of LatLonPoint in the form, eg 40.23, -105.1- Parameters:
pt
- the LatLonPointsigDigits
- significant digits- Returns:
- String representation
-
parseLatLonPoint
@Nullable public static LatLonPoint parseLatLonPoint(String source)
The inverse of toString(LatLonPoint), or null if cant parse
-
toString
public static String toString(ProjectionPoint pt, int sigDigits)
String representation of ProjectionPoint in the form, eg x, y- Parameters:
pt
- the ProjectionPointsigDigits
- significant digits- Returns:
- String representation
-
-