Reference
TrackMetric
Convert track fractions and distances in metres.
Usage context
| Module | Package | SDK source |
|---|---|---|
| Kotlin/JVM | fr.nimby.sdk | kotlin-client/src/main/kotlin/fr/nimby/sdk/TrackMetric.kt |
Public API for SDK 0.9.0-alpha.2. Each entry provides the Kotlin signature and its contract: what the value means, conditions of use and effects to understand. Choose imports from the module shown above.
import fr.nimby.sdk.TrackMetric
import fr.nimby.sdk.TrackDirectionUnits and validation
| Element | Type / unit | Validation |
|---|---|---|
| trackId | Opaque Long | Nonzero. |
| lengthM | Double · metres | Finite and strictly positive. |
| offsetM(fraction) | Double · metres | finite fraction in [0, 1]. |
| fraction(offsetM) | Double · fraction | finite offsetM in [0, lengthM]. |
| distanceM(fromFraction, toFraction) | Double · metres | Absolute distance, without route semantics. |
val metric = fr.nimby.sdk.TrackMetric(trackId = 1L, lengthM = 800.0)
check(metric.offsetM(0.25) == 200.0)
check(metric.fraction(400.0) == 0.5)
check(metric.distanceM(0.75, 0.25) == 400.0)TrackMetric
data class TrackMetric(val trackId: Long, val lengthM: Double)Observed longitudinal length in metres: nonzero identity and finite, strictly positive length. Converts fractions and metres locally; does not prove construction permission.
TrackMetric.trackId
val trackId: LongNonzero identity of the measured track.
TrackMetric.lengthM
val lengthM: DoubleLongitudinal length in metres, finite and strictly positive.
TrackMetric.offsetM
fun offsetM(fraction: Double): DoubleConverts a finite fraction between 0 and 1 to metres from track origin; rejects invalid input.
TrackMetric.fraction
fun fraction(offsetM: Double): DoubleConverts a finite distance between 0 and lengthM to a fraction; does not reverse direction.
TrackMetric.distanceM
fun distanceM(fromFraction: Double, toFraction: Double): DoubleAbsolute distance in metres between two valid fractions on this same track; not a route distance.
TrackMetric.positionAtMetres
fun positionAtMetres(offsetM: Double, direction: TrackDirection): PositionBuilds a Position at the given distance from origin with the chosen direction. Construction constraints still require separate checks.
TrackDirection
enum class TrackDirection(val nativeValue: Int) {
Forward(1),
Backward(-1)
}Longitudinal direction in the track representation, independent of its map orientation.
TrackDirection.nativeValue
val nativeValue: Int+1 for Forward, -1 for Backward, usable as Position.direction.
TrackDirection.Forward
Forward(1)Direction of increasing fractions, from 0 towards 1.
TrackDirection.Backward
Backward(-1)Direction of decreasing fractions, from 1 towards 0.