Interface to Indian Railways(part 2)
import train_of_thought as tot
tot.see_train_route(14006)
We can see that the coordinates we got for Nayagaon and Bhagwanpur are wrong but the distance from source is correct. This is often the case and thus we can use the distance from source to find whether the coordinates for a particular station are wrong. The way we do it is by calculating the haversine distance between coordinates of consecutive stations and comparing that with the distance between them calculated using distance from source:
tot.see_corrected_train_route(14006)
The same fault tolerance is also available for live running status:
tot.see_corrected_live_train_status(14006, "14-08-2017")
Handling False Positives
Sometimes while removing locations with wrong coordinates our algorithm might end up removing a few locations with correct coordinates too. In that case we can jump in and override its decisions:
tot.see_train_route(19019)
Well, the above route is a mess, let's try and clean it up:
tot.see_corrected_train_route(19019)
The only two false positives in this case are Keshorai Patan(KPTN) and Lakheri(LKE) and we can override the algorithm's decision to not include them in the map:
tot.see_corrected_train_route(19019, override = ("LKE", "KPTN"))
The same works for live running status too:
tot.see_corrected_live_train_status(19019, "14-08-2017", override = ("LKE", "KPTN"))