0

私は自分自身をググって死にました..メルカトルと平らな非投影(グリッド)マップの両方で、緯度と経度からXとYを返す2つのphp関数を書き込もうとしています。問題は、私が遭遇したすべての計算で、マップの隅に同じ緯度と経度があり、結果がメートル単位であると想定していることです。うーん

これが私が持っているものです..さまざまなサイズ、さまざまな緯度、経度の地図が4隅にあります。Proj4 php ポートをダウンロードしましたが、ドキュメントがなく、必要以上のコードがあり、圧倒されました...

ヘルプ !!

4

2 に答える 2

0

これは、緯度/経度座標が 10 進値であり、マップの可視範囲内で北/南または東/西から方向を変えないことを前提としています。その場合、そのような値は単一の形式に維持し、負にする必要があります (例: 1.0 S は -1.0 N になります)。

最初に、次の変数を設定します。PHP でそれらを見つけるか、スクリプトで既にわかっている場合は、次の変数を設定します。

$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 you want to find
$target_lat=//Latitude you want to find

次に使用します。

$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

または、その形式の何かがうまくいくはずです。

于 2012-06-04T20:54:54.190 に答える