ProjMath (OpenMap API)
Date: 2016-12-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.proj
Class ProjMath

    java.lang.Object
      com.bbn.openmap.proj.ProjMath

    public final class ProjMath

extends java.lang.Object

Math functions used by projection code.

Field Summary
`static double` | `DATELINE_D` Dateline longitude in radians.
`static double` | `DATELINE_DEG_D` Dateline longitude in degrees.
`static float` | `DATELINE_F` Dateline longitude in radians.
`static double` | `LON_RANGE_D` Longitude range in radians.
`static double` | `LON_RANGE_DEG_D` Longitude range in degrees.
`static float` | `LON_RANGE_F` Longitude range in radians.
`static double` | `NORTH_POLE_D` North pole latitude in radians.
`static double` | `NORTH_POLE_DEG_D` North pole latitude in degrees.
`static float` | `NORTH_POLE_F` North pole latitude in radians.
`static double` | `SOUTH_POLE_D` South pole latitude in radians.
`static double` | `SOUTH_POLE_DEG_D` South pole latitude in degrees.
`static float` | `SOUTH_POLE_F` South pole latitude in radians.

Method Summary
`static double[]` | `arrayDegToRad(double[] degs)` Converts an array of decimal degrees double lat/lons to double radians in place.
`static float[]` | `arrayDegToRad(float[] degs)` Converts an array of decimal degrees float lat/lons to float radians in place.
`static double[]` | `arrayRadToDeg(double[] rads)` Converts an array of radian double lat/lons to decimal degrees in place.
`static float[]` | `arrayRadToDeg(float[] rads)` Converts an array of radian float lat/lons to decimal degrees in place.
`static long` | `DEG_TO_SC(double deg)` Convert between decimal degrees and scoords.
`static double` | `degToRad(double deg)` Convert degrees to radians.
`static float` | `degToRad(float deg)` Convert degrees to radians.
`static double` | `distance(double[] radianCoords)` Cumulative distance calculated between coords.
`static float` | `geocentric_latitude(float lat, float lon)` Deprecated. use geocentricLatitude instead.
`static float` | `geocentricLatitude(float lat, float flat)` Calculate the geocentric latitude given a geographic latitude.
`static float` | `geographic_latitude(float lat, float lon)` Deprecated. use geographicLoatitude instead.
`static float` | `geographicLatitude(float lat, float flat)` Calculate the geographic latitude given a geocentric latitude.
`static double[]` | `getProjectionScreenOutlineCoords(Projection sourceMapProjection)` Walks around the perimeter of the sourceMapProjection and returns the lat/lon coords of the outline.
`static java.awt.geom.Rectangle2D` | `getRatioBox(Projection proj, java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2, boolean zoomOnCenter)` Given a projection to match against and the starting point of a box (pt1), look at pt2 to see if it represents the ratio of the projection map size.
`static java.awt.Point` | `getRatioPoint(Projection proj, java.awt.Point pt1, java.awt.Point pt2)` Given a projection and the starting point of a box (pt1), look at pt2 to see if it represents the ratio of the projection map size.
`protected static float` | `getScale(java.awt.geom.Point2D ll1, java.awt.geom.Point2D ll2, java.awt.geom.Point2D point1, java.awt.geom.Point2D point2, Projection projection)` Given a couple of points representing a bounding box, find out what the scale should be in order to make those points appear at the corners of the projection.
`static float` | `getScale(java.awt.geom.Point2D ll1, java.awt.geom.Point2D ll2, Projection projection)` Given a couple of points representing a bounding box, find out what the scale should be in order to make those points appear at the corners of the projection.
`static float` | `getScale(java.awt.Point point1, java.awt.Point point2, Projection projection)` Given a couple of points representing a bounding box, find out what the scale should be in order to make those points appear at the corners of the projection.
`static float` | `getScaleFromProjected(java.awt.geom.Point2D point1, java.awt.geom.Point2D point2, Projection projection)` Given a couple of points representing a bounding box of projected coordinates, find out what the scale should be in order to make those points appear at the corners of the projection, with the intention that the bounding box will then fill the projected space.
`static int` | `hashLatLon(float lat, float lon)` Generate a hashCode value for a lat/lon pair.
`static boolean` | `isCrossingDateline(double leftLon, double rightLon, float projScale)` Generic test for seeing if an left longitude value and a right longitude value seem to constitute crossing the dateline.
`static boolean` | `isVisible(Projection sourceMapProjection, java.awt.geom.Point2D llp)` Returns true if the Point is visible on the provided projection.
`static float` | `lonDistance(float lon1, float lon2)` Calculate the shortest arc distance between two lons.
`static double` | `normalize_latitude(double lat, double epsilon)` Deprecated. use normalizeLatitude instead.
`static float` | `normalize_latitude(float lat, float epsilon)` Deprecated. use normalizeLatitude instead.
`static double` | `normalizeLatitude(double lat, double epsilon)` Normalizes radian latitude.
`static float` | `normalizeLatitude(float lat, float epsilon)` Normalizes radian latitude.
`static double` | `qint(double x)` Rounds the quantity away from 0.
`static double` | `radToDeg(double rad)` Convert radians to degrees.
`static float` | `radToDeg(float rad)` Convert radians to degrees.
`static double` | `roundAdjust(double x)` rounds the quantity away from 0.
`static double` | `SC_TO_DEG(int sc)` Convert between decimal degrees and scoords.
`static float` | `sphericalUnitsToDeg(float u, float uCircumference)` Converts units (km, nm, miles, etc) to decimal degrees for a spherical planet.
`static float` | `sphericalUnitsToRad(float u, float uCircumference)` Converts units (km, nm, miles, etc) to arc radians for a spherical planet.
`static double` | `wrap_longitude(double lon)` Deprecated. use wrapLongitude instead.
`static float` | `wrap_longitude(float lon)` Deprecated. use wrapLongitde instead.
`static double` | `wrapLongitude(double lon)` Sets radian longitude to something sane.
`static float` | `wrapLongitude(float lon)` Sets radian longitude to something sane.
`static double` | `wrapLongitudeDeg(double lon)` Sets degree longitude to something sane.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### NORTH_POLE_F

    public static final transient float NORTH_POLE_F

  North pole latitude in radians.

  See Also:
    Constant Field Values

