Class TLcdLonLatCoord

java.lang.Object
com.luciad.util.TLcdLonLatCoord
All Implemented Interfaces:
Serializable

public class TLcdLonLatCoord extends Object implements Serializable
This utility class regroups a set of methods for converting latitude/longitude coordinates into String objects, and inversely, for parsing String objects into latitude/longitude coordinates. It also has some coordinate arithmetic methods and methods for normalizing coordinates. All coordinates are expressed in decimal degrees.
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    differenceLonEast2West(double aLon1, double aLon2)
    Computes the difference |aLon2 - aLon1| by tracing the sphere from East to West.
    static double
    differenceLonWest2East(double aLon1, double aLon2)
    Computes the difference |aLon2 - aLon1| by tracing the sphere from West to East.
    static double[]
    eliminate3OnLon180(double aLon1, double aLon2, double aLon3)
    Transforms aLon1, aLon2 and aLon3 into three new longitudes, taking into account the 180 degree meridian.
    static void
    eliminateNOnLon180SFCT(double[] aLon)
    Eliminates the 180 degree meridian on an array of longitudes.
    static double[]
    eliminateOnLon180(double aLon1, double aLon2)
    Transforms aLon1 and aLon2 into two new longitudes, taking into account the 180 degree meridian.
    static boolean
    equalLonLatPoint(double aLon1, double aLat1, double aZ1, double aLon2, double aLat2, double aZ2)
    Verify if two points are at the exact same location, taking into account longitude wrapping.
    static boolean
    Verify if two points are at the exact same location, taking into account longitude wrapping.
    static boolean
    interacts2D(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2)
    Check whether two bounds interact, taking into account longitude wrapping.
    static double
    normalizeLat(double aLat)
    Normalizes a latitude ordinate.
    static double
    normalizeLon(double aLon)
    Normalizes a longitude ordinate to [-180, +180].
    static double
    subtractLon(double aLon1, double aLon2)
    Subtracts aLon1 from aLon2 (aLon2 - aLon1), taking into account the 180 degree meridian.
    static String
    toDegMinSec(double aOrdinate)
    Formats a longitude or latitude ordinate as a degrees/minutes/seconds String: ddmmss.
    static double
    Parses a latitude String into a latitude ordinate.
    static double
    Parses a longitude String into a longitude ordinate.
    static String
    toLatDegMinSec(double aOrdinate)
    Formats a latitude ordinate as a degrees/minutes/seconds/hemisphere String: ddmmss[NS].
    static String
    toLonDegMinSec(double aOrdinate)
    Formats a longitude ordinate as a degrees/minutes/seconds/length String: dddmmss[EW].

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TLcdLonLatCoord

      public TLcdLonLatCoord()
  • Method Details

    • toDegMinSec

      public static String toDegMinSec(double aOrdinate)
      Formats a longitude or latitude ordinate as a degrees/minutes/seconds String: ddmmss.
      Parameters:
      aOrdinate - the coordinate to be formatted.
      Returns:
      the formatted String.
    • toLatDegMinSec

      public static String toLatDegMinSec(double aOrdinate)
      Formats a latitude ordinate as a degrees/minutes/seconds/hemisphere String: ddmmss[NS].
      Parameters:
      aOrdinate - the latitude ordinate to be formatted.
      Returns:
      the formatted String.
    • toLonDegMinSec

      public static String toLonDegMinSec(double aOrdinate)
      Formats a longitude ordinate as a degrees/minutes/seconds/length String: dddmmss[EW].
      Parameters:
      aOrdinate - the longitude ordinate to be formatted.
      Returns:
      the formatted String ("NaN" for Double.NAN ).
    • toDoubleLat

      public static double toDoubleLat(String aString) throws ParseException
      Parses a latitude String into a latitude ordinate. The only format understood is <Deg><Min><Sec>[NS]. The String must contain exactly 7 characters. Examples:
       021500N ->   2.25
       521500N ->  52.25
       521500S -> -52.25
       
      Parameters:
      aString - the String to be parsed.
      Returns:
      the parsed latitude ordinate.
      Throws:
      ParseException - if the String can't be parsed.
    • toDoubleLon

      public static double toDoubleLon(String aString) throws ParseException
      Parses a longitude String into a longitude ordinate. The only format understood is <Deg><Min><Sec>[EW]. The String must contain exactly 8 characters. Examples:
       0081500E ->  8.25
       0081500W -> -8.25
       
      Parameters:
      aString - the String to be parsed.
      Returns:
      the parsed longitude ordinate.
      Throws:
      ParseException - if the String can't be parsed.
    • normalizeLon

      public static double normalizeLon(double aLon)
      Normalizes a longitude ordinate to [-180, +180].
      Parameters:
      aLon - the longitude in decimal degrees.
      Returns:
      the longitude, normalized to lie between -180.0 and 180.0
    • normalizeLat

      public static double normalizeLat(double aLat)
      Normalizes a latitude ordinate.
      Parameters:
      aLat - a latitude in decimal degrees.
      Returns:
      the latitude, normalized to lie between -90.0 and 90.0 (by clipping to these bounds).
    • subtractLon

      public static double subtractLon(double aLon1, double aLon2)
      Subtracts aLon1 from aLon2 (aLon2 - aLon1), taking into account the 180 degree meridian.
      Parameters:
      aLon1 - a longitude in decimal degrees, -180.0 <= lon <= 180.0.
      aLon2 - a longitude in decimal degrees, -180.0 <= lon <= 180.0.
      Returns:
      the longitude difference between aLon1 and aLon2, such that its value lies between -180.0 and 180.0.
    • differenceLonWest2East

      public static double differenceLonWest2East(double aLon1, double aLon2)
      Computes the difference |aLon2 - aLon1| by tracing the sphere from West to East. The result is a value between 0 and 360 degrees.
      Parameters:
      aLon1 - a longitude in degrees.
      aLon2 - a longitude in degrees.
      Returns:
      the difference between aLon1 and aLon2.
    • differenceLonEast2West

      public static double differenceLonEast2West(double aLon1, double aLon2)
      Computes the difference |aLon2 - aLon1| by tracing the sphere from East to West. The result is a value between 0 and 360 degrees.
      Parameters:
      aLon1 - a longitude in degrees.
      aLon2 - a longitude in degrees.
      Returns:
      the difference between aLon1 and aLon2.
    • eliminateOnLon180

      public static double[] eliminateOnLon180(double aLon1, double aLon2)
      Transforms aLon1 and aLon2 into two new longitudes, taking into account the 180 degree meridian.
      Parameters:
      aLon1 - a longitude in decimal degrees, -180.0 <= lon <= 180.0.
      aLon2 - a longitude in decimal degrees, -180.0 <= lon <= 180.0.
      Returns:
      two longitudes lon[0] and lon[1], such that (aLon2 - aLon1) is between -180.0 and 180.0, with lon[0] corresponding to aLon1 and lon[1] corresponding to aLon2.
    • eliminate3OnLon180

      public static double[] eliminate3OnLon180(double aLon1, double aLon2, double aLon3)
      Transforms aLon1, aLon2 and aLon3 into three new longitudes, taking into account the 180 degree meridian.
      Parameters:
      aLon1 - a longitude in decimal degrees, -180.0 <= lon <= 180.0.
      aLon2 - a longitude in decimal degrees, -180.0 <= lon <= 180.0.
      aLon3 - a longitude in decimal degrees, -180.0 <= lon <= 180.0.
      Returns:
      three longitudes lon[0], lon[1] and lon[2], such that (aLon2 - aLon1) lies between -180.0 and 180.0 and (aLon3 - aLon2) lies between -180.0 and 180.0, with lon[0] corresponding to aLon1, lon[1] corresponding to aLon2 and lon[2] corresponding to aLon3.
    • eliminateNOnLon180SFCT

      public static void eliminateNOnLon180SFCT(double[] aLon)
      Eliminates the 180 degree meridian on an array of longitudes. The calculation is done by side-effect (note the suffix SFCT in the name of the method), i.e., the array aLon passed as a parameter is changed.
    • interacts2D

      public static boolean interacts2D(double aLon1, double aLat1, double aWidth1, double aHeight1, double aLon2, double aLat2, double aWidth2, double aHeight2)
      Check whether two bounds interact, taking into account longitude wrapping.
      Parameters:
      aLon1 - Longitude of the first bounds' position
      aLat1 - Latitude of the first bounds' position
      aWidth1 - Width of the first bounds
      aHeight1 - Height of the first bounds
      aLon2 - Longitude of the second bounds' position
      aLat2 - Latitude of the second bounds' position
      aWidth2 - Width of the second bounds
      aHeight2 - Height of the second bounds
      Returns:
      true if they interact, false otherwise
    • equalLonLatPoint

      public static boolean equalLonLatPoint(ILcdPoint aPoint1, ILcdPoint aPoint2)
      Verify if two points are at the exact same location, taking into account longitude wrapping.
      Parameters:
      aPoint1 - The first point
      aPoint2 - The second point
      Returns:
      true if they are the same location, false otherwise
    • equalLonLatPoint

      public static boolean equalLonLatPoint(double aLon1, double aLat1, double aZ1, double aLon2, double aLat2, double aZ2)
      Verify if two points are at the exact same location, taking into account longitude wrapping.
      Parameters:
      aLon1 - Longitude of the first point
      aLat1 - Latitude of the first point
      aZ1 - Height of the first point
      aLon2 - Longitude of the second point
      aLat2 - Latitude of the second point
      aZ2 - Height of the second point
      Returns:
      true if they are the same location, false otherwise