update javadoc

This commit is contained in:
ntruchsess 2018-01-22 16:18:38 +01:00
parent 1fd973daf2
commit 48d60dd69e

View file

@ -55,22 +55,22 @@ public class OsmNogoPolygon extends OsmNodeNamed
return 1.- l2 + l4 / 6.; // - l6 / 90; return 1.- l2 + l4 / 6.; // - l6 / 90;
} }
/** /**
* method calcBoundingCircle is inspired by the algorithm described on * calcBoundingCircle is inspired by the algorithm described on
* http://geomalgorithms.com/a08-_containers.html * http://geomalgorithms.com/a08-_containers.html
* (fast computation of bounding circly in c). It is not as fast (the original * (fast computation of bounding circly in c). It is not as fast (the original
* algorithm runs in linear time), as it may do more iterations but it takes * algorithm runs in linear time), as it may do more iterations but it takes
* into account the coslat-factor being used for the linear approximation that * into account the coslat-factor being used for the linear approximation that
* is also used in other places of brouter does change when moving the centerpoint * is also used in other places of brouter does change when moving the centerpoint
* with each iteration. * with each iteration.
* This is done to ensure the calculated radius being used * This is done to ensure the calculated radius being used
* in RoutingContext.calcDistance will actually contain the whole polygon. * in RoutingContext.calcDistance will actually contain the whole polygon.
* *
* For reasonable distributed vertices the implemented algorithm runs in O(n*ln(n)). * For reasonable distributed vertices the implemented algorithm runs in O(n*ln(n)).
* As this is only run once on initialization of OsmNogoPolygon this methods * As this is only run once on initialization of OsmNogoPolygon this methods
* overall usage of cpu is neglegible in comparism to the cpu-usage of the * overall usage of cpu is neglegible in comparism to the cpu-usage of the
* actual routing algoritm. * actual routing algoritm.
*/ */
public void calcBoundingCircle() public void calcBoundingCircle()
{ {
int cxmin, cxmax, cymin, cymax; int cxmin, cxmax, cymin, cymax;
@ -159,6 +159,22 @@ public class OsmNogoPolygon extends OsmNodeNamed
return; return;
} }
/**
* intersectsOrIsWithin
*
* tests whether a segment defined by lon and lat of two points does either
* intersect the polygon or any of the endpoints (or both) are enclosed by
* the polygon. Any point being positioned on any of the polygons edges is
* defined as being 'inside'. For this test the winding-number algorithm is
* being used. That means a point being within an overlapping region of the
* polygon is also taken as being 'inside' the polygon.
*
* @param lon0 longitude of start point
* @param lat0 latitude of start point
* @param lon1 longitude of end point
* @param lat1 latitude of start point
* @return true if segment or any of it's points are 'inside' of polygon
*/
public boolean intersectsOrIsWithin(int lon0, int lat0, int lon1, int lat1) public boolean intersectsOrIsWithin(int lon0, int lat0, int lon1, int lat1)
{ {
Point p0 = new Point (lon0,lat0); Point p0 = new Point (lon0,lat0);
@ -183,18 +199,22 @@ public class OsmNogoPolygon extends OsmNodeNamed
return false; return false;
} }
/** /* Copyright 2001 softSurfer, 2012 Dan Sunday, 2018 Norbert Truchses
* Copyright 2001 softSurfer, 2012 Dan Sunday This code may be freely used and modified for any purpose providing that
* This code may be freely used and modified for any purpose providing that this copyright notice is included with it. SoftSurfer makes no warranty for
* this copyright notice is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage
* this code, and cannot be held liable for any real or imagined damage resulting from its use. Users of this code must verify correctness for
* resulting from its use. Users of this code must verify correctness for their application. */
* their application. /**
* * cn_PnPoly(): crossing number test for a point in a polygon
* cn_PnPoly(): crossing number test for a point in a polygon Input: P = a *
* point, V[] = vertex points of a polygon V[n+1] with V[n]=V[0] Return: 0 = * @param p a point
* outside, 1 = inside This code is patterned after [Franklin, 2000] * @param v list of vertex points forming a polygon. This polygon
*/ * is implicitly closed connecting the last and first point.
* @return 0 = outside, 1 = inside.
*
* This code is patterned after [Franklin, 2000]
*/
private static boolean cn_PnPoly(final Point p, final List<Point> v) private static boolean cn_PnPoly(final Point p, final List<Point> v)
{ {
int cn = 0; // the crossing number counter int cn = 0; // the crossing number counter
@ -222,19 +242,20 @@ public class OsmNogoPolygon extends OsmNodeNamed
return ((cn & 1) > 0); // 0 if even (out), and 1 if odd (in) return ((cn & 1) > 0); // 0 if even (out), and 1 if odd (in)
} }
/** /* Copyright 2001 softSurfer, 2012 Dan Sunday, 2018 Norbert Truchses
* Copyright 2001 softSurfer, 2012 Dan Sunday This code may be freely used and modified for any purpose providing that
* This code may be freely used and modified for any purpose providing that this copyright notice is included with it. SoftSurfer makes no warranty for
* this copyright notice is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage
* this code, and cannot be held liable for any real or imagined damage resulting from its use. Users of this code must verify correctness for
* resulting from its use. Users of this code must verify correctness for their application. */
* their application. /**
* * winding number test for a point in a polygon
* wn_PnPoly(): winding number test for a point in a polygon Input: P = a *
* point, V = vertex points of a polygon V[n+1] with V[n]=V[0] Return: wn = * @param p a point
* the winding number (=0 only when P is outside) * @param v list of vertex points forming a polygon. This polygon
*/ * is implicitly closed connecting the last and first point.
* @return the winding number (=0 only when P is outside)
*/
private static int wn_PnPoly(final Point p, final List<Point> v) { private static int wn_PnPoly(final Point p, final List<Point> v) {
int wn = 0; // the winding number counter int wn = 0; // the winding number counter
@ -277,19 +298,21 @@ public class OsmNogoPolygon extends OsmNodeNamed
return wn; return wn;
} }
/** /* Copyright 2001 softSurfer, 2012 Dan Sunday, 2018 Norbert Truchses
* Copyright 2001 softSurfer, 2012 Dan Sunday This code may be freely used and modified for any purpose providing that
* This code may be freely used and modified for any purpose providing that this copyright notice is included with it. SoftSurfer makes no warranty for
* this copyright notice is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage
* this code, and cannot be held liable for any real or imagined damage resulting from its use. Users of this code must verify correctness for
* resulting from its use. Users of this code must verify correctness for their application. */
* their application. /**
* * inSegment(): determine if a point is inside a segment
* inSegment(): determine if a point is inside a segment *
* Input: a point P, and a collinear segment S * @param p a point
* Return: 1 = P is inside S * @param seg_p0 starting point of segment
* 0 = P is not inside S * @param seg_p1 ending point of segment
*/ * @return 1 = P is inside S
* 0 = P is not inside S
*/
private static boolean inSegment( final Point p, final Point seg_p0, final Point seg_p1) private static boolean inSegment( final Point p, final Point seg_p0, final Point seg_p1)
{ {
final int sp0x = seg_p0.x; final int sp0x = seg_p0.x;
@ -325,20 +348,22 @@ public class OsmNogoPolygon extends OsmNodeNamed
return false; return false;
} }
/** /* Copyright 2001 softSurfer, 2012 Dan Sunday, 2018 Norbert Truchses
* Copyright 2001 softSurfer, 2012 Dan Sunday This code may be freely used and modified for any purpose providing that
* This code may be freely used and modified for any purpose providing that this copyright notice is included with it. SoftSurfer makes no warranty for
* this copyright notice is included with it. SoftSurfer makes no warranty for this code, and cannot be held liable for any real or imagined damage
* this code, and cannot be held liable for any real or imagined damage resulting from its use. Users of this code must verify correctness for
* resulting from its use. Users of this code must verify correctness for their application. */
* their application. /**
* * intersect2D_2Segments(): find the 2D intersection of 2 finite segments
* intersect2D_2Segments(): find the 2D intersection of 2 finite segments * @param s1p0 start point of segment 1
* Input: two finite segments S1 and S2 * @param s1p1 end point of segment 1
* Return: 0=disjoint (no intersect) * @param s2p0 start point of segment 2
* 1=intersect in unique point I0 * @param s2p1 end point of segment 2
* 2=overlap in segment from I0 to I1 * @return 0=disjoint (no intersect)
*/ * 1=intersect in unique point I0
* 2=overlap in segment from I0 to I1
*/
private static int intersect2D_2Segments( final Point s1p0, final Point s1p1, final Point s2p0, final Point s2p1 ) private static int intersect2D_2Segments( final Point s1p0, final Point s1p1, final Point s2p0, final Point s2p1 )
{ {
final long ux = s1p1.x - s1p0.x; // vector u = S1P1-S1P0 (segment 1) final long ux = s1p1.x - s1p0.x; // vector u = S1P1-S1P0 (segment 1)