[OSM-dev] Question about Calculating Radius from GPS cord

Fire Girl firegirl at amorous.com
Sat Aug 9 03:03:50 BST 2008


Rogier (and David too :)  This is quite exciting.  Based on this, I think
I can formulate something.  Thank you for making me understand.

have a great day !! ~~


  ----- Original Message -----
  From: "Rogier Wolff"
  To: "Fire Girl"
  Subject: Re: [OSM-dev] Question about Calculating Radius from GPS
  cord
  Date: Fri, 8 Aug 2008 21:41:52 +0200


  On Fri, Aug 08, 2008 at 11:02:15AM -0500, Fire Girl wrote:
  > I think I am following you! :)
  >
  > Here is the math I have so far....
  >
  > Calculation: 5 miles

  I'm assuming radius, not diameter. So we'll get a ~10mile square.

  > of: 45.5 latitude
  > and: 25.5 longitude

  Note that Milo thinks this is inaccurate. He's right. But these
  "quick" calculations are very efficient. If for example, you want to
  select all OSM objects within 5 miles distance from a certain
  coordinate, you damn well better do THIS math first, and only then
  use
  proper geo-valid formulas to select the real ones.

  The reason is that if you put all objects in the database through the
  "calculate-distance-to-reference-point" formula, this will take ages,
  but selecting on a 10 mile min longitude / max longitude and min
  latitude max latitude first will be fast: There should be an index
  on those elements of the database.

  Now for some applications, the "quick-n-dirty" method is already good
  enough.

  So.... here we go.

  kmpermile = 1.609;
  circumferencekm = 40000;
  circumferencemile = circumferencekm / kmpermile;

  radius = 5; // Miles!
  latitude = 45.5; // North
  longitude = 25.5; // east!

  delta = radius / (circumferencemile / 360);

  latmin = latitude - delta;
  latmax = latitude + delta;

  longmin = longitude - delta / cos (latitude);
  longmax = longitude + delta / cos (latitude);

  which according to my calculator comes to:

  latmin = 45.42759500000000000000
  latmax = 45.57240500000000000000
  longmin = 25.39669848650172993913
  longmax = 25.60330151349827006087

  Apparently the cosine changes by about 1 in 776 on this 5 mile
  stretch
  of earth. So this square is only about 9.987 miles wide at the north
  end, and 10.013 miles wide a the south end.

  Similar differences can be expected to crop up because the earth is
  not a perfect sphere.

  Roger.




  >
  > -------------------------------
  >
  > so, for the latitude, (i.e. add and subtract 2.5/69ths of a degree
  of
  > latitude)
  >
  > With 5 miles assumed, and using that forumla, the distance from
  45.5
  > would be:
  >
  > 45.505797 (on the plus side)
  > 45.494203 (on the minus side)
  >
  > Right? :)
  >
  >
  > but on the Longitude side, (i.e. 2.5/f) .... f = 69 * sin(latitude)
  >
  > .... i am not so clear what Latitude number I should be using there
  and
  > what that might look like. How do I look at least so far in my
  > calculations? :) ----- Original Message -----
  > From: "David Earl"
  > To: "Fire Girl"
  > Subject: Re: [OSM-dev] Question about Calculating Radius from GPS
  > cord
  > Date: Fri, 08 Aug 2008 16:02:10 +0100
  >
  >
  > On 08/08/2008 14:30, Fire Girl wrote:
  > > I am working with OSM data, and would like to be able to spec out
  > > 5 mile bounding boxes from certain GPS points.
  > >
  > > After research into this problem, I am to understand that each
  > > degree of latitude is approximately 69 miles (111 kilometers)
  > > apart with a slight variance (68.703 - 69.407 miles) between the
  > > equator and the poles, and that each degree of longitude is
  > > widest at the equator @ 69.172 miles (111.321 kilometers) and
  > > gradually shrinks to zero at the poles. : ) :)
  > >
  > > So what does this mean? If I want to take a input point, like
  lets
  > say,
  > >
  > > 167.9 lat
  > > -29.1 lon
  > >
  > > or
  > >
  > > -63.1
  > > 18.1
  > >
  > > Can someone say with authority, what the 'calculus' would be to
  > > definitivly construct a NSWE bounding box with a 5 mile radius
  > > around those points?.... that would be basically close enough or
  > > accurate? :)
  >
  >
  > If you want accuracy, then you are asking the wrong question,
  > because the "bounding box" will be a curved section of a surface of
  > the earth (or, rather, the approximation to it defined by the
  > ellipsoid for the datum you're using for the lat/lon coordinates -
  > unless you want to start taking altitude and terrain into account),
  > not a flat straight-edged box. So if you want to talk in terms of
  > flat bounding boxes, you have to start asking "in what projection?"
  > etc.
  >
  > If all you want is the lat/lon of the corners an approximate box
  > parallel to lines of latitude and longitude approx 5 miles across,
  > then
  > you could indeed just add and subtract 2.5/69ths of a degree of
  > latitude and 2.5/f of a degree of longitude, where f is the approx
  > length of one degree at that latitude, i.e. f = 69 * sin(latitude)
  > miles (with the reasonable approximation that the earth is a
  > sphere, so the trigonometry is trivial).
  >
  > David
  >
  > -- Be Yourself @ mail.com!
  > Choose From 200+ Email Addresses
  > Get a Free Account at www.mail.com
  >

  > _______________________________________________
  > dev mailing list
  > dev at openstreetmap.org
  > http://lists.openstreetmap.org/listinfo/dev


  --
  ** R.E.Wolff at BitWizard.nl ** http://www.BitWizard.nl/ **
  +31-15-2600998 **
  ** Delftechpark 26 2628 XH Delft, The Netherlands. KVK: 27239233 **
  *-- BitWizard writes Linux device drivers for any device you may
  have! --*
  Q: It doesn't work. A: Look buddy, doesn't work is an ambiguous
  statement.
  Does it sit on the couch all day? Is it unemployed? Please be
  specific!
  Define 'it' and what it isn't doing. --------- Adapted from lxrbot
  FAQ

-- 
Be Yourself @ mail.com!
Choose From 200+ Email Addresses
Get a Free Account at www.mail.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20080808/16255fc4/attachment.html>


More information about the dev mailing list