NRF SDK 0.9

Reference

TrackMetric

Convert track fractions and distances in metres.

Usage context

ModulePackageSDK source
Kotlin/JVMfr.nimby.sdkkotlin-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.

Imports on this page
import fr.nimby.sdk.TrackMetric
import fr.nimby.sdk.TrackDirection

Units and validation

ElementType / unitValidation
trackIdOpaque LongNonzero.
lengthMDouble · metresFinite and strictly positive.
offsetM(fraction)Double · metresfinite fraction in [0, 1].
fraction(offsetM)Double · fractionfinite offsetM in [0, lengthM].
distanceM(fromFraction, toFraction)Double · metresAbsolute distance, without route semantics.
kotlin
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

fr.nimby.sdk · class
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

fr.nimby.sdk · val
val trackId: Long

Nonzero identity of the measured track.

TrackMetric.lengthM

fr.nimby.sdk · val
val lengthM: Double

Longitudinal length in metres, finite and strictly positive.

TrackMetric.offsetM

fr.nimby.sdk · fun
fun offsetM(fraction: Double): Double

Converts a finite fraction between 0 and 1 to metres from track origin; rejects invalid input.

TrackMetric.fraction

fr.nimby.sdk · fun
fun fraction(offsetM: Double): Double

Converts a finite distance between 0 and lengthM to a fraction; does not reverse direction.

TrackMetric.distanceM

fr.nimby.sdk · fun
fun distanceM(fromFraction: Double, toFraction: Double): Double

Absolute distance in metres between two valid fractions on this same track; not a route distance.

TrackMetric.positionAtMetres

fr.nimby.sdk · fun
fun positionAtMetres(offsetM: Double, direction: TrackDirection): Position

Builds a Position at the given distance from origin with the chosen direction. Construction constraints still require separate checks.

TrackDirection

fr.nimby.sdk · class
enum class TrackDirection(val nativeValue: Int) {
    Forward(1),
    Backward(-1)
}

Longitudinal direction in the track representation, independent of its map orientation.

TrackDirection.nativeValue

fr.nimby.sdk · val
val nativeValue: Int

+1 for Forward, -1 for Backward, usable as Position.direction.

TrackDirection.Forward

fr.nimby.sdk · enum-entry
Forward(1)

Direction of increasing fractions, from 0 towards 1.

TrackDirection.Backward

fr.nimby.sdk · enum-entry
Backward(-1)

Direction of decreasing fractions, from 1 towards 0.