com.bbn.openmap.proj
Class Mercator

java.lang.Object
  extended by com.bbn.openmap.proj.Proj
      extended by com.bbn.openmap.proj.GeoProj
          extended by com.bbn.openmap.proj.Cylindrical
              extended by com.bbn.openmap.proj.Mercator
All Implemented Interfaces:
Projection, java.io.Serializable, java.lang.Cloneable

public class Mercator
extends Cylindrical

Implements the Mercator projection.

See Also:
Serialized Form

Field Summary
protected  double asinh_of_tanCtrLat
           
protected static double epsilon
           
protected  double hy
           
protected static int MAX_RHUMB_SEGS
           
static java.lang.String MercatorName
          The Mercator name.
protected  double tanCtrLat
           
protected  double wx
           
 
Fields inherited from class com.bbn.openmap.proj.Cylindrical
half_world, world
 
Fields inherited from class com.bbn.openmap.proj.GeoProj
DATELINE, mercator, NORTH_POLE, NUM_DEFAULT_CIRCLE_VERTS, NUM_DEFAULT_GREAT_SEGS, pixelsPerMeter, planetPixelCircumference, planetPixelRadius, planetRadius, scaled_radius, SOUTH_POLE, XSCALE_THRESHOLD, XTHRESHOLD
 
Fields inherited from class com.bbn.openmap.proj.Proj
centerX, centerY, height, maxscale, MIN_HEIGHT, MIN_WIDTH, minscale, projID, rotationAngle, scale, ucuom, width
 
Constructor Summary
Mercator(LatLonPoint center, float scale, int width, int height)
          Construct a Mercator projection.
 
Method Summary
protected  void computeParameters()
          Called when some fundamental parameters change.
 java.awt.geom.Point2D forward(double lat, double lon, java.awt.geom.Point2D p, boolean isRadian)
          Forward projects lat,lon into XY space and returns a Point2D.
 java.lang.String getName()
          Get the name string of the projection.
<T extends java.awt.geom.Point2D>
T
inverse(double x, double y, T llp)
          Inverse project x,y coordinates into a LatLonPoint.
 boolean isPlotable(double lat, double lon)
          Checks if a LatLonPoint is plot-able.
 double normalizeLatitude(double lat)
          Sets radian latitude to something sane.
protected  float[] rhumbProject(java.awt.geom.Point2D from, java.awt.geom.Point2D to, boolean include_last, int nsegs)
          Calculates the points along a rhumbline between two XY points.
protected  double[] rhumbProjectDouble(java.awt.geom.Point2D from, java.awt.geom.Point2D to, boolean include_last, int nsegs)
          Calculates the points along a rhumbline between two XY points.
protected static int rhumbStep(java.awt.geom.Point2D pt1, java.awt.geom.Point2D pt2)
          Computes the best stepping factor for a rhumbline.
 java.lang.String toString()
          Return stringified description of this projection.
 
Methods inherited from class com.bbn.openmap.proj.Cylindrical
_forwardPoly, _forwardPoly, dumpPoly, dumpPoly, forwardRaw, forwardRaw, getLowerRight, getUpperLeft, init
 
Methods inherited from class com.bbn.openmap.proj.GeoProj
assertLatLonPoint, clone, doPolyDispatch, doPolyDispatch, forward, forward, forward, forward, forwardArc, forwardArc, forwardArc, forwardCircle, forwardCircle, forwardCircle, forwardGreatPoly, forwardGreatPoly, forwardLine, forwardLine, forwardLLPoly, forwardPoly, forwardPoly, forwardRect, forwardRect, forwardRect, forwardRhumbPoly, forwardRhumbPoly, getCenter, getCenter, getGCTForProjection, getPlanetPixelCircumference, getPlanetPixelRadius, getPlanetRadius, getPPM, getReferenceLon, getScale, getUcuom, inverse, inverse, isComplicatedLineType, isPlotable, normalize_latitude, normalizeLatitude, pan, pan, setCenter, setCenter, setCenter, setPlanetRadius, setPPM, setUcuom, wrap_longitude, wrapLongitude, wrapLongitude, wrapLongitudeDeg
 
Methods inherited from class com.bbn.openmap.proj.Proj
drawBackground, drawBackground, equals, forward, forward, forward, forwardLine, forwardPoly, forwardPoly, forwardRect, forwardShape, getHeight, getMaxScale, getMinScale, getProjectionID, getRotationAngle, getScale, getWidth, hashCode, inverse, inverseShape, makeClone, panE, panE, panN, panN, panNE, panNE, panNW, panNW, panS, panS, panSE, panSE, panSW, panSW, panW, panW, setCenter, setHeight, setMaxScale, setMinScale, setParms, setProjectionID, setRotationAngle, setScale, setWidth
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MercatorName

