Section 77. No railroad or part thereof which is operated by steam power shall be located or constructed within three miles of the state house without the previous written consent of the department, and of the board of aldermen of any city or of the selectmen of any town where the location is sought.