com.bbn.openmap.geo
Class Geo

java.lang.Object
  |
  +--com.bbn.openmap.geo.Geo

public class Geo
extends java.lang.Object

This is a Ken Anderson class for dealing with geographical coordinates.

A class that represents a point on the Earth as a three dimensional unit length vector, rather than latitude and longitude. For the theory and an efficient implementation using partial evaluation see:
http://openmap.bbn.com/~kanderso/lisp/performing-lisp/essence.ps

This implementation matches the theory carefully, but does not use partial evaluation.

For the area calculation see: http://math.rice.edu/~pcmi/sphere/

Author:
Ken Anderson with additions by Ben Lubin

Field Summary
static double f
           
static double flattening
          Constants for the shape of the earth.
static Geo north
          North pole.
 
Constructor Summary
Geo(double lat, double lon)
          Construct a Geo from its latitude and longitude.
Geo(double x, double y, double z)
          Construct a Geo from its parts.
 
Method Summary
 Geo add(Geo b)
          Returns this + b.
static double angle(Geo p0, Geo p1, Geo p2)
          Given 3 points on a sphere, p0, p1, p2, return the angle between them in radians.
 Geo antipode()
          Returns the point opposite this point on the earth.
static double area(java.util.Enumeration vs)
          Computes the area of a polygon on the surface of a unit sphere given an enumeration of its point.
 double azimuth(Geo v2)
          Azimuth in radians from this to v2.
static Geo createGeo(double rlatR, double rlon)
          Construct a Geo from its latitude and longitude in radians.
 Geo cross(Geo b)
          Vector cross product.
 double crossLength(Geo b)
          Equivalent to this.cross(b).length().
 Geo crossNormalize(Geo b)
          Equivalent to this.cross(b).normalize().
static Geo crossNormalize(Geo a, Geo b)
          Eqvivalent to this.cross(b).normalize().
static double degrees(double radians)
          Convert from radians to degrees.
static double distance(double lat1, double lon1, double lat2, double lon2)
          Angular distance, in radians between the two lat lon points.
 double distance(Geo v2)
          Angular distance, in radians between this and v2.
static double distance(Geo v1, Geo v2)
          Angular distance, in radians between v1 and v2.
static double distanceKM(double lat1, double lon1, double lat2, double lon2)
          Distance in kilometers.
 double distanceKM(Geo v2)
          Distance in kilometers.
static double distanceKM(Geo v1, Geo v2)
          Distance in kilometers.
static double distanceNM(double lat1, double lon1, double lat2, double lon2)
          Distance in nautical miles.
 double distanceNM(Geo v2)
          Distance in nautical miles.
static double distanceNM(Geo v1, Geo v2)
          Distance in nautical miles.
 double dot(Geo b)
          Dot product.
static double dot(Geo a, Geo b)
          Dot product.
static double geocentricLatitude(double geographicLatitude)
          Convert from geographic to geocentric latitude (radians).
static double geographicLatitude(double geocentricLatitude)
          Convert from geocentric to geographic latitude (radians)
 double getLatitude()
           
 double getLongitude()
           
 boolean inBubble(Geo v2, double forwardRadius, double backRadius, Geo p)
          Is Geo p inside the time bubble along the great circle segment from this to v2 looking forward forwardRadius and backward backwardRadius.
 Geo interpolate(Geo g2, double x)
           
 Geo intersect(Geo q, Geo r)
          Find the intersection of the great circle between this and q and the great circle normal to r.
static boolean isInside(double lat1, double lon1, double lat2, double lon2, double radius, double lat3, double lon3)
          Static versions using conventional coordinates.
 boolean isInside(Geo v2, double radius, Geo p)
          Is the point, p, within radius radians of the great circle segment between this and v2?
static double km(double radians)
          Convert radians to kilometers.
static double kmToAngle(double km)
          Convert kilometers to radians.
 double length()
          Euclidian length.
 Geo midPoint(Geo g2)
           
static double nm(double radians)
          Convert radians to nauticalMiles.
static double nmToAngle(double nm)
          Convert nautical miles to radians.
 Geo normalize()
          Returns a unit length vector parallel to this.
static double radians(double degrees)
          Convert from degrees to radians.
 Geo scale(double s)
          Multiply this by s.
 Geo subtract(Geo b)
          Returns this - b.
 java.lang.String toString()
           
 double x()
           
 double y()
           
 double z()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

flattening

public static final double flattening
Constants for the shape of the earth. see http://www.gfy.ku.dk/%7Eiag/HB2000/part4/groten.htm

See Also:
Constant Field Values

f

public static final double f
See Also:
Constant Field Values

north

public static Geo north
North pole.

Constructor Detail

Geo

public Geo(double lat,
           double lon)
Construct a Geo from its latitude and longitude.


