views:

32

answers:

2

Hi,

I'm trying to figure out how to calculate a min/max lat/long bound on the specific given range of a gps coordinate.

for example: gps coord 37.42935699924869,-122.16962099075317 range .2 miles

I'm looking at the point + range + bearing in the http://www.movable-type.co.uk/scripts/latlong.html site but im not sure if this is exactly what i want.

This gives 4 unique lat/long pairs and I want/need a max/min lat and a max/min long.

Sweet, thanks!

A: 
  1. Calculate the distance between the (constant) central point and the point you want to test. (This page should give you the distance (in meters)).
  2. If (distance < 0.2) then ...

Well, given a point and a distance, you will get a circle.

You're looking for two points, which will essentially describe a square (two opposite corners). The two points you're looking for won't even be on the circle. I'm not exactly sure why you want this, but I don't think there is an answer to your question.

Perhaps you could tell us what you're trying to accomplish.

EDIT: Added image to illustrate. The orange line is the distance from the centre (e.g. 0.2 miles)

alt text

Turtle
yeah im trying to find all of the locations inside a bounding circle which i am approximating by the bounding square. Which formula should i use to account for the earth curvature (or does that even matter at such small distances) ie. 100 ft - 10 mi
N V
and by "find all of the locations" I mean that I have a list of gps location coordinates
N V
I updated my answer, I think it now answers your question.
Turtle
The whole difficulty is that i don't have a second point i want to test, and that I need to figure out the gps coordinates of the lat/long of the bounding box. Rather than calculating the distance formula to every point in the database, im calculating the lat / long and comparing that directly with lat/long fields in the database indexed to make the query as fast as possible. If you know any other method which is better than the way im trying, please let me know and ill gladly try. So the issue right now is that I'm not sure how to compute the min / max lat/long values
N V
Haversine Formula for distance over the earth.
dbasnett
A: 

After your clarification, here is a less elegant answer that might give you what you want. Well, you want the inverse of a really complicated function. I'm afraid my math skills aren't up to the task, but it should be doable.

A less elegant solution is to find it by trial and error. Essentially, keep longitude the same and vary latitude. Using the right algorithm, you should be able to find one that is very close to the distance you want. This will give you a point on the circle (one of four that is also on the square).

Then keep latitude the same and vary longitude. This will give you a second point on the square (on the middle of one of the sides), from there you can find the 4 corners of the square.

This will slow, depending on how often you have to do it, that might or might not matter.

Turtle