|
@@ -718,7 +718,7 @@ class ApiController extends BaseController
|
|
|
public function getGuiji(){
|
|
|
$result['status'] = true;
|
|
|
$result['msg'] = ApiEnum::RETURN_SUCCESS;
|
|
|
- $result['data'] = [];
|
|
|
+ $list1 = [];
|
|
|
|
|
|
$date = Input::get('date', '');
|
|
|
$depart = Input::get('depart', '');
|
|
@@ -738,11 +738,31 @@ class ApiController extends BaseController
|
|
|
|
|
|
if(count($list) > 0){
|
|
|
for($i=0;$i<count($list);$i++){
|
|
|
- $result['data'][$i]['lat'] = $list[$i]->lat;
|
|
|
- $result['data'][$i]['lng'] = $list[$i]->lng;
|
|
|
+ $list1[$i]['lat'] = $list[$i]->lat;
|
|
|
+ $list1[$i]['lng'] = $list[$i]->lng;
|
|
|
+ $list1[$i]['title'] = $list[$i]->xjqy;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //去重
|
|
|
+ $serialized = array_map('serialize', $list1);
|
|
|
+ $unique = array_unique($serialized);
|
|
|
+ $list2 = array_map('unserialize', $unique);
|
|
|
+
|
|
|
+ //取中心点
|
|
|
+ $total = array_reduce($list2, function($carry, $item) {
|
|
|
+ $carry['lat'] += (float)$item['lat'];
|
|
|
+ $carry['lng'] += (float)$item['lng'];
|
|
|
+ return $carry;
|
|
|
+ }, ['lat' => 0, 'lng' => 0]);
|
|
|
+ $avgLat = $total['lat'] / count($list2);
|
|
|
+ $avgLng = $total['lng'] / count($list2);
|
|
|
+
|
|
|
+ $result['list1'] = $list1;
|
|
|
+ $result['list2'] = $list1;
|
|
|
+ $result['lat'] = $avgLat;
|
|
|
+ $result['lng'] = $avgLng;
|
|
|
+
|
|
|
return self::successResponse($result);
|
|
|
}
|
|
|
|