
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.