Beispiel #1
0
    def parse(self, argstring):
        arg, argstring = re_getarg.match(argstring).groups()
        argu = arg.upper()

        # Try aircraft first: translate a/c id into a valid position text with a lat,lon
        idx = bs.traf.id2idx(argu)
        if idx >= 0:
            return bs.traf.lat[idx], bs.traf.lon[idx], argstring

        # Check if lat/lon combination
        if islat(argu):
            nextarg, argstring = re_getarg.match(argstring).groups()
            return txt2lat(argu), txt2lon(nextarg), argstring

        # apt,runway ? Combine into one string with a slash as separator
        if argstring[:2].upper() == "RW" and argu in bs.navdb.aptid:
            arg, argstring = re_getarg.match(argstring).groups()
            argu = argu + "/" + arg.upper()

        if refdata.lat is None:
            refdata.lat, refdata.lon = bs.scr.getviewctr()

        posobj = Position(argu, refdata.lat, refdata.lon)
        if posobj.error:
            raise ValueError(
                f'{argu} is not a valid waypoint, airport, runway, or aircraft id.'
            )

        # Update reference lat/lon
        refdata.lat = posobj.lat
        refdata.lon = posobj.lon
        refdata.hdg = posobj.refhdg

        return posobj.lat, posobj.lon, argstring
Beispiel #2
0
    def parse(self, argstring):
        arg, argstring = re_getarg.match(argstring).groups()
        name = arg.upper()

        # Try aircraft first: translate a/c id into a valid position text with a lat,lon
        idx = bs.traf.id2idx(name)
        if idx >= 0:
            name = f'{bs.traf.lat[idx]},{bs.traf.lon[idx]}'

        # Check if lat/lon combination
        elif islat(name):
            # lat,lon ? Combine into one string with a comma
            arg, argstring = re_getarg.match(argstring).groups()
            name = name + "," + arg

        # apt,runway ? Combine into one string with a slash as separator
        elif argstring[:2].upper() == "RW" and name in bs.navdb.aptid:
            arg, argstring = re_getarg.match(argstring).groups()
            name = name + "/" + arg.upper()

        return name, argstring