Page 1 of 1

Longitude and Latitude Calculations

Posted: Wed Oct 08, 2008 6:50 am
by john_mcc1983
I was wondering if anyone could help me with Longitude and Latitude calculations.

What I am trying to do is see if a longitude and latitude supplied by a user falls within a pre-defined circular area (unfortunately it has to be circular, it would have been easy working with a rectangular area)

The information I have is:

- The centre point (longitude and latitude) of the circular area and the radius of the area in miles. (stored in database)
- User supplied longitude and latitude co-ordinates (supplied via web site)

I am new to working with longitude and latitudes and not really sure where to start.

Any help would be greatly appreciated.

Thanks and regards

John

Re: Longitude and Latitude Calculations

Posted: Wed Oct 08, 2008 1:58 pm
by koen.h
This should help.

Image

No seriously, looking at wikipedia it seems like it's not that simple. Maybe you could try using the google maps api.

Re: Longitude and Latitude Calculations

Posted: Wed Oct 08, 2008 3:55 pm
by visu
Do some googling for 'haversine', 'haversine formula' and 'haversine distance', there's implementations for php/mysql/any other language you can think of.

Another alternative is the mysql spatial extension, never used it but seen it recommended by others, http://dev.mysql.com/doc/refman/5.0/en/ ... sions.html