Project.php
1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace addons\inspection\service;
class Project
{
public $model;
public function __construct()
{
}
function checkDistance($lng1, $lat1, $lng2, $lat2) {
// 将角度转为狐度
$radLat1 = deg2rad($lat1); //deg2rad()函数将角度转换为弧度
$radLat2 = deg2rad($lat2);
$radLng1 = deg2rad($lng1);
$radLng2 = deg2rad($lng2);
$a = $radLat1 - $radLat2;
$b = $radLng1 - $radLng2;
$s = 2 * asin(sqrt(pow(sin($a / 2), 2) + cos($radLat1) * cos($radLat2) * pow(sin($b / 2), 2))) * 6378.137 * 1000;
return $s;
}
public function getProjectInfo($where){
$projectModel = new \app\admin\model\inspection\Project();
$data = $projectModel
->alias("project")
->field("project.id,project.plan_id,project.route_id,project.checktime,project.images,project.content,plan.time,site.lnglat,site.verify,site.distance,project.status,project.state,project.begintime,project.endtime,project.area_site_id,site.verify,site.site_name")
->join("inspection_plan plan","project.plan_id=plan.id")
->join("inspection_area_site site","project.area_site_id=site.id")
->where($where)
->find();
if($data){
return $data;
}
return false;
}
}