|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.bbn.openmap.geo.Intersection
public class Intersection
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.
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 |
---|
protected final MatchFilter filter
protected final MatchCollector collector
Constructor Detail |
---|
public Intersection(MatchFilter filter, MatchCollector collector)
filter
- collector
- Method Detail |
---|
public static Intersection intersector()
public static Intersection intersector(MatchParameters params)
public static Intersection intersector(MatchParameters params, java.util.Collection c)
public static Intersection intersector(MatchFilter filter, MatchCollector collector)
public MatchCollector getCollector()
public MatchFilter getFilter()
public void consider(java.lang.Object a, java.lang.Object b)
a
- A GeoExtent object, generally.b
- A ExtentImpl object or GeoExtent object, generally.public void considerRegionXRegions(GeoRegion r, java.util.Collection regions)
r
- the region in questionregions
- a Collection of GeoRegions.public void considerRegionXRegion(GeoRegion r, GeoRegion region)
r
- region
- public void considerPathXRegions(GeoPath path, java.util.Collection regions)
path
- regions
- public void considerPathXRegion(GeoPath path, GeoRegion region)
path
- region
- public boolean considerSegmentXRegion(GeoSegment seg, GeoRegion region)
seg
- region
-
public void considerPointXRegions(GeoPoint p, java.util.Collection regions)
p
- regions
- public boolean considerPointXRegion(GeoPoint p, GeoRegion region)
p
- region
-
public static java.util.Iterator intersect(java.lang.Object path, java.lang.Object regions)
path
- regions
-
public static float[] getIntersection(float lat1, float lon1, float lat2, float lon2, float lat3, float lon3, float lat4, float lon4)
public static double[] getIntersection(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4)
public static Geo getIntersectionGeo(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4)
public static boolean intersects(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4)
public static boolean polyIntersect(float[] polyPoints1, float[] polyPoints2)
public static boolean polyIntersect(double[] polyPoints1, double[] polyPoints2)
public static boolean polyIntersect_optimized(double[] polyPoints1, double[] polyPoints2)
public static boolean isSelfIntersectingPoly(float[] polyPoints)
public static boolean isSelfIntersectingPoly(double[] polyPoints)
public static double pointCircleDistanceNM(Geo p1, Geo p2, Geo center)
public static double pointCircleDistance(Geo p1, Geo p2, Geo center)
public static boolean isOnSegment(Geo a, Geo b, Geo i)
public static boolean isOnSegment(Geo a, Geo b, Geo i, double withinRad)
public static Geo segIntersection(Geo a, Geo b, Geo c)
public static final boolean segIntersects(Geo p1, Geo p2, Geo p3, Geo p4)
public static double pointSegDistanceNM(double lat1, double lon1, double lat2, double lon2, double lat, double lon)
public static double pointSegDistance(Geo a, Geo b, Geo c)
public static boolean intersectsCircle(Geo p1, Geo p2, Geo center, double radius)
public static boolean intersectsCircle(float[] polyPoints, double lat, double lon, double radius)
public static boolean intersectsCircle(double[] polyPoints, double lat, double lon, double radius)
public static Geo center(Geo[] poly)
public static Geo center(Geo[] poly, Geo ret)
public static Geo center(GeoArray poly)
public static Geo center(GeoArray poly, Geo ret)
poly
- the GeoArray of the polygonret
- a Geo to use for the return values.
public static boolean isPointInPolygon(Geo x, GeoArray poly)
x
is inside poly
.
N.B.
poly
must be a closed polygon. In other words, the first
and last point must be the same.
x
or the antipode (the
point on the opposite side of the planet) of x
are inside
poly
.
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
x
- a geographic coordinatepoly
- an array of lat/lons describing a closed polygon
x
or antipode(x)
is inside
poly
public static boolean isPointInPolygon(Geo x, GeoArray poly, Geo internal)
public static boolean isPointInPolygon(Geo x, double[] poly, boolean polyInDegrees)
x
- poly
- double array where [lat, lon, lat, lon,...]polyInDegrees
- true of poly floats represent decimal degrees.
public static boolean isPointInPolygon(Geo x, float[] poly, boolean polyInDegrees)
x
- poly
- float array where [lat, lon, lat, lon,...]polyInDegrees
- true of poly floats represent decimal degrees.
public static boolean isPolylineInsidePolygon(GeoArray poly, GeoArray region)
public static double[] getSegIntersection(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3, double lat4, double lon4)
public static final Geo[] getSegIntersection(Geo p1, Geo p2, Geo p3, Geo p4)
public static final boolean isSegmentNearRadialRegion(GeoSegment segment, Geo rCenter, double rRadius, double near)
public static final boolean isSegmentNearRadialRegion(Geo s1, Geo s2, Geo rCenter, double rRadius, double near)
public static final boolean isSegmentNearRegion(GeoSegment segment, double hrange, GeoRegion region)
public static final boolean isSegmentNearPolyRegion(GeoSegment segment, GeoArray r, double near)
public static final boolean isSegmentNearPolyRegion(Geo s1, Geo s2, GeoArray r, double near)
public static final Geo isSegmentNearPoly(GeoSegment segment, GeoArray r, double near)
public static final Geo isSegmentNearPoly(Geo s1, Geo s2, GeoArray r, double near)
s1
- Endpoint of segments2
- Endpoint of segmentr
- Region of interestnear
- acceptable range between the segment and region, in radians.
public static final java.util.List<Geo> segmentNearPoly(GeoSegment segment, GeoArray r, double near)
public static final java.util.List<Geo> segmentNearPoly(Geo s1, Geo s2, GeoArray r, double near)
s1
- Endpoint of segments2
- Endpoint of segmentr
- Region of interestnear
- acceptable range between the segment and region, in radians.
public static final boolean isPointNearPoly(Geo s, GeoArray r, double near)
public static final Geo isPolyNearPoly(GeoArray s, GeoArray r, double near)
public static final java.util.List<Geo> polyNearPoly(GeoArray s, GeoArray r, double near)
public static Geo segmentsIntersect(Geo a1, Geo a2, Geo b1, Geo b2)
public static Geo segmentsIntersectOrNear(Geo a1, Geo a2, Geo b1, Geo b2, double r)
public static Geo segmentsIntersectOrNear(Geo a1, Geo a2, Geo b1, Geo b2, double r, Geo ret)
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |