com.bbn.openmap.geo
Class Intersection

java.lang.Object
  extended by com.bbn.openmap.geo.Intersection
Direct Known Subclasses:
BoundaryCrossing.CrossingIntersection

public class Intersection
extends java.lang.Object

Contains great circle intersection algorithms and helper methods. Sources: http://williams.best.vwh.net/intersect.htm http://mathforum.org/library/drmath/view/60711.html

The Intersection class has been updated to manage query intersections of GeoExtents over other GeoExtents. MatchCollectors and MatchFilters can be used to help optimize the search and manage the results.

Version:
$Revision: 1.20 $ on $Date: 2009/01/21 01:24:42 $
Author:
Sachin Date, Ken Anderson

Field Summary
protected  MatchCollector collector
           
protected  MatchFilter filter
           
 
Constructor Summary
Intersection(MatchFilter filter, MatchCollector collector)
          Create an Intersection class that will use the provided MatchFilter and MatchCollector.
 
Method Summary
static Geo center(Geo[] poly)
          Returns the center of the polygon poly.
static Geo center(Geo[] poly, Geo ret)
          Returns the center of the polygon poly.
static Geo center(GeoArray poly)
          Returns the center of the polygon poly.
static Geo center(GeoArray poly, Geo ret)
          Returns the center of the polygon poly.
 void consider(java.lang.Object a, java.lang.Object b)
          Asks the Intersection class to calculate the relationships between object a and b.
 void considerPathXRegion(GeoPath path, GeoRegion region)
          Puts the region in the Collector if it intersects with the path.
 void considerPathXRegions(GeoPath path, java.util.Collection regions)
          Puts regions in the Collector if they intersect the path.
 boolean considerPointXRegion(GeoPoint p, GeoRegion region)
           
 void considerPointXRegions(GeoPoint p, java.util.Collection regions)
          Adds regions to the Collector if the GeoPoint p is on or in the regions of the Collection.
 void considerRegionXRegion(GeoRegion r, GeoRegion region)
          Puts the region in the Collector if r intersects with it.
 void considerRegionXRegions(GeoRegion r, java.util.Collection regions)
          Loads the collector with regions from the Collection that intersect with r.
 boolean considerSegmentXRegion(GeoSegment seg, GeoRegion region)
          Returns true if the segment intersects with the region.
 MatchCollector getCollector()
          Retrieve the MatchCollector that contains the results from the Intersection query.
 MatchFilter getFilter()
          Retrieve the MatchFilter that can be used to control which GeoExtents are considered for Intersection queries.
static double[] getIntersection(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4)
          Returns the two antipodal points of intersection of two great circles defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4).
static float[] getIntersection(float lat1, float lon1, float lat2, float lon2, float lat3, float lon3, float lat4, float lon4)
          Returns the two antipodal points of intersection of two great circles defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4).
static Geo getIntersectionGeo(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4)
          Returns a Geo representing the intersection of two great circles defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4).
static double[] getSegIntersection(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4)
          Returns the point of intersection of two great circle segments defined by the segments.
static Geo[] getSegIntersection(Geo p1, Geo p2, Geo p3, Geo p4)
          Find the intersection(s) between [p1-p2] and [p3-p4]
static java.util.Iterator intersect(java.lang.Object path, java.lang.Object regions)
          Simplified version of #intersect(Path, Collection, Algorithm) for old code, using the default match algorithm, and returning the identifiers of the regions that intersect with the path.
static Intersection intersector()
          Create an Intersection class that will use the MatchFilter.MatchParameters class with STRICT settings, and a MatchCollector.SetMatchCollector.
static Intersection intersector(MatchFilter filter, MatchCollector collector)
          Create an Intersection class that will use the provided MatchFilter class and the provided MatchCollector.
static Intersection intersector(MatchParameters params)
          Create an Intersection class that will use the MatchFilter.MatchParameters class with provided settings, and a MatchCollector.SetMatchCollector.
