com.bbn.openmap.proj
Class AspectRatioProjection

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

public class AspectRatioProjection
extends GeoProj

A Projection that wraps another projection, but stretch the image to another aspect ratio.

The motivation for this projection is to support the following clause in wms 1.1.1.

OGC 01-068r3 (wms 1.1.1) 7.2.3.8. "In the case where the aspect ratio of the BBOX and the ratio width/height are different, the WMS shall stretch the returned map so that the resulting pixels could themselves be rendered in the aspect ratio of the BBOX"

Author:
halset
See Also:
Serialized Form

Field Summary
 
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
AspectRatioProjection(GeoProj proj, int w, int h)
          Constructor that takes a projection and the new width/height.
 
Method Summary
protected  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.
protected  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 p)
          Draw the background for the projection.
 java.awt.geom.Point2D forward(double lat, double lon, java.awt.geom.Point2D pt)
          Project the point into view space.
 java.awt.geom.Point2D forward(double lat, double lon, java.awt.geom.Point2D pt, boolean isRadian)
          Project the point into view space.
 java.awt.geom.Point2D forward(java.awt.geom.Point2D llp, java.awt.geom.Point2D pt)
          Forward project a point.
 boolean forwardRaw(float[] rawllpts, int rawoff, float[] xcoords, float[] ycoords, boolean[] visible, int copyoff, int copylen)
          Forward project a raw array of points.
 java.awt.geom.Point2D getLowerRight()
          Get the world coordinate of the lower right corner of the map.
 java.awt.geom.Point2D getUpperLeft()
          Get the world coordinate of the upper left corner of the map.
 java.awt.geom.Point2D inverse(double x, double y, java.awt.geom.Point2D llpt)
          Inverse project x,y coordinates into world coordinates.
 java.awt.geom.Point2D inverse(java.awt.geom.Point2D point, java.awt.geom.Point2D llpt)
          Inverse project a Point2D from map x/y space into world coordinates.
 boolean isPlotable(double lat, double lon)
          Checks if a location is plot-able.
 double normalizeLatitude(double lat)
           
 
Methods inherited from class com.bbn.openmap.proj.GeoProj
assertLatLonPoint, clone, doPolyDispatch, doPolyDispatch, 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, 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, forwardRaw, forwardRect, forwardShape, getHeight, getMaxScale, getMinScale, getName, getProjectionID, getRotationAngle, getScale, getWidth, hashCode, 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
 

Constructor Detail

AspectRatioProjection

public AspectRatioProjection(GeoProj proj,
                             int w,
                             int h)
Constructor that takes a projection and the new width/height.

Parameters:
proj - a projection to wrap
w - a int with the new width
h - a int with the new height
Method Detail

_forwardPoly

protected java.util.ArrayList<float[]> _forwardPoly(float[] 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 - 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?
Returns:
ArrayList of x[], y[], x[], y[], ... projected poly

computeParameters

protected void computeParameters()
Description copied from class: Proj
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

drawBackground

public void drawBackground(java.awt.Graphics2D g,
                           java.awt.Paint p)
Description copied from class: Proj
Draw the background for the projection.

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

drawBackground

public void drawBackground(java.awt.Graphics g)
Description copied from class: Proj
Draw the background for the projection. Assume that the Graphics has been set with the Paint/Color needed, just render the shape of the background.

Overrides:
drawBackground in class Proj
Parameters:
g - Graphics

normalizeLatitude

public double normalizeLatitude(double lat)
Specified by:
normalizeLatitude in class GeoProj

forward

public java.awt.geom.Point2D forward(java.awt.geom.Point2D llp,
                                     java.awt.geom.Point2D pt)
Description copied from class: GeoProj
Forward project a point.

Specified by:
forward in interface Projection
Overrides:
forward in class GeoProj
Parameters:
llp - LatLonPoint to be projected
pt - Resulting XY Point2D
Returns:
Point2D pt

forward

public java.awt.geom.Point2D forward(double lat,
                                     double lon,
                                     java.awt.geom.Point2D pt)
Description copied from class: GeoProj
Project the point into view space.

Specified by:
forward in interface Projection
Overrides:
forward in class GeoProj
Parameters:
lat - latitude in decimal degrees.
lon - longitue in decimal degrees.
pt - A Point2D object to load the result into, a new Point2D object will be created if this is null.
Returns:
Point2D The Point2D object provided (for convenience) or created with the result.

forwardRaw

public boolean forwardRaw(float[] 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.

getLowerRight

public java.awt.geom.Point2D getLowerRight()
Description copied from class: Proj
Get the world coordinate of the lower right corner of the map.

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

getUpperLeft

public java.awt.geom.Point2D getUpperLeft()
Description copied from class: Proj
Get the world coordinate of the upper left corner of the map.

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

inverse

public java.awt.geom.Point2D inverse(java.awt.geom.Point2D point,
                                     java.awt.geom.Point2D llpt)
Description copied from interface: Projection
Inverse project a Point2D from map x/y space into world coordinates.

Specified by:
inverse in interface Projection
Overrides:
inverse in class Proj
Parameters:
point - XY Point2D
llpt - resulting Point2D object to load the result into, a new Point2D object will be created if this is null.
Returns:
Point2D Object containing result.

_forwardPoly

protected 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

forward

public java.awt.geom.Point2D forward(double lat,
                                     double lon,
                                     java.awt.geom.Point2D pt,
                                     boolean isRadian)
Description copied from class: GeoProj
Project the point into view space.

Specified by:
forward in class GeoProj
Parameters:
lat - latitude
lon - longitude
pt - return point
isRadian - true if lat/lon are radians instead of decimal degrees
Returns:
Point2D for projected point

inverse

public java.awt.geom.Point2D inverse(double x,
                                     double y,
                                     java.awt.geom.Point2D llpt)
Description copied from interface: Projection
Inverse project x,y coordinates into world coordinates.

Specified by:
inverse in interface Projection
Specified by:
inverse in class Proj
Parameters:
x - integer x coordinate
y - integer y coordinate
llpt - Point2D to be loaded with the result. A new Point2D object will be created if this is null.
Returns:
Point2D llpt
See Also:
Proj.inverse(Point2D)

isPlotable

public boolean isPlotable(double lat,
                          double lon)
Description copied from interface: Projection
Checks if a location is plot-able.

Call this to check and see if a location can be plotted. This is meant to be used for checking before projecting and rendering Point2D objects (bitmaps or text objects tacked at a location, for instance).

Specified by:
isPlotable in interface Projection
Overrides:
isPlotable in class Proj
Parameters:
lat - vertical location component (units depend on the projection implementation).
lon - horizontal location component (units depend on the projection implementation).
Returns:
boolean true of plotable.


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