diff --git a/src/App/Search.php b/src/App/Search.php index 820b439..8542ec8 100644 --- a/src/App/Search.php +++ b/src/App/Search.php @@ -44,18 +44,13 @@ final class Search $whereParts[] = implode(' AND ', $conditions); } - $sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng"; + $sql = "SELECT id, title, teaser_public, description, city, region, zip, starts_at, visibility, allow_kids, location_label, lat, lng, 30 AS distance_km"; $distanceFiltering = false; if ($hasGeo) { $lat = (float)$geo['lat']; $lng = (float)$geo['lng']; $radius = isset($geo['radius']) && is_numeric($geo['radius']) ? max(0.1, (float)$geo['radius']) : 5.0; - $sql .= ", - (6371 * ACOS(LEAST(1, - COS(RADIANS(?)) * COS(RADIANS(lat)) * COS(RADIANS(lng) - RADIANS(?)) + - SIN(RADIANS(?)) * SIN(RADIANS(lat)) - ))) AS distance_km"; $distanceFiltering = true; $latRange = $radius / 111.0; @@ -63,9 +58,6 @@ final class Search $whereParts[] = "(lat IS NOT NULL AND lng IS NOT NULL)"; $whereParts[] = "(lat BETWEEN ? AND ?)"; $whereParts[] = "(lng BETWEEN ? AND ?)"; - $bind[] = $lat; - $bind[] = $lng; - $bind[] = $lat; $bind[] = $lat - $latRange; $bind[] = $lat + $latRange; $bind[] = $lng - $lngRange;