aerofiles.xcsoar

class aerofiles.xcsoar.Writer(fp, encoding='utf-8')

A writer class for the XCSoar task file format:

with open('task.tsk', 'w') as fp:
    writer = Writer(fp)

This task file format contains one task per file. Writing more than one task will cause an exception. A task can be written by using the write_task() method.

write_observation_zone(**kw)

Write an observation zone declaration to the file:

writer.write_observation_zone(
    type=ObservationZoneType.CYLINDER,
    radius=30000,
)

# <ObservationZone type="Cylinder" radius="30000"/>

The required parameters depend on the type parameter. Different observation zone types require different parameters.

Parameters:
  • type – observation zone type (one of the constants in ObservationZoneType)

  • length – length of the line (only used with type LINE)

  • radius – (outer) radius of the observation zone (used with types CYLINDER, SECTOR, SYMMETRIC_QUADRANT and CUSTOM_KEYHOLE)

  • inner_radius – inner radius of the observation zone (only used with type CUSTOM_KEYHOLE)

  • angle – angle of the observation zone (only used with type CUSTOM_KEYHOLE)

  • start_radial – start radial of the observation zone (only used with type SECTOR)

  • end_radial – end radial of the observation zone (only used with type SECTOR)

write_point(**kw)

Write a task point to the file:

with writer.write_point(type=PointType.TURN):
    writer.write_waypoint(...)
    writer.write_observation_zone(...)

# <Point type="Turn"> ... </Point>

Inside the with clause the write_waypoint() and write_observation_zone() methods must be used to write the details of the task point.

Parameters:

type – type of the task point (one of the constants in PointType)

write_task(**kw)

Write the main task to the file:

with writer.write_task(type=TaskType.RACING):
    ...

# <Task type="RT"> ... </Task>

Inside the with clause the write_point() method should be used to write the individual task points. All parameters are optional.

Parameters:
  • type – type of the task (one of the constants in TaskType)

  • start_requires_armTrue: start has to be armed manually, False: task will be started automatically

  • start_max_height – maximum altitude when the task is started (in m)

  • start_max_height_ref – altitude reference of start_max_height (one of the constants in AltitudeReference)

  • start_max_speed – maximum speed when the task is started (in m/s)

  • start_open_time – time that the start line opens as datetime.time

  • start_close_time – time that the start line is closing as datetime.time

  • aat_min_time – AAT time as datetime.timedelta

  • finish_min_height – minimum altitude when the task is finished (in m)

  • finish_min_height_ref – altitude reference of finish_min_height (one of the constants in AltitudeReference)

  • fai_finishTrue: FAI finish rules apply

write_waypoint(**kw)

Write a waypoint to the file:

writer.write_waypoint(
    name='Meiersberg',
    latitude=51.4,
    longitude=7.1
)

# <Waypoint name="Meiersberg">
#     <Location latitude="51.4" longitude="7.1"/>
# </Waypoint>
Parameters:
  • name – name of the waypoint

  • latitude – latitude of the waypoint (in WGS84)

  • longitude – longitude of the waypoint (in WGS84)

  • altitude – altitude of the waypoint (in m, optional)

  • id – internal id of the waypoint (optional)

  • comment – extended description of the waypoint (optional)

class aerofiles.xcsoar.constants.AltitudeReference
AGL = 'AGL'
MSL = 'MSL'
class aerofiles.xcsoar.constants.ObservationZoneType
BGA_ENHANCED = 'BGAEnhancedOption'
BGA_FIXED = 'BGAFixedCourse'
BGA_START = 'BGAStartSector'
CUSTOM_KEYHOLE = 'CustomKeyhole'
CYLINDER = 'Cylinder'
FAI_SECTOR = 'FAISector'
KEYHOLE = 'Keyhole'
LINE = 'Line'
MAT_CYLINDER = 'MatCylinder'
SECTOR = 'Sector'
SYMMETRIC_QUADRANT = 'SymmetricQuadrant'
class aerofiles.xcsoar.constants.PointType
AREA = 'Area'
FINISH = 'Finish'
OPTIONAL_START = 'OptionalStart'
START = 'Start'
TURN = 'Turn'
class aerofiles.xcsoar.constants.TaskType
AAT = 'AAT'
FAI_GENERAL = 'FAIGeneral'
FAI_GOAL = 'FAIGoal'
FAI_OUT_AND_RETURN = 'FAIOR'
FAI_TRIANGLE = 'FAITriangle'
MAT = 'MAT'
MIXED = 'Mixed'
RACING = 'RT'
TOURING = 'Touring'