org.onebusaway.geospatial.services
Class SphericalGeometryLibrary

java.lang.Object
  extended by org.onebusaway.geospatial.services.SphericalGeometryLibrary

public class SphericalGeometryLibrary
extends Object


Field Summary
static double COS_MAX_LAT
           
static double METERS_PER_DEGREE_AT_EQUATOR
           
static double RADIUS_OF_EARTH_IN_KM
           
 
Constructor Summary
SphericalGeometryLibrary()
           
 
Method Summary
static CoordinateBounds bounds(CoordinateBounds b, double distance)
           
static CoordinateBounds bounds(CoordinatePoint point, double distance)
           
static CoordinateBounds bounds(double lat, double lon, double distance)
           
static CoordinateBounds bounds(double lat, double lon, double latDistance, double lonDistance)
           
static CoordinateBounds boundsFromLatLonOffset(double lat, double lon, double latOffset, double lonOffset)
           
static CoordinateBounds boundsFromLatLonSpan(double lat, double lon, double latSpan, double lonSpan)
           
static double distance(CoordinatePoint a, CoordinatePoint b)
           
static double distance(double lat1, double lon1, double lat2, double lon2)
           
static double distance(double lat1, double lon1, double lat2, double lon2, double radius)
           
static double distanceFaster(double lat1, double lon1, double lat2, double lon2)
          This method is fast but not very accurate
static CoordinatePoint getCenterOfBounds(CoordinateBounds b)
           
static double getOrientation(double latFrom, double lonFrom, double latTo, double lonTo)
          If Wikipedia is to be trusted, then: http://en.wikipedia.org/wiki/Spherical_law_of_cosines claims that the standard ordinary planar law of cosines is a reasonable approximation for the more-complex spherical law of cosines when the central angles of the spherical triangle are small.
static CoordinatePoint projectPointToSegmentAppropximate(CoordinatePoint point, CoordinatePoint segmentStart, CoordinatePoint segmentEnd)
          Note that this is an approximate method at best that will perform increasingly worse as the distance between the points increases.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RADIUS_OF_EARTH_IN_KM

public static final double RADIUS_OF_EARTH_IN_KM
See Also:
Constant Field Values

COS_MAX_LAT

public static final double COS_MAX_LAT

METERS_PER_DEGREE_AT_EQUATOR

public static final double METERS_PER_DEGREE_AT_EQUATOR
See Also:
Constant Field Values
Constructor Detail

SphericalGeometryLibrary

public SphericalGeometryLibrary()
Method Detail

distanceFaster

public static double distanceFaster(double lat1,
                                    double lon1,
                                    double lat2,
                                    double lon2)
This method is fast but not very accurate

Parameters:
lat1 -
lon1 -
lat2 -
lon2 -
Returns:

distance

public static final double distance(double lat1,
                                    double lon1,
                                    double lat2,
                                    double lon2)

distance

public static final double distance(CoordinatePoint a,
                                    CoordinatePoint b)

distance

public static final double distance(double lat1,
                                    double lon1,
                                    double lat2,
                                    double lon2,
                                    double radius)

bounds

public static final CoordinateBounds bounds(CoordinatePoint point,
                                            double distance)

bounds

public static CoordinateBounds bounds(CoordinateBounds b,
                                      double distance)

bounds

public static final CoordinateBounds bounds(double lat,
                                            double lon,
                                            double distance)

bounds

public static final CoordinateBounds bounds(double lat,
                                            double lon,
                                            double latDistance,
                                            double lonDistance)

boundsFromLatLonOffset

public static final CoordinateBounds boundsFromLatLonOffset(double lat,
                                                            double lon,
                                                            double latOffset,
                                                            double lonOffset)
Parameters:
lat -
lon -
latOffset -
lonOffset -
Returns:
CoordinateBounds(lat-latOffser,lon-lonOffset,lat+latOffset,lon+lonOffset )

boundsFromLatLonSpan

public static final CoordinateBounds boundsFromLatLonSpan(double lat,
                                                          double lon,
                                                          double latSpan,
                                                          double lonSpan)

getCenterOfBounds

public static CoordinatePoint getCenterOfBounds(CoordinateBounds b)

getOrientation

public static double getOrientation(double latFrom,
                                    double lonFrom,
                                    double latTo,
                                    double lonTo)
If Wikipedia is to be trusted, then: http://en.wikipedia.org/wiki/Spherical_law_of_cosines claims that the standard ordinary planar law of cosines is a reasonable approximation for the more-complex spherical law of cosines when the central angles of the spherical triangle are small.

Parameters:
latFrom -
lonFrom -
latTo -
lonTo -
Returns:
the orientation angle in degrees, 0º is East, 90º is North, 180º is West, and 270º is South

projectPointToSegmentAppropximate

public static CoordinatePoint projectPointToSegmentAppropximate(CoordinatePoint point,
                                                                CoordinatePoint segmentStart,
                                                                CoordinatePoint segmentEnd)
Note that this is an approximate method at best that will perform increasingly worse as the distance between the points increases.

Parameters:
point -
segmentStart -
segmentEnd -
Returns:


Copyright © 2011 OneBusAway. All Rights Reserved.