Documentation
¶
Index ¶
- Variables
- func IsCatContinuous(a, b CatTrack) bool
- func MustContinuousTimeOffset(a, b CatTrack) time.Duration
- func MustTimeOffset(a, b CatTrack) time.Duration
- func NewDedupeLRUFunc(size int) func(CatTrack) bool
- func SlicesSortFunc(a, b CatTrack) int
- func WithTimeOffset(ctx context.Context, in <-chan CatTrack) chan CatTrack
- type CatLap
- func (cl *CatLap) BearingDeltaRate() float64
- func (cl *CatLap) DistanceTraversed() (distance float64)
- func (cl *CatLap) Duration() time.Duration
- func (cl *CatLap) IsValid() bool
- func (cl CatLap) MarshalJSON() ([]byte, error)
- func (cl *CatLap) SelfIntersectionRate() float64
- func (cl *CatLap) UnmarshalJSON(data []byte) error
- type CatNap
- type CatTrack
- func (ct *CatTrack) CatID() conceptual.CatID
- func (ct *CatTrack) Copy() *CatTrack
- func (ct *CatTrack) DeletePropertySafe(key string)
- func (ct *CatTrack) HasRawB64Image() bool
- func (ct *CatTrack) HasS3URL() bool
- func (ct *CatTrack) IsEmpty() bool
- func (ct *CatTrack) IsGyroOK() bool
- func (ct *CatTrack) IsSnap() bool
- func (ct *CatTrack) IsValid() bool
- func (ct CatTrack) MarshalJSON() ([]byte, error)
- func (ct *CatTrack) MustActivity() activity.Activity
- func (ct *CatTrack) MustS3Key() string
- func (ct *CatTrack) MustTime() time.Time
- func (ct CatTrack) Point() orb.Point
- func (ct *CatTrack) S3SnapBucketName() string
- func (ct *CatTrack) SetPropertiesSafe(props map[string]interface{})
- func (ct *CatTrack) SetPropertySafe(key string, val any)
- func (ct *CatTrack) StringPretty() string
- func (ct *CatTrack) Time() (time.Time, error)
- func (ct *CatTrack) UnmarshalJSON(data []byte) error
- func (ct *CatTrack) Validate() error
- func (ct *CatTrack) ValidateSnap() error
- type Indexer
- type OffsetIndexT
- type SinkerErrFn
- type SinkerFn
- type TransformerErrFn
- type TransformerFn
Constants ¶
This section is empty.
Variables ¶
var GyroscopeProps = []string{"GyroscopeX", "GyroscopeY", "GyroscopeZ"}
var GyroscopeStableThresholdReading = 0.01
Functions ¶
func IsCatContinuous ¶
func MustContinuousTimeOffset ¶
MustContinuousTimeOffset is more than it seems. It returns the time offset between two tracks, but with magic/opinionated/adhoc caveats. If the offset is more than 24 hours, it resets to 1 second. If the offset is negative, it resets to 0.
func MustTimeOffset ¶
MustTimeOffset gets the time offset between two tracks, assuming a track happens before b track.
func NewDedupeLRUFunc ¶
func SlicesSortFunc ¶
SlicesSortFunc implements the slices.SortFunc for CatTrack slices. Sorting is done by time (chronologically, at 1 second granularity); then, in case of equivalence, by accuracy. > cmp(a, b) should return a negative number when a < b, > a positive number when a > b, and zero when a == b
Types ¶
type CatLap ¶
func (*CatLap) BearingDeltaRate ¶
BearingDeltaRate is an experiment in spikeball identification.
func (*CatLap) DistanceTraversed ¶
func (CatLap) MarshalJSON ¶
func (*CatLap) SelfIntersectionRate ¶
func (*CatLap) UnmarshalJSON ¶
type CatTrack ¶
CatTrack is a track a cat makes. It's an alias of geojson.Feature, with definite point geometry, and a time property. (This might want to - someday - become a more generic type of type; for example, a struct with a geojson.Feature embedded, or pure []byte's.) A geojson.Feature is a data structure with a type, geometry, and properties, which implements a special encoding spec (GeoJSON), which is conventional for geographic data. Notably, a geojson.Feature has no concept of time, but a CatTrack is as much a point in time as it is a point in space. catd and Cat Tracks use `properties.Time` and `properties.UnixTime` almost interchangeably, and they're in use constantly. UnixTime is preferred, since it represents 1-second granularity, which Cat Tracks asserts.
func Lap2TrackP ¶
func Nap2TrackP ¶
func NewCatTrack ¶
NewCatTrack creates and initializes a GeoJSON feature given the required attributes.
func Sanitize ¶
Sanitize normalizes and streamlines a track. It sets an Alias (cat alias/catID/conceptual.CatID/nee-Name) property unless already set. It removes unnecessary properties, and sets a zero-value ID.
func SetTimeOffset ¶
func (*CatTrack) CatID ¶
func (ct *CatTrack) CatID() conceptual.CatID
CatID conceptually returns the CatID of the track.
func (*CatTrack) DeletePropertySafe ¶
DeletePropertySafe deletes properties in thread safety. See SetPropertySafe.
func (*CatTrack) HasRawB64Image ¶
func (CatTrack) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*CatTrack) MustActivity ¶
func (*CatTrack) MustS3Key ¶
MustS3Key returns the conventional "key" for use primarily with catsnaps. If AWS S3 upload configured, that uses: AWS_BUCkETNAME/this-key. It is a cat/device/time-unique value.
func (*CatTrack) S3SnapBucketName ¶
S3SnapBucketName returns the bucket name from the imgS3 field, conventionally using the first of (two) /-delimited values.
func (*CatTrack) SetPropertiesSafe ¶
SetPropertiesSafe sets properties in thread safety. See SetPropertySafe.
func (*CatTrack) SetPropertySafe ¶
SetPropertySafe sets a property on a track in a thread safe way. Thread safe is not atomic, nor guaranteed stable. Unexpected side effects may occur.
func (*CatTrack) StringPretty ¶
func (*CatTrack) Time ¶
Time Here's a big deal. Cat Tracks only deals in tracks with a granularity of 1 second. Cat Tracks prefers the UnixTime property, but if it's not there, falls back to Time, which should be a string in RFC3339 format. If both times exist, they must be within 1 second of each other.
func (*CatTrack) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
func (*CatTrack) Validate ¶
Validate checks the track for basic validity. It returns the first error it encounters. TODO: JSON schema?
func (*CatTrack) ValidateSnap ¶
type Indexer ¶
type Indexer interface { // FromCatTrack associates a given cattrack value with an Indexer. // The indexer can choose to maintain a reference to the CatTrack or not. // Since the Indexer is responsible for managing the/a/some CatTrack's properties, // it should be able to read relevant data from the cattrack too, // and this is where you do that. // It should return a new Indexer instance. FromCatTrack(ct CatTrack) Indexer // IsEmpty returns true if the Indexer has no data. // The initial 'loaded' index value of an Indexer is considered always empty, // and may be nil. IsEmpty() bool // Index applies the next Indexer to the current Indexer. // This is where this accumulator is seduced. // The Indexer should return a new Indexer instance. Index(old, next Indexer) Indexer // ApplyToCatTrack applies the Indexer a given CatTrack, // usually the one that was used to create the Indexer. // The Indexer should return a new CatTrack value ref. // This is where you install the properties, or modify the geometry, // or do whatever cat track magic you need to do. ApplyToCatTrack(idxr Indexer, ct CatTrack) CatTrack }
Indexer is an interface that defines the methods for indexing a CatTrack. By another name, a Reducer. Maybe, a dimension reducer. CatTrack asserts here its own opinion that it is the only type of data that can be indexed. Some day, the Indexer (actually, Reducer) will take the Index and IsEmpty interface methods for its own, and will deal in any kind of data structure you want. Then, FromCatTrack might become Unmarshal/Decode, and ApplyToCatTrack might become Marshal/Encode.
type OffsetIndexT ¶
type OffsetIndexT struct { Count int // VisitCount is the number of times the cat has entered and left this cell. // It is bounded by a time threshold which the cat needs to exceed // in order to be considered as "having left". VisitCount int VisitThreshold time.Duration FirstTime time.Time LastTime time.Time // TotalTimeOffset is the sum of the time (track offsets) spent in the cell. TotalTimeOffset time.Duration // Activity is the primary activity mode of the cat while in the cell. Activity activity.Activity // AMx are the activity tallies measured in cumulative time offset seconds. AMUnknown float64 AMStationary float64 AMWalking float64 AMRunning float64 AMBike float64 AMAutomotive float64 AMFly float64 }
OffsetIndexT is an Indexer implementation that tracks the number of times a cat has entered and left a cell, as well as the total time spent in the cell. It also tracks the activity mode of the cat while in the cell, and the first and last times the cat was in the cell. TODO: Pull apart into OffsetIndexT and OffsetIndexActivityT.
func (*OffsetIndexT) ApplyToCatTrack ¶
func (*OffsetIndexT) ApplyToCatTrack(idxr Indexer, ct CatTrack) CatTrack
func (*OffsetIndexT) FromCatTrack ¶
func (*OffsetIndexT) FromCatTrack(ct CatTrack) Indexer
func (*OffsetIndexT) Index ¶
func (ix *OffsetIndexT) Index(old, next Indexer) Indexer
func (*OffsetIndexT) IsEmpty ¶
func (ix *OffsetIndexT) IsEmpty() bool