ecologylab.projection
Class Projection

java.lang.Object
  extended by ecologylab.generic.Debug
      extended by ecologylab.projection.Projection
Direct Known Subclasses:
PlateCarreeProjection

public abstract class Projection
extends Debug

Using two GPSDatum objects, demarking two corners of real-world space, provides functionality to map real-world coordinates to another (virtual) set of coordinates within a rectangle specified by its size. The center of the virtual world is considered to be at the center of the two specified points. The angle at which it is laid out depends on the projection mode. CARDINAL_DIRECTIONS mode CARDINAL_DIRECTIONS mode aligns the virtual world with the cardinal directions of the compass. It's height dimension specifies its N/S length and its width dimension specifies its E/W length. In this mode, the two real world coordinates are used to create a bounding box which contains the virtual world and scales it depending upon its aspect ratio, so that it is always contained by the bounding box. ANCHOR_POINTS mode ANCHOR_POINTS mode rotates the virtual world, so that the midpoints of its top and bottom verticies are anchored to the two specified GPS coordinates. A projection's virtual world scale may be specified in one of two ways: CONSTANT_SCALE_FACTOR mode In this mode, a constant factor is used to scale the virtual world to the real world, specified as the ratio of points (virtual space) : some real world measure (real space). In this mode, the size of the virtual world changes depending on the specified real world space. The real-world measure must be specified by subclasses. It may be degrees of latitude/longitude, real world distance, etc. CONSTANT_SIZE mode In this mode, the virtual world is held at a constant, specified size (width/height) and the scale between it and the real world changes, depending on the other specifications.

Author:
Zachary O. Toups (toupsz@cs.tamu.edu)

Nested Class Summary
static class Projection.RotationConstraintMode
           
static class Projection.ScaleConstraintMode
           
 
Field Summary
protected  double aspectRatio
           
protected  GPSDatum physicalWorldPointNE
          The normalized northwest-most physical world point for this mapping; supplied coordinates will automatically be transformed to match this specification; that is, if the points are essentially NE and SW, then this point will be computed using the north-most and west-most components of those two coordinates.
protected  GPSDatum physicalWorldPointSW
          The normalized southest-most physical world point for this mapping; supplied coordinates will automatically be transformed to match this specification; that is, if the points are essentially NE and SW, then this point will be computed using the south-most and east-most components of those two coordinates.
protected  double realWorldHeight
           
protected  double realWorldWidth
           
protected  Projection.RotationConstraintMode rotConstMode
           
protected  Projection.ScaleConstraintMode scaleConstMode
           
protected  GPSDatum specedPWP1
           
protected  GPSDatum specedPWP2
           
protected  double virtualWorldHeight
           
protected  double virtualWorldWidth
           
 
Constructor Summary
protected Projection(GPSDatum physicalWorldPoint1, GPSDatum physicalWorldPoint2, double virtualWorldWidth, double virtualWorldHeight, double scaleFactor, Projection.RotationConstraintMode rotConstMode, Projection.ScaleConstraintMode scaleConstMode)
          Catch-all constructor that is called by all the other constructors.
  Projection(GPSDatum physicalWorldPoint1, GPSDatum physicalWorldPoint2, double virtualWorldWidth, double virtualWorldHeight, Projection.RotationConstraintMode rotConstMode)
          Constructs a new Projection using the specified rotation constraint mode and using constant size scale mode.
  Projection(GPSDatum physicalWorldPoint1, GPSDatum physicalWorldPoint2, double scaleFactor, Projection.RotationConstraintMode rotConstMode)
           
 
Method Summary
protected abstract  void configure()
          Adjusts internal variables to match the modes, based on the current parameters.
 GPSDatum getPhysicalWorldPointNE()
           
 GPSDatum getPhysicalWorldPointSW()
           
abstract  double getScale()
          Compute (if necessary) the scale factor between virtual world and real world units.
 double getVirtualWorldHeight()
           
 double getVirtualWorldWidth()
           
 GPSDatum projectIntoReal(java.awt.geom.Point2D.Double origPoint)
           
 GPSDatum projectIntoReal(java.awt.geom.Point2D.Double origPoint, GPSDatum destDatum)
           
protected abstract  GPSDatum projectIntoRealImpl(java.awt.geom.Point2D.Double destPoint, GPSDatum destDatum)
          This method does the real work of projectIntoReal; all calls to it are guaranteed to pass an instantiated GPSDatum object.
 java.awt.geom.Point2D.Double projectIntoVirtual(GPSDatum origDatum)
          Projects the given GPSDatum's coordinates into the virtual space, using some type of projection.
 java.awt.geom.Point2D.Double projectIntoVirtual(GPSDatum origDatum, java.awt.geom.Point2D.Double destPoint)
          Projects the given GPSDatum's coordinates into the virtual space, using some type of projection.
