NASA World Wind

gov.nasa.worldwind.globes
Class FlatGlobe

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.globes.EllipsoidalGlobe
              extended by gov.nasa.worldwind.globes.FlatGlobe
All Implemented Interfaces:
AVList, MessageListener, Extent, Globe, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
EarthFlat

public class FlatGlobe
extends EllipsoidalGlobe

Defines a globe represented as a projection onto a plane. The projection type is modifiable. The default projection is Mercator. New projections may be added by extending this class and overriding geodeticToCartesian cartesianToGeodetic.

This globe uses a Cartesian coordinate system in the world plane is located at the origin and has UNIT-Z as normal. The Y axis points to the north pole. The Z axis points up. The X axis completes a right-handed coordinate system, and points east. Latitude and longitude zero are at the origin on y and x respectively. Sea level is at z = zero.


Nested Class Summary
 
Nested classes/interfaces inherited from class gov.nasa.worldwind.globes.EllipsoidalGlobe
EllipsoidalGlobe.StateKey
 
Field Summary
static String PROJECTION_LAT_LON
          Latitude/Longitude projection.
static String PROJECTION_MERCATOR
          Mercator projection.
static String PROJECTION_MODIFIED_SINUSOIDAL
           
static String PROJECTION_SINUSOIDAL
          Sinusoidal projection.
 
Fields inherited from class gov.nasa.worldwind.globes.EllipsoidalGlobe
egm96, equatorialRadius, es, polarRadius
 
Constructor Summary
FlatGlobe(double equatorialRadius, double polarRadius, double es, ElevationModel em)
          Create a new globe.
 
Method Summary
protected  Position cartesianToGeodetic(Vec4 cart)
          Compute the geographic position to corresponds to a Cartesian point.
 Vec4 computeNorthPointingTangentAtLocation(Angle latitude, Angle longitude)
          Computes a vector tangent to this globe and pointing toward the north pole.
 Vec4 computeSurfaceNormalAtLocation(Angle latitude, Angle longitude)
          Returns the normal to the Globe at the specified position.
 Vec4 computeSurfaceNormalAtPoint(Vec4 point)
          Returns the normal to the Globe at the specified cartiesian point.
 Matrix computeSurfaceOrientationAtPosition(Angle latitude, Angle longitude, double metersElevation)
          Returns the cartesian transform Matrix that maps model coordinates to a local coordinate system at (latitude, longitude, metersElevation).
 Matrix computeSurfaceOrientationAtPosition(Position position)
          Returns the cartesian transform Matrix that maps model coordinates to a local coordinate system at (latitude, longitude, metersElevation).
protected  Vec4 geodeticToCartesian(Angle latitude, Angle longitude, double metersElevation)
          Maps a position to a flat world Cartesian coordinates.
 double getElevation(Angle latitude, Angle longitude)
          Indicates the elevation at a specified location.
 GlobeStateKey getGlobeStateKey()
          Returns a typed state key identifying this globe's current configuration.
 GlobeStateKey getGlobeStateKey(DrawContext dc)
          Returns a typed state key identifying this globe's current configuration.
 String getProjection()
          Indicates the projection used to project the globe onto a plane.
 double getRadiusAt(Angle latitude, Angle longitude)
          Indicates the radius of the globe at a location.
 double getRadiusAt(LatLon latLon)
          Indicates this globe's radius at a specified location.
 Object getStateKey(DrawContext dc)
          Returns a state key identifying this globe's current configuration.
protected  Intersection[] intersect(Line line, double equRadius, double polarRadius)
           
 boolean intersects(Line line)
          Determines whether or not line intersects this Extent.
 boolean intersects(Plane plane)
          Calculate whether or not this Extent is intersected by plane.
 boolean isPointAboveElevation(Vec4 point, double elevation)
          Determines whether a point is above a given elevation
 void setProjection(String projection)
          Set the projection used to project the globe onto a plane.
 
Methods inherited from class gov.nasa.worldwind.globes.EllipsoidalGlobe
applyEGMA96Offsets, computeModelCoordinateOriginTransform, computeModelCoordinateOriginTransform, computePointFromLocation, computePointFromPosition, computePointFromPosition, computePointFromPosition, computePositionFromPoint, getCenter, getDiameter, getEccentricitySquared, getEffectiveRadius, getElevationModel, getElevations, getEquatorialRadius, getExtent, getIntersectionPosition, getMaxElevation, getMaximumRadius, getMinAndMaxElevations, getMinAndMaxElevations, getMinElevation, getPolarRadius, getProjectedArea, getRadius, getTessellator, intersect, intersect, intersect, intersects, makeElevationModel, setElevationModel, setTessellator, tessellate
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
 

Field Detail

PROJECTION_LAT_LON

public static final String PROJECTION_LAT_LON
Latitude/Longitude projection. Also known as the geographic projection, the equirectangular projection, or the Plate Carree projection.

See Also:
Constant Field Values

PROJECTION_MERCATOR

public static final String PROJECTION_MERCATOR
Mercator projection.

See Also:
Constant Field Values

PROJECTION_MODIFIED_SINUSOIDAL

