/** * Method to calculate the distance to a waypoint * * @param dest lat, lon * @return distance to waypoint in Rad */ public double getDistanceRad(double latDecD, double lonDecD) { double phi1 = this.latDec * PiOver180; double lambda0 = this.lonDec * PiOver180; double phi = latDecD * PiOver180; double lambda = lonDecD * PiOver180; double pdiff = Math.sin(((phi - phi1) / 2.0)); double ldiff = Math.sin((lambda - lambda0) / 2.0); double rval = Math.sqrt((pdiff * pdiff) + Math.cos(phi1) * Math.cos(phi) * (ldiff * ldiff)); return 2.0 * Math.asin(rval); }
/** * shift the point * * @param meters positiv to north (east), negativ to south (west) * @param direction 0 north-south, 1 east-west */ public void shift(double meters, int direction) { double meters2deglon = 1 / (1000 * (new CWPoint(0, 0)).getDistance(new CWPoint(1, 0))); switch (direction) { // TODO use ellipsoid distance calculations for better accuracy case 0: latDec += meters * meters2deglon; return; case 1: lonDec += meters * (meters2deglon / Math.cos(latDec / 180 * Math.PI)); return; } }