How to determine whether the GPS point will lie in a given set of GPS start and end locations?

I am looking for a solution on Android to check whether the GPS point will lie in a given set of GPS start and end locations or not. As an example, Mr. A starts at point X and reaches point Z through Y. Now, if Mr B has given location P, we want to check whether this point P lies on Mr A. or not.

If it turns out that GPS is not enough for this, you can also suggest any other methods.

I look forward to hearing from you.

+5
source share
1 answer

, "Given Set of Starting and Ending" , . . ,

public static float getDistance (float lat1, float lng1, float lat2, float lng2 ) 
{
    double earthRadius = 3958.75;
    double dLat = Math.toRadians(lat2-lat1);
    double dLng = Math.toRadians(lng2-lng1);
    double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
    Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) *
    Math.sin(dLng/2) * Math.sin(dLng/2);
    double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
    double dist = earthRadius * c;

    int meterConversion = 1609;

    return new Float(dist * meterConversion).floatValue();
}

lat-l Mr DB . , , - . . , GPS - , .

0

All Articles