问题描述:

I am searching for a solution in Android to check whether a GPS point will lie in given set of Start and End GPS location or not. For Example Mr A will start from point X and will reach point Z via Y. Now if Mr B given a location P then we want to check whether this point P is lying on the Mr A's route or not.

If it appears that GPS is not sufficient for it then you can suggest any other ways as well.

I am looking forward to hear back from you!!

I am assuming that "Given Set of Starting and Ending" means you have one defined root in your Database. My answer is based on same purpose. Have a look at to following method,

```
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();
}
```

Now you need to compare your Mr A's lat-lon values with the DB's one by one. If you the distance is few meters that means Mr A has visited that point. Using this logic you need to check all the GPS Point of Mr A with the root stored in your DB.

您可能感兴趣的文章：

- Meteor verification, enrollment, etc. email via 3rd party mailer
- python - Change icon in a Matplotlib figure window
- r - How to split a url
- algorithm - How to average multiple images using Octave and matrix manipulation to reduce noise?
- search - Detecting duplicate lines on file using c
- php - Reading a specific line from a text file
- clr - Any implementation of an Unrolled Linked List in C#?
- Finding Hudson Log Files
- Forward to a payment-gateway together with POST data using cURL (or any other PHP server side solution)
- WCF in Winforms app - is it always single-threaded?

随机阅读：

**推荐内容**-

**热点内容**-
- php - Reading a specific line from a text file
- clr - Any implementation of an Unrolled Linked List in C#?
- Finding Hudson Log Files
- Forward to a payment-gateway together with POST data using cURL (or any other PHP server side solution)
- WCF in Winforms app - is it always single-threaded?
- git svn - git svn fetch does not fetch a Subversion commit message modified after initial clone
- java me - Why I am getting the bad length exception when I am running this application?
- java - How to get string.format to complain at compile time
- ruby on rails - Trigger observer of parent class on change
- python - Issue with URL pattern in Django with webmonkey tutorial