static Intersection intersector(MatchParameters params, java.util.Collection c)
          Create an Intersection class that will use the MatchFilter.MatchParameters class with provided settings, and a MatchCollector.CollectionMatchCollector with the provided collector.
static boolean intersects(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4)
          Returns true if the two segs intersect in at least one point.
static boolean intersectsCircle(double[] polyPoints, double lat, double lon, double radius)
          returns true if the specified poly path intersects the circle centered at (lat, lon).
static boolean intersectsCircle(float[] polyPoints, double lat, double lon, double radius)
          returns true if the specified poly path intersects the circle centered at (lat, lon).
static boolean intersectsCircle(Geo p1, Geo p2, Geo center, double radius)
          Returns true or false depending on whether the great circle seg from point p1 to point p2 intersects the circle of radius (radians) around center.
static boolean isOnSegment(Geo a, Geo b, Geo i)
          Point i is on the great circle defined by the points a and b.
static boolean isOnSegment(Geo a, Geo b, Geo i, double withinRad)
          Returns true if i is on the great circle between a and b and between them, false otherwise.
static boolean isPointInPolygon(Geo x, double[] poly, boolean polyInDegrees)
          Ask if a Geo point is in a polygon.
static boolean isPointInPolygon(Geo x, float[] poly, boolean polyInDegrees)
          Ask if a Geo point is in a polygon.
static boolean isPointInPolygon(Geo x, GeoArray poly)
          Determines whether x is inside poly.
static boolean isPointInPolygon(Geo x, GeoArray poly, Geo internal)
           
static boolean isPointNearPoly(Geo s, GeoArray r, double near)
          Does the point s come within 'near' radians of the boarder of the region defined by the polygon in r[*]?
static boolean isPolylineInsidePolygon(GeoArray poly, GeoArray region)
          return true IFF some point of the first argument is inside the region specified by the closed polygon specified by the second argument
static Geo isPolyNearPoly(GeoArray s, GeoArray r, double near)
          Is one region's boundary within 'near' range of a region? Note: good practice is s describes a smaller area than r.
static Geo isSegmentNearPoly(Geo s1, Geo s2, GeoArray r, double near)
          Is a segment, represented by endpoints 's1' and 's2', withing a range 'near' of region 'r'?
static Geo isSegmentNearPoly(GeoSegment segment, GeoArray r, double near)
          Where is a segment within range of a region?
static boolean isSegmentNearPolyRegion(Geo s1, Geo s2, GeoArray r, double near)
          Does the segment s1-s2 come within near radians of the region defined by the polygon in r[*]? Catches segments within poly region and returns after first hit, which is why it returns boolean.
static boolean isSegmentNearPolyRegion(GeoSegment segment, GeoArray r, double near)
          Does the segment come within near radians of the region defined by the polygon in r[*]? Catches segments within poly region and returns after first hit, which is why it returns boolean.
static boolean isSegmentNearRadialRegion(Geo s1, Geo s2, Geo rCenter, double rRadius, double near)
          Does the segment come within near radians of the region defined by rCenter at rRadius?
static boolean isSegmentNearRadialRegion(GeoSegment segment, Geo rCenter, double rRadius, double near)
          Does the segment come within near radians of the region defined by rCenter at rRadius?
static boolean isSegmentNearRegion(GeoSegment segment, double hrange, GeoRegion region)
          Is a segment horizontally within range of a Region region?
static boolean isSelfIntersectingPoly(double[] polyPoints)
          checks if the polygon or polyline represented by the polypoints contains any lines that intersect each other.
static boolean isSelfIntersectingPoly(float[] polyPoints)
          checks if the polygon or polyline represented by the polypoints contains any lines that intersect each other.
static void main(java.lang.String[] args)
           
static double pointCircleDistance(Geo p1, Geo p2, Geo center)
          Calculates the great circle distance from the point (center) to the great circle containing the points (p1) and (p2).
