Class MapUtils

java.lang.Object
edu.cnu.mdi.mapping.theme.MapUtils

public final class MapUtils extends Object
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 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.NaN when lon is not finite
    • lonDegreesToRadians

      public static double lonDegreesToRadians(double lonDegrees)
      Converts longitude from degrees to radians and wraps to (-π, π].

      Convenience method combining Math.toRadians(double) and wrapLongitude(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 (-π, π]