Btw. I'm using Lumen I have a table of events which have a LAT and a LNG each. Then I want to deliver these events with the distance to an user with LAT and LNG rounded by 12 digits.
$lat and $lng are the two parameters i get from the user:
Event::select(DB::raw('ROUND((6371 * acos( cos( radians('.$lat.') ) * cos( radians( events.lat ) ) * cos( radians( events.lng ) - radians('.$lng.') ) + sin( radians('.$lat.') ) * sin( radians( events.lat ) ) ) ),12) AS distance'));
For example: An Event has the LAT 48.4 and the LNG 16.4 and the user has the LAT 48.27040239999999 and the LNG 14.52828969999996 that would result in following query:
select ROUND((6371 * acos( cos( radians(48.27040239999999) ) * cos( radians( events.lat ) ) * cos( radians( events.lng ) - radians(14.52828969999996) ) + sin( radians(48.27040239999999) ) * sin( radians( events.lat ) ) ) ),12) AS distance from events;
result: 139.100262465025
But if I execute the Eloquent Statement from above with exact same parameters:
result: 139.10026246502
Anyone had a similar issue?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community