Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
colombus
Posts: 264
Registered: ‎06-04-2009
My Device: Not Specified

Suggestion for calculating the distance which is the best option

Hi

 

I have a requirement to calculate the distance travelled by the user. I have gone through the forum and I found there are 2 ways of doing it.

1) Using GPS to get the latitiude & longitude and using the Haversine formula to get the distance

2) Using the accelerometer to find the number of steps and calculate the distance.

 

Please comment on which one will be more accurate . This application will be used daily basis and it will be used to track the running on a circular track. Is there any example available on how to use the accelerometer to use as a pedometer.

Please suggest.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Suggestion for calculating the distance which is the best option

no experience with the second one, i would suggest GPS, it's fairly accurate most of the time.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Eugen
Posts: 467
Registered: ‎07-16-2009
My Device: Z10 LE

Re: Suggestion for calculating the distance which is the best option

For the second one. I could imagine that you could count steps, but what about step distance. Tall people have bigger steps than short one. And if you run they should be bigger then you just walking. I'm not sure that you have this measurment from accelerometer.

Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Suggestion for calculating the distance which is the best option

[ Edited ]

Can I just comment that I think you will have problems using GPS to track someone round a small circular track.  Two reasons:

a) There is a fair amount of what I call jitter with GPS locations, in other words, even standing still, the phone can get GPS locations that suggest it is moving

b) There can be a fair degree of error in the readings anyway, so I think you will struggle to determine exactly when the user gets back to the starting point.

 

By small here I am talking about a standard athletics track.   If you are doing a 10 K circular route GPS will be fine. 

 

Like Simon, I have never looked at using the accelerometer to measure steps. 

 

Edit:

Note that the class Coordinates includes a distance claculation.  So if you have two Coordinates, you can easily find the distance between them. 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Suggestion for calculating the distance which is the best option

in my experience the gps display on google maps, for example, is quite accurate.
they have an algorithm that checks the coordinates for validity for sure, when developing a tracking solution i sometimes got results a few 100m off that would have required a speed of 5000km/h, if you filter these you should be fine.

of course there are limits, but if you display the number of satellites used and maybe how many results were inaccurate by your filter the user can see for himself if it is good.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: Suggestion for calculating the distance which is the best option

[ Edited ]

I agree with Simon's points having also worked on a tracking solution. You can watch for things like dramatic changes in height that suggest the location is dodgy. 

 

But I still suspect that in a small area, like an athletics track, you will have problems accurately measuring the distance.

 

As an example of this, I remember a presentation at one of the DevCons where the presenters had been to a ball game and tried to use GPS to find their location.  They basically took 10 locations, removed outliers, and then averaged.  It was fairly close to their seats but not exactly on it.  And they were sitting still.  In your case, 10 readings each say 2 seconds apart will give you a scatter gun of locations and I think you will struggle to determine which is the accurate path through these values and hence the accurate distance.

 

This is not a problem with BlackBerry specifically.  You might find this interesting reading.

https://discussions.apple.com/thread/3688762?start=0&tstart=0

I was interested to see that one of the Posters in this Thread dismisses accelerometers as a viable way to do this.

 

One further minor point.  If you start doing this, you will need to run the GPS hot (i.e. get locations every 10 seconds or less), which does have an impact on the battery life too.  Tracking all day will kill the battery, 20 minutes or should be fine.