def readReporterFromFile(inputfile):
    """
    Read Reporter  from a handbuilt text file

    Args:
        inputfile: Pathname of file

    Returns:
        An Reporter object

        Very basic - no error checking whatsoever! File format is:
            Line 1: Name of reporter (no more than 10 chars)
            Line 2: reporter type piaware or mutability, although this field isn't used by anything yet
            Line 3: Lat/lon of reporter location, comma separated.
            Line 4: URL to access the reporter, e.g. http://planereporter/dump1090/data/aircraft.json

    """
    reporter = {}
    name = inputfile.readline().strip('\n')
    mytype = inputfile.readline().strip('\n')
    coords = inputfile.readline().split(",")
    lat = float(coords[0].strip())
    lon = float(coords[1].strip())
    url = inputfile.readline().strip('\n')
    reporter = pr.Reporter(name=name, mytype=mytype, lat=lat, lon=lon,
                           url=url, location="")

    return reporter
args = parser.parse_args()

reporter = None
dbconn = None

if not args.dump1090url and not args.db_conf and not args.datafile:
    print("A valid URL or a valid filename or db connection is needed!")
    exit(-1)

if args.db_conf:
    dbconn = pr.connDB(args.db_conf)
    reporter = pr.readReporter(dbconn, key=args.reporter, printQuery=args.debug)

if not args.db_conf and (args.lat and args.lon):
    reporter = pr.Reporter(name='bodge', lat=args.lat, lon=args.lon, url='',
                           location="", mytype='')
#if args.datafile and not args.db_conf:
#    print("When specifying an input file, a database connection is needed")
#    exit(-1)

if not args.datafile:
    #
    # Set up the acquisition loop
    #
    samps_taken = 0
    while samps_taken < args.num_samps or args.num_samps < 0:
        t1 = time.time()
        if args.vrs_fmt:
            myparams = {'fDstL': args.minDistance,  'fDstU': args.maxDistance/1000, 'lat': reporter.lat, 'lng': reporter.lon,
                        'fAltL': args.minAltitude/pr.FEET_TO_METRES, 'fAltU': args.maxAltitude/pr.FEET_TO_METRES}
            if args.debug:
Beispiel #3
0
args = parser.parse_args()

if not args.db_conf:
    print("A valid URL db configuration file is needed!")
    exit(1)
else:
    if not args.start_time:
        args.start_time = datetime.date.today().strftime("%F") + " 00:00:00"
    dbconn = pr.connDB(args.db_conf)

    if args.reporter:
        reporter = pr.readReporter(dbconn, args.reporter)
    else:
        reporter = pr.Reporter(name=None,
                               mytype=None,
                               lon=None,
                               lat=None,
                               url=None,
                               location=None)

    cur = pr.queryReportsDB(dbconn,
                            myhex=args.hexcodes,
                            myStartTime=args.start_time,
                            myEndTime=args.end_time,
                            myflight=args.flights,
                            minDistance=args.minDistance,
                            maxDistance=args.maxDistance,
                            minAltitude=args.minAltitude,
                            maxAltitude=args.maxAltitude,
                            minSpeed=args.minSpeed,
                            maxSpeed=args.maxSpeed,
                            minRssi=args.minRssi,
MAPY = 850000

lats, lons, alts = [], [], []
drawableslst = []
annolist = []

time_slices = []
time_slices.append([])
time_slc_idx = 0
max_dist = 0.0
max_alt = 0.0

reporter = pr.Reporter(name="",
                       type="",
                       lon=args.longitude,
                       lat=args.latitude,
                       location="",
                       url="",
                       mytype="")

inputfile = pr.openFile(args.datafile)
data = pr.readFromFile(inputfile)

if data:
    first_time = data[0].time
    next_time = first_time + args.sec_per_frame

while data:
    for plane in data:
        if plane.time >= next_time:
            # Catch case where there's a long time without action
Beispiel #5
0
                                                 and not args.reporter):
    print("Need a location of some sort - either reporter or lat/lon pair")
    exit(1)

if not args.db_conf:
    print("Need a dbconfig file to read database!")
    exit(1)

dbconn = pr.connDB(args.db_conf)

if args.latitude and args.longitude:
    point = Point(args.longitude, args.latitude)
    reporter = pr.Reporter(name="",
                           type="",
                           lon=args.longitude,
                           lat=args.latitude,
                           location=point.wkb_hex,
                           url="",
                           mytype="")
else:
    reporter = pr.readReporter(dbconn,
                               key=args.reporter,
                               printQuery=args.debug)

if args.debug:
    print(reporter.to_JSON())

postSql = None

if args.sortOrder:
    if args.sortOrder == "name":