Package edu.cnu.mdi.mapping.util
Class GeoUtils
java.lang.Object
edu.cnu.mdi.mapping.util.GeoUtils
Utility class for geographic coordinate conversions using the WGS84 ellipsoid.
Supports bidirectional conversion between:
- Radians (longitude, latitude) as
Point2D.Double— the internal representation used by the mapping system - UTM (Universal Transverse Mercator) as
UTMCoordinate - Decimal degrees as a convenience intermediate
Coordinate convention: All Point2D.Double values used here
follow the mapping convention where .x = longitude and .y = latitude,
both in radians.
Accuracy: The UTM implementation uses the standard transverse Mercator series expansion (Bowring/Snyder approach). Accuracy is better than 1 mm within the standard UTM zone bounds (±3° from the central meridian). Results degrade gracefully outside those bounds but are not intended for use beyond ±10°.
Coverage: Valid for latitudes -80° to +84° (the defined
UTM coverage area). Polar regions require a separate UPS implementation.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic UTMCoordinatefromDecimalDegrees(double latDeg, double lonDeg) Converts a geographic position given in decimal degrees to aUTMCoordinate.static UTMCoordinatefromRadians(Point2D.Double latLonRad) Converts a geographic position given in radians to aUTMCoordinate.static double[]Converts aUTMCoordinateto decimal degrees (latitude, longitude).static Point2D.DoubletoRadians(UTMCoordinate utm) Converts aUTMCoordinateto a geographic position in radians.
-
Method Details
-
fromRadians
Converts a geographic position given in radians to aUTMCoordinate.- Parameters:
latLonRad- the position to convert;.x= longitude in radians,.y= latitude in radians- Returns:
- the corresponding UTM coordinate on the WGS84 ellipsoid, or (per
fromDecimalDegrees(double, double)) an out-of-range sentinel coordinate (seeUTMCoordinate(boolean)) if the latitude falls outside the UTM-defined range of-80°to+84°— this method never throws for an out-of-range latitude
-
fromDecimalDegrees
Converts a geographic position given in decimal degrees to aUTMCoordinate.- Parameters:
latDeg- latitude in decimal degrees, positive north (-80to+84)lonDeg- longitude in decimal degrees, positive east (-180to+180)- Returns:
- the corresponding UTM coordinate on the WGS84 ellipsoid
-
toRadians
Converts aUTMCoordinateto a geographic position in radians.- Parameters:
utm- the UTM coordinate to convert- Returns:
- the corresponding geographic position;
.x= longitude in radians,.y= latitude in radians - Throws:
IllegalArgumentException- if the UTM zone number is not in the range1to60
-
toDecimalDegrees
Converts aUTMCoordinateto decimal degrees (latitude, longitude).- Parameters:
utm- the UTM coordinate to convert- Returns:
- a two-element array
[latitudeDeg, longitudeDeg] - Throws:
IllegalArgumentException- if the UTM zone number is not in the range1to60
-