0

这是我的数学:

$range = 0.43218;
$this->location['longitude'] = -78.852972745895;
$this->location['latitude'] = 42.879424080703;

$minlong = $this->location['longitude']-$range;
$maxlong = $this->location['longitude']+$range;
$minlat = $this->location['latitude']-$range;
$maxlat = $this->location['latitude']+$range;

但我最终得到了这个:

$minlong = -79.285152745895;
$maxlong = -78.420792745895;
$minlat = 42.447244080703;
$maxlat = 43.311604080703;

我试图最终得到两个原始纬度和经度之间的范围,任何人都可以帮助我计算数学。我整天都在处理数字,他们正在杀死我!

4

1 回答 1

1

找到我的答案,好像我只需要翻转它们

if($this->location['longitude'] < 0){ /* Flip if negative */
    $minlong = $this->location['longitude']+$range;
    $maxlong = $this->location['longitude']-$range;
}else{
    $minlong = $this->location['longitude']-$range;
    $maxlong = $this->location['longitude']+$range;
}
if($this->location['latitude'] < 0){ /* Flip if negative */
    $minlat = $this->location['latitude']+$range;
    $maxlat = $this->location['latitude']-$range;
}else{
    $minlat = $this->location['latitude']-$range;
    $maxlat = $this->location['latitude']+$range;
}
于 2013-07-26T21:40:59.820 回答