When two or more railroad companies have two or more tracks of the same gauge in the same street, alley, public way, or opening through a municipal corporation, the legislative authority of such municipal corporation may require such companies to use such tracks in common and to pass their locomotives and cars over each track in one direction only.