protected abstract  java.awt.geom.Point2D.Double projectIntoVirtualImpl(GPSDatum origDatum, java.awt.geom.Point2D.Double destPoint)
          This method does the real work of projectIntoVirtual; all calls to it are guaranteed to pass an instantiated Point2D.Double object.
 void setPhysicalWorldCoordinates(GPSDatum physicalWorldPoint1, GPSDatum physicalWorldPoint2)
           
protected  void setPhysicalWorldCoordinatesOnly(GPSDatum physicalWorldPoint1, GPSDatum physicalWorldPoint2)
           
 void setRotConstMode(Projection.RotationConstraintMode rotConstMode)
           
protected  void setRotConstModeOnly(Projection.RotationConstraintMode rotConstMode)
           
 void setScaleConstMode(Projection.ScaleConstraintMode scaleConstMode)
           
protected  void setScaleConstModeOnly(Projection.ScaleConstraintMode scaleConstMode)
           
 void setVirtualWorldPoints(double virtualWorldWidth, double virtualWorldHeight)
           
protected  void setVirtualWorldSizeOnly(double virtualWorldWidth, double virtualWorldHeight)
           
 
Methods inherited from class ecologylab.generic.Debug
classSimpleName, closeLoggingFile, debug, debug, debug, debug, debugA, debugA, debugA, debugI, debugI, debugI, error, error, getClassName, getClassName, getInteractive, getPackageName, getPackageName, getPackageName, initialize, level, level, level, logToFile, print, print, println, println, println, println, println, println, printlnA, printlnA, printlnA, printlnI, printlnI, printlnI, printlnI, setLoggingFile, show, show, superString, toggleInteractive, toString, toString, warning, warning, weird, weird
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

physicalWorldPointNE

protected GPSDatum physicalWorldPointNE
The normalized northwest-most physical world point for this mapping; supplied coordinates will automatically be transformed to match this specification; that is, if the points are essentially NE and SW, then this point will be computed using the north-most and west-most components of those two coordinates.


physicalWorldPointSW

protected GPSDatum physicalWorldPointSW
The normalized southest-most physical world point for this mapping; supplied coordinates will automatically be transformed to match this specification; that is, if the points are essentially NE and SW, then this point will be computed using the south-most and east-most components of those two coordinates.


specedPWP1

protected GPSDatum specedPWP1

specedPWP2

protected GPSDatum specedPWP2

rotConstMode

protected Projection.RotationConstraintMode rotConstMode

scaleConstMode

protected Projection.ScaleConstraintMode scaleConstMode

virtualWorldWidth

protected double virtualWorldWidth

virtualWorldHeight

protected double virtualWorldHeight

realWorldWidth

protected double realWorldWidth

realWorldHeight

protected double realWorldHeight

aspectRatio

protected double aspectRatio
Constructor Detail

Projection

public Projection(GPSDatum physicalWorldPoint1,
                  GPSDatum physicalWorldPoint2,
                  double virtualWorldWidth,
                  double virtualWorldHeight,
                  Projection.RotationConstraintMode rotConstMode)
           throws SameCoordinatesException
Constructs a new Projection using the specified rotation constraint mode and using constant size scale mode.

Parameters:
physicalWorldPoint1 -
physicalWorldPoint2 -
virtualWorldWidth -
virtualWorldHeight -
rotConstMode -
Throws:
SameCoordinatesException

Projection

public Projection(GPSDatum physicalWorldPoint1,
                  GPSDatum physicalWorldPoint2,
                  double scaleFactor,
                  Projection.RotationConstraintMode rotConstMode)
           throws SameCoordinatesException
Throws:
SameCoordinatesException

Projection

protected Projection(GPSDatum physicalWorldPoint1,
                     GPSDatum physicalWorldPoint2,
                     double virtualWorldWidth,
                     double virtualWorldHeight,
                     double scaleFactor,
                     Projection.RotationConstraintMode rotConstMode,
                     Projection.ScaleConstraintMode scaleConstMode)
              throws SameCoordinatesException
Catch-all constructor that is called by all the other constructors.

Parameters:
physicalWorldPoint1 -
physicalWorldPoint2 -
virtualWorldWidth -
virtualWorldHeight -
scaleFactor -
rotConstMode -
scaleConstMode -
Throws:
SameCoordinatesException
Method Detail

getPhysicalWorldPointNE

