Beispiel #1
0
def create_stops():
	'''
	Create stops objects
	:return list: List of created stops
	'''
	list_stops = list()
	stops = set()
	for file in data_file_name:
		list_stop = elements(file, 'regular_path').split(' + ')
		for s in list_stop:
			s = s.split(' N ')
			for e in s:
				stops.add(e)

	#FORK
	for stop in stops:
		if stop == 'Vernod':
			right_stop = Stop('LYCÉE_DE_POISY')
			left_stop = Stop('POISY_COLLÈGE')
			s = Stop(stop)
			s.set_left_stop(left_stop)
			s.set_right_stop(right_stop)

			list_stops.append(s)
			list_stops.append(left_stop)
			list_stops.append(right_stop)

		elif stop != 'LYCÉE_DE_POISY' and stop != 'POISY_COLLÈGE':
			list_stops.append(Stop(stop))

	return list_stops
Beispiel #2
0
    def test_calculate_walking_time_from_starting_position(self):
        expectedValue = 0

        stop = Stop(-36.854134, 174.767841)
        actualValue = self.user.calculate_walking_time(stop)

        self.assertEqual(expectedValue, actualValue)
def main():
    print("starting")

    user = User(-36.854134, 174.767841)
    stop = Stop(-36.843574, 174.766931)

    print(user.calculate_walking_time(stop))
Beispiel #4
0
  def open_stops_file(self, file_name):
    logging.info("Opening stops file: %s" % file_name)

    # Get the stops number, name, poss and max capacity
    with open(file_name, newline='') as csvfile:
      reader = csv.DictReader(csvfile)
      # Get stop first columns
      for row in reader:
        stop = Stop(int(row['stop_number']), row['stop_name'],
                    int(row['x_pos']), int(row['y_pos']), int(row['max_capacity']))
        self.stops_list.append(stop)
        globalConstants.stops_name_to_num[row['stop_name']] = int(row['stop_number'])

    # Get stop destination vector
    with open(file_name, newline='') as csvfile:
      reader = csv.DictReader(csvfile)
      # Rows have the destinations of the stop users
      for row in reader:
        i = int(row['stop_number'])
        for stop in self.stops_list:
          self.stops_list[i].destination_vector[stop.number] = int(row[stop.name])
          self.stops_list[stop.number].expected_alight_pass += int(row[stop.name])

    # Calculate total pass in and input queue
    for stop in self.stops_list:
      stop.calculate_total_pass_in()
      stop.generate_pass_input_queue()
Beispiel #5
0
def startup():
    for i, (r, direction) in enumerate(ROUTES):
        stop, route = mbta_api.get_nearest_stop(r, direction)

        s = Stop(
            mbta_api=mbta_api,
            route_id=route["id"],
            direction_name=route["attributes"]["direction_destinations"]
            [direction],
            stop_id=stop["id"],
            stop_name=stop["attributes"]["name"],
        )

        STOPS.append(s)
        DISPLAYS.append(RouteDisplay(group=group, stop=s, i=i))

    for s in STOPS:
        s.load_predictions()

    for s in STOPS:
        print(s.route_id, s.stop_name)

        for t in s.predictions:
            print(t)

        print()
Beispiel #6
0
 def add_stop(self, station):
     """
     Add stop to the trip
     :param station: add the station to the stops
     :return: Void
     """
     self.stops.append(Stop(station))
Beispiel #7
0
    def test_calculate_distance_from_stop_at_starting_position(self):
        stop = Stop(-36.854134, 174.767841)

        distance = self.user.calculate_distance_from_stop(stop)

        self.assertEqual(distance, self.user.distance)

        self.assertEqual(distance, 0)
Beispiel #8
0
def getAndroclickObject(objectType):
    if objectType == BUS:
        return Bus()
    elif objectType == STOP:
        return Stop()
    elif objectType == RESPONSE:
        return Response()
    else:
        print("Invalid object type")
