MaheshValu
MaheshValu

Reputation: 101

Variation in GPS data being at same location

In my application, I have calculated speed based on GPS locations.

As GPS receiver can have different coordinates even being on the same location, my app is recording speed even when phone is on my desk.

I need to avoid GPS data if I am receiving it being on same location.

I am thinking of adding some logic based on “bearing”, so that I can decide if the phone is actually moving or it’s receiving jumpy location data from any direction.

Before that I would like to know is there any other way to avoid this kind of data?

Upvotes: 0

Views: 491

Answers (2)

MaheshValu
MaheshValu

Reputation: 101

After working on many methods I programmed it with bearing.

I am getting speed based on last 5 locations. I added Logic to check bearing for each location with next location and if all bearing have larger difference, I assumed locations are being received from random directions and so the device is not actually moving.

And it worked great for me :)

Upvotes: 0

Praful Bhatnagar
Praful Bhatnagar

Reputation: 7435

AS per the Javadoc for the method request public void requestLocationUpdates (long minTime, float minDistance, Criteria criteria, PendingIntent intent) found here

minTime minimum time interval between location updates, in milliseconds minDistance
minimum distance between location updates, in meters

so you can use minDistance parameter to avoid getting update for very short distances...

Upvotes: 1

Related Questions