Package edu.cnu.mdi.mapping.theme
Class MapUtils
java.lang.Object
edu.cnu.mdi.mapping.theme.MapUtils
Shared geographic utility methods used across the MDI mapping package.
These methods were previously duplicated as private static
helpers in GeoJsonCityLoader, GeoJsonCountryLoader,
ShapefileCountryLoader, ShapefileCityLoader, and
ShapefileFeatureLoader. Centralising them here eliminates the
duplication and provides a single well-tested implementation.
This class is not instantiable.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublelonDegreesToRadians(double lonDegrees) Converts longitude from degrees to radians and wraps to (-π, π].static doublewrapLongitude(double lon) Wraps a longitude value to the canonical half-open range (-π, π].
-
Method Details
-
wrapLongitude
public static double wrapLongitude(double lon) Wraps a longitude value to the canonical half-open range (-π, π].This is the standard normalization used throughout the mapping subsystem. The range is half-open: values less than or equal to -π are mapped to their equivalent in (-π, π].
- Parameters:
lon- longitude in radians- Returns:
- equivalent longitude in (-π, π], or
Double.NaNwhenlonis not finite
-
lonDegreesToRadians
public static double lonDegreesToRadians(double lonDegrees) Converts longitude from degrees to radians and wraps to (-π, π].Convenience method combining
Math.toRadians(double)andwrapLongitude(double)— the most common operation when reading geographic data from files that store coordinates in degrees.- Parameters:
lonDegrees- longitude in decimal degrees- Returns:
- equivalent longitude in radians, in (-π, π]
-