public static final String PROJECTION_MODIFIED_SINUSOIDAL
See Also:
Constant Field Values

PROJECTION_SINUSOIDAL

public static final String PROJECTION_SINUSOIDAL
Sinusoidal projection.

See Also:
Constant Field Values
Constructor Detail

FlatGlobe

public FlatGlobe(double equatorialRadius,
                 double polarRadius,
                 double es,
                 ElevationModel em)
Create a new globe. The globe will use the Mercator projection. The projection can be changed using setProjection(String).

Parameters:
equatorialRadius - Radius of the globe at the equator.
polarRadius - Radius of the globe at the poles.
es - Square of the globe's eccentricity.
em - Elevation model. May be null.
Method Detail

cartesianToGeodetic

protected Position cartesianToGeodetic(Vec4 cart)
Description copied from class: EllipsoidalGlobe
Compute the geographic position to corresponds to a Cartesian point.

Overrides:
cartesianToGeodetic in class EllipsoidalGlobe
Parameters:
cart - Cartesian point to convert to geographic.
Returns:
The geographic position of cart.
See Also:
EllipsoidalGlobe.geodeticToCartesian(gov.nasa.worldwind.geom.Angle, gov.nasa.worldwind.geom.Angle, double)

computeNorthPointingTangentAtLocation

public Vec4 computeNorthPointingTangentAtLocation(Angle latitude,
                                                  Angle longitude)
Description copied from interface: Globe
Computes a vector tangent to this globe and pointing toward the north pole.

Specified by:
computeNorthPointingTangentAtLocation in interface Globe
Overrides:
computeNorthPointingTangentAtLocation in class EllipsoidalGlobe
Parameters:
latitude - Latitude of the location at which to compute the tangent vector.
longitude - Longitude of the location at which to compute the tangent vector.
Returns:
A vector tangent to this globe at (latitude, longitude), and pointing toward the north pole of this globe.

computeSurfaceNormalAtLocation

public Vec4 computeSurfaceNormalAtLocation(Angle latitude,
                                           Angle longitude)
Description copied from class: EllipsoidalGlobe
Returns the normal to the Globe at the specified position.

Specified by:
computeSurfaceNormalAtLocation in interface Globe
Overrides:
computeSurfaceNormalAtLocation in class EllipsoidalGlobe
Parameters:
latitude - the latitude of the position.
longitude - the longitude of the position.
Returns:
the Globe normal at the specified position.

computeSurfaceNormalAtPoint

public Vec4 computeSurfaceNormalAtPoint(Vec4 point)
Description copied from class: EllipsoidalGlobe
Returns the normal to the Globe at the specified cartiesian point.

Specified by:
computeSurfaceNormalAtPoint in interface Globe
Overrides:
computeSurfaceNormalAtPoint in class EllipsoidalGlobe
Parameters:
point - the cartesian point.
Returns:
the Globe normal at the specified point.

computeSurfaceOrientationAtPosition

public Matrix computeSurfaceOrientationAtPosition(Angle latitude,
                                                  Angle longitude,
                                                  double metersElevation)
Description copied from class: EllipsoidalGlobe
Returns the cartesian transform Matrix that maps model coordinates to a local coordinate system at (latitude, longitude, metersElevation). The X axis is mapped to the vector tangent to the globe and pointing East. The Y axis is mapped to the vector tangent to the Globe and pointing to the North Pole. The Z axis is mapped to the Globe normal at (latitude, longitude, metersElevation). The origin is mapped to the cartesian position of (latitude, longitude, metersElevation).

Specified by:
computeSurfaceOrientationAtPosition in interface Globe
Overrides:
computeSurfaceOrientationAtPosition in class EllipsoidalGlobe
Parameters:
latitude - the latitude of the position.
longitude - the longitude of the position.
metersElevation - the number of meters above or below mean sea level.
Returns:
the cartesian transform Matrix that maps model coordinates to the local coordinate system at the specified position.

computeSurfaceOrientationAtPosition

public Matrix computeSurfaceOrientationAtPosition(Position position)
Description copied from class: EllipsoidalGlobe
Returns the cartesian transform Matrix that maps model coordinates to a local coordinate system at (latitude, longitude, metersElevation). They X axis is mapped to the vector tangent to the globe and pointing East. The Y axis is mapped to the vector tangent to the Globe and pointing to the North Pole. The Z axis is mapped to the Globe normal at (latitude, longitude, metersElevation). The origin is mapped to the cartesian position of (latitude, longitude, metersElevation).

Specified by:
computeSurfaceOrientationAtPosition in interface Globe
Overrides:
computeSurfaceOrientationAtPosition in class EllipsoidalGlobe
Parameters:
position - the latitude, longitude, and number of meters above or below mean sea level.
Returns:
the cartesian transform Matrix that maps model coordinates to the local coordinate system at the specified position.

geodeticToCartesian

protected Vec4 geodeticToCartesian(Angle latitude,
                                   Angle longitude,
                                   double metersElevation)
Maps a position to a flat world Cartesian coordinates. The world plane is located at the origin and has UNIT-Z as normal. The Y axis points to the north pole. The Z axis points up. The X axis completes a right-handed coordinate system, and points east. Latitude and longitude zero are at the origin on y and x respectively. Sea level is at z = zero.

