Jump to content

[SOLVED] Coordinate conversion


hellouthere

Recommended Posts

Hi all,

    I need a function that will convert a latitude/longditue stored in the variable $position in the format "N50 43.9122 W3 25.6329" to two seperate coordinates $lat and $long which can be read by the google maps api... http://www.google.com/apis/maps/documentation/

 

thats all the information i have... Thanks in advance...

Link to comment
https://forums.phpfreaks.com/topic/41022-solved-coordinate-conversion/
Share on other sites

o may be mising omething but that still leaves the problem of not having acces to the 50 seperately... i have trried using barands "explode with the /60 but the coordinates are not "corrrect" as it were ;) not sure whether its actually possible...

 

i have woprked out that the coordinate that i need from the above example are... lng="-3.427215" lat="50.73187"

 

the function needs to seperate the N50 from the 43.9122... DONE

divide the 43.9122 by 60... DONE

add the 50 (from the N50)... ???

work out whether the final rersult is + or - based on the W/E (W is negative i think)... ???

 

hmm im lost

do you mean

 

<?php

$position = "N50 43.9122 W3 25.6329";

list ($n, $latmin, $w, $longmin) = explode (' ', $position);

printf ('%s, %d, %f<br>', $n{0}, substr($n,1), $latmin);
printf ('%s, %d, %f<br>', $w{0}, substr($w,1), $longmin);

?>

 

-->[pre]

N, 50, 43.912200

W, 3, 25.632900

[/pre]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.