<div>
<br>
Rogier (and David too :)  This is quite exciting.  Based on this, I think I can formulate something.  Thank you for making me understand.<br><br>have a great day !! ~~<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>----- Original Message -----<br>
From: "Rogier Wolff" <r.e.wolff@bitwizard.nl><br>
To: "Fire Girl" <firegirl@amorous.com><br>
Subject: Re: [OSM-dev] Question about Calculating Radius from GPS cord<br>
Date: Fri, 8 Aug 2008 21:41:52 +0200<br>
<br>
<br>
On Fri, Aug 08, 2008 at 11:02:15AM -0500, Fire Girl wrote:<br>
>  I think I am following you! :)<br>
><br>
> Here is the math I have so far....<br>
><br>
> Calculation: 5 miles<br>
<br>
I'm assuming radius, not diameter. So we'll get a ~10mile square.<br>
<br>
> of: 45.5 latitude<br>
> and: 25.5 longitude<br>
<br>
Note that Milo thinks this is inaccurate. He's right. But these<br>
"quick" calculations are very efficient. If for example, you want to<br>
select all OSM objects within 5 miles distance from a certain<br>
coordinate, you damn well better do THIS math first, and only then use<br>
proper geo-valid formulas to select the real ones.<br>
<br>
The reason is that if you put all objects in the database through the<br>
"calculate-distance-to-reference-point" formula, this will take ages,<br>
but selecting on a 10 mile min longitude / max longitude and min<br>
latitude max latitude first will be fast: There should be an index<br>
on those elements of the database.<br>
<br>
Now for some applications, the "quick-n-dirty" method is already good<br>
enough.<br>
<br>
So.... here we go.<br>
<br>
kmpermile = 1.609;<br>
circumferencekm = 40000;<br>
circumferencemile =  circumferencekm / kmpermile;<br>
<br>
radius = 5; // Miles!<br>
latitude = 45.5;  // North<br>
longitude = 25.5; // east!<br>
<br>
delta = radius / (circumferencemile / 360);<br>
<br>
latmin = latitude - delta;<br>
latmax = latitude + delta;<br>
<br>
longmin = longitude - delta / cos (latitude);<br>
longmax = longitude + delta / cos (latitude);<br>
<br>
which according to my calculator comes to:<br>
<br>
latmin  = 45.42759500000000000000<br>
latmax  = 45.57240500000000000000<br>
longmin = 25.39669848650172993913<br>
longmax = 25.60330151349827006087<br>
<br>
Apparently the cosine changes by about 1 in 776 on this 5 mile stretch<br>
of earth. So this square is only about 9.987 miles wide at the north<br>
end, and 10.013 miles wide a the south end.<br>
<br>
Similar differences can be expected to crop up because the earth is<br>
not a perfect sphere.<br>
<br>
        Roger.<br>
<br>
<br>
<br>
<br>
><br>
> -------------------------------<br>
><br>
> so, for the latitude, (i.e. add and subtract 2.5/69ths of a degree of<br>
> latitude)<br>
><br>
> With 5 miles assumed, and using that forumla, the distance from 45.5<br>
> would be:<br>
><br>
> 45.505797 (on the plus side)<br>
> 45.494203 (on the minus side)<br>
><br>
> Right? :)<br>
><br>
><br>
> but on the Longitude side, (i.e. 2.5/f) .... f = 69 * sin(latitude)<br>
><br>
> .... i am not so clear what Latitude number I should be using there and<br>
> what that might look like. How do I look at least so far in my <br>
> calculations? :)   ----- Original Message -----<br>
>   From: "David Earl"<br>
>   To: "Fire Girl"<br>
>   Subject: Re: [OSM-dev] Question about Calculating Radius from GPS<br>
>   cord<br>
>   Date: Fri, 08 Aug 2008 16:02:10 +0100<br>
><br>
><br>
>   On 08/08/2008 14:30, Fire Girl wrote:<br>
>   > I am working with OSM data, and would like to be able to spec out<br>
>   > 5 mile bounding boxes from certain GPS points.<br>
>   ><br>
>   > After research into this problem, I am to understand that each<br>
>   > degree of latitude is approximately 69 miles (111 kilometers)<br>
>   > apart with a slight variance (68.703 - 69.407 miles) between the<br>
>   > equator and the poles, and that each degree of longitude is<br>
>   > widest at the equator @ 69.172 miles (111.321 kilometers) and<br>
>   > gradually shrinks to zero at the poles. : ) :)<br>
>   ><br>
>   > So what does this mean? If I want to take a input point, like lets<br>
>   say,<br>
>   ><br>
>   > 167.9 lat<br>
>   > -29.1 lon<br>
>   ><br>
>   > or<br>
>   ><br>
>   > -63.1<br>
>   > 18.1<br>
>   ><br>
>   > Can someone say with authority, what the 'calculus' would be to<br>
>   > definitivly construct a NSWE bounding box with a 5 mile radius<br>
>   > around those points?.... that would be basically close enough or<br>
>   > accurate? :)<br>
><br>
><br>
>   If you want accuracy, then you are asking the wrong question,<br>
>   because the "bounding box" will be a curved section of a surface of<br>
>   the earth (or, rather, the approximation to it defined by the<br>
>   ellipsoid for the datum you're using for the lat/lon coordinates -<br>
>   unless you want to start taking altitude and terrain into account),<br>
>   not a flat straight-edged box. So if you want to talk in terms of<br>
>   flat bounding boxes, you have to start asking "in what projection?"<br>
>   etc.<br>
><br>
>   If all you want is the lat/lon of the corners an approximate box<br>
>   parallel to lines of latitude and longitude approx 5 miles across,<br>
>   then<br>
>   you could indeed just add and subtract 2.5/69ths of a degree of<br>
>   latitude and 2.5/f of a degree of longitude, where f is the approx<br>
>   length of one degree at that latitude, i.e. f = 69 * sin(latitude)<br>
>   miles (with the reasonable approximation that the earth is a<br>
>   sphere, so the trigonometry is trivial).<br>
><br>
>   David<br>
><br>
> -- Be Yourself @ mail.com!<br>
> Choose From 200+ Email Addresses<br>
> Get a Free Account at www.mail.com<br>
><br>
<br>
> _______________________________________________<br>
> dev mailing list<br>
> dev@openstreetmap.org<br>
> http://lists.openstreetmap.org/listinfo/dev<br>
<br>
<br>
--<br>
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2600998 **<br>
**    Delftechpark 26 2628 XH  Delft, The Netherlands. KVK: 27239233    **<br>
*-- BitWizard writes Linux device drivers for any device you may have! --*<br>
Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous statement.<br>
Does it sit on the couch all day? Is it unemployed? Please be specific!<br>
Define 'it' and what it isn't doing. --------- Adapted from lxrbot FAQ<br>
</firegirl@amorous.com></r.e.wolff@bitwizard.nl></blockquote>
</div>
<BR>

-- 
<div> Be Yourself @ mail.com!<br>
Choose From 200+ Email Addresses<br>
Get a <b>Free</b> Account at <a href="http://www.mail.com/Product.aspx" target="_blank">www.mail.com</a>!</div>