I need to calculate the direction between two geolocation points (lat and log defined). I don’t really need the entire angle (I found something like this), but only N, NE, E, SE, S, SW, W, NW is fine.
Any help is appreciated
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use Location.bearingTo ( http://developer.android.com/reference/android/location/Location.html#bearingTo%28android.location.Location%29 )
Create 2 location objects from your points, and you can get a precise bearing. Then you simply compare it to the 8 values. (like between -22.5 and +22.5 it’s N, until 67.5 it’s NE, until 112.5 it’s E, and so on)