Пример #1
0
  /**
   * *
   *
   * @param gc1 GPS coordinate
   * @param gc2 GPS coordinate
   * @return the distance between two gps coordinates
   */
  public static double getGPSDelta(GlobalCoordinates gc1, GlobalCoordinates gc2) {
    if (geoCalc == null) {
      geoCalc = new GeodeticCalculator();
    }

    GeodeticCurve geoCurve = geoCalc.calculateGeodeticCurve(reference, gc1, gc2);

    return geoCurve.getEllipsoidalDistance() / 1000000.0;
  }
Пример #2
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();
  }