@@ -92,7 +92,7 @@ public class GPSCoordinate {
/**
* Calculates min and max values and passed it to calculate if coordinate is in the boundary
* @param coordinate coordinate of interest
* @param boundary List of points which make a boundry
* @param boundary List of points which make a bounda ry
* @return true if coordinate is in the boundary
*/
public static boolean isInsideBoundary ( GPSCoordinate coordinate , List < GPSCoordinate > boundary ) {
@@ -139,7 +139,7 @@ public class GPSCoordinate {
/**
* Helper function to find if a point is in a boundary
* @param boundaryA The first coordinate of the boundary.
* @param boundaryB The second coordinate of the bounary.
* @param boundaryB The second coordinate of the bound ary.
* @param coordinate The coordinate to test.
* @return true if a line from the point intersects the two boundary points
*/
@@ -307,7 +307,7 @@ public class GPSCoordinate {
List < Pair < GPSCoordinate , GPSCoordinate > > shrunkEdges = new ArrayList < > ( ) ;
//We need to invert some of our opert ations depending if the boundary is clockwise or anti-clockwise.
//We need to invert some of our operations depending if the boundary is clockwise or anti-clockwise.
boolean isClockwise = GPSCoordinate . isClockwisePolygon ( boundary ) ;
double clockwiseScaleFactor = 0 ;
@@ -318,8 +318,8 @@ public class GPSCoordinate {
}
/**
* Starting at a vertex, face anti-clockwise along an adjacent edge.
/*
Starting at a vertex, face anti-clockwise along an adjacent edge.
Replace the edge with a new, parallel edge placed at distance d to the "left" of the old one.
Repeat for all edges.
Find the intersections of the new edges to get the new vertices.
@@ -337,11 +337,11 @@ public class GPSCoordinate {
Bearing bearing = GPSCoordinate . calculateBearing ( firstPoint , secondPoint ) ;
//Calculate angle perpendicular to bearing.
Bearing perpindicularBearing = Bearing . fromDegrees ( bearing . degrees ( ) + ( 90d * clockwiseScaleFactor ) ) ;
Bearing perpendicularBearing = Bearing . fromDegrees ( bearing . degrees ( ) + ( 90d * clockwiseScaleFactor ) ) ;
//Translate both first and second point by 50m, using this bearing. These form our inwards shifted edge.
GPSCoordinate firstPointTranslated = GPSCoordinate . calculateNewPosition ( firstPoint , shrinkDistance , Azimuth . fromBearing ( perpindicularBearing ) ) ;
GPSCoordinate secondPointTranslated = GPSCoordinate . calculateNewPosition ( secondPoint , shrinkDistance , Azimuth . fromBearing ( perpindicularBearing ) ) ;
GPSCoordinate firstPointTranslated = GPSCoordinate . calculateNewPosition ( firstPoint , shrinkDistance , Azimuth . fromBearing ( perpendicularBearing ) ) ;
GPSCoordinate secondPointTranslated = GPSCoordinate . calculateNewPosition ( secondPoint , shrinkDistance , Azimuth . fromBearing ( perpendicularBearing ) ) ;
//Add edge to list.
shrunkEdges . add ( new Pair < > ( firstPointTranslated , secondPointTranslated ) ) ;
@@ -357,11 +357,11 @@ public class GPSCoordinate {
Bearing bearing = GPSCoordinate . calculateBearing ( firstPoint , secondPoint ) ;
//Calculate angle perpendicular to bearing.
Bearing perpindicularBearing = Bearing . fromDegrees ( bearing . degrees ( ) + ( 90d * clockwiseScaleFactor ) ) ;
Bearing perpendicularBearing = Bearing . fromDegrees ( bearing . degrees ( ) + ( 90d * clockwiseScaleFactor ) ) ;
//Translate both first and second point by 50m, using this bearing. These form our inwards shifted edge.
GPSCoordinate firstPointTranslated = GPSCoordinate . calculateNewPosition ( firstPoint , shrinkDistance , Azimuth . fromBearing ( perpindicularBearing ) ) ;
GPSCoordinate secondPointTranslated = GPSCoordinate . calculateNewPosition ( secondPoint , shrinkDistance , Azimuth . fromBearing ( perpindicularBearing ) ) ;
GPSCoordinate firstPointTranslated = GPSCoordinate . calculateNewPosition ( firstPoint , shrinkDistance , Azimuth . fromBearing ( perpendicularBearing ) ) ;
GPSCoordinate secondPointTranslated = GPSCoordinate . calculateNewPosition ( secondPoint , shrinkDistance , Azimuth . fromBearing ( perpendicularBearing ) ) ;
//Add edge to list.
shrunkEdges . add ( new Pair < > ( firstPointTranslated , secondPointTranslated ) ) ;
@@ -460,13 +460,13 @@ public class GPSCoordinate {
/**
* Determines if a list of coordinates describes a boundary polygon in clockwise or anti-clockwise order.
* @param boundary The list of coodinates.
* @param boundary The list of coor dinates.
* @return True if clockwise, false if anti-clockwise.
*/
public static boolean isClockwisePolygon ( List < GPSCoordinate > boundary ) {
/** From https://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
* sum all pairs (x2 − x1)(y2 + y1)
/* From https://stackoverflow.com/questions/1165647/how-to-determine-if-a-list-of-polygon-points-are-in-clockwise-order
sum all pairs (x2 − x1)(y2 + y1)
point[0] = (5,0) edge[0]: (6-5)(4+0) = 4
point[1] = (6,4) edge[1]: (4-6)(5+4) = -18
point[2] = (4,5) edge[2]: (1-4)(5+5) = -30