Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

 Subscribe to receive our newsletter. Subscribe Unsubscribe

## Need help with formula.

This is a discussion on Need help with formula. within the MapPoint Desktop Discussion forums, part of the Map Forums category; I have a gps system that fails to report speed and direction about 1 in 5 times. The positions average ...

1. Member Yellow Belt
Join Date
Dec 2004
Posts
41

## Need help with formula.

I have a gps system that fails to report speed and direction about 1 in 5 times. The positions average about 2-3 minutes apart butI still get the lat/lon.

I think that I can infer the probable speed and direction by looking at how far the unit traveled and where the unit is, in relation to the last fix. I am writing in VBA.

Does someone know a easy way to get bearing between 2 waypoints?

My program will probably look like this.

Check to se if position fix reports speed and direction at zero.
Is the fix less than 10 minutes since previous fix (accuracy of inference issue)
Is the fix more than 1 mile from the previous fix. (The unit may actually be stopped)

Then the unit is probably in motion or at the end of a route and I will calculate the time between fixes and the distance between fixes and devide out the speed. I will also get the bearing of the current fix from the previous fix and infer a direction.

Otherwise if the unit is close to where it was at the previous fix then I will guess that it is actually stopped.

Can someone help me with the bearing issue or is there a an easy Mappoint funtion that I am missing?

2. Senior Member Black Belt
Join Date
Nov 2004
Location
Belgium
Posts
2,433

## Re: Need help with formula.

Hi,

Before "helping" first some information:

A GPS receiver must have a view to minimum 4 satellites (needed for position). Their may be only less satellites in view. Note the the frequency is in a high range and there must be a 'visible view' from the antenna to the satellites.

Because of this each GPS receiver ahs a dead recogning. When it does not have GPS is 'assumes' it has by calculating the points it "should" be if last speed and direction did not changed. When this happens the GPS receiver does not give you speed and direction. Seems exacly what you have.

This be says you can as well take last speed because it is a 'assumption' and the position is also. Note that you can set dead recogning to zero also. I'm not sure abouth the name.

3. Member Yellow Belt
Join Date
Dec 2004
Posts
41

## Re: Need help with formula.

Thanks;

The GPS is actually a Nextel cellphone, and is without DR perameters to set. I think I am stuck with the lapses in speed and direction. I found some trig on the net some time ago that allow me to calculate the distance between 2 la/lon points and I can fall back on that if there is not an easy way to get distance between 2 points in MapPoint. But I can not find anything that will allow me to get a bearing from one point to another.

4. Senior Member Black Belt
Join Date
Nov 2004
Location
Belgium
Posts
2,433

## Re: Need help with formula.

Hi,

This is an example in C, returning distance and bearing between 2 points. It is working example from one of my boardcomputers:

Code:
```u_16 get_bearing(double lat1, double lon1, double lat2, double lon2, u_32* miles)
{
double lat  = lat2 - lat1;
double lon  = (lon2 - lon1) * cos(deg2rad((lat1 + lat2) / 2));
double dist = hypot(lat, lon);
double bear = rad2deg(acos(lat / dist));

if (nv->par.km)
*miles = (u_32)(dist * 60 * 10 * 1.852);
else
*miles = (u_32)(dist * 60 * 10 * 1.852 / 1.609);

if (lon < 0)	// Western direction
bear = 360 - bear;
return bear;
}```

5. Member Yellow Belt
Join Date
Dec 2004
Posts
41

## Re: Need help with formula.

I write in VBA and I think that I can get this to work.

Thank you very much

#### Thread Information

##### Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•