Beispiel #9
0
 def __init__(self):
     '''
     Constructor
     '''
     self.Stop = Stop()
     self.goStraight = GoStraight()
     self.Turn = Turn()
     self.FullTurn = FullTurn()
     self.Approach = Approach()
def bus_line_calculator(travel_log):
    busses = {}
    stops = set()

    for log in travel_log:
        bus = BusLine(log["bus_id"])

        if bus.get_id() not in busses:
            busses[bus.get_id()] = bus

        stop = Stop(log["stop_id"])
        stop_name = log["stop_name"]
        stop.add_name(stop_name)
        stop_type = log["stop_type"]

        busses[bus.get_id()].add_stop(stop)

        if stop_type == "S":
            busses[bus.get_id()].set_starting_stop(stop)
        elif stop_type == "F":
            busses[bus.get_id()].set_finishing_stop(stop)

    starting_stops = []
    finish_stops = []

    all_routes = []

    for bus_id, bus in busses.items():
        if bus.starting_and_finishing_exists():
            if bus.starting_stop.get_name() not in starting_stops:
                starting_stops.append(bus.starting_stop.get_name())
            if bus.finishing_stop.get_name() not in finish_stops:
                finish_stops.append(bus.finishing_stop.get_name())

            all_routes.append(bus.route)
        else:
            # print(f"There is no start or end stop for the line: {bus_id}")
            sys.exit()

    named_stops_in_routes = []

    for route in all_routes:
        temp_set = set()
        for stop in route:
            temp_set.add(stop.get_name())
        named_stops_in_routes.append(temp_set)

    combinations = itertools.combinations(named_stops_in_routes, 2)

    transfer_stops_initial = [i.intersection(k) for i, k in (combination for combination in combinations)]

    transfer_stops_set = set()
    for stop_set in transfer_stops_initial:
        for name in stop_set:
            transfer_stops_set.add(name)

    transfer_stops = [*transfer_stops_set]
Beispiel #11
0
def get_list_of_stops(stops):
    stop_list = []
    for stop in stops['data']['stops']:
        name = stop['name']
        direction = stop['direction']
        code = stop['code']
        buses = []
        for routes in stop['routes']:
            buses.append(routes['shortName'])
            print(routes['shortName'])
        stop = Stop(name,code,buses,direction)
        stop_list.append(stop)
    return filterStops(stop_list)[:5]
Beispiel #12
0
    def stop(self):
        now_page = int(
            self.pushButton_start.text().split('/')[0].split('(')[-1])
        self.thread_stop = Stop(now_page)

        self.thread_stop.log_append.connect(self.log_append)
        self.thread_stop.log_moveCursor.connect(self.log_moveCursor)
        self.thread_stop.enable_start_button.connect(self.enable_start_button)
        self.thread_stop.disable_stop_button.connect(self.disable_stop_button)
        self.thread_stop.set_startbutton_text.connect(
            self.set_startbutton_text)
        self.thread_stop.stop_worker.connect(self.stop_worker)

        self.thread_stop.start()
Beispiel #13
0
async def main():
    db.init(os.getenv("DB"))
    db.connect()
    db.create_tables([User, Raid, Log, PriorActivity])

    async with Session() as kol:
        await kol.login(os.getenv("KOL_USER"), os.getenv("KOL_PASS"))
        cache = pickle.load(open("oaf.cache", "rb"))
        bot = commands.Bot("!")
        bot.kol = kol
        bot.raid_guild = int(os.getenv("DISCORD_GUILD"))
        bot.raid_channel = int(os.getenv("DISCORD_CHANNEL"))
        bot.add_cog(Verification(bot))
        bot.add_cog(RaidLogs(bot, clans))
        bot.add_cog(Whitelist(bot, clans))
        bot.add_cog(OAF(bot, cache))
        bot.add_cog(Stop(bot))
        await bot.login(os.getenv("DISCORD_TOKEN"))
        await bot.connect()
        pickle.dump(cache, open("oaf.cache", "wb"))