static double pointCircleDistanceNM(Geo p1, Geo p2, Geo center)
          Calculates the great circle distance from the point (lat, lon) to the great circle containing the points (lat1, lon1) and (lat2, lon2).
static double pointSegDistance(Geo a, Geo b, Geo c)
          Returns the distance in radians between the point c and the point of intersection of the great circle passing through c and perpendicular to great circle segment between a and b.
static double pointSegDistanceNM(double lat1, double lon1, double lat2, double lon2, double lat, double lon)
          returns the distance in NM between the point (lat, lon) and the point of intersection of the great circle passing through (lat, lon) and perpendicular to great circle segment (lat1, lon1, lat2, lon2).
static boolean polyIntersect_optimized(double[] polyPoints1, double[] polyPoints2)
          Checks if the two polygonal areas intersect.
static boolean polyIntersect(double[] polyPoints1, double[] polyPoints2)
          Checks if the two polygonal areas intersect.
static boolean polyIntersect(float[] polyPoints1, float[] polyPoints2)
          Checks if the two polygonal areas intersect.
static java.util.List<Geo> polyNearPoly(GeoArray s, GeoArray r, double near)
          Is one region's boundary within 'near' range of a region? Note: good practice is s describes a smaller area than r.
static Geo segIntersection(Geo a, Geo b, Geo c)
           
static boolean segIntersects(Geo p1, Geo p2, Geo p3, Geo p4)
          Test if [p1-p2] and [p3-p4] intersect
static java.util.List<Geo> segmentNearPoly(Geo s1, Geo s2, GeoArray r, double near)
          Where is a segment, represented by endpoints 's1' and 's2', withing a range 'near' of region 'r'?
static java.util.List<Geo> segmentNearPoly(GeoSegment segment, GeoArray r, double near)
          Where is a segment within range of a region?
static Geo segmentsIntersect(Geo a1, Geo a2, Geo b1, Geo b2)
           
static Geo segmentsIntersectOrNear(Geo a1, Geo a2, Geo b1, Geo b2, double r)
           
static Geo segmentsIntersectOrNear(Geo a1, Geo a2, Geo b1, Geo b2, double r, Geo ret)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filter

protected final MatchFilter filter

collector

protected final MatchCollector collector
Constructor Detail

Intersection

public Intersection(MatchFilter filter,
                    MatchCollector collector)
Create an Intersection class that will use the provided MatchFilter and MatchCollector.

Parameters:
filter -
collector -
Method Detail

intersector

public static Intersection intersector()
Create an Intersection class that will use the MatchFilter.MatchParameters class with STRICT settings, and a MatchCollector.SetMatchCollector.


intersector

public static Intersection intersector(MatchParameters params)
Create an Intersection class that will use the MatchFilter.MatchParameters class with provided settings, and a MatchCollector.SetMatchCollector.


intersector

public static Intersection intersector(MatchParameters params,
                                       java.util.Collection c)
Create an Intersection class that will use the MatchFilter.MatchParameters class with provided settings, and a MatchCollector.CollectionMatchCollector with the provided collector.


intersector

public static Intersection intersector(MatchFilter filter,
                                       MatchCollector collector)
Create an Intersection class that will use the provided MatchFilter class and the provided MatchCollector.


getCollector

public MatchCollector getCollector()
Retrieve the MatchCollector that contains the results from the Intersection query.

Returns:
MatchCollector that can be used to retrieve intersection results.

getFilter

public MatchFilter getFilter()
Retrieve the MatchFilter that can be used to control which GeoExtents are considered for Intersection queries.

Returns:
The MatchFilter used to process intersection results.

consider

public void consider(java.lang.Object a,
                     java.lang.Object b)
Asks the Intersection class to calculate the relationships between object a and b. Calls the other consider methods, depending on what a and b are. Consult the MatchCollector for the results.

Parameters:
a - A GeoExtent object, generally.
b - A ExtentImpl object or GeoExtent object, generally.

considerRegionXRegions

