com.bbn.openmap.proj
Class Cylindrical

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

public abstract class Cylindrical
extends GeoProj

Base of all cylindrical projections.

See Also:
Projection, Proj, Mercator, CADRG, Serialized Form

Field Summary
protected  int half_world
           
protected  java.awt.Point 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
Cylindrical(LatLonPoint center, float scale, int width, int height)
          Construct a cylindrical projection.
 
Method Summary
protected  java.util.ArrayList<float[]> _forwardPoly(double[] rawllpts, int ltype, int nsegs, boolean isFilled)
          Forward project a raw float[] Poly.
protected  java.util.ArrayList<float[]> _forwardPoly(float[] rawllpts, int ltype, int nsegs, boolean isFilled)
          Forward project a raw float[] Poly.
protected  void computeParameters()
          Called when some fundamental parameters change.
static void dumpPoly(double[] rawllpts, float[] xs, float[] ys)
           
static void dumpPoly(float[] rawllpts, float[] xs, float[] ys)
           
 boolean forwardRaw(double[] rawllpts, int rawoff, float[] xcoords, float[] ycoords, boolean[] visible, int copyoff, int copylen)
          Forward project a raw array of radian 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.
 LatLonPoint getUpperLeft()
          Get the upper left (northwest) point of the projection.
protected  void init()
          Called after the center and scale is set in setParams, but before the scale is checked for legitimacy.
 java.lang.String toString()
          Return string-ified description of this projection.
 
Methods inherited from class com.bbn.openmap.proj.GeoProj
assertLatLonPoint, clone, doPolyDispatch, doPolyDispatch, forward, 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, 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, inverse, inverseShape, isPlotable, 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

world

protected transient java.awt.Point world

half_world

protected transient int half_world
Constructor Detail

Cylindrical

public Cylindrical(LatLonPoint center,
                   float scale,
                   int width,
                   int height)
Construct a cylindrical 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 string-ified description of this projection.

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

init

protected void init()
Description copied from class: Proj
Called after the center and scale is set in setParams, but before the scale is checked for legitimacy. This is an opportunity to set constants in subclasses before anything else gets called or checked for validity. This is different than computeParameters() which is called after some checks. This is a good time to pre-calculate constants and set maxscale and minscale.

Make sure you call super.init() if you override this method.

Overrides:
init in class GeoProj

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.

Specified by:
computeParameters in class Proj

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

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

_forwardPoly

protected java.util.ArrayList<float[]> _forwardPoly(float[] rawllpts,
                                                    int ltype,
                                                    int nsegs,
                                                    boolean isFilled)
Forward project a raw float[] Poly.

Implementation:
For the cylindrical "boxy" family of projections, we project all the points, and check the horizontal (longitudinal) spacing between vertices as we go. If the spacing is greater than half the world width (circumference) in pixels, we assume that the segment has wrapped off one edge of the screen and back onto the other side. (NOTE that our restrictions on line segments mentioned in the Projection interface do not allow for lines >= 180 degrees of arc or for the difference in longitude between two points to be >= 180 degrees of arc).

For the case where a segment wraps offscreen, we keep track of the wrapping adjustment factor, and shift the points as we go. After projecting and shifting all the points, we have a single continuous x-y polygon. We then need to make shifted copies of this polygon for the maxima and minima wrap values calculated during the projection process. This allows us to see the discontinuous (wrapped) sections on the screen when they are drawn.

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 segments between vertices (or if < 0, generate this value internally)
isFilled - filled poly? this is currently ignored for cylindrical projections.
Returns:
ArrayList of x[], y[], x[], y[], ... the projected poly

_forwardPoly

protected java.util.ArrayList<float[]> _forwardPoly(double[] rawllpts,
                                                    int ltype,
                                                    int nsegs,
                                                    boolean isFilled)
Forward project a raw float[] Poly.

Implementation:
For the cylindrical "boxy" family of projections, we project all the points, and check the horizontal (longitudinal) spacing between vertices as we go. If the spacing is greater than half the world width (circumference) in pixels, we assume that the segment has wrapped off one edge of the screen and back onto the other side. (NOTE that our restrictions on line segments mentioned in the Projection interface do not allow for lines >= 180 degrees of arc or for the difference in longitude between two points to be >= 180 degrees of arc).

For the case where a segment wraps offscreen, we keep track of the wrapping adjustment factor, and shift the points as we go. After projecting and shifting all the points, we have a single continuous x-y polygon. We then need to make shifted copies of this polygon for the maxima and minima wrap values calculated during the projection process. This allows us to see the discontinuous (wrapped) sections on the screen when they are drawn.

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 segments between vertices (or if < 0, generate this value internally)
isFilled - filled poly? this is currently ignored for cylindrical projections.
Returns:
ArrayList of x[], y[], x[], y[], ... the projected poly

dumpPoly

public static final void dumpPoly(float[] rawllpts,
                                  float[] xs,
                                  float[] ys)

dumpPoly

public static final void dumpPoly(double[] rawllpts,
                                  float[] xs,
                                  float[] ys)

getName

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

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


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