### SOUTH_POLE_F

    public static final transient float SOUTH_POLE_F

  South pole latitude in radians.

  See Also:
    Constant Field Values

### NORTH_POLE_D

    public static final transient double NORTH_POLE_D

  North pole latitude in radians.

  See Also:
    Constant Field Values

### NORTH_POLE_DEG_D

    public static final transient double NORTH_POLE_DEG_D

  North pole latitude in degrees.

  See Also:
    Constant Field Values

### SOUTH_POLE_D

    public static final transient double SOUTH_POLE_D

  South pole latitude in radians.

  See Also:
    Constant Field Values

### SOUTH_POLE_DEG_D

    public static final transient double SOUTH_POLE_DEG_D

  South pole latitude in degrees.

  See Also:
    Constant Field Values

### DATELINE_F

    public static final transient float DATELINE_F

  Dateline longitude in radians.

  See Also:
    Constant Field Values

### DATELINE_D

    public static final transient double DATELINE_D

  Dateline longitude in radians.

  See Also:
    Constant Field Values

### DATELINE_DEG_D

    public static final transient double DATELINE_DEG_D

  Dateline longitude in degrees.

  See Also:
    Constant Field Values

### LON_RANGE_F

    public static final transient float LON_RANGE_F

  Longitude range in radians.

  See Also:
    Constant Field Values

### LON_RANGE_D

    public static final transient double LON_RANGE_D

  Longitude range in radians.

  See Also:
    Constant Field Values

### LON_RANGE_DEG_D

    public static final transient double LON_RANGE_DEG_D

  Longitude range in degrees.

  See Also:
    Constant Field Values

Method Detail

### roundAdjust

    public static final double roundAdjust(double x)

  rounds the quantity away from 0.

  Parameters:
    `x` - in value
  Returns:
    double
  See Also:
    `qint(double)`

### qint

    public static final double qint(double x)

  Rounds the quantity away from 0.

  Parameters:
    `x` - value
  Returns:
    double

