No local government shall exercise any of its powers to enact local laws or ordinances within an agricultural area in a manner which would unreasonably restrict or regulate farm structures or farming practices in contravention of the purposes of this Act unless such restrictions or regulations bear a direct relationship to the public health or safety.
505 ILCS 5/18