public static final transient java.lang.String MercatorName
The Mercator name.

See Also:
Constant Field Values

MAX_RHUMB_SEGS

protected static final int MAX_RHUMB_SEGS
See Also:
Constant Field Values

epsilon

protected static double epsilon

hy

protected transient double hy

wx

protected transient double wx

tanCtrLat

protected transient double tanCtrLat

asinh_of_tanCtrLat

protected transient double asinh_of_tanCtrLat
Constructor Detail

Mercator

public Mercator(LatLonPoint center,
                float scale,
                int width,
                int height)
Construct a Mercator projection.

Parameters:
center - LatLonPoint center of projection
scale - float scale of projection
width - width of screen
height - height of screen
Method Detail

toString

public java.lang.String toString()
Return stringified description of this projection.

Overrides:
toString in class Cylindrical
Returns:
String
See Also:
Projection.getProjectionID()

computeParameters

protected void computeParameters()
Called when some fundamental parameters change.

Each projection will decide how to respond to this change. For instance, they may need to recalculate "constant" parameters used in the forward() and inverse() calls.

Overrides:
computeParameters in class Cylindrical

normalizeLatitude

public double normalizeLatitude(double lat)
Sets radian latitude to something sane. This is an abstract function since some projections don't deal well with extreme latitudes.

Specified by:
normalizeLatitude in class GeoProj
Parameters:
lat - float latitude in radians
Returns:
float latitude (-PI/2 <= y <= PI/2)

isPlotable

public boolean isPlotable(double lat,
                          double lon)
Checks if a LatLonPoint is plot-able.

A point is always plot-able in the Mercator projection (even the North and South poles since we normalize latitude).

Specified by:
isPlotable in interface Projection
Overrides:
isPlotable in class Proj
Parameters:
lat - double latitude in decimal degrees
lon - double longitude in decimal degrees
Returns:
boolean

forward

public java.awt.geom.Point2D forward(double lat,
                                     double lon,
                                     java.awt.geom.Point2D p,
                                     boolean isRadian)
Forward projects lat,lon into XY space and returns a Point2D.

Specified by:
forward in class GeoProj
Parameters:
lat - double latitude in radians
lon - double longitude in radians
p - Resulting XY Point2D
isRadian - bogus argument indicating that lat,lon arguments are in radians
Returns:
Point2D p

inverse

public <T extends java.awt.geom.Point2D> T inverse(double x,
                                                   double y,
                                                   T llp)
Inverse project x,y coordinates into a LatLonPoint.

Specified by:
inverse in interface Projection
Specified by:
inverse in class Proj
Parameters:
x - integer x coordinate
y - integer y coordinate
llp - LatLonPoint
Returns:
LatLonPoint llp
See Also:
Proj.inverse(Point2D)

rhumbStep

protected static final int rhumbStep(java.awt.geom.Point2D pt1,
                                     java.awt.geom.Point2D pt2)
Computes the best stepping factor for a rhumbline.

Computes the best stepping factor between two x,y points in order to interpolate points on a rhumb line. (We calculate rhumb lines by forward projecting the line in the Mercator projection, and then calculating segments along the straight line between them.)

Parameters:
pt1 - Point2D
pt2 - Point2D
Returns:
int number of points to use

rhumbProject

protected float[] rhumbProject(java.awt.geom.Point2D from,
                               java.awt.geom.Point2D to,
                               boolean include_last,
                               int nsegs)
Calculates the points along a rhumbline between two XY points.

Loxodromes are straight in the Mercator projection. Calculate a bunch of extra points between the two points, inverse project back into LatLons and return all the vertices.

Parameters:
from - Point2D
to - Point2D
include_last - include the very last point?
nsegs - number of segments
Returns:
float[] of lat, lon, lat, lon, ... in RADIANS!

rhumbProjectDouble

protected double[] rhumbProjectDouble(java.awt.geom.Point2D from,
                                      java.awt.geom.Point2D to,
                                      boolean include_last,
                                      int nsegs)
Calculates the points along a rhumbline between two XY points.

Loxodromes are straight in the Mercator projection. Calculate a bunch of extra points between the two points, inverse project back into LatLons and return all the vertices.

Parameters:
from - Point2D
to - Point2D
include_last - include the very last point?
nsegs - number of segments
Returns:
double[] of lat, lon, lat, lon, ... in RADIANS!

getName

public java.lang.String getName()
Get the name string of the projection.

Specified by:
getName in interface Projection
Overrides:
getName in class Cylindrical


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