### lonDistance

    public static final float lonDistance(float lon1,
                                          float lon2)

  Calculate the shortest arc distance between two lons.

  Parameters:
    `lon1` - radians
    `lon2` - radians
  Returns:
    float distance

### DEG_TO_SC

    public static final long DEG_TO_SC(double deg)

  Convert between decimal degrees and scoords.

  Parameters:
    `deg` - degrees
  Returns:
    long scoords

### SC_TO_DEG

    public static final double SC_TO_DEG(int sc)

  Convert between decimal degrees and scoords.

  Parameters:
    `sc` - scoords
  Returns:
    double decimal degrees

### radToDeg

    public static final double radToDeg(double rad)

  Convert radians to degrees.

  Parameters:
    `rad` - radians
  Returns:
    double decimal degrees

### radToDeg

    public static final float radToDeg(float rad)

  Convert radians to degrees.

  Parameters:
    `rad` - radians
  Returns:
    float decimal degrees

### degToRad

    public static final double degToRad(double deg)

  Convert degrees to radians.

  Parameters:
    `deg` - degrees
  Returns:
    double radians

### degToRad

    public static final float degToRad(float deg)

  Convert degrees to radians.

  Parameters:
    `deg` - degrees
  Returns:
    float radians

### hashLatLon

    public static final int hashLatLon(float lat,
                                       float lon)

  Generate a hashCode value for a lat/lon pair.

  Parameters:
    `lat` - latitude
    `lon` - longitude
  Returns:
    int hashcode

### arrayDegToRad

    public static final float[] arrayDegToRad(float[] degs)

  Converts an array of decimal degrees float lat/lons to float radians in place.

  Parameters:
    `degs` - float[] lat/lons in decimal degrees
  Returns:
    float[] lat/lons in radians

### arrayRadToDeg

    public static final float[] arrayRadToDeg(float[] rads)

  Converts an array of radian float lat/lons to decimal degrees in place.

  Parameters:
    `rads` - float[] lat/lons in radians
  Returns:
    float[] lat/lons in decimal degrees

### arrayDegToRad

    public static final double[] arrayDegToRad(double[] degs)

  Converts an array of decimal degrees double lat/lons to double radians in place.

  Parameters:
    `degs` - double[] lat/lons in decimal degrees
  Returns:
    double[] lat/lons in radians

### arrayRadToDeg

    public static final double[] arrayRadToDeg(double[] rads)

  Converts an array of radian double lat/lons to decimal degrees in place.

  Parameters:
    `rads` - double[] lat/lons in radians
  Returns:
    double[] lat/lons in decimal degrees

### normalize_latitude

    public static final float normalize_latitude(float lat,
                                                 float epsilon)

  Deprecated. use normalizeLatitude instead.

### normalizeLatitude

    public static final float normalizeLatitude(float lat,
                                                float epsilon)

  Normalizes radian latitude. Normalizes latitude if at or exceeds epsilon distance from a pole.

  Parameters:
    `lat` - float latitude in radians
    `epsilon` - epsilon (>= 0) radians distance from pole
  Returns:
    float latitude (-PI/2 <= phi <= PI/2)
  See Also:
    `LatLonPoint.normalizeLatitude(double)`

### normalize_latitude

    public static final double normalize_latitude(double lat,
                                                  double epsilon)

  Deprecated. use normalizeLatitude instead.

### normalizeLatitude

    public static final double normalizeLatitude(double lat,
                                                 double epsilon)

  Normalizes radian latitude. Normalizes latitude if at or exceeds epsilon distance from a pole.

  Parameters:
    `lat` - double latitude in radians
    `epsilon` - epsilon (>= 0) radians distance from pole
  Returns:
    double latitude (-PI/2 <= phi <= PI/2)
  See Also:
    `LatLonPoint.normalizeLatitude(double)`

### wrap_longitude

    public static final float wrap_longitude(float lon)

  Deprecated. use wrapLongitde instead.

### wrapLongitude

    public static final float wrapLongitude(float lon)

  Sets radian longitude to something sane.

  Parameters:
    `lon` - float longitude in radians
  Returns:
    float longitude (-PI <= lambda < PI)

