我有:
$my_location** =array(latitude,longitude);
$shop_location** =array(latitude,longitude);
$shop_distribution_circle** =10KM;
我想检查商店是否在我的位置发货。
答案 0 :(得分:0)
“A” - set /p =^""" <nul >file.txt
set /p =""^" <nul >file.txt
set /p ^"="""" <nul >file.txt
set /p "="^""" <nul >file.txt
set /p "="""^" <nul >file.txt
“B” - $my_location
您已经拥有$shop_location
和"a"
。现在,您必须计算"b"
和c
毕达哥拉斯公式:
check if C <= $shop_distribution_circle
祝你好运!
答案 1 :(得分:0)
您可以使用此套件:https://github.com/thephpleague/geotools
这是他们用来计算点之间距离的例子:
<?php
$geotools = new \League\Geotools\Geotools();
$coordA = new \League\Geotools\Coordinate\Coordinate([48.8234055, 2.3072664]);
$coordB = new \League\Geotools\Coordinate\Coordinate([43.296482, 5.36978]);
$distance = $geotools->distance()->setFrom($coordA)->setTo($coordB);
printf("%s\n",$distance->flat()); // 659166.50038742 (meters)
printf("%s\n",$distance->greatCircle()); // 659021.90812846
printf("%s\n",$distance->in('km')->haversine()); // 659.02190812846
printf("%s\n",$distance->in('mi')->vincenty()); // 409.05330679648
printf("%s\n",$distance->in('ft')->flat()); // 2162619.7519272