public GPSDatum getPhysicalWorldPointNE()
Returns:
the physicalWorldPointNE

getPhysicalWorldPointSW

public GPSDatum getPhysicalWorldPointSW()
Returns:
the physicalWorldPointSW

getScale

public abstract double getScale()
Compute (if necessary) the scale factor between virtual world and real world units. Should be virtual points : real world measure. The real world measure is dependent on the subclass.

Returns:
the scale factor between the virtual world and the real world.

getVirtualWorldHeight

public double getVirtualWorldHeight()
Returns:
the virtualWorldHeight

getVirtualWorldWidth

public double getVirtualWorldWidth()
Returns:
the virtualWorldWidth

projectIntoReal

public final GPSDatum projectIntoReal(java.awt.geom.Point2D.Double origPoint)

projectIntoReal

public final GPSDatum projectIntoReal(java.awt.geom.Point2D.Double origPoint,
                                      GPSDatum destDatum)

projectIntoVirtual

public final java.awt.geom.Point2D.Double projectIntoVirtual(GPSDatum origDatum)
Projects the given GPSDatum's coordinates into the virtual space, using some type of projection. Subclasses may override this method, if they are not making affine transformations.

Parameters:
origDatum -
Returns:
a new Point2D.Double containing the virtual space point for origPoint.

projectIntoVirtual

public final java.awt.geom.Point2D.Double projectIntoVirtual(GPSDatum origDatum,
                                                             java.awt.geom.Point2D.Double destPoint)
Projects the given GPSDatum's coordinates into the virtual space, using some type of projection. This version takes an instantiated Point2D, so as not to expend resources instantating a new one. Subclasses may override this method, if they are not making affine transformations.

Parameters:
origDatum -
destPoint -
Returns:
destPoint containing the virtual space point for origPoint.

setPhysicalWorldCoordinates

public final void setPhysicalWorldCoordinates(GPSDatum physicalWorldPoint1,
                                              GPSDatum physicalWorldPoint2)
                                       throws SameCoordinatesException
Parameters:
physicalWorldPoint1 -
physicalWorldPoint2 -
Throws:
SameCoordinatesException

setRotConstMode

public final void setRotConstMode(Projection.RotationConstraintMode rotConstMode)
Parameters:
rotConstMode -

setScaleConstMode

public final void setScaleConstMode(Projection.ScaleConstraintMode scaleConstMode)
Parameters:
scaleConstMode - the scaleConstMode to set

setVirtualWorldPoints

public final void setVirtualWorldPoints(double virtualWorldWidth,
                                        double virtualWorldHeight)
                                 throws SameCoordinatesException
Parameters:
virtualWorldPointUpperLeft -
virtualWorldPointLowerRight -
Throws:
SameCoordinatesException

configure

protected abstract void configure()
Adjusts internal variables to match the modes, based on the current parameters. This method should be called whenever any parameters are changed. This method is automatically called by the public setter methods.


projectIntoRealImpl

protected abstract GPSDatum projectIntoRealImpl(java.awt.geom.Point2D.Double destPoint,
                                                GPSDatum destDatum)
This method does the real work of projectIntoReal; all calls to it are guaranteed to pass an instantiated GPSDatum object.

Parameters:
destPoint -
destDatum -
Returns:

projectIntoVirtualImpl

protected abstract java.awt.geom.Point2D.Double projectIntoVirtualImpl(GPSDatum origDatum,
                                                                       java.awt.geom.Point2D.Double destPoint)
This method does the real work of projectIntoVirtual; all calls to it are guaranteed to pass an instantiated Point2D.Double object.

Parameters:
origDatum -
destPoint -
Returns:

setPhysicalWorldCoordinatesOnly

protected void setPhysicalWorldCoordinatesOnly(GPSDatum physicalWorldPoint1,
                                               GPSDatum physicalWorldPoint2)
                                        throws SameCoordinatesException
Parameters:
physicalWorldPoint1 -
physicalWorldPoint2 -
Throws:
SameCoordinatesException

setRotConstModeOnly

protected void setRotConstModeOnly(Projection.RotationConstraintMode rotConstMode)
Parameters:
rotConstMode -

setScaleConstModeOnly

protected void setScaleConstModeOnly(Projection.ScaleConstraintMode scaleConstMode)
Parameters:
scaleConstMode -

setVirtualWorldSizeOnly

protected void setVirtualWorldSizeOnly(double virtualWorldWidth,
                                       double virtualWorldHeight)
                                throws SameCoordinatesException
Parameters:
virtualWorldPointUpperLeft -
virtualWorldPointLowerRight -
Throws:
SameCoordinatesException