com.bbn.openmap.proj
Class Mercator

java.lang.Object
  extended bycom.bbn.openmap.proj.Proj
      extended bycom.bbn.openmap.proj.Cylindrical
          extended bycom.bbn.openmap.proj.Mercator
All Implemented Interfaces:
java.lang.Cloneable, Projection, java.io.Serializable
Direct Known Subclasses:
MercatorView

public class Mercator
extends Cylindrical

Implements the Mercator projection.

See Also:
Serialized Form

Field Summary
protected  float asinh_of_tanCtrLat
           
protected static float epsilon
           
protected  int hy
           
protected static int MAX_RHUMB_SEGS
           
static java.lang.String MercatorName
          The Mercator name.
static int MercatorType
          The Mercator type of projection.
protected  float tanCtrLat
           
protected  int wx
           
 
Fields inherited from class com.bbn.openmap.proj.Cylindrical
half_world, world
 
Fields inherited from class com.bbn.openmap.proj.Proj
ctrLat, ctrLon, DATELINE, height, maxscale, mercator, MIN_HEIGHT, MIN_WIDTH, minscale, NORTH_POLE, NUM_DEFAULT_CIRCLE_VERTS, NUM_DEFAULT_GREAT_SEGS, pixelsPerMeter, planetPixelCircumference, planetPixelRadius, planetRadius, projID, scale, scaled_radius, SOUTH_POLE, type, width, XSCALE_THRESHOLD, XTHRESHOLD
 
Constructor Summary
Mercator(LatLonPoint center, float scale, int width, int height)
          Construct a Mercator projection.
Mercator(LatLonPoint center, float scale, int width, int height, int type)
           
 
Method Summary
protected  void computeParameters()
          Called when some fundamental parameters change.
 java.awt.Point forward(float lat, float lon, java.awt.Point p)
          Forward projects a lat,lon coordinates.
 java.awt.Point forward(float lat, float lon, java.awt.Point p, boolean isRadian)
          Forward projects lat,lon into XY space and returns a Point.
 java.awt.Point forward(LatLonPoint pt, java.awt.Point p)
          Projects a point from Lat/Lon space to X/Y space.
 java.lang.String getName()
          Get the name string of the projection.
 LatLonPoint inverse(int x, int y, LatLonPoint llp)
          Inverse project x,y coordinates into a LatLonPoint.
 LatLonPoint inverse(java.awt.Point pt, LatLonPoint llp)
          Inverse project a Point.
 boolean isPlotable(float lat, float lon)
          Checks if a LatLonPoint is plot-able.
 float normalize_latitude(float lat)
          Sets radian latitude to something sane.
protected  float[] rhumbProject(java.awt.Point from, java.awt.Point to, boolean include_last, int nsegs)
          Calculates the points along a rhumbline between two XY points.
protected static int rhumbStep(java.awt.Point pt1, java.awt.Point 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, drawBackground, drawBackground, dumpPoly, forwardRaw, getLowerRight, getUpperLeft, pan
 
Methods inherited from class com.bbn.openmap.proj.Proj
clone, doPolyDispatch, equals, forward, forward, forwardArc, forwardArc, forwardArc, forwardCircle, forwardCircle, forwardCircle, forwardGreatPoly, forwardLine, forwardLine, forwardPoly, forwardPoly, forwardRaster, forwardRect, forwardRect, forwardRect, forwardRhumbPoly, getCenter, getHeight, getMaxScale, getMinScale, getPlanetPixelCircumference, getPlanetPixelRadius, getPlanetRadius, getPPM, getProjectionID, getProjectionType, getScale, getScale, getWidth, hashCode, init, inverse, inverse, isComplicatedLineType, isPlotable, makeClone, pan, panE, panE, panN, panN, panNE, panNE, panNW, panNW, panS, panS, panSE, panSE, panSW, panSW, panW, panW, setCenter, setCenter, setHeight, setMaxScale, setMinScale, setParms, setPlanetRadius, setPPM, setProjectionID, setScale, setWidth, wrap_longitude
 
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

MercatorType

public static final transient int MercatorType
The Mercator type of projection.

See Also:
Constant Field Values

MAX_RHUMB_SEGS

protected static int MAX_RHUMB_SEGS

epsilon

protected static float epsilon

hy

protected int hy

wx

protected int wx

tanCtrLat

protected float tanCtrLat

asinh_of_tanCtrLat

protected float 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

Mercator

public Mercator(LatLonPoint center,
                float scale,
                int width,
                int height,
                int type)
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" paramters used in the forward() and inverse() calls.

Overrides:
computeParameters in class Cylindrical

normalize_latitude

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

Specified by:
normalize_latitude in class Proj
Parameters:
lat - float latitude in radians
Returns:
float latitude (-PI/2 <= y <= PI/2)
See Also:
LatLonPoint.normalize_latitude(float)

isPlotable

public boolean isPlotable(float lat,
                          float 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).

Parameters:
lat - float latitude in decimal degrees
lon - float longitude in decimal degrees
Returns:
boolean

forward

public java.awt.Point forward(LatLonPoint pt,
                              java.awt.Point p)
Projects a point from Lat/Lon space to X/Y space.

Parameters:
pt - LatLonPoint
p - Point retval
Returns:
Point p

forward

public java.awt.Point forward(float lat,
                              float lon,
                              java.awt.Point p)
Forward projects a lat,lon coordinates.

Parameters:
lat - raw latitude in decimal degrees
lon - raw longitude in decimal degrees
p - Resulting XY Point
Returns:
Point p

forward

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

Parameters:
lat - float latitude in radians
lon - float longitude in radians
p - Resulting XY Point
isRadian - bogus argument indicating that lat,lon arguments are in radians
Returns:
Point p
See Also:
Projection.forward(float,float,Point)

inverse

public LatLonPoint inverse(java.awt.Point pt,
                           LatLonPoint llp)
Inverse project a Point.

Parameters:
pt - x,y Point
llp - resulting LatLonPoint
Returns:
LatLonPoint llp

inverse

public LatLonPoint inverse(int x,
                           int y,
                           LatLonPoint llp)
Inverse project x,y coordinates into a LatLonPoint.

Parameters:
x - integer x coordinate
y - integer y coordinate
llp - LatLonPoint
Returns:
LatLonPoint llp
See Also:
Proj.inverse(Point)

rhumbStep

protected static final int rhumbStep(java.awt.Point pt1,
                                     java.awt.Point 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 - Point
pt2 - Point
Returns:
int number of points to use

rhumbProject

protected float[] rhumbProject(java.awt.Point from,
                               java.awt.Point 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 - Point
to - Point
include_last - include the very last point?
nsegs - number of segments
Returns:
float[] 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