def test_altitude_format():
    """ Check altitude formatting """

    eq_(units.format_altitude(-10), '-10 m')
    eq_(units.format_altitude(0), '0 m')
    eq_(units.format_altitude(432), '432 m')
    eq_(units.format_altitude(10, 1), '10.0 m')
Exemple #2
0
def test_altitude_format():
    """ Check altitude formatting """

    assert units.format_altitude(-10) == '-10 m'
    assert units.format_altitude(0) == '0 m'
    assert units.format_altitude(432) == '432 m'
    assert units.format_altitude(10, 1) == '10.0 m'
def test_altitude_format():
    """ Check altitude formatting """

    eq_(units.format_altitude(-10), "-10 m")
    eq_(units.format_altitude(0), "0 m")
    eq_(units.format_altitude(432), "432 m")
    eq_(units.format_altitude(10, 1), "10.0 m")
Exemple #4
0
def format_phase(phase):
    """Format phase properties to human readable format
    """
    is_circling = phase.phase_type == FlightPhase.PT_CIRCLING
    r = dict(start="%s" % format_time(phase.start_time),
             fraction="%d%%" % phase.fraction if phase.fraction is not None else "",
             speed=units.format_speed(phase.speed) if phase.speed is not None else "",
             vario=units.format_lift(phase.vario),
             alt_diff=units.format_altitude(phase.alt_diff),
             count=phase.count,
             duration=phase.duration,
             is_circling=is_circling,
             type=PHASETYPE_NAMES[phase.phase_type],
             circling_direction="",
             distance="",
             glide_rate="")

    if not is_circling:
        r['distance'] = units.format_distance(phase.distance, 1)

        # Sensible glide rate values are formatted as numbers. Others are shown
        # as infinity symbol.
        if abs(phase.alt_diff) > 0 and abs(phase.glide_rate) < 1000:
            r['glide_rate'] = format_number(phase.glide_rate)
        else:
            r['glide_rate'] = u'\u221e'  # infinity
    else:
        r['circling_direction'] = CIRCDIR_NAMES[phase.circling_direction]
    return r
Exemple #5
0
def format_phase(phase):
    """Format phase properties to human readable format
    """
    is_circling = phase.phase_type == FlightPhase.PT_CIRCLING
    r = dict(start="%s" % format_time(phase.start_time),
             fraction="%d%%" %
             phase.fraction if phase.fraction is not None else "",
             speed=units.format_speed(phase.speed)
             if phase.speed is not None else "",
             vario=units.format_lift(phase.vario),
             alt_diff=units.format_altitude(phase.alt_diff),
             count=phase.count,
             duration=phase.duration,
             is_circling=is_circling,
             type=PHASETYPE_NAMES[phase.phase_type],
             circling_direction="",
             distance="",
             glide_rate="")

    if not is_circling:
        r['distance'] = units.format_distance(phase.distance, 1)

        # Sensible glide rate values are formatted as numbers. Others are shown
        # as infinity symbol.
        if abs(phase.alt_diff) > 0 and abs(phase.glide_rate) < 1000:
            r['glide_rate'] = format_number(phase.glide_rate)
        else:
            r['glide_rate'] = u'\u221e'  # infinity
    else:
        r['circling_direction'] = CIRCDIR_NAMES[phase.circling_direction]
    return r