objects

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

View Source
const GlobalObjectID = 0

Variables

View Source
var ErrNotFound = errors.New("property not found")

ErrNotFound indicates that a property is missing.

View Source
var ErrParseFailure = errors.New("error parsing object")

ErrParseFailure indicates that a property is present but failed to parse.

Functions

This section is empty.

Types

type Coordinates

type Coordinates struct {
	// Longitude. This is the object's actual longitude, after applying any reference longitude.
	Longitude *float64
	// Latitude. This is the object's actual latitude, after applying any reference latitude.
	Latitude *float64
	// Altitude above sea level
	Altitude *unit.Length
	// X is the object's native coordinate within the sim
	X *float64
	// Y is the object's native coordiante within the sim
	Y *float64
	// Roll angle
	Roll *unit.Angle
	// Pitch angle
	Pitch *unit.Angle
	// Yaw angle (this may be different from heading)
	Yaw *unit.Angle
	// Heading is the object's flat earth heading
	Heading *unit.Angle
}

Coordinates models the position and orientation of an object within ACMI data.

func NewCoordinates

func NewCoordinates(
	longitude, latitude *float64,
	altitude *unit.Length,
	x, y *float64,
	roll, pitch, yaw, heading *unit.Angle,
) *Coordinates

NewCoordinates instantiates Coordinates with the given values.

func (*Coordinates) Parse

func (c *Coordinates) Parse(transform string, referenceLongitude float64, referenceLatitude float64) error

Parse reads the value of a Transform property and updates the coordinates accordingly. The referenceLongitude and referenceLatitude parameters must be the reference point from the global properties.

func (*Coordinates) Transform

func (c *Coordinates) Transform(referenceLongitude float64, referenceLatitude float64) string

Transform serializes the coordinates into a coordinate transformation suitable for use in the Transform property in an ACMI object update. The referenceLongitude and referenceLatitude parameters must be the reference point in the global properties.

func (*Coordinates) Update

func (c *Coordinates) Update(next *Coordinates)

Update updates the coordinates with the values from the next coordinates.

type Object

type Object struct {
	ID         uint64
	Properties map[string]string
}

Object models the ID and properties of an object within ACMI data.

func New

func New(id uint64) *Object

New instantiates a new object with the given ID.

func (*Object) GetAngle

func (o *Object) GetAngle(property string) (unit.Angle, error)

GetAngle is a helper to read the given property as an angle.

func (*Object) GetCoordinates

func (o *Object) GetCoordinates(referenceLongitude, referenceLatitude float64) (*Coordinates, error)

GetCoordinates returns the coordinates of the object, if possible. Objects may have insufficient information to determine their coordinates. In such a case, the function returns nil and no error. The referenceLongitude and referenceLatitude are the reference point from the global properties.

func (*Object) GetLength

func (o *Object) GetLength(property string) (unit.Length, error)

GetLength is a helper to read the given property as a length or distance.

func (*Object) GetProperty

func (o *Object) GetProperty(p string) (string, bool)

func (*Object) GetSpeed

func (o *Object) GetSpeed(property string) (unit.Speed, error)

GetSpeed is a helper to read the given property as a speed.

func (*Object) GetTypes

func (o *Object) GetTypes() ([]string, error)

GetTypes returns all object type tags.

func (*Object) SetProperty

func (o *Object) SetProperty(p, v string)

func (*Object) String added in v1.0.3

func (o *Object) String() string

func (*Object) Update

func (o *Object) Update(update *Update, referenceLongitude, referenceLatitude float64) error

Update applies the given update to the object. If the update contains a coordinate transformation, the object's coordinates are updated. Other properties in the update are merged into the object's properties. The referenceLongitude and referenceLatitude are the reference point from the global properties.

type Update

type Update struct {
	// ID of the object.
	ID uint64
	// IsRemove indicates if the update removes the object.
	IsRemoval bool
	// Properties provided in the update.
	Properties map[string]string
}

/ Update models the changes to an object within a line of ACMI data.

func (*Update) String added in v1.0.3

func (u *Update) String() string

Jump to

Keyboard shortcuts

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