com.bbn.openmap.proj
Class LambertConformal

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

public class LambertConformal
extends GeoProj

Implements the LambertConformalConic projection.

NOTE: This implementation only works for the northern hemisphere.

Needs to be modified for use in the southern hemisphere.

See http://www.epsg.org/guides/docs/G7-2.pdf

Author:
David J. Ward, Chris van Lith
See Also:
Serialized Form

Field Summary
static double EPS10
          A small number 10^(-10) This number can be re-factored into MoreMath
static java.lang.String LambertConformalName
          The LambertCC name.
protected  java.awt.geom.Point2D plotablePoint
           
 
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
protected LambertConformal(LatLonPoint center, float scale, int width, int height)
          Construct a Lambert projection.
  LambertConformal(LatLonPoint center, float scale, int width, int height, double centralMeridian, double sp_one, double sp_two, double reference_latitude, double falseEasting, double falseNorthing, Ellipsoid ellps)
          Constructor for the lambert conformal projection.
protected LambertConformal(LatLonPoint center, float scale, int width, int height, float centralMeridian, float sp_one, float sp_two, Ellipsoid ellps)
          Constructor for the lambert conformal projection.
 
Method Summary
protected  double _forward(double lat, double lon, java.awt.geom.Point2D p, boolean isRadian)
           
 java.util.ArrayList<float[]> _forwardPoly(double[] rawllpts, int ltype, int nsegs, boolean isFilled)
          Forward project a lat/lon Poly.
protected  java.util.ArrayList<float[]> _forwardPoly(float[] rawllpts, int ltype, int nsegs, boolean isFilled)
          Forward project a lat/lon Poly.
 void computeParameters()
          Called when some fundamental parameters change.
 void drawBackground(java.awt.Graphics g)
          Draw the background for the projection.
 void drawBackground(java.awt.Graphics2D g, java.awt.Paint paint)
          Draw the background for the projection.
 java.awt.geom.Point2D forward(double lat, double lon, java.awt.geom.Point2D p, boolean isRadian)
          Forward projects lat,lon into XY space and sets the results in the p provided.
 boolean forwardRaw(double[] rawllpts, int rawoff, float[] xcoords, float[] ycoords, boolean[] visible, int copyoff, int copylen)
          Forward project a raw array of points.
 boolean forwardRaw(float[] rawllpts, int rawoff, float[] xcoords, float[] ycoords, boolean[] visible, int copyoff, int copylen)
          Forward project a raw array of radian points.
 LatLonPoint getLowerRight()
          Get the lower right (southeast) point of the projection.
 java.lang.String getName()
          Get the name string of the projection.
 double getReferenceLon()
           
 float getScale(java.awt.geom.Point2D ll1, java.awt.geom.Point2D ll2, java.awt.geom.Point2D point1, java.awt.geom.Point2D point2)
          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.
 LatLonPoint getUpperLeft()
          Get the upper left (northwest) point 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)
          Determine if the location is plotable on the screen.
 boolean isPlotable(LatLonPoint llpoint)
          Determine if the location is plotable
static double lambMsfn(double sinphi, double cosphi, double e)
          Special function m = cos(phi) / sqrt(1.0 - (e*sin(phi))**2)
static double lambTsfn(double phi, double sinphi, double e)
          Special function t = tan(PI/4-phi/2) / pow((1-sinphi)/(1+sinphi), .5*e)
 double LLToPixel(double lat, double lon, java.awt.geom.Point2D p)
           
 java.awt.geom.Point2D LLToWorld(double lat, double lon, java.awt.geom.Point2D lp)
           
protected  double LLToWorldReturningLon(double lat, double lon, java.awt.geom.Point2D lp)
          LLToWorld that returns normalized longitude in radians, to be used for more calculations in some methods.
static void main(java.lang.String[] argv)
          test method
 double normalizeLatitude(double lat)
          Sets radian latitude to something sane.
 java.awt.geom.Point2D pixelToLL(double xabs, double yabs, java.awt.geom.Point2D llp)
           
 java.awt.geom.Point2D pixelToWorld(java.awt.Point p, java.awt.geom.Point2D lp)
           
 java.awt.geom.Point2D worldToLL(double x, double y, java.awt.geom.Point2D llp)
           
 java.awt.Point worldToPixel(java.awt.geom.Point2D lp, java.awt.Point p)
           
 
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, getUcuom, init, inverse, inverse, isComplicatedLineType, isPlotable, normalize_latitude, normalizeLatitude, pan, pan, setCenter, setCenter, setCenter, setPlanetRadius, setPPM, setUcuom, toString, wrap_longitude, wrapLongitude, wrapLongitude, wrapLongitudeDeg
 
Methods inherited from class com.bbn.openmap.proj.Proj
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

LambertConformalName

public static final transient java.lang.String LambertConformalName
The LambertCC name.

See Also:
Constant Field Values

EPS10

