def get_stops(): ''' The initial query to set up the stop db ''' all_stops = DB_Stop.query.all() all_ids = [stop.id for stop in all_stops] url = "http://www.swu.de/fileadmin/gtfs/stops.txt" req = requests.get(url) req.encoding = "utf-8" text = req.text.split("\n")[1:] for line in text: # start in line 35 to exlclude stops in Poland if len(line) > 1: Stop = VBB_Stop(line) if Stop.stop_id not in all_ids and int(Stop.ismainstation) != 0: feedback = Stop.is_in_osm() if feedback > 0: print_success(Stop.name + ": " + str(feedback)) else: print_failure(Stop.name + ": 0") new_stop = DB_Stop( name=Stop.name, lat=Stop.lat, lon=Stop.lon, matches=feedback, vbb_id=Stop.stop_id ) db.session.add(new_stop) db.session.commit()
def get_stops(): ''' The initial query to set up the stop db ''' url = "http://datenfragen.de/openvbb/GTFS_VBB_Okt2012/stops.txt" req = requests.get(url) text = req.text.split("\n")[1:] for line in text: if len(line) > 1: Stop = VBB_Stop(line) if "(Berlin)" in Stop.name: feedback = Stop.is_in_osm() if feedback > 0: print_success(Stop.name + ": " + str(feedback)) else: print_failure(Stop.name + ": 0") new_stop = DB_Stop( name = Stop.name, lat = Stop.lat, lon = Stop.lon, matches = feedback, vbb_id = Stop.stop_id ) db.session.add(new_stop) db.session.commit()