### wrap_longitude

    public static final double wrap_longitude(double lon)

  Deprecated. use wrapLongitude instead.

### wrapLongitude

    public static final double wrapLongitude(double lon)

  Sets radian longitude to something sane.

  Parameters:
    `lon` - double longitude in radians
  Returns:
    double longitude (-PI <= lambda < PI)

### wrapLongitudeDeg

    public static final double wrapLongitudeDeg(double lon)

  Sets degree longitude to something sane.

  Parameters:
    `lon` - double longitude in degrees
  Returns:
    double longitude (-180 <= lambda < 180)

### sphericalUnitsToDeg

    public static final float sphericalUnitsToDeg(float u,
                                                  float uCircumference)

  Converts units (km, nm, miles, etc) to decimal degrees for a spherical planet. This does not check for arc distances > 1/2 planet circumference, which are better represented as (2pi - calculated arc).

  Parameters:
    `u` - units float value
    `uCircumference` - units circumference of planet
  Returns:
    float decimal degrees

### sphericalUnitsToRad

    public static final float sphericalUnitsToRad(float u,
                                                  float uCircumference)

  Converts units (km, nm, miles, etc) to arc radians for a spherical planet. This does not check for arc distances > 1/2 planet circumference, which are better represented as (2pi - calculated arc).

  Parameters:
    `u` - units float value
    `uCircumference` - units circumference of planet
  Returns:
    float arc radians

### geocentric_latitude

    public static final float geocentric_latitude(float lat,
                                                  float lon)

  Deprecated. use geocentricLatitude instead.

### geocentricLatitude

    public static final float geocentricLatitude(float lat,
                                                 float flat)

  Calculate the geocentric latitude given a geographic latitude. According to John Synder:
  "The geographic or geodetic latitude is the angle which a line perpendicular to the surface of the ellipsoid at the given point makes with the plane of the equator. ...The geocentric latitude is the angle made by a line to the center of the ellipsoid with the equatorial plane". ( Map Projections --A Working Manual , p 13)

  Translated from Ken Anderson's lisp code Freeing the Essence of Computation

  Parameters:
    `lat` - float geographic latitude in radians
    `flat` - float flatening factor
  Returns:
    float geocentric latitude in radians
  See Also:
    `geographic_latitude(float, float)`

### geographic_latitude

    public static final float geographic_latitude(float lat,
                                                  float lon)

  Deprecated. use geographicLoatitude instead.

### geographicLatitude

    public static final float geographicLatitude(float lat,
                                                 float flat)

  Calculate the geographic latitude given a geocentric latitude. Translated from Ken Anderson's lisp code Freeing the Essence of Computation

  Parameters:
    `lat` - float geocentric latitude in radians
    `flat` - float flatening factor
  Returns:
    float geographic latitude in radians
  See Also:
    `geocentric_latitude(float, float)`

### getScale

    public static float getScale(java.awt.geom.Point2D ll1,
                                 java.awt.geom.Point2D ll2,
                                 Projection projection)

  Given a couple of points representing a bounding box, find out what the scale should be in order to make those points appear at the corners of the projection.

  Parameters:
    `ll1` - the upper left coordinates of the bounding box.
    `ll2` - the lower right coordinates of the bounding box.
    `projection` - the projection to use for other projection parameters, like map width and map height.

### getScale

    public static float getScale(java.awt.Point point1,
                                 java.awt.Point point2,
                                 Projection projection)

  Given a couple of points representing a bounding box, find out what the scale should be in order to make those points appear at the corners of the projection. This method is generally called from objects dealing with MouseEvents.

  Parameters:
    `point1` - a java.awt.Point reflecting a pixel spot on the projection, usually the upper left corner of the area of interest.
    `point2` - a java.awt.Point reflecting a pixel spot on the projection, usually the lower right corner of the area of interest.
    `projection` - the projection to use for other projection parameters, like map width and map height.