public static final double EPS10
A small number 10^(-10) This number can be re-factored into MoreMath

See Also:
Constant Field Values

plotablePoint

protected java.awt.geom.Point2D plotablePoint
Constructor Detail

LambertConformal

protected LambertConformal(LatLonPoint center,
                           float scale,
                           int width,
                           int height)
Construct a Lambert projection.

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

LambertConformal

protected LambertConformal(LatLonPoint center,
                           float scale,
                           int width,
                           int height,
                           float centralMeridian,
                           float sp_one,
                           float sp_two,
                           Ellipsoid ellps)
Constructor for the lambert conformal projection.

Parameters:
center - center location for projections
scale - scale of projection
width - width of projection
height - height of projection
centralMeridian - the Central Meridian in degrees.
sp_one - Standard Parallel One in degrees.
sp_two - Standard Parallel Two in degrees.

LambertConformal

public LambertConformal(LatLonPoint center,
                        float scale,
                        int width,
                        int height,
                        double centralMeridian,
                        double sp_one,
                        double sp_two,
                        double reference_latitude,
                        double falseEasting,
                        double falseNorthing,
                        Ellipsoid ellps)
Constructor for the lambert conformal projection.

Parameters:
center - center location for projections
scale - scale of projection
width - width of projection
height - height of projection
centralMeridian - the Central Meridian in degrees.
sp_one - Standard Parallel One in degrees.
sp_two - Standard Parallel Two in degrees.
reference_latitude - the latitude for the origin of the projection
falseEasting - number of meters added as buffer to origin E/W.
falseNorthing - number of meters added as buffer to origin for N/S.
ellps - the Ellipsoid used for the projection
Method Detail

computeParameters

public 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.

Specified by:
computeParameters in class Proj

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)

LLToWorld

public java.awt.geom.Point2D LLToWorld(double lat,
                                       double lon,
                                       java.awt.geom.Point2D lp)

LLToWorldReturningLon

protected double LLToWorldReturningLon(double lat,
                                       double lon,
                                       java.awt.geom.Point2D lp)
LLToWorld that returns normalized longitude in radians, to be used for more calculations in some methods. Do not provide a NULL lp here if you want the world coordinates provided back to you.

Parameters:
lat - latitude in degrees
lon - longitude in degrees.
lp - world coordinates are provided back in this object, make sure it's not null if you care about them.
Returns:
normalized longitude in radians, radians lon - radians lat.

LLToPixel

public double LLToPixel(double lat,
                        double lon,
                        java.awt.geom.Point2D p)

worldToPixel

public java.awt.Point worldToPixel(java.awt.geom.Point2D lp,
                                   java.awt.Point p)

pixelToWorld

public java.awt.geom.Point2D pixelToWorld(java.awt.Point p,
                                          java.awt.geom.Point2D lp)

worldToLL

public java.awt.geom.Point2D worldToLL(double x,
                                       double y,
                                       java.awt.geom.Point2D llp)

pixelToLL

public java.awt.geom.Point2D pixelToLL(double xabs,
                                       double yabs,
                                       java.awt.geom.Point2D llp)

isPlotable

public boolean isPlotable(double lat,
                          double lon)
Determine if the location is plotable on the screen. The Lambert Conformal projection does not lend its self to a simple determination. This method invokes forward to obtain the screen coordinates. If the screen coordinates are visible returns true otherwise returns false.

Specified by:
isPlotable in interface Projection
Overrides:
isPlotable in class Proj
Parameters:
lat - latitude in degrees
lon - longitude in degrees
Returns:
true is plotable, otherwise false

isPlotable

public boolean isPlotable(LatLonPoint llpoint)
Determine if the location is plotable

Parameters:
llpoint - location to check
Returns:
returns true is plotable, otherwise false

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 sets the results in the p provided.

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

_forward

protected double _forward(double lat,
                          double lon,
                          java.awt.geom.Point2D p,
                          boolean isRadian)

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)

getUpperLeft

public LatLonPoint getUpperLeft()
Get the upper left (northwest) point of the projection.

Returns the upper left point (or closest equivalent) of the projection based on the center point and height and width of screen.

Specified by:
getUpperLeft in interface Projection
Overrides:
getUpperLeft in class Proj
Returns:
LatLonPoint

getLowerRight

public LatLonPoint getLowerRight()
Get the lower right (southeast) point of the projection.

Returns the lower right point (or closest equivalent) of the projection based on the center point and height and width of screen.

Specified by:
getLowerRight in interface Projection
Overrides:
getLowerRight in class Proj
Returns:
LatLonPoint

getReferenceLon

public double getReferenceLon()
Overrides:
getReferenceLon in class GeoProj
Returns:
the reference longitude of the projection. For most projections, it'll just be the center point longitude. For LLC, it'll be the reference meridian.

getName

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

Specified by:
getName in interface Projection
Overrides:
getName in class Proj
Returns:
the projection name

