Android examples for App:APK Information
A not super efficient mapping from a starting lat/long + a distance at a certain direction
/******************************************************************************* * Gaggle is Copyright 2010 by Geeksville Industries LLC, a California limited liability corporation. * /*from w w w.jav a 2 s .c o m*/ * Gaggle is distributed under a dual license. We've chosen this approach because within Gaggle we've used a number * of components that Geeksville Industries LLC might reuse for commercial products. Gaggle can be distributed under * either of the two licenses listed below. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Commercial Distribution License * If you would like to distribute Gaggle (or portions thereof) under a license other than * the "GNU General Public License, version 2", contact Geeksville Industries. Geeksville Industries reserves * the right to release Gaggle source code under a commercial license of its choice. * * GNU Public License, version 2 * All other distribution of Gaggle must conform to the terms of the GNU Public License, version 2. The full * text of this license is included in the Gaggle source, see assets/manual/gpl-2.0.txt. ******************************************************************************/ //package com.java2s; public class Main { /** * A not super efficient mapping from a starting lat/long + a distance at a * certain direction * * @param lat * @param longitude * @param distMeters * @param theta * in radians, 0 == north * @return an array with lat and long */ public static double[] addDistance(double lat, double longitude, double distMeters, double theta) { double dx = distMeters * Math.sin(theta); // theta measured clockwise // from due north double dy = distMeters * Math.cos(theta); // dx, dy same units as R double dLong = dx / (111320 * Math.cos(lat)); // dx, dy in meters double dLat = dy / 110540; // result in degrees long/lat return new double[] { lat + dLat, longitude + dLong }; } }