The technology detects scheduled-service vehicles using a model generated based on onboard beacon location data. A trajectory of the onboard beacon may be determined by correlating the beacon detection data with the location data of the detecting devices. The trajectory may be analyzed to derive features of the beacon trajectory that correlate with a periodic motion typical of scheduled-service vehicles. Such features may be used to train a machine capable of learning patterns from data to generate a model that classifies whether a beacon trajectory is that of a scheduled-service vehicle. Various beacon trajectories may be classified by the generated model as either a scheduled-service vehicle or not. Once certain beacons are identified as onboard scheduled-service vehicles, further trajectory data may be gathered on such beacons to map out accurate public-transit routes and schedules, as well as to provide real-time locations and changes to routes and schedules.