use the compass heading and compare it with the bearing from your current 
location to the building. Here's the formula in Objective-C but you 
shouldn't have problems to convert this to Java

//spherical bearing between two coordinates
- (CGFloat) sphericalBearingFromLat1:(CGFloat)lat1 Lon1:(CGFloat)lon1 
toLat2:(CGFloat)lat2 Lon2:(CGFloat)lon2 {
    lat1 *= 0.0174533; 
    lat2 *= 0.0174533;
    float dLon = (lon2-lon1) * 0.0174533;
    float brng = 57.29578 * atan2(sin(dLon) * cos(lat2), 
                                  cos(lat1) * sin(lat2) - sin(lat1) * 
cos(lat2) * cos(dLon));
    if(brng <= 0.0f) brng += 360.0f;
    return brng;
}
 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to