Exemple #1
0
def val_pos(p, key, log):
    if not key in p:
        log.append("Missing key '%s' in object: %s" % (key, p))
        return False
    x = p[key]
    if not type(x) in [str, unicode]:
        log.append("Key %s must be a string representing position, not %s" %
                   (key, repr(x)))
        return False
    try:
        pos = mapper.anyparse(x)
        p[key] = pos
        return True
    except Exception, cause:
        log.append("Couldn't parse position: %s" % (cause, ))
        return False
Exemple #2
0
def val_runway(point, log):
    if not 'runways' in point: return
    for rwy in point['runways']:
        if not 'ends' in rwy:
            log.append("Must have 'ends' key in runway information object.")
            continue
        ends = rwy['ends']
        if len(ends) != 2:
            log.append("A runway must have exactly two ends, not %d: %s" %
                       (len(ends), ends))
            continue
        for end in ends:
            if not 'thr' in end:
                log.append(
                    "Must have thr (threshold) key in runway end-object, have only: %s"
                    % (end.keys()))
                continue
            if not 'pos' in end:
                log.append(
                    "Must have pos key in runway end-object, have only: %s" %
                    (end.keys()))
                continue
            end['pos'] = mapper.anyparse(end['pos'])