Geo

public Geo(double x,
           double y,
           double z)
Construct a Geo from its parts.

Method Detail

geocentricLatitude

public static double geocentricLatitude(double geographicLatitude)
Convert from geographic to geocentric latitude (radians).


geographicLatitude

public static double geographicLatitude(double geocentricLatitude)
Convert from geocentric to geographic latitude (radians)


radians

public static double radians(double degrees)
Convert from degrees to radians.


degrees

public static double degrees(double radians)
Convert from radians to degrees.


km

public static double km(double radians)
Convert radians to kilometers.


kmToAngle

public static double kmToAngle(double km)
Convert kilometers to radians.


nm

public static double nm(double radians)
Convert radians to nauticalMiles.


nmToAngle

public static double nmToAngle(double nm)
Convert nautical miles to radians.


createGeo

public static Geo createGeo(double rlatR,
                            double rlon)
Construct a Geo from its latitude and longitude in radians.


midPoint

public Geo midPoint(Geo g2)

interpolate

public Geo interpolate(Geo g2,
                       double x)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getLatitude

public double getLatitude()

getLongitude

public double getLongitude()

x

public double x()

y

public double y()

z

public double z()

dot

public double dot(Geo b)
Dot product.


dot

public static double dot(Geo a,
                         Geo b)
Dot product.


length

public double length()
Euclidian length.


scale

public Geo scale(double s)
Multiply this by s.


normalize

public Geo normalize()
Returns a unit length vector parallel to this.


cross

public Geo cross(Geo b)
Vector cross product.


crossLength

public double crossLength(Geo b)
Equivalent to this.cross(b).length().


crossNormalize

public Geo crossNormalize(Geo b)
Equivalent to this.cross(b).normalize().


crossNormalize

public static Geo crossNormalize(Geo a,
                                 Geo b)
Eqvivalent to this.cross(b).normalize().


add

public Geo add(Geo b)
Returns this + b.


subtract

public Geo subtract(Geo b)
Returns this - b.


distance

public double distance(Geo v2)
Angular distance, in radians between this and v2.


distance

public static double distance(Geo v1,
                              Geo v2)
Angular distance, in radians between v1 and v2.


distance

public static double distance(double lat1,
                              double lon1,
                              double lat2,
                              double lon2)
Angular distance, in radians between the two lat lon points.


distanceKM

public double distanceKM(Geo v2)
Distance in kilometers.


distanceKM

public static double distanceKM(Geo v1,
                                Geo v2)
Distance in kilometers.


distanceKM

public static double distanceKM(double lat1,
                                double lon1,
                                double lat2,
                                double lon2)
Distance in kilometers.


distanceNM

public double distanceNM(Geo v2)
Distance in nautical miles.


distanceNM

public static double distanceNM(Geo v1,
                                Geo v2)
Distance in nautical miles.


distanceNM

public static double distanceNM(double lat1,
                                double lon1,
                                double lat2,
                                double lon2)
Distance in nautical miles.


azimuth

public double azimuth(Geo v2)
Azimuth in radians from this to v2.


angle

public static double angle(Geo p0,
                           Geo p1,
                           Geo p2)
Given 3 points on a sphere, p0, p1, p2, return the angle between them in radians.


area

public static double area(java.util.Enumeration vs)
Computes the area of a polygon on the surface of a unit sphere given an enumeration of its point. For a non unit sphere, multiply this by the radius of sphere squared.

Parameters:
vs - an Enumeration of Geos marking the polygon.

isInside

public boolean isInside(Geo v2,
                        double radius,
                        Geo p)
Is the point, p, within radius radians of the great circle segment between this and v2?

Parameters:
v2 - Geo marking the center of the area to test.
radius - great circle length of segment to test for p's distance away from v2. In radians.
p - Geo marking the test point.

isInside

public static boolean isInside(double lat1,
                               double lon1,
                               double lat2,
                               double lon2,
                               double radius,
                               double lat3,
                               double lon3)
Static versions using conventional coordinates.


inBubble

public boolean inBubble(Geo v2,
                        double forwardRadius,
                        double backRadius,
                        Geo p)
Is Geo p inside the time bubble along the great circle segment from this to v2 looking forward forwardRadius and backward backwardRadius.


antipode

public Geo antipode()
Returns the point opposite this point on the earth.


intersect

public Geo intersect(Geo q,
                     Geo r)
Find the intersection of the great circle between this and q and the great circle normal to r.

That is, find the point y lying between this and q such that

 
   y = x*this + (1-x)*q
   y.dot(r) = 0
   [x*this + (1-x)*q].dot(r) = 0
   x*this.dot(r) + (1-x)*q.dot(r) = 0
   x*a + (1-x)*b = 0
   x = -b/(a - b)
   
 



Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details