No railroad company or rail center shall allow the whistle of any locomotive engine to be sounded within the city, except as may be required by state or federal law, rule or regulation, or absolutely necessary to prevent injury to person or property.