forwardRaw

public boolean forwardRaw(float[] rawllpts,
                          int rawoff,
                          float[] xcoords,
                          float[] ycoords,
                          boolean[] visible,
                          int copyoff,
                          int copylen)
Forward project a raw array of radian points. This assumes nothing about the array of coordinates. In no way does it assume the points are connected or that the composite figure is to be filled.

It does populate a visible array indicating whether the points are visible on the projected view of the world.

Specified by:
forwardRaw in interface Projection
Overrides:
forwardRaw in class Proj
Parameters:
rawllpts - array of lat,lon,... in radians
rawoff - offset into rawllpts
xcoords - x coordinates
ycoords - y coordinates
visible - coordinates visible?
copyoff - offset into x,y,visible arrays
copylen - number of coordinates (coordinate arrays should be at least this long, rawllpts should be at least twice as long).
Returns:
boolean true if all points visible, false if some points not visible.

forwardRaw

public boolean forwardRaw(double[] rawllpts,
                          int rawoff,
                          float[] xcoords,
                          float[] ycoords,
                          boolean[] visible,
                          int copyoff,
                          int copylen)
Description copied from class: Proj
Forward project a raw array of points. This assumes nothing about the array of coordinates. In no way does it assume the points are connected or that the composite figure is to be filled.

It does populate a visible array indicating whether the points are visible on the projected view of the world.

Specified by:
forwardRaw in interface Projection
Overrides:
forwardRaw in class Proj
Parameters:
rawllpts - array of y, x world coordinates.
rawoff - offset into rawllpts.
xcoords - x projected horizontal map coordinates.
ycoords - y projected vertical map coordinates.
visible - coordinates visible?
copyoff - offset into x,y visible arrays.
copylen - number of coordinates (coordinate arrays should be at least this long, rawllpts should be at least twice as long).
Returns:
boolean true if all points visible, false if some points not visible.

_forwardPoly

protected java.util.ArrayList<float[]> _forwardPoly(float[] rawllpts,
                                                    int ltype,
                                                    int nsegs,
                                                    boolean isFilled)
Forward project a lat/lon Poly. Remember to specify vertices in radians!

Specified by:
_forwardPoly in class GeoProj
Parameters:
rawllpts - float[] of lat,lon,lat,lon,... in RADIANS!
ltype - line type (straight, rhumbline, greatcircle)
nsegs - number of segment points (only for greatcircle or rhumbline line types, and if < 1, this value is generated internally)
isFilled - filled poly? this is currently ignored for cylindrical projections.
Returns:
ArrayList float[] of x[], y[], x[], y[], ... projected poly

_forwardPoly

public java.util.ArrayList<float[]> _forwardPoly(double[] rawllpts,
                                                 int ltype,
                                                 int nsegs,
                                                 boolean isFilled)
Description copied from class: GeoProj
Forward project a lat/lon Poly. Remember to specify vertices in radians!

Specified by:
_forwardPoly in class GeoProj
Parameters:
rawllpts - double[] of lat,lon,lat,lon,... in RADIANS!
ltype - line type (straight, rhumbline, greatcircle)
nsegs - number of segment points (only for greatcircle or rhumbline line types, and if < 1, this value is generated internally)
isFilled - filled poly?
Returns:
ArrayList of x[], y[], x[], y[], ... projected poly

getScale

public float getScale(java.awt.geom.Point2D ll1,
                      java.awt.geom.Point2D ll2,
                      java.awt.geom.Point2D point1,
                      java.awt.geom.Point2D point2)
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.

Specified by:
getScale in interface Projection
Overrides:
getScale in class GeoProj
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, the upper left corner of the area of interest.
point2 - a java.awt.Point reflecting a pixel spot on the projection that matches the ll2 coordinate, usually the lower right corner of the area of interest.

drawBackground

public void drawBackground(java.awt.Graphics2D g,
                           java.awt.Paint paint)
Draw the background for the projection.

Overrides:
drawBackground in class Proj
Parameters:
g - Graphics2D
paint - java.awt.Paint to use for the background

drawBackground

public void drawBackground(java.awt.Graphics g)
Draw the background for the projection.

Overrides:
drawBackground in class Proj
Parameters:
g - Graphics

lambMsfn

public static double lambMsfn(double sinphi,
                              double cosphi,
                              double e)
Special function m = cos(phi) / sqrt(1.0 - (e*sin(phi))**2)

Parameters:
sinphi - double
cosphi - double
e - double
Returns:
double

lambTsfn

public static double lambTsfn(double phi,
                              double sinphi,
                              double e)
Special function t = tan(PI/4-phi/2) / pow((1-sinphi)/(1+sinphi), .5*e)

Parameters:
phi - double
sinphi - double
e - double
Returns:
double

main

public static void main(java.lang.String[] argv)
test method

Parameters:
argv - command line parameters


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