Re: Coordenates latitude / longitude on PHP - SOLVED
| From: | Ruben Rubio Rey | Date: | Fri, 03 Mar 2006 09:00:42 +0000 |
| Subject: | Re: Coordenates latitude / longitude on PHP - SOLVED | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231396@lists.php.net to get a copy of this message | ||
It wasn't so hard!
I ll post the solution, so everyone ll be able to do it
function getlocationcoords($lat, $lon, $width, $height)
{
$lat=$lat*20; $lon=$lon*28; $x = (($lon + 180) * ($width / 360)); $y = ((($lat * -1) + 90) * ($height / 180));
return array("x"=>round($x),"y"=>round($y+3500));
}
$lat -> Latitude
$lon -> Longitude
$width -> Image's width (Where u are going to represent the data)
$height -> Image's height (Where u are going to represent the data)
This is the zoom of the data
$lat=$lat*20; $lon=$lon*28; If the data is lo flat (for example), u can fix it writting bigger values on the data that is multiplying.
$x = (($lon + 180) * ($width / 360)); $y = ((($lat * -1) + 90) * ($height / 180));
This translates lat / lon to cardinal data. I found it on the net.
return array("x"=>round($x+VALUEONE),"y"=>round($y+3500));
If u puts the rights values on VALUEONE or 3500, u will be able to center the coordenates on the image.
Done!
:)
By Tk421