public void considerRegionXRegions(GeoRegion r,
                                   java.util.Collection regions)
Loads the collector with regions from the Collection that intersect with r.

Parameters:
r - the region in question
regions - a Collection of GeoRegions.

considerRegionXRegion

public void considerRegionXRegion(GeoRegion r,
                                  GeoRegion region)
Puts the region in the Collector if r intersects with it.

Parameters:
r -
region -

considerPathXRegions

public void considerPathXRegions(GeoPath path,
                                 java.util.Collection regions)
Puts regions in the Collector if they intersect the path.

Parameters:
path -
regions -

considerPathXRegion

public void considerPathXRegion(GeoPath path,
                                GeoRegion region)
Puts the region in the Collector if it intersects with the path.

Parameters:
path -
region -

considerSegmentXRegion

public boolean considerSegmentXRegion(GeoSegment seg,
                                      GeoRegion region)
Returns true if the segment intersects with the region. The range of the query is determined by the filter set on this Intersection object.

Parameters:
seg -
region -
Returns:
true if segment intersects region

considerPointXRegions

public void considerPointXRegions(GeoPoint p,
                                  java.util.Collection regions)
Adds regions to the Collector if the GeoPoint p is on or in the regions of the Collection.

Parameters:
p -
regions -

considerPointXRegion

public boolean considerPointXRegion(GeoPoint p,
                                    GeoRegion region)
Parameters:
p -
region -
Returns:
true if p is in region.

intersect

public static java.util.Iterator intersect(java.lang.Object path,
                                           java.lang.Object regions)
Simplified version of #intersect(Path, Collection, Algorithm) for old code, using the default match algorithm, and returning the identifiers of the regions that intersect with the path.

Parameters:
path -
regions -
Returns:
an iterator over list of the intersecting regions.

getIntersection

public static float[] getIntersection(float lat1,
                                      float lon1,
                                      float lat2,
                                      float lon2,
                                      float lat3,
                                      float lon3,
                                      float lat4,
                                      float lon4)
Returns the two antipodal points of intersection of two great circles defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4). All lat-lon values are in degrees.

Returns:
an array of two lat-lon points arranged as lat, lon, lat, lon

getIntersection

public static double[] getIntersection(double lat1,
                                       double lon1,
                                       double lat2,
                                       double lon2,
                                       double lat3,
                                       double lon3,
                                       double lat4,
                                       double lon4)
Returns the two antipodal points of intersection of two great circles defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4). All lat-lon values are in degrees.

Returns:
an array of two lat-lon points arranged as lat, lon, lat, lon

getIntersectionGeo

public static Geo getIntersectionGeo(double lat1,
                                     double lon1,
                                     double lat2,
                                     double lon2,
                                     double lat3,
                                     double lon3,
                                     double lat4,
                                     double lon4)
Returns a Geo representing the intersection of two great circles defined by the arcs (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4). All lat-lon values are in degrees.

Returns:
Geo containing intersection, might have to check antipode of Geo for actual intersection.

intersects

public static boolean intersects(double lat1,
                                 double lon1,
                                 double lat2,
                                 double lon2,
                                 double lat3,
                                 double lon3,
                                 double lat4,
                                 double lon4)
Returns true if the two segs intersect in at least one point. All lat-lon values are in degrees. lat1,lon1-lat2,lon2 make up one segment, lat3,lon3-lat4,lon4 make up the other segment.


polyIntersect

public static boolean polyIntersect(float[] polyPoints1,
                                    float[] polyPoints2)
Checks if the two polygonal areas intersect. The two polygonal regions are represented by two lat-lon arrays in the lat1, lon1, lat2, lon2,... format. For closed polygons the last pair of points in the array should be the same as the first pair. All lat-lon values are in degrees.


polyIntersect

public static boolean polyIntersect(double[] polyPoints1,
                                    double[] polyPoints2)
