NASA World Wind

gov.nasa.worldwind.geom
Class Sector

java.lang.Object
  extended by gov.nasa.worldwind.geom.Sector
All Implemented Interfaces:
Cacheable, Comparable<Sector>

public class Sector
extends Object
implements Cacheable, Comparable<Sector>

Sector represents a rectangular reqion of latitude and longitude. The region is defined by four angles: its minimum and maximum latitude, its minimum and maximum longitude. The angles are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude. The minimums and maximums are relative to these ranges, e.g., -80 is less than 20. Behavior of the class is undefined for angles outside these ranges. Normalization is not performed on the angles by this class, nor is it verifed by the class' methods. See Angle for a description of specifying angles.

Sector instances are immutable.

See Also:
Angle

Field Summary
static Sector EMPTY_SECTOR
           
static Sector FULL_SPHERE
          A Sector of latitude [-90 degrees, + 90 degrees] and longitude [-180 degrees, + 180 degrees].
 
Constructor Summary
Sector(Angle minLatitude, Angle maxLatitude, Angle minLongitude, Angle maxLongitude)
          Creates a new Sector and initializes it to the specified angles.
Sector(Sector sector)
           
 
Method Summary
static Sector boundingSector(Iterator<TrackPoint> positions)
           
static Sector boundingSector(Position pA, Position pB)
           
static Sector boundingSectorfromLatLons(Iterable<LatLon> positions)
           
static Sector boundingSectorfromPositions(Iterable<Position> positions)
           
 int compareTo(Sector that)
          Compares this sector to a specified sector according to their minimum latitude, minimum longitude, maximum latitude, and maximum longitude, respectively.
static Extent computeBoundingSphere(Globe globe, double verticalExaggeration, Sector sector)
          Returns a sphere that minimally surrounds the sector at a specified vertical exaggeration.
 Vec4 computeCenterPoint(Globe globe)
           
 Vec4[] computeCornerPoints(Globe globe)
           
 boolean contains(Angle latitude, Angle longitude)
           
 boolean contains(LatLon latLon)
          Determines whether a latitude/longitude position is within the sector.
 boolean containsDegrees(double degreesLatitude, double degreesLongitude)
           
 boolean containsRadians(double radiansLatitude, double radiansLongitude)
          Determines whether a latitude/longitude postion expressed in radians is within the sector.
 boolean equals(Object o)
          Tests the equality of the sectors' angles.
