xctrack

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2021 License: BSD-2-Clause Imports: 14 Imported by: 1

README

go-xctrack

GoDoc

Package xctrack implements XCTrack's task format.

Features:

  • Reading and writing of .xctsk files.
  • Generation and parsing of XCTSK: URLs.
  • Encoding and decoding XCTSK: URLs as QR codes.

Additionally, a command line utility in cmd/xctrack converts between these formats.

Licence

MIT

Documentation

Overview

Package xctrack implements XCTrack's task format. See http://xctrack.org/ and http://xctrack.org/Competition_Interfaces.html.

Index

Constants

View Source
const (
	QRCodeScheme      = "XCTSK:"
	QRCodeTaskVersion = 2
)

Constants.

View Source
const (
	TaskExtension = ".xctsk"
	TaskMIMEType  = "application/xctsk"
	TaskVersion   = 1
)

Constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction string

An Direction is a direction.

const (
	DirectionEnter Direction = "ENTER"
	DirectionExit  Direction = "EXIT"
)

Directions.

type EarthModel

type EarthModel string

An EarthModel is an Earth model.

const (
	EarthModelWGS84     EarthModel = "WGS84"
	EarthModelFAISphere EarthModel = "FAI_SPHERE"
)

Earth models.

type Goal

type Goal struct {
	Type     GoalType `json:"type,omitempty"`
	Deadline *Time    `json:"deadline,omitempty"`
}

A Goal is a goal.

type GoalType

type GoalType string

A GoalType is a goal type.

const (
	GoalTypeCylinder GoalType = "CYLINDER"
	GoalTypeLine     GoalType = "LINE"
)

Goal types.

type QRCodeDirection

type QRCodeDirection int

A QRCodeDirection is a QR code direction.

const (
	QRCodeDirectionEnter QRCodeDirection = 1
	QRCodeDirectionExit  QRCodeDirection = 2
)

QR code directions.

type QRCodeEarthModel

type QRCodeEarthModel int

A QRCodeEarthModel is a QR code Earth model.

const (
	QRCodeEarthModelWGS84     QRCodeEarthModel = 0
	QRCodeEarthModelFAISphere QRCodeEarthModel = 1
)

QR code Earth models.

type QRCodeGoal

type QRCodeGoal struct {
	Deadline *Time          `json:"d,omitempty"`
	Type     QRCodeGoalType `json:"t,omitempty"`
}

A QRCodeGoal is a QR code goal.

type QRCodeGoalType

type QRCodeGoalType int

A QRCodeGoalType is a QR code goal type.

const (
	QRCodeGoalTypeLine     QRCodeGoalType = 1
	QRCodeGoalTypeCylinder QRCodeGoalType = 2
)

QR code goal types.

type QRCodeSSS

type QRCodeSSS struct {
	TimeGates []*Time         `json:"g"`
	Direction QRCodeDirection `json:"d"`
	Type      QRCodeSSSType   `json:"t"`
}

A QRCodeSSS is a QR code start.

type QRCodeSSSType

type QRCodeSSSType int

A QRCodeSSSType is a QR code start of speed section type.

const (
	QRCodeSSSTypeRace        QRCodeSSSType = 1
	QRCodeSSSTypeElapsedTime QRCodeSSSType = 2
)

QR code start of speed section types.

type QRCodeTask

type QRCodeTask struct {
	TaskType   TaskType           `json:"taskType"`
	Version    int                `json:"version"`
	Turnpoints []*QRCodeTurnpoint `json:"t"`
	SSS        *QRCodeSSS         `json:"s,omitempty"`
	Goal       *QRCodeGoal        `json:"g,omitempty"`
	EarthModel QRCodeEarthModel   `json:"e"`
}

A QRCodeTask is a QR code task.

func (*QRCodeTask) String

func (q *QRCodeTask) String() (string, error)

func (*QRCodeTask) Task

func (q *QRCodeTask) Task() *Task

Task returns t as a Task.

type QRCodeTaskType

type QRCodeTaskType int

A QRCodeTaskType is a QR code task type.

const (
	QRCodeTaskTypeRace        QRCodeTaskType = 1
	QRCodeTaskTypeElapsedTime QRCodeTaskType = 2
)

