Пример #1
0
  public static double distancia(RegistroGPS p, RegistroGPS q) {
    // instantiate the calculator
    GeodeticCalculator geoCalc = new GeodeticCalculator();

    // select a reference elllipsoid
    Ellipsoid reference = Ellipsoid.WGS84;

    // set origin coordinates
    GlobalCoordinates origin;
    origin = new GlobalCoordinates(p.getLatitud(), p.getLongitud());

    // set destination coordinates
    GlobalCoordinates destination;
    destination = new GlobalCoordinates(q.getLatitud(), q.getLongitud());

    // calculate the geodetic curve
    GeodeticCurve geoCurve = geoCalc.calculateGeodeticCurve(reference, origin, destination);
    return geoCurve.getEllipsoidalDistance();
  }