package space.nstart.pcp.pcp_mission_planing_service.service.satellite_type

import space.nstart.pcp.pcp_mission_planing_service.entity.PlanEntity
import space.nstart.pcp.pcp_mission_planing_service.entity.SurveyModeEntity
import space.nstart.pcp.pcp_mission_planing_service.entity.SurveyModeSource
import space.nstart.pcp.pcp_types_lib.dto.routes.SurveyModeStatus
import space.nstart.pcp.pcp_types_lib.dto.satellite.SatelliteDTO
import space.nstart.pcp.pcp_types_lib.dto.satellite.mission.SatelliteModeResponseDTO

abstract class LegacySatelliteMissionTypeSupport : SatelliteMissionType {
    override fun prepareSurvey(
        satellite: SatelliteDTO,
        surv: SatelliteModeResponseDTO,
        plan: PlanEntity
    ): SurveyModeEntity = SurveyModeEntity(
        plan = plan,
        timeStart = surv.startTime,
        revolution = surv.revolution,
        lat = surv.lat,
        long = surv.longitude,
        duration = surv.duration,
        contourWkt = surv.contourWkt,
        roll = surv.roll,
        satelliteModeId = surv.id,
        status = SurveyModeStatus.PLANNED,
        source = SurveyModeSource.valueOf(surv.source)
    )

    override fun calculateDropDuration(
        satellite: SatelliteDTO,
        survey: SurveyModeEntity
    ): Double = survey.duration * DEFAULT_DROP_DURATION_MULTIPLIER

    companion object {
        const val DEFAULT_DROP_DURATION_MULTIPLIER = 10.1
    }
}