Checks if the two polygonal areas intersect. The two polygonal regions are represented by two lat-lon arrays in the lat1, lon1, lat2, lon2,... format. For closed polygons the last pair of points in the array should be the same as the first pair. All lat-lon values are in degrees.


polyIntersect_optimized

public static boolean polyIntersect_optimized(double[] polyPoints1,
                                              double[] polyPoints2)
Checks if the two polygonal areas intersect. The two polygonal regions are represented by two lat-lon arrays in the lat1, lon1, lat2, lon2,... format. For closed polygons the last pair of points in the array should be the same as the first pair. All lat-lon values are in degrees. KM optimized to create each Geo only once. (TODO consider optimizing the other paths.)


isSelfIntersectingPoly

public static boolean isSelfIntersectingPoly(float[] polyPoints)
checks if the polygon or polyline represented by the polypoints contains any lines that intersect each other. All lat-lon values are in degrees.


isSelfIntersectingPoly

public static boolean isSelfIntersectingPoly(double[] polyPoints)
checks if the polygon or polyline represented by the polypoints contains any lines that intersect each other. All lat-lon values are in degrees.


pointCircleDistanceNM

public static double pointCircleDistanceNM(Geo p1,
                                           Geo p2,
                                           Geo center)
Calculates the great circle distance from the point (lat, lon) to the great circle containing the points (lat1, lon1) and (lat2, lon2).

Returns:
nautical miles

pointCircleDistance

public static double pointCircleDistance(Geo p1,
                                         Geo p2,
                                         Geo center)
Calculates the great circle distance from the point (center) to the great circle containing the points (p1) and (p2).

Returns:
radians

isOnSegment

public static boolean isOnSegment(Geo a,
                                  Geo b,
                                  Geo i)
Point i is on the great circle defined by the points a and b. Returns true if i is between a and b, false otherwise. NOTE: i is assumed to be on the great circle line.


isOnSegment

public static boolean isOnSegment(Geo a,
                                  Geo b,
                                  Geo i,
                                  double withinRad)
Returns true if i is on the great circle between a and b and between them, false otherwise. In other words, this method does the great circle test for you, too.


segIntersection

public static Geo segIntersection(Geo a,
                                  Geo b,
                                  Geo c)
Returns:
the Geo point i, which is on the great circle segment between Geo points a and b and which is closest to Geo point c. Returns null if there is no such point.

segIntersects

public static final boolean segIntersects(Geo p1,
                                          Geo p2,
                                          Geo p3,
                                          Geo p4)
Test if [p1-p2] and [p3-p4] intersect


pointSegDistanceNM

public static double pointSegDistanceNM(double lat1,
                                        double lon1,
                                        double lat2,
                                        double lon2,
                                        double lat,
                                        double lon)
returns the distance in NM between the point (lat, lon) and the point of intersection of the great circle passing through (lat, lon) and perpendicular to great circle segment (lat1, lon1, lat2, lon2). returns -1 if point of intersection of the two great circle segs is not on the great circle segment (lat1, lon1, lat2, lon2).


pointSegDistance

public static double pointSegDistance(Geo a,
                                      Geo b,
                                      Geo c)
Returns the distance in radians between the point c and the point of intersection of the great circle passing through c and perpendicular to great circle segment between a and b. Returns -1 if point of intersection of the two great circle segs is not on the great circle segment a-b.


intersectsCircle

public static boolean intersectsCircle(Geo p1,
                                       Geo p2,
                                       Geo center,
                                       double radius)
Returns true or false depending on whether the great circle seg from point p1 to point p2 intersects the circle of radius (radians) around center.


intersectsCircle

public static boolean intersectsCircle(float[] polyPoints,
                                       double lat,
                                       double lon,
                                       double radius)
returns true if the specified poly path intersects the circle centered at (lat, lon). All lat-lon values are in degrees. radius is in radians.


intersectsCircle

public static boolean intersectsCircle(double[] polyPoints,
                                       double lat,
                                       double lon,
                                       double radius)
