mil.af.afit.router
Class GeographicRegion

java.lang.Object
  |
  +--java.util.Observable
        |
        +--mil.af.afit.router.GeographicRegion
All Implemented Interfaces:
java.io.Serializable

public class GeographicRegion
extends java.util.Observable
implements java.io.Serializable

Used by RestrictedOperatingZone to specify a region on the ground. This uses a java.awt.Polygon to maintain the vertices. The latitudes and longitudes, which are normally stored as doubles, are multiplied by GeographicRegion.DOUBLE_TO_INT_MULTIPLIER since a Polygon only stores ints. A java.awt.geom.GeneralPath would be easier to use, but it's only supported in Java 2 v1.2 and later. I wanted to keep compatibility with Java 1.1.

Since:
1.0
See Also:
RestrictedOperatingZone, Polygon, Serialized Form

Field Summary
static int DOUBLE_TO_INT_MULTIPLIER
           
 
Constructor Summary
GeographicRegion()
          Constructs an empty geographic region.
GeographicRegion(double[][] verticesLatLong)
          Constructs a region based on the vertices given by the matrix verticeslatLong.
 
Method Summary
 boolean contains(double lat, double lon)
          Returns true if the given latitude and longitude are contained in the region.
 int getID()
          Return an automatically-assigned id for this region.
 java.awt.Polygon getPolygon()
          Returns the polygon associated with the region.
 double[][] getVertices()
          Returns the latitudes and longitudes in a matrix of doubles.
 java.lang.String toString()
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DOUBLE_TO_INT_MULTIPLIER

public static final int DOUBLE_TO_INT_MULTIPLIER
Constructor Detail

GeographicRegion

public GeographicRegion()
Constructs an empty geographic region.
Since:
1.0

GeographicRegion

public GeographicRegion(double[][] verticesLatLong)
Constructs a region based on the vertices given by the matrix verticeslatLong. Each sub-array should be of length two and contain a latitude in the [][0] position and a longitude in the [][1] position.
Parameters:
verticesLatLong - n x 2 matrix of vertices
Since:
1.0
Method Detail

getPolygon

public final java.awt.Polygon getPolygon()
Returns the polygon associated with the region.
Returns:
polygon associated with the region
Since:
1.0
See Also:
Polygon

getVertices

public final double[][] getVertices()
Returns the latitudes and longitudes in a matrix of doubles. Unlike the polygon, these points are actual lat/lon values where positive is north and east.
Returns:
lat/lon vertices
Since:
1.0

contains

public final boolean contains(double lat,
                              double lon)
Returns true if the given latitude and longitude are contained in the region. This accounts for the double to int conversion.
Parameters:
lat - latitude of point
lon - longitude of point
Since:
1.0

getID

public final int getID()
Return an automatically-assigned id for this region. This id does not persist after serialization. It's probably not a good thing to use.
Returns:
id of region
Since:
1.0

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object