QR code task types.

type QRCodeTurnpoint

type QRCodeTurnpoint struct {
	Z           QRCodeTurnpointZ    `json:"z"`
	Name        string              `json:"n"`
	Description string              `json:"d,omitempty"`
	Type        QRCodeTurnpointType `json:"t,omitempty"`
}

A QRCodeTurnpoint is a QR code turnpoint.

type QRCodeTurnpointType

type QRCodeTurnpointType int

A QRCodeTurnpointType is a QR code turnpoint type.

const (
	QRCodeTurnpointTypeNone QRCodeTurnpointType = 0
	QRCodeTurnpointTypeSSS  QRCodeTurnpointType = 2
	QRCodeTurnpointTypeESS  QRCodeTurnpointType = 3
)

QR code turnpoint types.

type QRCodeTurnpointZ

type QRCodeTurnpointZ struct {
	Lon    float64
	Lat    float64
	Alt    int
	Radius int
}

A QRCodeTurnpointZ is a QR code turnpoint Z.

func (*QRCodeTurnpointZ) MarshalJSON

func (z *QRCodeTurnpointZ) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*QRCodeTurnpointZ) UnmarshalJSON

func (z *QRCodeTurnpointZ) UnmarshalJSON(value []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type SSS

type SSS struct {
	Type      SSSType   `json:"type"`
	Direction Direction `json:"direction"`
	TimeGates []*Time   `json:"timeGates"`
}

An SSS is a start of speed section.

type SSSType

type SSSType string

An SSSType is a start of speed section type.

const (
	SSSTypeRace        SSSType = "RACE"
	SSSTypeElapsedTime SSSType = "ELAPSED-TIME"
)

Start of speed section types.

type Takeoff

type Takeoff struct {
	TimeOpen  *Time `json:"timeOpen,omitempty"`
	TimeClose *Time `json:"timeClose,omitempty"`
}

A Takeoff is a takeoff.

type Task

type Task struct {
	TaskType   TaskType     `json:"taskType"`
	Version    int          `json:"version"`
	EarthModel EarthModel   `json:"earthModel,omitempty"`
	Turnpoints []*Turnpoint `json:"turnpoints"`
	Takeoff    *Takeoff     `json:"takeoff,omitempty"`
	SSS        *SSS         `json:"sss,omitempty"`
	Goal       *Goal        `json:"goal,omitempty"`
}

A Task is an XC Track task, see http://xctrack.org/Competition_Interfaces.html.

func ParseTask

func ParseTask(data []byte) (*Task, error)

ParseTask parses a Task from data.

func (*Task) QRCodeTask

func (t *Task) QRCodeTask() *QRCodeTask

QRCodeTask returns t as a QRCodeTask.

type TaskType

type TaskType string

A TaskType is a task type.

const (
	TaskTypeClassic TaskType = "CLASSIC"
)

Task types.

type Time

type Time struct {
	Hour   int
	Minute int
	Second int
}

A Time is a time.

func (*Time) MarshalJSON

func (t *Time) MarshalJSON() ([]byte, error)

MarshalJSON implements encoding/json.Marshaler.

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(b []byte) error

UnmarshalJSON implements encoding/json.Unmarshaler.

type Turnpoint

type Turnpoint struct {
	Type     TurnpointType `json:"type,omitempty"`
	Radius   int           `json:"radius"`
	Waypoint Waypoint      `json:"waypoint"`
}

A Turnpoint is a turnpoint.

type TurnpointType

type TurnpointType string

A TurnpointType is a turnpoint type.

const (
	TurnpointTypeNone    TurnpointType = ""
	TurnpointTypeTakeoff TurnpointType = "TAKEOFF"
	TurnpointTypeSSS     TurnpointType = "SSS"
	TurnpointTypeESS     TurnpointType = "ESS"
)

Turnpoint types.

type Waypoint

type Waypoint struct {
	Name        string  `json:"name"`
	Description string  `json:"description,omitempty"`
	Lat         float64 `json:"lat"`
	Lon         float64 `json:"lon"`
	AltSmoothed int     `json:"altSmoothed"`
}

A Waypoint is a waypoint.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL