package org.nstart.dep265.tletools.zeptomoby.orbit

import org.nstart.dep265.tletools.zeptomoby.core.Julian
import org.nstart.dep265.tletools.zeptomoby.core.TLE

@Suppress("unused")
class Satellite(tle: TLE, n: String? = null) {

    val name: String
    val orbit: Orbit

    init {
        orbit = Orbit(tle)
        name = n ?: orbit.satName
    }

    fun positionEci(time: Julian) = positionEci(time.spanMin(orbit.epoch))
    fun positionEci(mpe: Double) = orbit.positionEci(mpe)

    fun copy(src: Satellite) = Satellite(TLE(src.orbit.satName, src.orbit.tleFirstLine, src.orbit.tleSecondLine), name.ifEmpty { null })

    val tleName: String
        get() = orbit.satName
}