I am working on an Android app that uses the GPS. I would like to know if there is a way I can throw out GPS Location data if the "new location" (point C) is too far away from line segment AB. I am using the Point to Line Segment formula found on Wikipedia.
So far, the code I have is returning NaN when I try to use Latitude and Longitude coordinates.
private void verifyGPSLocation(Location start, Location end, Location current){
final double errorValue = 0.0000216;
double normalLength = Math.hypot(end.getLatitude() - start.getLatitude(), end.getLongitude() - start.getLongitude());
double ret = Math.abs(((current.getLatitude() - start.getLatitude()) * (end.getLongitude() - start.getLongitude()) - (end.getLatitude() - start.getLatitude()))/normalLength );
Log.e("Coooooord", normalLength+"--"+ret);
}
This is my first post so please let me know if I have not done this correctly or with enough information. Thanks for your help, I love this site!