4
나는 Laravel 5.1에서 네거비 상점을 얻으려고합니다. 좌표 계산 도구 인 지오 코딩 파서가 있습니다. 하지만 haversine 수식에 문제가 있습니다. 기본적으로 나는 표 Aziende (점포)에서 위도, 경도 URL을 통과 한 긴 전자 카테고리, 주변 상점을 가져 와서 주어진 필요합니다.근처 상점에서 Laravel
는이 코드로 시도 : 당신은 SQL 쿼리의 하버 사인 공식을 구현하기 위해
$dove = Input::get('dove');
$categoria_id = Input::get('id_categoria');
// 4: check if any matches found in the database table
if (!empty($dove)) {
$response = \GoogleMaps::load('geocoding')->setParamByKey ('address', $dove)->get();
$response = json_decode($response, true);
$latitude = $response['results'][0]['geometry']['location']['lat'];
$longitude = $response['results'][0]['geometry']['location']['lng'];
$radius = '5';
$aziende = DB::table('aziende')
->select(
('lat * acos(cos(radians(50)) * cos(radians(lat)) * cos(radians(lng) - radians(-122))
+ sin(radians(37)) * sin(radians(lat))) as distance'))->get();
} else {
$aziende = DB::table("aziende")->where('categoria', $categoria_id)->get();
}
?>
어떤 데이터베이스/버전을 사용하고 있습니까? MySQL을 사용한다면 ST_Distance ... v5.7은 ST_Distance_Sphere가 있습니다 https://dev.mysql.com/doc/refman/5.7/en/spatial-convenience-functions.html – jcorry