public class Sector extends java.lang.Object implements Cacheable, java.lang.Comparable<Sector>, java.lang.Iterable<LatLon>
Sector
represents a rectangular region 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 verified by the class' methods. See Angle
for a description of
specifying angles. Sector
instances are immutable. Angle
Modifier and Type | Field and Description |
---|---|
static Sector |
EMPTY_SECTOR |
static Sector |
FULL_SPHERE
A
Sector of latitude [-90 degrees, + 90 degrees] and longitude [-180 degrees, + 180 degrees]. |
Constructor and Description |
---|
Sector(Angle minLatitude,
Angle maxLatitude,
Angle minLongitude,
Angle maxLongitude)
Creates a new
Sector and initializes it to the specified angles. |
Sector(Sector sector) |
Modifier and Type | Method and Description |
---|---|
double[] |
asDegreesArray()
Returns the coordinates of the sector as an array of values in degrees, in the order minLat, maxLat, minLon,
maxLon.
|
java.util.List<LatLon> |
asList()
Returns the coordinates of the sector as a list, in the order minLat, maxLat, minLon, maxLon.
|
double[] |
asRadiansArray()
Returns the coordinates of the sector as an array of values in radians, in the order minLat, maxLat, minLon,
maxLon.
|
static Sector |
boundingSector(Globe globe,
LatLon center,
double radius)
Returns a new
Sector encompassing a circle centered at a given position, with a given radius in
meter. |
static Sector |
boundingSector(java.lang.Iterable<? extends LatLon> locations) |
static Sector |
boundingSector(java.util.Iterator<TrackPoint> positions) |
static Sector |
boundingSector(LatLon pA,
LatLon pB) |
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 Box |
computeBoundingBox(Globe globe,
double verticalExaggeration,
Sector sector)
|
static Box |
computeBoundingBox(Globe globe,
double verticalExaggeration,
Sector sector,
double minElevation,
double maxElevation)
|
static Cylinder |
computeBoundingCylinder(Globe globe,
double verticalExaggeration,
Sector sector)
Returns a cylinder that minimally surrounds the specified sector at a specified vertical exaggeration.
|
static Cylinder |
computeBoundingCylinder(Globe globe,
double verticalExaggeration,
Sector sector,
double minElevation,
double maxElevation)
Returns a cylinder that minimally surrounds the specified sector at a specified vertical exaggeration and minimum
and maximum elevations for the sector.
|
static Cylinder |
computeBoundingCylinderOrig(Globe globe,
double verticalExaggeration,
Sector sector) |
static Cylinder |
computeBoundingCylinderOrig(Globe globe,
double verticalExaggeration,
Sector sector,
double minElevation,
double maxElevation)
Returns a cylinder that minimally surrounds the specified minimum and maximum elevations in the sector at a
specified vertical exaggeration.
|
static Sphere |
computeBoundingSphere(Globe globe,
double verticalExaggeration,
Sector sector)
Returns a sphere that minimally surrounds the sector at a specified vertical exaggeration.
|
Vec4 |
computeCenterPoint(Globe globe,
double exaggeration)
Computes the Cartesian coordinates of a Sector's center.
|
Vec4[] |
computeCornerPoints(Globe globe,
double exaggeration)
Computes the Cartesian coordinates of a Sector's corners.
|
boolean |
contains(Angle latitude,
Angle longitude) |
boolean |
contains(LatLon latLon)
Determines whether a latitude/longitude position is within the sector.
|
boolean |
contains(Sector that)
Determines whether another sector is fully contained within this one.
|
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.
|
double |
distanceTo(DrawContext dc,
Vec4 point)
Returns an approximation of the distance in model coordinates between the surface geometry defined by this sector
and the specified model coordinate point.
|
boolean |
equals(java.lang.Object o)
Tests the equality of the sectors' angles.
|
static Sector |
fromDegrees(double[] array)
Creates a new
Sector and initializes it to angles in the specified array. |
static Sector |
fromDegrees(double minLatitude,
double maxLatitude,
double minLongitude,
double maxLongitude)
Creates a new
Sector and initializes it to the specified angles. |
static Sector |
fromDegrees(java.awt.geom.Rectangle2D rectangle)
Creates a new
Sector and initializes it to the angles resulting from the given Rectangle2D in degrees lat-lon coordinates where x corresponds to longitude and y to latitude. |
static Sector |
fromDegreesAndClamp(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. |
static Sector |
fromUTMRectangle(int zone,
java.lang.String hemisphere,
double minEasting,
double maxEasting,
double minNorthing,
double maxNorthing)
Returns a geographic Sector which bounds the specified UTM rectangle.
|
LatLon |
getCentroid()
Returns the latitude and longitude of the sector's angular center: (minimum latitude + maximum latitude) / 2,
(minimum longitude + maximum longitude) / 2.
|
LatLon[] |
getCorners()
Returns a list of the Lat/Lon coordinates of a Sector's corners.
|
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) |
static Sector |
intersection(java.lang.Iterable<? extends Sector> sectors)
Returns the intersection of all sectors in the specified iterable.
|
Sector |
intersection(Sector that) |
boolean |
intersects(Sector that)
Determines whether this sector intersects another sector's range of latitude and longitude.
|
boolean |
intersectsAny(java.lang.Iterable<? extends Sector> sectors)
Determines whether this sector intersects any one of the sectors in the specified iterable.
|
boolean |
intersectsInterior(Sector that)
Determines whether the interiors of this sector and another sector intersect.
|
boolean |
intersectsSegment(LatLon begin,
LatLon end)
Determines whether this sector intersects the specified geographic line segment.
|
boolean |
isSameSector(java.lang.Iterable<? extends LatLon> corners) |
static boolean |
isSector(java.lang.Iterable<? extends LatLon> corners) |
boolean |
isWithinLatLonLimits() |
java.util.Iterator<LatLon> |
iterator()
Creates an iterator over the four corners of the sector, starting with the southwest position and continuing
counter-clockwise.
|
static Sector[] |
splitBoundingSectors(Globe globe,
LatLon center,
double radius)
Returns an array of Sectors encompassing a circle centered at a given position, with a given radius in meters.
|
static Sector[] |
splitBoundingSectors(java.lang.Iterable<? extends LatLon> locations) |
Sector[] |
subdivide() |
Sector[] |
subdivide(int div) |
double[] |
toArrayDegrees()
Returns a four element array containing the Sector's angles in degrees.
|
java.awt.geom.Rectangle2D |
toRectangleDegrees()
Returns a
Rectangle2D corresponding to this Sector in degrees lat-lon coordinates where x
corresponds to longitude and y to latitude. |
java.lang.String |
toString()
Returns a string indicating the sector's angles.
|
Sector |
union(Angle latitude,
Angle longitude) |
static Sector |
union(java.lang.Iterable<? extends Sector> sectors) |
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) |
public static final Sector EMPTY_SECTOR
public static final Sector FULL_SPHERE
Sector
of latitude [-90 degrees, + 90 degrees] and longitude [-180 degrees, + 180 degrees].public Sector(Angle minLatitude, Angle maxLatitude, Angle minLongitude, Angle maxLongitude)
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.minLatitude
- the sector's minimum latitude.maxLatitude
- the sector's maximum latitude.minLongitude
- the sector's minimum longitude.maxLongitude
- the sector's maximum longitude.java.lang.IllegalArgumentException
- if any of the angles are nullpublic Sector(Sector sector)
public double[] asDegreesArray()
public java.util.List<LatLon> asList()
public double[] asRadiansArray()
public static Sector boundingSector(Globe globe, LatLon center, double radius)
Sector
encompassing a circle centered at a given position, with a given radius in
meter.globe
- a Globe instance.center
- the circle center position.radius
- the circle radius in meter.public static Sector boundingSector(java.util.Iterator<TrackPoint> positions)
public int compareTo(Sector that)
compareTo
in interface java.lang.Comparable<Sector>
that
- the Sector
to compareTo with this
.java.lang.IllegalArgumentException
- if that
is nullpublic static Box computeBoundingBox(Globe globe, double verticalExaggeration, Sector sector)
Box
that bounds the specified sector on the surface of the specified
Globe
. The returned box encloses the globe's surface terrain in the sector,
according to the specified vertical exaggeration and the globe's minimum and maximum elevations in the sector. If
the minimum and maximum elevation are equal, this assumes a maximum elevation of 10 + the minimum. If this fails
to compute a box enclosing the sector, this returns a unit box enclosing one of the boxes corners.globe
- the globe the extent relates to.verticalExaggeration
- the globe's vertical surface exaggeration.sector
- a sector on the globe's surface to compute a bounding box for.java.lang.IllegalArgumentException
- if either the globe or sector is null.public static Box computeBoundingBox(Globe globe, double verticalExaggeration, Sector sector, double minElevation, double maxElevation)
Box
that bounds the specified sector on the surface of the specified
Globe
. The returned box encloses the globe's surface terrain in the sector,
according to the specified vertical exaggeration, minimum elevation, and maximum elevation. If the minimum and
maximum elevation are equal, this assumes a maximum elevation of 10 + the minimum. If this fails to compute a box
enclosing the sector, this returns a unit box enclosing one of the boxes corners.globe
- the globe the extent relates to.verticalExaggeration
- the globe's vertical surface exaggeration.sector
- a sector on the globe's surface to compute a bounding box for.minElevation
- the globe's minimum elevation in the sector.maxElevation
- the globe's maximum elevation in the sector.java.lang.IllegalArgumentException
- if either the globe or sector is null.public static Cylinder computeBoundingCylinder(Globe globe, double verticalExaggeration, Sector sector)
globe
- The globe associated with the sector.verticalExaggeration
- the vertical exaggeration to apply to the minimum and maximum elevations when
computing the cylinder.sector
- the sector to return the bounding cylinder for.java.lang.IllegalArgumentException
- if sector
is nullpublic static Cylinder computeBoundingCylinder(Globe globe, double verticalExaggeration, Sector sector, double minElevation, double maxElevation)
globe
- The globe associated with the sector.verticalExaggeration
- the vertical exaggeration to apply to the minimum and maximum elevations when
computing the cylinder.sector
- the sector to return the bounding cylinder for.minElevation
- the minimum elevation of the bounding cylinder.maxElevation
- the maximum elevation of the bounding cylinder.java.lang.IllegalArgumentException
- if sector
is nullpublic static Cylinder computeBoundingCylinderOrig(Globe globe, double verticalExaggeration, Sector sector)
public static Cylinder computeBoundingCylinderOrig(Globe globe, double verticalExaggeration, Sector sector, double minElevation, double maxElevation)
globe
- The globe associated with the sector.verticalExaggeration
- the vertical exaggeration to apply to the minimum and maximum elevations when
computing the cylinder.sector
- the sector to return the bounding cylinder for.minElevation
- the minimum elevation of the bounding cylinder.maxElevation
- the maximum elevation of the bounding cylinder.java.lang.IllegalArgumentException
- if sector
is nullpublic static Sphere computeBoundingSphere(Globe globe, double verticalExaggeration, Sector sector)
globe
- the globe the sector is associated withverticalExaggeration
- the vertical exaggeration to apply to the globe's elevations when computing the
sphere.sector
- the sector to return the bounding sphere for.java.lang.IllegalArgumentException
- if globe
or sector
is nullpublic Vec4 computeCenterPoint(Globe globe, double exaggeration)
globe
- The globe associated with the sector.exaggeration
- The vertical exaggeration to apply.java.lang.IllegalArgumentException
- if globe
is null.public Vec4[] computeCornerPoints(Globe globe, double exaggeration)
globe
- The globe associated with the sector.exaggeration
- The vertical exaggeration to apply.java.lang.IllegalArgumentException
- if globe
is null.public final boolean contains(LatLon latLon)
latLon
- the position to test, with angles normalized to +/- π latitude and +/- 2π longitude.true
if the position is within the sector, false
otherwise.java.lang.IllegalArgumentException
- if latlon
is null.public boolean contains(Sector that)
that
- the sector to test for containment.true
if this sector fully contains the input sector, otherwise false
.public boolean containsDegrees(double degreesLatitude, double degreesLongitude)
public boolean containsRadians(double radiansLatitude, double radiansLongitude)
radiansLatitude
- the latitude in radians of the position to test, normalized +/- π.radiansLongitude
- the longitude in radians of the position to test, normalized +/- 2π.true
if the position is within the sector, false
otherwise.public double distanceTo(DrawContext dc, Vec4 point)
dc
- The draw context defining the surface geometry.point
- The model coordinate point to compute a distance to.java.lang.IllegalArgumentException
- if any argument is null.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- the sector to compareTo with this
.true
if the four corresponding angles of each sector are equal, false
otherwise.public static Sector fromDegrees(double[] array)
Sector
and initializes it to angles in the specified array. The array is assumed to
hold four elements containing the Sector's angles, and must be ordered as follows: minimum latitude, maximum
latitude, minimum longitude, and maximum longitude. Additionally, the angles are assumed to be normalized to +/-
90 degrees latitude and +/- 180 degrees longitude, but this method does not verify that.array
- the array of angles in degrees.Sector
java.lang.IllegalArgumentException
- if array
is null or if its length is less than 4.public static Sector fromDegrees(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
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.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.Sector
public static Sector fromDegrees(java.awt.geom.Rectangle2D rectangle)
Sector
and initializes it to the angles resulting from the given Rectangle2D
in degrees lat-lon coordinates where x corresponds to longitude and y to latitude. The
resulting geographic angles are assumed to be normalized to +/- 90 degrees latitude and +/- 180 degrees
longitude, but this method does not verify that.rectangle
- the sector's rectangle in degrees lat-lon coordinates.Sector
public static Sector fromDegreesAndClamp(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
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.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.Sector
public static Sector fromRadians(double minLatitude, double maxLatitude, double minLongitude, double maxLongitude)
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.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.Sector
public static Sector fromUTMRectangle(int zone, java.lang.String hemisphere, double minEasting, double maxEasting, double minNorthing, double maxNorthing)
zone
- the UTM zone.hemisphere
- the UTM hemisphere, either AVKey.NORTH
or AVKey.SOUTH
.minEasting
- the minimum UTM easting, in meters.maxEasting
- the maximum UTM easting, in meters.minNorthing
- the minimum UTM northing, in meters.maxNorthing
- the maximum UTM northing, in meters.java.lang.IllegalArgumentException
- if zone
is outside the range 1-60, if hemisphere
is
null, or if hemisphere
is not one of AVKey.NORTH
or AVKey.SOUTH
.public LatLon getCentroid()
public LatLon[] getCorners()
public final Angle getDeltaLat()
public final double getDeltaLatDegrees()
public final double getDeltaLatRadians()
public final Angle getDeltaLon()
public final double getDeltaLonDegrees()
public final double getDeltaLonRadians()
public final Angle getMaxLatitude()
public final Angle getMaxLongitude()
public final Angle getMinLatitude()
public final Angle getMinLongitude()
public long getSizeInBytes()
getSizeInBytes
in interface Cacheable
public int hashCode()
hashCode
in class java.lang.Object
public static Sector intersection(java.lang.Iterable<? extends Sector> sectors)
sectors
- the sectors to intersect.java.lang.IllegalArgumentException
- if the iterable is null.public boolean intersects(Sector that)
that
- the sector to test for intersection.true
if the sectors intersect, otherwise false
.public boolean intersectsAny(java.lang.Iterable<? extends Sector> sectors)
sectors
- the sectors to test for intersection.java.lang.IllegalArgumentException
- if the iterable is null.public boolean intersectsInterior(Sector that)
that
- the sector to test for intersection.true
if the sectors' interiors intersect, otherwise false
.intersects(Sector)
public boolean intersectsSegment(LatLon begin, LatLon end)
begin
- the line segment begin location.end
- the line segment end location.true
if this sector intersects the line segment, otherwise false
.java.lang.IllegalArgumentException
- if either the begin location or the end location is null.public boolean isSameSector(java.lang.Iterable<? extends LatLon> corners)
public static boolean isSector(java.lang.Iterable<? extends LatLon> corners)
public boolean isWithinLatLonLimits()
public java.util.Iterator<LatLon> iterator()
iterator
in interface java.lang.Iterable<LatLon>
public static Sector[] splitBoundingSectors(Globe globe, LatLon center, double radius)
globe
- a Globe instance.center
- the circle center location.radius
- the circle radius in meters.java.lang.IllegalArgumentException
- if either the globe or center is null, or if the radius is less than zero.public static Sector[] splitBoundingSectors(java.lang.Iterable<? extends LatLon> locations)
public Sector[] subdivide()
public Sector[] subdivide(int div)
public double[] toArrayDegrees()
public java.awt.geom.Rectangle2D toRectangleDegrees()
Rectangle2D
corresponding to this Sector in degrees lat-lon coordinates where x
corresponds to longitude and y to latitude.Rectangle2D
corresponding to this Sector in degrees lat-lon coordinates.public java.lang.String toString()
toString
in class java.lang.Object
public final Sector union(Sector that)
that
- the sector to join with this
.this
if the incoming sector is
null
.