@startuml
class Track {
    -id
    -name
    -description
    -category
    -numberOfPoints
    -icon
}
Track o-- TrackPoint
Track o-- Marker
Track "1" - "1" TrackStatistics

class TrackStatistics {
    - startTime
    - stopTime
    - totalDistance
    - totalTime
    - movingTime
    - maxSpeed
    - totalGain
}

class TrackStatisticsUpdater {
}

TrackStatisticsUpdater ..> TrackStatistics : creates/updates
TrackStatisticsUpdater ..> TrackPoint : uses

class TrackPoint {
    - id (database id, order)
    - type
    - trackId
    - longitude
    - latitude
    - time
    - altitude
    - accuracy
    - speed
    - bearing
    - sensor_heartrate
    - sensor_cadence
    - sensor_power
}

class Marker {
    - id
    - trackId
    - name
    - description
    - category
    - icon
    - length
    - duration
    - longitude
    - latitude
    - photoUrl
}

class DataField {
    - key
    - title
    - isVisible
    - isPrimary
    - isWide
}

class StatisticData {
    - value
    - unit
    - description
}
StatisticData o-- DataField

class Layout {
    - profile
}
Layout "1" o-- "many" DataField

note left of TrackPoint
As of OpenTracks version 3.15.0, all times are using device time.
Before that TrackPoint.time contained GPS time (determined by GPS hardware).
However, start/pause/stop events (also stored as TrackPoints) used device time.
end note

note right of Track
A track is an ordered collection of one or more segments (i.e., continuous parts of distance covered).
Segments may be started by a user (i.e., start a track recording, continue a paused track, or resume a track) as well as stopped by the user (i.e., pausing or stopping a recording).
Also segments may started automatically while recording (i.e., distance to previous location was to large).
Note that this finishes the previous segment.

Segment data is stored as TrackPoints (Type.SEGMENT_START_MANUAL, Type.SEGMENT_START_AUTOMATIC, or Type.SEGMENT_END_MANUAL).
Trackpoints with Type.SEGMENT_START_AUTOMATIC also mark the end of the previous segment.
All TrackPoints of Type.TRACKPOINT belong to the segment started by the prior TrackPoint with Type.SEGMENT_START_(MANUAL|AUTOMATIC).
Trackpoints of Type.SEGMENT_START_MANUAL or Type.SEGMENT_END_MANUAL do not contain location data or sensor data.

Tracks recorded prior to OpenTracks version 3.15.0, do neither begin with a Type.SEGMENT_START_MANUAL nor end with a Type.SEGMENT_END_MANUAL.
end note
@enduml
