1

I am wondering if there is a simple way to manually change a android.location to be one meter away from a given bearing.

Lets say i have two locations and i get the bearing by saying:

location1.bearingTo(location2)

and i have a static distance traveled of 1 meter..

how would i go about saying:

location1 = //1 meter from location1 at bearing

I am wondering if there is a built in method for android.location that does this.. I looked and didn't see one, but maybe i am just missing it.. or if anyone can point me in the right direction for figuring out the math

erik
  • 4,946
  • 13
  • 70
  • 120
  • Have a look at my answer here http://stackoverflow.com/questions/20079536/add-distance-to-a-particular-latitude-longitude-position/20092884#20092884 – Mark Setchell Jun 23 '14 at 08:09
  • Thanks but your answer deals with north south or east west.. I'd like to go strictly by degrees – erik Jun 23 '14 at 11:31
  • The maths is here, note that 6371 is the Earth radius in km... http://www.etechpulse.com/2014/02/calculate-latitude-and-longitude-based.html – Mark Setchell Jun 23 '14 at 13:00
  • thanks don't know why i couldn't find that.. – erik Jun 23 '14 at 15:42

1 Answers1

1

There are two built-in methods that I know of:

  1. Using SphericalUtil:

SphericalUtil.computeOffsetOrigin(startLocation, distance, bearing);

  1. Using OsmDroid:

    GeoPoint startLocation = ...;

    startLocation.destinationPoint(distance, bearing);

M. Usman Khan
  • 3,689
  • 1
  • 59
  • 69