def commandRouter( lineJson ):
	"""Routes the command to the right function. Throws `Warning` if
	   command not matched."""

	cmd = lineJson['command']
	opt = lineJson['options']

	# Make `case`-like functionality with if/elif checks
	if cmd == "getContent":
		Routes.getContent()

	elif cmd == "getGraphviz":
		Routes.getGraphviz()

	elif cmd == "getTessellation":
		acc = opt['accuracy'] # Throws KeyError
		Routes.getTessellation( acc )

	elif cmd == "changeParam":
		objName = opt['objName']
		param = opt['param']
		val = opt['val']
		Routes.changeParam( objName, param, val )

	else:
		# if not matched, throw error
		raise Warning("Command not matched")
def getOfFile():
    allObjects = getOfConfigFile()

    adresse = str(path["routesFilePath"])
    routes = Routes.initRT(adresse)

    adresse = path["characteristicsPointsFilePath"]
    charactPoints, tahitiAirports = CharacteristicPoints.initCP(adresse)

    adresse = path["fdpFilePath"]
    fdp = Fdp.initFDP(adresse)

    adresse = path["aoiFilePath"]
    aoi = Aoi.initAOI(adresse)

    adresse = path["fplFilePath"]
    fpl = Fpl.initFPL(adresse, charactPoints, routes["codedRoutes"], tahitiAirports)

    adresse = path["adsFilePath"]
    ads = Ads.initADS(adresse, charactPoints, routes["codedRoutes"], fpl)

    allObjects["routes"] = routes
    allObjects["charactPoints"] = charactPoints
    allObjects["tahitiAirport"] = tahitiAirports
    allObjects["fdp"] = fdp
    allObjects["aoi"] = aoi
    allObjects["fpl"] = fpl
    allObjects["ads"] = ads
    return allObjects
Пример #3
0
def OptimalEvacuation(
        start_pos, realRoute, resultFlag, disaster,
        disasterScale):  #最適な避難場所の探索、及び最適な避難経路の探索、実際に避難した経路と最適な避難場所を同じ画像に出力
    if (resultFlag):
        #そこから取得
        with open("../data/result.json", encoding="utf-8_sig") as f:
            resultJson = json.load(f)
        places = resultJson["EvacuationPlaces"]
        goal_pos = places["0"]["coordinates"]
        optimal_goal = HazapModules.Coordinates()
        optimal_goal.lat, optimal_goal.lon = float(goal_pos[0]), float(
            goal_pos[1])
    else:
        places = getplace.searchplace(start_pos, disaster,
                                      disasterScale)  #最適な避難場所を取得
        resultJson = {}
        resultJson["EvacuationPlaces"] = places
        with open("../data/result.json", "w", encoding="utf-8_sig") as f:
            json.dump(resultJson, f, ensure_ascii=False, indent=4)
        goal_pos = places[0]["coordinates"]
        optimal_goal = HazapModules.Coordinates()
        optimal_goal.lat, optimal_goal.lon = float(goal_pos[0]), float(
            goal_pos[1])
    Routes.Search_route(start_pos, optimal_goal, realRoute,
                        resultFlag)  #最適なルートを作成
    return places  #評価の高かった場所のリストを返す
Пример #4
0
def authenticate():
    req_data = request.get_json()
    print req_data
    username = req_data['username']
    password = req_data['password']
    print username, password
    return Routes.auth(username, password)
Пример #5
0
 def __init__(self, db):
     '''
         General description:
         This function initializes the database variables and \
         index to refer in functions.
     '''
     DBUtil.__init__(self, db)
     self.collection = db.PermissionGroup
     self.permissiondb = Permissions.Permissions(db)
     self.routesb = Routes.Routes(db)
     # indexes
     self.collection.create_index(
         [('groupname', ASCENDING)],
         unique=True,
     )
Пример #6
0
def initial_setup():
    Database.wait_for_available()
    Logger.log.info('Setting up database structure')

    # Make a database connection
    session = Database.connect(create_all=True)

    if session.query(db.Route).count() > 0 or session.query(
            db.Station).count() > 0:
        Logger.log.error(
            "ERROR: Initial setup cannot continue, this database already has route and station data."
        )
        sys.exit(1)

    routes = Routes.get_route_objects()
    for route in routes:
        session.add(route)

    # Get the station objects and add them to the database
    stations = APIFunctionsV3.get_stations(session)
    for station in stations:
        session.add(station)

    session.commit()
Пример #7
0
def model_frequency_for_route(session, route_name):
    return model_frequency(todays_vehicles_for_route(session, Routes.route_ids(session)[route_name]), route_name)
Пример #8
0
def hello():
    return Routes.hello()
Пример #9
0
def RunServer(args=[]):
    Database.Initialize()
    Routes.Serve()