/** * Function to calculate the area of a, according to the algorithm * defined at http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ * * @param polyLatLongs * array of LatLongs in the polygon * @return area of the polygon defined by pgLatLongs */ public static double GetArea( LatLong[] polyLatLongs) int i, j, n = polyLatLongs.Length; double area = 0; for (i = 0; i < n; i++) j = (i + 1) % n; area += polyLatLongs[i].X * polyLatLongs[j].Y; area -= polyLatLongs[j].X * polyLatLongs[i].Y; area /= 2.0; return (area ); /** * Function to calculate the center of mass for confirmed polygon, according * ot the algorithm defined at * http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ * * @param polyLatLongs * array of LatLongs in the polygon * @return LatLong that's the center of mass */ public static LatLong centerOfMass( LatLong[] polyLatLongs) {double cx = 0, cy = 0; double area = GetArea( polyLatLongs ); // might change this to LatLong2D.Float if you like to make use of less storage int i, j, n = polyLatLongs.Length; double factor = 0; for (i = 0; i < n; i++) j = (i + 1) % cx,cy );