returns true if the specified poly path intersects the circle centered at (lat, lon). All lat-lon values are in degrees. radius is in radians.


center

public static Geo center(Geo[] poly)
Returns the center of the polygon poly.


center

public static Geo center(Geo[] poly,
                         Geo ret)
Returns the center of the polygon poly.


center

public static Geo center(GeoArray poly)
Returns the center of the polygon poly.


center

public static Geo center(GeoArray poly,
                         Geo ret)
Returns the center of the polygon poly.

Parameters:
poly - the GeoArray of the polygon
ret - a Geo to use for the return values.
Returns:
ret.

isPointInPolygon

public static boolean isPointInPolygon(Geo x,
                                       GeoArray poly)
Determines whether x is inside poly.

N.B.

poly is an array of latitude/longitude points where:

                                                        
                                                                                               
                 poly[0] = latitude 1
                 poly[1] = longitude 1
                 poly[2] = latitude 2
                 poly[3] = longitude 2
                 .
                 .
                 .
                 poly[n-1] = latitude 1
                 poly[n] = longitude 1
                                                                                                
 

Parameters:
x - a geographic coordinate
poly - an array of lat/lons describing a closed polygon
Returns:
true iff x or antipode(x) is inside poly

isPointInPolygon

public static boolean isPointInPolygon(Geo x,
                                       GeoArray poly,
                                       Geo internal)

isPointInPolygon

public static boolean isPointInPolygon(Geo x,
                                       double[] poly,
                                       boolean polyInDegrees)
Ask if a Geo point is in a polygon.

Parameters:
x -
poly - double array where [lat, lon, lat, lon,...]
polyInDegrees - true of poly floats represent decimal degrees.
Returns:
true for Geo in poly

isPointInPolygon

public static boolean isPointInPolygon(Geo x,
                                       float[] poly,
                                       boolean polyInDegrees)
Ask if a Geo point is in a polygon.

Parameters:
x -
poly - float array where [lat, lon, lat, lon,...]
polyInDegrees - true of poly floats represent decimal degrees.
Returns:
true for Geo in poly

isPolylineInsidePolygon

public static boolean isPolylineInsidePolygon(GeoArray poly,
                                              GeoArray region)
return true IFF some point of the first argument is inside the region specified by the closed polygon specified by the second argument


getSegIntersection

public static double[] getSegIntersection(double lat1,
                                          double lon1,
                                          double lat2,
                                          double lon2,
                                          double lat3,
                                          double lon3,
                                          double lat4,
                                          double lon4)
Returns the point of intersection of two great circle segments defined by the segments. (lat1, lon1) to (lat2, lon2) and (lat2, lon2) to (lat4, lon4). All lat-lon values are in degrees.

Returns:
a float array of length 4 containing upto 2 valid lat-lon points of intersection that lie on both segments. Positions in the array not containing a valid lat/lon value are initialized to Float.MAX_VALUE.

getSegIntersection

public static final Geo[] getSegIntersection(Geo p1,
                                             Geo p2,
                                             Geo p3,
                                             Geo p4)
Find the intersection(s) between [p1-p2] and [p3-p4]


isSegmentNearRadialRegion

public static final boolean isSegmentNearRadialRegion(GeoSegment segment,
                                                      Geo rCenter,
                                                      double rRadius,
                                                      double near)
Does the segment come within near radians of the region defined by rCenter at rRadius?


isSegmentNearRadialRegion

public static final boolean isSegmentNearRadialRegion(Geo s1,
                                                      Geo s2,
                                                      Geo rCenter,
                                                      double rRadius,
                                                      double near)
Does the segment come within near radians of the region defined by rCenter at rRadius?


isSegmentNearRegion

public static final boolean isSegmentNearRegion(GeoSegment segment,
                                                double hrange,
                                                GeoRegion region)
Is a segment horizontally within range of a Region region?


isSegmentNearPolyRegion

public static final boolean isSegmentNearPolyRegion(GeoSegment segment,
                                                    GeoArray r,
                                                    double near)