Beispiel #14
0
 def createStop(self,tabStop):
     res = tabStop
     listNameStop = self.listStopAller() 
     #nom des stop que l'on veut rajouter
     tabNameStop = []
     #nom des stop qu'on a déjà
     if (tabStop != []):
         for i in range(0,len(tabStop)):
             tabNameStop.append(tabStop[i].name)
     for j in range(0,len(self.listStopAller())):
         if not(listNameStop[j] in tabNameStop):
             nStop = Stop(self.getScheduleAller()[j][0],self.nbLine,self.getScheduleAller()[j][1])
             res.append(nStop)
         else:
             for n in range(0,len(tabStop)):
                 if listNameStop[j]==tabStop[n].name:
                     tabStop[n].setSchedule(self.nbLine,self.getScheduleAller()[j][1])
     for k in range(0,len(listNameStop)-1):
         for l in range(0,len(res)):
             if listNameStop[k]==res[l].name:
                 for m in range(0,len(res)):
                     if listNameStop[k+1]==res[m].name:
                         res[l].addNeighbors(res[m])
     return res
Beispiel #15
0
 def setUp(self):
     self.user = User(-36.854134, 174.767841)
     self.stop = Stop(-36.843574, 174.766931)
import sys
import itertools
from BusLine import BusLine
from Stop import Stop

travel_log = json.loads(input())
busses = {}
stops = set()

for log in travel_log:
    bus = BusLine(log["bus_id"])

    if bus.get_id() not in busses:
        busses[bus.get_id()] = bus

    stop = Stop(log["stop_id"])
    stop_name = log["stop_name"]
    stop.add_name(stop_name)
    stop_type = log["stop_type"]

    busses[bus.get_id()].add_stop(stop)

    if stop_type == "S":
        busses[bus.get_id()].set_starting_stop(stop)
    elif stop_type == "F":
        busses[bus.get_id()].set_finishing_stop(stop)

starting_stops = []
finish_stops = []

all_routes = []
Beispiel #17
0
        dic[tmp[0]] = tmp[1:]
    return dic


slited_content = content.split("\n\n")
regular_path = slited_content[0]
regular_date_go = dates2dic(slited_content[1])
regular_date_back = dates2dic(slited_content[2])
we_holidays_path = slited_content[3]
we_holidays_date_go = dates2dic(slited_content[4])
we_holidays_date_back = dates2dic(slited_content[5])

Sibra_Networkw = Network()
for element in regular_path.split():
    if not (element in ['N', '+']):
        stop = Stop(element, [regular_date_go[element]])
        stop.addSchedule(
            [regular_date_go[element], regular_date_back[element]])
        Sibra_Networkw.addStops([stop])

c = 0
for element in Sibra_Networkw.stops:
    if c == 0:
        element.addNextStops([Sibra_Networkw.stops[1]])
    elif c == len(Sibra_Networkw.stops) - 1:
        element.addNextStops([Sibra_Networkw.stops[c - 1]])
    else:
        element.addNextStops(
            [Sibra_Networkw.stops[c - 1], Sibra_Networkw.stops[c + 1]])
    c += 1
"""
Beispiel #18
0
# -*- coding: utf-8 -*-
"""
Created on Tue Feb 26 18:54:36 2019

@author: Akanksha Singhal
"""

from Bus import Bus
from Stop import Stop
from Route import Route

# Initializing the stops on a Route
stop1 = Stop(latitude=27.028486,
             longitude=75.769043,
             stopname="Todi",
             stopcode=1000,
             duration=0,
             distance=0)
stop2 = Stop(latitude=26.9181,
             longitude=75.8498,
             stopname="Galta Gate",
             stopcode=1001,
             duration=20,
             distance=5.2)
stop3 = Stop(latitude=26.9243,
             longitude=75.8124,
             stopname="Chandpole",
             stopcode=1005,
             duration=10,
             distance=3)
stops = [stop1, stop2, stop3]