'failure', 'message' => 'Missing required parameters (passenger_id, lat, lng).']); exit; } try { $engine = new LocationIntelligenceEngine($con); $newGeofences = $engine->processLocationUpdate($passengerId, $lat, $lng, $source, $batteryLevel); // Respond with success and optionally new geofences echo json_encode([ 'status' => 'success', 'message' => 'Location synced successfully', 'update_geofences' => $newGeofences // App can use this array to update device geofencing regions ]); } catch (Exception $e) { error_log("[sync_location.php] Error: " . $e->getMessage()); http_response_code(500); echo json_encode(['status' => 'failure', 'message' => 'Internal server error.']); } ?>