更新
This commit is contained in:
parent
0ad0213870
commit
aa548966b5
@ -13,7 +13,7 @@ use Symfony\Component\HttpClient\HttpClient;
|
||||
|
||||
class CeshiController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['index','ceshi'];
|
||||
public array $notNeedLogin = ['index','ceshi','ceshi1'];
|
||||
|
||||
public function index()
|
||||
{
|
||||
@ -41,33 +41,23 @@ class CeshiController extends BaseApiController
|
||||
}
|
||||
}
|
||||
|
||||
function getClosestPoint($points, $target) {
|
||||
$minDistance = PHP_INT_MAX;
|
||||
$closestPoint = null;
|
||||
foreach ($points as $point) {
|
||||
// halt($point,$target);
|
||||
$distance = sqrt(pow(($point['lat'] - $target['lat']), 2) + pow(($point['lon'] - $target['lon']), 2));
|
||||
|
||||
if ($distance < $minDistance) {
|
||||
$minDistance = $distance;
|
||||
$closestPoint = $point;
|
||||
public function ceshi1(){
|
||||
$params=[
|
||||
'car_id'=>3,
|
||||
'start_time'=>'2023-08-18',
|
||||
'end_time'=>'2023-08-18 23:59:59'
|
||||
];
|
||||
$task=Task::where('id',485)->select()->toArray();
|
||||
foreach($task as $k=>$v){
|
||||
if(isset($v['extend']['terminus']['lnglat'])){
|
||||
$arr=$v['extend']['terminus']['lnglat'];
|
||||
app(RemoteController::class)->coordinate($params,$arr[0],$arr[1]);
|
||||
}
|
||||
if(isset($v['extend']['transfer']['lnglat'])){
|
||||
$arr=$v['extend']['transfer']['lnglat'];
|
||||
app(RemoteController::class)->coordinate($params,$arr[0],$arr[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return [$closestPoint,$distance];
|
||||
}
|
||||
|
||||
function calculateDistance( $longitude1,$latitude1, $longitude2,$latitude2 ) {
|
||||
$earthRadius = 6371; // 地球半径,单位为公里
|
||||
|
||||
$dLat = deg2rad($latitude2 - $latitude1);
|
||||
$dLon = deg2rad($longitude2 - $longitude1);
|
||||
|
||||
$a = sin($dLat/2) * sin($dLat/2) +
|
||||
cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) *
|
||||
sin($dLon/2) * sin($dLon/2);
|
||||
$c = 2 * asin(sqrt($a));
|
||||
|
||||
return $earthRadius * $c*1000;
|
||||
}
|
||||
}
|
@ -17,6 +17,7 @@ namespace app\common\model;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\dict\DictData;
|
||||
use think\facade\Db;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
/**
|
||||
* Company模型
|
||||
@ -25,6 +26,9 @@ use think\facade\Db;
|
||||
*/
|
||||
class Company extends BaseModel
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
protected $name = 'company';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user