Planimeter.java 992 Bytes
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/**
 * A test program for the GeographicLib.PolygonArea class
 **********************************************************************/

import java.util.*;
import net.sf.geographiclib.*;
/**
 * Compute the area of a geodesic polygon.
 *
 * This program reads lines with lat, lon for each vertex of a polygon.  At the
 * end of input, the program prints the number of vertices, the perimeter of
 * the polygon and its area (for the WGS84 ellipsoid).
 **********************************************************************/
public class Planimeter {
  public static void main(String[] args) {
    PolygonArea p = new PolygonArea(Geodesic.WGS84, false);
    try {
      Scanner in = new Scanner(System.in);
      while (true) {
        double lat = in.nextDouble(), lon = in.nextDouble();
        p.AddPoint(lat, lon);
      }
    }
    catch (Exception e) {}
    PolygonResult r = p.Compute();
    System.out.println(r.num + " " + r.perimeter + " " + r.area);
  }
}