Overrides:
geodeticToCartesian in class EllipsoidalGlobe
Parameters:
latitude - the latitude of the position.
longitude - the longitude of the position.
metersElevation - the number of meters above or below mean sea level.
Returns:
The Cartesian point corresponding to the input position.

getElevation

public double getElevation(Angle latitude,
                           Angle longitude)
Description copied from interface: Globe
Indicates the elevation at a specified location. If the elevation at the specified location is the elevation model's missing data signal, or if the location specified is outside the elevation model's coverage area, the elevation model's missing data replacement value is returned.

The elevation returned from this method is the best available in memory. If no elevation is in memory, the elevation model's minimum extreme elevation at the location is returned. Local disk caches are not consulted.

Specified by:
getElevation in interface Globe
Overrides:
getElevation in class EllipsoidalGlobe
Parameters:
latitude - the latitude of the location at which to determine elevation.
longitude - the longitude of the location at which to determine elevation.
Returns:
The elevation corresponding to the specified location, or the elevation model's missing-data replacement value if there is no elevation for the given location. Returns zero if no elevation model is available.
See Also:
Globe.getElevationModel()

getGlobeStateKey

public GlobeStateKey getGlobeStateKey()
Description copied from interface: Globe
Returns a typed state key identifying this globe's current configuration. Can be used to subsequently determine whether the globe's configuration has changed.

Specified by:
getGlobeStateKey in interface Globe
Overrides:
getGlobeStateKey in class EllipsoidalGlobe
Returns:
a state key for the globe's current configuration.

getGlobeStateKey

public GlobeStateKey getGlobeStateKey(DrawContext dc)
Description copied from interface: Globe
Returns a typed state key identifying this globe's current configuration. Can be used to subsequently determine whether the globe's configuration has changed.

Specified by:
getGlobeStateKey in interface Globe
Overrides:
getGlobeStateKey in class EllipsoidalGlobe
Parameters:
dc - the current draw context.
Returns:
a state key for the globe's current configuration.

getProjection

public String getProjection()
Indicates the projection used to project the globe onto a plane. The default projection is Mercator.

Returns:
The active projection.
See Also:
setProjection(String)

getRadiusAt

public double getRadiusAt(Angle latitude,
                          Angle longitude)
Description copied from interface: Globe
Indicates the radius of the globe at a location.

Specified by:
getRadiusAt in interface Globe
Overrides:
getRadiusAt in class EllipsoidalGlobe
Parameters:
latitude - Latitude of the location at which to determine radius.
longitude - Longitude of the location at which to determine radius.
Returns:
The radius of the globe at the specified location, in meters.

getRadiusAt

public double getRadiusAt(LatLon latLon)
Description copied from interface: Globe
Indicates this globe's radius at a specified location.

Specified by:
getRadiusAt in interface Globe
Overrides:
getRadiusAt in class EllipsoidalGlobe
Parameters:
latLon - the location of interest.
Returns:
the globe's radius at that location.

getStateKey

public Object getStateKey(DrawContext dc)
Description copied from interface: Globe
Returns a state key identifying this globe's current configuration. Can be used to subsequently determine whether the globe's configuration has changed.

Specified by:
getStateKey in interface Globe
Overrides:
getStateKey in class EllipsoidalGlobe
Parameters:
dc - the current draw context.
Returns:
a state key for the globe's current configuration.

intersect

protected Intersection[] intersect(Line line,
                                   double equRadius,
                                   double polarRadius)
Overrides:
intersect in class EllipsoidalGlobe

intersects

public boolean intersects(Line line)
Description copied from interface: Extent
Determines whether or not line intersects this Extent. This method may be faster than checking the size of the array returned by intersect(Line). Implementing methods must ensure that this method returns true if and only if intersect(Line) returns a non-null array containing at least one element.

Specified by:
intersects in interface Extent
Overrides:
intersects in class EllipsoidalGlobe
Parameters:
line - the Line with which to test for intersection.
Returns:
true if an intersection is found, false otherwise.

intersects

public boolean intersects(Plane plane)
Description copied from interface: Extent
Calculate whether or not this Extent is intersected by plane.

Specified by:
intersects in interface Extent
Overrides:
intersects in class EllipsoidalGlobe
Parameters:
plane - the Plane with which to test for intersection.
Returns:
true if plane is found to intersect this Extent.

isPointAboveElevation

public boolean isPointAboveElevation(Vec4 point,
                                     double elevation)
Determines whether a point is above a given elevation

Specified by:
isPointAboveElevation in interface Globe
Overrides:
isPointAboveElevation in class EllipsoidalGlobe
Parameters:
point - the Vec4 point to test.
elevation - the elevation to test for.
Returns:
true if the given point is above the given elevation.

setProjection

public void setProjection(String projection)
Set the projection used to project the globe onto a plane.

Parameters:
projection - New projection. One of PROJECTION_LAT_LON, PROJECTION_MERCATOR, PROJECTION_SINUSOIDAL, or PROJECTION_MODIFIED_SINUSOIDAL.

NASA World Wind