proj - PHP Map projections -
i have googled myself death.. attempting write 2 php functions return x , y lat , long, in both mercator , flat non-projected (grid) maps. problem being every calculation have ran across assumes map(s) has same lat , lon @ corners, , result in meters. ugh
here have .. maps of different sizes, different lat's, long's @ 4 corners. downloaded proj4 php port, 0 documentation , more code need, on whelmed ...
help !!
this presumes lat/long coords decimal values, , don't change direction north/south or east/west within visible range of map. if do, such values should kept single format, , made negativel (eg: 1.0 s become -1.0 n)
first you'd set following variables, either finding them php or if know them in script:
$width=//width of image $height=//height of image $long_at_left=//longitude of left-hand coordinates $long_at_right=//longitude of right-hand coordinates $lat_at_left=//latitude of left-hand coordinates $lat_at_right=//latitude of right-hand coordinates $target_long=//longitude want find $target_lat=//latitude want find then use:
$xtarget=$target_long-$long_at_left; $ytarget=$target_lat-$lat_at_top; $xdist=$long_at_left-$long_at_right; $ydist=$lat_at_top-$lat_at_bottom; $x=round(($xtarget/$xdist)*$width); //percentage of distance times width $y=round(($ytarget/$ydist)*$height); //percentage of distance times height or of form should trick.
Comments
Post a Comment