bearing and coordinate calculations

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
o2fill
Forum Newbie
Posts: 2
Joined: Thu Sep 24, 2009 9:24 pm

bearing and coordinate calculations

Post 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
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: bearing and coordinate calculations

Post by josh »

User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: bearing and coordinate calculations

Post by onion2k »

Great circle only does distances, not bearings, and Vincenty is much more accurate.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: bearing and coordinate calculations

Post by josh »

Would arc-tangent get the job done?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: bearing and coordinate calculations

Post 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
o2fill
Forum Newbie
Posts: 2
Joined: Thu Sep 24, 2009 9:24 pm

Re: bearing and coordinate calculations

Post 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
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: bearing and coordinate calculations

Post by josh »

Cool
Post Reply