public Point2D shiftTo ( final double DISTANCE , final double ANGLE ) { final double EARTH_RADIUS = 6371000.0 ; // m final double LON1 = Math . toRadians ( this . lon ) ; final double LAT1 = Math . toRadians ( this . lat ) ; final double LAT2 = Math . asin ( Math . sin ( LAT1 ) * Math . cos ( DISTANCE / EARTH_RADIUS ) + Math . cos ( LAT1 ) * Math . sin ( DISTANCE / EARTH_RADIUS ) * Math . cos ( Math . toRadians ( ANGLE ) ) ) ; final double LON2 = LON1 + Math . atan2 ( Math . sin ( Math . toRadians ( ANGLE ) ) * Math . sin ( DISTANCE / EARTH_RADIUS ) * Math . cos ( LAT1 ) , Math . cos ( DISTANCE / EARTH_RADIUS ) - Math . sin ( LAT1 ) * Math . sin ( LAT2 ) ) ; final double LON2_CORRECTED = ( LON2 + 3 * Math . PI ) % ( 2 * Math . PI ) - Math . PI ; //normalise to -180...+180 setLocation ( Math . toDegrees ( LAT2 ) , Math . toDegrees ( LON2_CORRECTED ) ) ; return getLocation ( ) ; }
Moves the poi to the position defined by the given distance and angle