def get_unassigned_bus_schedule_target(self): targets = Target.new_targets( self.relation.get_related( Target.new_target(None, SIM_BUS.NODE_NAME))) if len(targets) == 0: return None return targets[0]
def set_spots(self, spots): self.__spots = dict( map( lambda x: (x["ID"], Spot.new_spot( Target.new_targets(x["targets"]), Location.new_location(x["contact"]["waypointID"], x[ "contact"]["arrowCode"], x["contact"]["geohash"]), None, None)), spots))
def load_bus_schedule_json(path_bus_schedule_json): with open(path_bus_schedule_json, "r") as f: bus_schedules_json = json.load(f)["busSchedules"] bus_schedules = {} for target_bus_schedules in bus_schedules_json: schedule_branches = [] for schedule_branch in target_bus_schedules["scheduleBranches"]: common_schedules = [] for common in schedule_branch["common"]: common_schedules = Schedule.get_merged_schedules(common_schedules, [Schedule.new_schedule( Target.new_targets(common["targets"]) if "targets" in common else None, common["event"], None, None, Route.decode_route_code(common["routeCode"]) )]) main_schedules = [] for main in schedule_branch["main"]: main_schedules = Schedule.get_merged_schedules( main_schedules, [Schedule.new_schedule( Target.new_targets(main["targets"]) if "targets" in main else None, main["event"], None, None, Route.decode_route_code(main["routeCode"]) )] ) sub_schedules = [] for sub in schedule_branch["sub"]: sub_schedules = Schedule.get_merged_schedules( sub_schedules, [Schedule.new_schedule( Target.new_targets(sub["targets"]) if "targets" in sub else None, sub["event"], None, None, Route.decode_route_code(sub["routeCode"]) )] ) schedule_branches.append( ScheduleBranch.new_schedule_branch(common_schedules, main_schedules, sub_schedules)) bus_schedules[target_bus_schedules["ID"]] = schedule_branches return bus_schedules