Page 1 of 1

bearing and coordinate calculations

Posted: Thu Sep 24, 2009 9:28 pm
by o2fill
Hi,

Does anyone know of a php library for handling map coordinates?

I'm trying to calculate the bearing to a coordinate2 (with a longitude and latitude in degrees) given coordinate1. Then I would like to calculate a third coordinate 'n' km from coordinate 1 on that bearing.

If anyone can point me to php source code or a library that might simplify things, I would greatly appreciate it.

Thanks in advance,

Phil

Re: bearing and coordinate calculations

Posted: Fri Sep 25, 2009 1:23 am
by josh

Re: bearing and coordinate calculations

Posted: Fri Sep 25, 2009 3:00 am
by onion2k
Great circle only does distances, not bearings, and Vincenty is much more accurate.

Re: bearing and coordinate calculations

Posted: Fri Sep 25, 2009 4:38 am
by josh
Would arc-tangent get the job done?

Re: bearing and coordinate calculations

Posted: Fri Sep 25, 2009 5:06 am
by onion2k
Yes.. or strictly speaking atan2 in coding. It's arctan with extras.

This page will give you all the code you need.. you'll just need to port it from Javascript into PHP: http://www.movable-type.co.uk/scripts/latlong.html

Re: bearing and coordinate calculations

Posted: Sat Sep 26, 2009 3:41 pm
by o2fill
Thanks for the moveable type link. it is just what I need. I note that it uses a three part modulus function. The mod function in php appears tO have just two arguments. Does anyone know how to replicate this method in php? If not, I'll develop a method and post it here.

Best,

phil

Re: bearing and coordinate calculations

Posted: Sat Sep 26, 2009 10:08 pm
by josh
Cool