Depends on how you run. If you plot your GPS positions on a map you
will notice they jump around a little bit. Generally GPS accuracy is
in the 5 to 15 meter range. That can mean quite a zig zag especially
considering you are running slow.

So what you could do is some track smoothing/averaging over let's say
five positions. That would however introduce an error if you come to a
violent halt at an obstacle, or get hit by another runner from the
side, or just run around a corner.

Get a better GPS receiver with built in tracking.

On Mar 8, 10:28 am, fwaokda <[email protected]> wrote:
> I'm trying to learn new things and decided as a project to make an
> application for recording data from running.  I've got a rough
> calculation of my distance on runs, but am trying to get it more
> accurate.  I was hoping someone might have some ideas.  Right now I'm
> simply accepting gps fixes and then using the distance formula on the
> fixes in a sequential order to determine how far I've ran.  I'm hoping
> however to get the distance more accurate and save battery life.  If
> anyone has any idea on how I can improve the method I'm using now I
> would love to discuss it.
>
>                                         public void 
> onLocationChanged(Location location) {
>                                                 if(location != null) {
>                                                         if(gpsLats.size() >= 
> 1) {
>
>                                                                 //add new gps 
> info to List
>                                                                 
> gpsLats.add(location.getLatitude());
>                                                                 
> gpsLongs.add(location.getLongitude());
>
>                                                                 //create new 
> location and store previous gps coordinates
>                                                                 Location loc 
> = new Location(location);
>                                                                 
> loc.setLatitude(gpsLats.get(gpsLats.size()-2));
>                                                                 
> loc.setLongitude(gpsLongs.get(gpsLats.size()-2));
>
>                                                                 //find 
> distance traveled
>                                                                 tmpDistance 
> += loc.distanceTo(location)*0.000621371192;
>
>                                                         } else {
>
>                                                                 // add first 
> gps coordinates to List and append to list
>                                                                 
> gpsLats.add(location.getLatitude());
>                                                                 
> gpsLongs.add(location.getLongitude());
>
>                                                         }
>
>                                                 } else {
>                                                         mSB.append("Location 
> can not be found!");
>                                                 }
>
>                                                 tv2.setText("Distance: " + 
> Double.toString(tmpDistance) + "
> miles");
>                                                 tv.setText(mSB.toString());
>
>                                         }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to