Map Matching with Train Data

Given some GPS positions along a rail track, how could I do map matching for that given the assumption that the vehicle moves on the rails? I have seen [1] as a readable collection of vehicles implemented so far which are in the same directory, e.g. for a bike [2]. Is there anything else to consider? Have you heard of somebody who has already implemented such a thing?