Every railroad company heretofore or hereafter incorporated which has, by the building of its road, or otherwise, obstructed, or shall hereafter obstruct, any state or county-district road, shall, as far as possible, put the road so obstructed in as good condition as it was in before the obstruction. Every railroad company which has changed, or shall hereafter change, the grade or location of any state or county-district road, shall put the same in as good condition and repair, and on as practical a grade, as such road was before its change; and if such road, after construction, becomes damaged or injured or is caused to be damaged or injured by reason of the construction of any railroad, such railroad company shall be liable for all damages occasioned thereby and for all costs incurred in repairing and keeping in repair the road so damaged or injured as aforesaid.