The precision machining of the rail base for high-speed Magnetically Levitated Trains (MAGLEV) is the precondition for laying the high-quality whole rail and accomplishing the integrative performance test of the train. A new method is advanced to improving the machining precision in this paper. The X and Y coordinates of the cross centers on the rail base for MAGLEV will be obtained through two raster displacement sensors which are perpendicular to each other. So the machining datum position of the rail will be determined. According to the spatial position relationship between the straight movement error of the guideway on the numerical control machine tools and the central line of the rail base for MAGLEV, error compensation will be made to improve the machining precision in the process of the numerical control machining. The mechanism design theory of the measuring system is presented in this paper. On basis of both the design theory and the software platform of LabWindows/CVI, the virtual measurement system for measuring straight movement error of the rail on the numerical control machine tool, which is used to machining the rail base for MAGLEV will be established.