### getScaleFromProjected

    public static float getScaleFromProjected(java.awt.geom.Point2D point1,
                                              java.awt.geom.Point2D point2,
                                              Projection projection)

  Given a couple of points representing a bounding box of projected coordinates, find out what the scale should be in order to make those points appear at the corners of the projection, with the intention that the bounding box will then fill the projected space.

  Parameters:
    `point1` - a java.awt.Point reflecting a pixel spot on the projection, usually the upper left corner of the area of interest.
    `point2` - a java.awt.Point reflecting a pixel spot on the projection, usually the lower right corner of the area of interest.
    `projection` - the projection to use for other projection parameters, like map width and map height.

### getScale

    protected static float getScale(java.awt.geom.Point2D ll1,
                                    java.awt.geom.Point2D ll2,
                                    java.awt.geom.Point2D point1,
                                    java.awt.geom.Point2D point2,
                                    Projection projection)

  Given a couple of points representing a bounding box, find out what the scale should be in order to make those points appear at the corners of the projection.

  Parameters:
    `ll1` - the upper left coordinates of the bounding box.
    `ll2` - the lower right coordinates of the bounding box.
    `point1` - a java.awt.Point reflecting a pixel spot on the projection that matches the ll1 coordinate in the new space, the upper left corner of the area of interest. Where the ll1 is going to go in the new projection.
    `point2` - a java.awt.Point reflecting a pixel spot on the projection that matches the ll2 coordinate in the new space, usually the lower right corner of the area of interest. Where the ll2 is going to go in the new projection.
    `projection` - the projection to use to query to get the scale for, for projection type and height and width.

### isCrossingDateline

    public static boolean isCrossingDateline(double leftLon,
                                             double rightLon,
                                             float projScale)

  Generic test for seeing if an left longitude value and a right longitude value seem to constitute crossing the dateline.

  Parameters:
    `leftLon` - the leftmost longitude, in decimal degrees. Expected to represent the location of the left side of a map window.
    `rightLon` - the rightmost longitude, in decimal degrees. Expected to represent the location of the right side of a map window.
    `projScale` - the projection scale, considered if the two values are very close to each other and leftLon less than rightLon.
  Returns:
    true if it seems like these two longitude values represent a dateline crossing.

### getRatioPoint

    public static java.awt.Point getRatioPoint(Projection proj,
                                               java.awt.Point pt1,
                                               java.awt.Point pt2)

  Given a projection and the starting point of a box (pt1), look at pt2 to see if it represents the ratio of the projection map size. If it doesn't, provide a point that does. You need to make sure that the proj, pt1 and pt2 is not null.

  Parameters:
    `proj` - the projection to use for the calculations.
    `pt1` - upper left point in pixel space
    `pt2` - second point in pixel space.
  Returns:
    new pt that matches projection h/w ratio.

### getRatioBox

    public static java.awt.geom.Rectangle2D getRatioBox(Projection proj,
                                                        java.awt.geom.Point2D pt1,
                                                        java.awt.geom.Point2D pt2,
                                                        boolean zoomOnCenter)

  Given a projection to match against and the starting point of a box (pt1), look at pt2 to see if it represents the ratio of the projection map size. Return a rectangle for the resulting zoom area.

  Parameters:
    `proj` - the current projection.
    `pt1` - first point, where mouse down happened, for instance.
    `pt2` - latest point, where mouse released happened, for instance.
    `zoomOnCenter` - whether the first point represents the center of the zoom box, or one of the corners.
  Returns:
    Rectangle2D representing the new zoom box.

### getProjectionScreenOutlineCoords

    public static double[] getProjectionScreenOutlineCoords(Projection sourceMapProjection)

  Walks around the perimeter of the sourceMapProjection and returns the lat/lon coords of the outline.

  Parameters:
    `sourceMapProjection` - the source map's projection.
  Returns:
    double[] in y, x order, in whatever units the source map projection's inverse function returns.

### isVisible

    public static boolean isVisible(Projection sourceMapProjection,
                                    java.awt.geom.Point2D llp)

  Returns true if the Point is visible on the provided projection.

  Parameters:
    `sourceMapProjection` -
    `llp` -
  Returns:
    true if the Point is visible on the provided projection.

### distance

    public static double distance(double[] radianCoords)

  Cumulative distance calculated between coords.

  Parameters:
    `radianCoords` - lat, lon, lat, lon order
  Returns:
    distance in radians

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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