Database
(1)
Louisiana
(1)
Lakewood
(1)
Avenue
(1)
Lon
(1)
Lat
(1)
Approximates
(1)
Longitude
(1)

GPS and finding

Asked By James hotmail
12-Nov-09 08:33 AM
Hello All,

I am playing with a GPS application. I have a database of gps positions and
would like to know how you go about matching these records with the current
position. An exact match is not good enough. Also, having the ability to
show/update the user on status - your 5 blocks away, 4,3,2 and 1 block away.
Lastly, provide some guidance, like "Head North", "Head East" etc.

Is there a good book or website that discussing this type of math?


-James

Hi,I simply truncate the current Lat/Lon values, as read from my GPS device

DickGrier replied to James hotmail
13-Nov-09 12:02 AM
Hi,

I simply truncate the current Lat/Lon values, as read from my GPS device to
some number of digits past the decimal places and use the SQL Like statement
to return a dataset that corresponds with them.

Here is some simple math that approximates distance.  Since "blocks" are not
of fixed-size (some are 10 to the mile, but there is not a pure standard),
I am not sure how useful trying to state something in blocks might be.

Approximate distance in miles:

sqrt(x * x + y * y)

where x = 69.1 * (lat2 - lat1)
and y = 53.0 * (lon2 - lon1)

You can improve the accuracy of this approximate distance calculation by
adding the cosine math function:

Improved approximate distance in miles:

sqrt(x * x + y * y)

where x = 69.1 * (lat2 - lat1)
and y = 69.1 * (lon2 - lon1) * cos(lat1/57.3)

Make sure you convert the latitude and longitude values from degrees to
radians. Trigonometric math functions such as sine and cosine normally
require conversion of degrees to radians, as described above.

You can use some very simply comparison of the target Lat and Lon, with the
current Lat and Lon to say, "North, South, East, West."  If the target Lat
is greater than the current, then head north, if less then head south; if
the target Lon is greater than the current, then head west, and if less,
then head east.  Now, the math work is almost done for you.  The legs of the
triangle that you calculate above are the actual distances
north/south/east/west (as needed).

Dick

--
Richard Grier, Consultant, Hard & Software 12962 West Louisiana Avenue
Lakewood, CO 80228 303-986-2179 (voice) Homepage: www.hardandsoftware.net
Author of Visual Basic Programmer's Guide to Serial Communications, 4th
Edition ISBN 1-890422-28-2 (391 pages) published July 2004, Revised July
2006.

Thanks Dick,That's a good point, not all blocks are the same size.

James hotmail replied to DickGrier
12-Nov-09 09:23 PM
Thanks Dick,
That's a good point, not all blocks are the same size. Providing directions
like North, South etc. will be descent... adding an approximate distance
will be helpful, more of a gauge or 'rule of thumb'.

-James
Post Question To EggHeadCafe