这是我的数学:
$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;
我试图以两个原始纬度和经度之间的范围结束,任何人都可以帮我解决数学问题。我一直在和数字一起工作,他们正在杀了我!
答案 0 :(得分: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;
}