panliang 2024-06-12 15:39:42 +08:00
parent de5c209399
commit 67ab53ba94
3 changed files with 14 additions and 16 deletions

View File

@ -80,12 +80,12 @@ class SignController extends Controller
$lon = $request->input('lon'); $lon = $request->input('lon');
$lat = $request->input('lat'); $lat = $request->input('lat');
// 切换坐标系 // 切换坐标系
$locationType = $request->input('location_type', 'wgs84'); // $locationType = $request->input('location_type', 'wgs84');
if ($locationType == 'wgs84') { // if ($locationType == 'wgs84') {
$res = wgs84ToGcj02($lat, $lon); // $res = wgs84ToGcj02($lat, $lon);
$lon = $res['lon']; // $lon = $res['lon'];
$lat = $res['lat']; // $lat = $res['lat'];
} // }
// 计算距离 // 计算距离
$distance = $service->haversineDistance( $distance = $service->haversineDistance(
$lat, $lat,
@ -142,12 +142,12 @@ class SignController extends Controller
$lon = $request->input('position.lon'); $lon = $request->input('position.lon');
$lat = $request->input('position.lat'); $lat = $request->input('position.lat');
// 切换坐标系 // 切换坐标系
$locationType = $request->input('position.location_type', 'wgs84'); // $locationType = $request->input('position.location_type', 'wgs84');
if ($locationType == 'wgs84') { // if ($locationType == 'wgs84') {
$res = wgs84ToGcj02($lat, $lon); // $res = wgs84ToGcj02($lat, $lon);
$lon = $res['lon']; // $lon = $res['lon'];
$lat = $res['lat']; // $lat = $res['lat'];
} // }
$distance = $service->haversineDistance( $distance = $service->haversineDistance(
$lat, $lat,
$lon, $lon,

View File

@ -12,8 +12,6 @@ class ExampleTest extends TestCase
*/ */
public function test_the_application_returns_a_successful_response(): void public function test_the_application_returns_a_successful_response(): void
{ {
$response = $this->get('/'); dump(wgs84ToGcj02('29.421605', '106.524698'));
// $response->assertStatus(200);
} }
} }

View File

@ -11,6 +11,6 @@ class ExampleTest extends TestCase
*/ */
public function test_that_true_is_true(): void public function test_that_true_is_true(): void
{ {
dump(round(2.6666, 2, PHP_ROUND_HALF_DOWN)); $this->assertTrue(true);
} }
} }