static Sector fromDegrees(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
          Creates a new Sector and initializes it to the specified angles.
static Sector fromRadians(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
          Creates a new Sector and initializes it to the specified angles.
 LatLon getCentroid()
          Returns the latitude and longitude of the sector's angular center: (minimum latitude + maximum latitude) / 2, (minimum longitude + maximum longitude) / 2.
 Angle getDeltaLat()
          Returns the angular difference between the sector's minimum and maximum latitudes: max - min
 double getDeltaLatDegrees()
           
 double getDeltaLatRadians()
           
 Angle getDeltaLon()
          Returns the angular difference between the sector's minimum and maximum longitudes: max - min.
 double getDeltaLonDegrees()
           
 double getDeltaLonRadians()
           
 Angle getMaxLatitude()
          Returns the sector's maximum latitude.
 Angle getMaxLongitude()
          Returns the sector's maximum longitude.
 Angle getMinLatitude()
          Returns the sector's minimum latitude.
 Angle getMinLongitude()
          Returns the sector's minimum longitude.
 long getSizeInBytes()
          Retrieve the size of this object in bytes.
 int hashCode()
          Computes a hash code from the sector's four angles.
 Sector intersection(Angle latitude, Angle longitude)
           
 Sector intersection(Sector that)
           
 boolean intersects(Sector that)
          Determines whether this sector intersects another sector's range of latitude and longitude.
 Sector[] subdivide()
           
 String toString()
          Returns a string indicating the sector's angles.
 Sector union(Angle latitude, Angle longitude)
           
 Sector union(Sector that)
          Returns a new sector whose angles are the extremes of the this sector and another.
static Sector union(Sector sectorA, Sector sectorB)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_SECTOR

public static final Sector EMPTY_SECTOR

FULL_SPHERE

public static final Sector FULL_SPHERE
A Sector of latitude [-90 degrees, + 90 degrees] and longitude [-180 degrees, + 180 degrees].

Constructor Detail

Sector

public Sector(Angle minLatitude,
              Angle maxLatitude,
              Angle minLongitude,
              Angle maxLongitude)
Creates a new Sector and initializes it to the specified angles. The angles are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude, but this method does not verify that.

Parameters:
minLatitude - the sector's minimum latitude.
maxLatitude - the sector's maximum latitude.
minLongitude - the sector's minimum longitude.
maxLongitude - the sector's maximum longitude.
Throws:
IllegalArgumentException - if any of the angles are null

Sector

public Sector(Sector sector)
Method Detail

boundingSector

public static Sector boundingSector(Iterator<TrackPoint> positions)

boundingSector

public static Sector boundingSector(Position pA,
                                    Position pB)

boundingSectorfromLatLons

public static Sector boundingSectorfromLatLons(Iterable<LatLon> positions)

boundingSectorfromPositions

public static Sector boundingSectorfromPositions(Iterable<Position> positions)

compareTo

public int compareTo(Sector that)
Compares this sector to a specified sector according to their minimum latitude, minimum longitude, maximum latitude, and maximum longitude, respectively.

Specified by:
compareTo in interface Comparable<Sector>
Parameters:
that - the Sector to compareTo with this.
Returns:
-1 if this sector compares less than that specified, 0 if they're equal, and 1 if it compares greater.
Throws:
IllegalArgumentException - if that is null

computeBoundingSphere

public static Extent computeBoundingSphere(Globe globe,
                                           double verticalExaggeration,
                                           Sector sector)
Returns a sphere that minimally surrounds the sector at a specified vertical exaggeration.

Parameters:
globe - the globe the sector is associated with
verticalExaggeration - the vertical exaggeration to apply to the globe's elevations when computing the sphere.
sector - the sector to return the bounding sphere for.
Returns:
The minimal bounding sphere in Cartesian coordinates.
Throws:
IllegalArgumentException - if globe or sector is null

computeCenterPoint

public Vec4 computeCenterPoint(Globe globe)

computeCornerPoints

public Vec4[] computeCornerPoints(Globe globe)

contains

public final boolean contains(Angle latitude,
                              Angle longitude)

contains

public final boolean contains(LatLon latLon)
Determines whether a latitude/longitude position is within the sector. The sector's angles are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude. The result of the operation is undefined if they are not.

Parameters:
latLon - the position to test, with angles normalized to +/- π latitude and +/- 2π longitude.
Returns:
true if the position is within the sector, false otherwise.
Throws:
IllegalArgumentException - if latlon is null.

containsDegrees

public final boolean containsDegrees(double degreesLatitude,
                                     double degreesLongitude)

containsRadians

public final boolean containsRadians(double radiansLatitude,
                                     double radiansLongitude)
Determines whether a latitude/longitude postion expressed in radians is within the sector. The sector's angles are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude. The result of the operation is undefined if they are not.

Parameters:
radiansLatitude - the latitude in radians of the position to test, normalized +/- π.
radiansLongitude - the longitude in radians of the position to test, normalized +/- 2π.
Returns:
true if the position is within the sector, false otherwise.

equals

public boolean equals(Object o)
Tests the equality of the sectors' angles. Sectors are equal if all of their corresponding angles are equal.

Overrides:
equals in class Object
Parameters:
o - the sector to compareTo with this.
Returns:
true if the four corresponding angles of each sector are equal, false otherwise.

fromDegrees

public static Sector fromDegrees(double minLatitude,
                                 double maxLatitude,
                                 double minLongitude,
                                 double maxLongitude)
Creates a new Sector and initializes it to the specified angles. The angles are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude, but this method does not verify that.

Parameters:
minLatitude - the sector's minimum latitude in degrees.
maxLatitude - the sector's maximum latitude in degrees.
minLongitude - the sector's minimum longitude in degrees.
maxLongitude - the sector's maximum longitude in degrees.
Returns:
the new Sector

fromRadians

public static Sector fromRadians(double minLatitude,
                                 double maxLatitude,
                                 double minLongitude,
                                 double maxLongitude)
Creates a new Sector and initializes it to the specified angles. The angles are assumed to be normalized to +/- ¹/2 radians latitude and +/- ¹ radians longitude, but this method does not verify that.

Parameters:
minLatitude - the sector's minimum latitude in radians.
maxLatitude - the sector's maximum latitude in radians.
minLongitude - the sector's minimum longitude in radians.
maxLongitude - the sector's maximum longitude in radians.
Returns:
the new Sector

getCentroid

public final LatLon getCentroid()
Returns the latitude and longitude of the sector's angular center: (minimum latitude + maximum latitude) / 2, (minimum longitude + maximum longitude) / 2.

Returns:
The latitude and longitude of the sector's angular center

getDeltaLat

public final Angle getDeltaLat()
Returns the angular difference between the sector's minimum and maximum latitudes: max - min

Returns:
The angular difference between the sector's minimum and maximum latitudes.

getDeltaLatDegrees

public final double getDeltaLatDegrees()

getDeltaLatRadians

public final double getDeltaLatRadians()

getDeltaLon

public final Angle getDeltaLon()
Returns the angular difference between the sector's minimum and maximum longitudes: max - min.

Returns:
The angular difference between the sector's minimum and maximum longitudes

getDeltaLonDegrees

public final double getDeltaLonDegrees()

getDeltaLonRadians

public final double getDeltaLonRadians()

getMaxLatitude

public final Angle getMaxLatitude()
Returns the sector's maximum latitude.

Returns:
The sector's maximum latitude.

getMaxLongitude

public final Angle getMaxLongitude()
Returns the sector's maximum longitude.

Returns:
The sector's maximum longitude.

getMinLatitude

public final Angle getMinLatitude()
Returns the sector's minimum latitude.

Returns:
The sector's minimum latitude.

getMinLongitude

public final Angle getMinLongitude()
Returns the sector's minimum longitude.

Returns:
The sector's minimum longitude.

getSizeInBytes

public long getSizeInBytes()
Retrieve the size of this object in bytes. This implementation returns an exact value of the object's size.

Specified by:
getSizeInBytes in interface Cacheable
Returns:
the size of this object in bytes

hashCode

public int hashCode()
Computes a hash code from the sector's four angles.

Overrides:
hashCode in class Object
Returns:
a hash code incorporating the sector's four angles.

intersection

public final Sector intersection(Angle latitude,
                                 Angle longitude)

intersection

public final Sector intersection(Sector that)

intersects

public boolean intersects(Sector that)
Determines whether this sector intersects another sector's range of latitude and longitude. The sector's angles are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude. The result of the operation is undefined if they are not.

Parameters:
that - the sector to test for intersection.
Returns:
true if the sectors intersect, otherwise false.

subdivide

public final Sector[] subdivide()

toString

public String toString()
Returns a string indicating the sector's angles.

Overrides:
toString in class Object
Returns:
A string indicating the sector's angles.

union

public final Sector union(Angle latitude,
                          Angle longitude)

union

public final Sector union(Sector that)
Returns a new sector whose angles are the extremes of the this sector and another. The new sector's minimum latitude and longitude will be the minimum of the two sectors. The new sector's maximum latitude and longitude will be the maximum of the two sectors. The sectors are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees longitude. The result of the operation is undefined if they are not.

Parameters:
that - the sector to join with this.
Returns:
A new sector formed from the extremes of the two sectors, or this if the incoming sector is null.

union

public static Sector union(Sector sectorA,
                           Sector sectorB)

NASA World Wind