Does the segment come within near radians of the region defined by the polygon in r[*]? Catches segments within poly region and returns after first hit, which is why it returns boolean.


isSegmentNearPolyRegion

public static final boolean isSegmentNearPolyRegion(Geo s1,
                                                    Geo s2,
                                                    GeoArray r,
                                                    double near)
Does the segment s1-s2 come within near radians of the region defined by the polygon in r[*]? Catches segments within poly region and returns after first hit, which is why it returns boolean.


isSegmentNearPoly

public static final Geo isSegmentNearPoly(GeoSegment segment,
                                          GeoArray r,
                                          double near)
Where is a segment within range of a region?


isSegmentNearPoly

public static final Geo isSegmentNearPoly(Geo s1,
                                          Geo s2,
                                          GeoArray r,
                                          double near)
Is a segment, represented by endpoints 's1' and 's2', withing a range 'near' of region 'r'?

Parameters:
s1 - Endpoint of segment
s2 - Endpoint of segment
r - Region of interest
near - acceptable range between the segment and region, in radians.
Returns:
Geo location where the condition was initially met (yes), null if conditions weren't met (no).

segmentNearPoly

public static final java.util.List<Geo> segmentNearPoly(GeoSegment segment,
                                                        GeoArray r,
                                                        double near)
Where is a segment within range of a region?


segmentNearPoly

public static final java.util.List<Geo> segmentNearPoly(Geo s1,
                                                        Geo s2,
                                                        GeoArray r,
                                                        double near)
Where is a segment, represented by endpoints 's1' and 's2', withing a range 'near' of region 'r'?

Parameters:
s1 - Endpoint of segment
s2 - Endpoint of segment
r - Region of interest
near - acceptable range between the segment and region, in radians.
Returns:
Geo location where the condition was met (yes), null if conditions weren't met (no).

isPointNearPoly

public static final boolean isPointNearPoly(Geo s,
                                            GeoArray r,
                                            double near)
Does the point s come within 'near' radians of the boarder of the region defined by the polygon in r[*]?


isPolyNearPoly

public static final Geo isPolyNearPoly(GeoArray s,
                                       GeoArray r,
                                       double near)
Is one region's boundary within 'near' range of a region? Note: good practice is s describes a smaller area than r.

Returns:
the Geo location where the condition was first met, null if the condition wasn't met.

polyNearPoly

public static final java.util.List<Geo> polyNearPoly(GeoArray s,
                                                     GeoArray r,
                                                     double near)
Is one region's boundary within 'near' range of a region? Note: good practice is s describes a smaller area than r.

Returns:
a List where the polys intersect within the range, null if the condition wasn't met.

segmentsIntersect

public static Geo segmentsIntersect(Geo a1,
                                    Geo a2,
                                    Geo b1,
                                    Geo b2)
Returns:
a Geo location iff the great circle segments defined by a1-a2 and b1-b2 intersect. the angles between the segments must be < PI or the results are ambiguous.Returns null if the segments don't intersect within the range.

segmentsIntersectOrNear

public static Geo segmentsIntersectOrNear(Geo a1,
                                          Geo a2,
                                          Geo b1,
                                          Geo b2,
                                          double r)
Returns:
a Geo location iff the great circle segments defined by a1-a2 and b1-b2 come within the range (r, radians) of each other. The angles between the segments must be < PI or the results are ambiguous. Returns null if the segments don't intersect within the range.

segmentsIntersectOrNear

public static Geo segmentsIntersectOrNear(Geo a1,
                                          Geo a2,
                                          Geo b1,
                                          Geo b2,
                                          double r,
                                          Geo ret)
Returns:
a Geo location iff the great circle segments defined by a1-a2 and b1-b2 come within the range (r, radians) of each other. The angles between the segments must be < PI or the results are ambiguous. Returns null if the segments don't intersect within the range.

main

public static void main(java.lang.String[] args)


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