сравнение TLE

This commit is contained in:
emelianov
2026-05-27 12:35:20 +03:00
parent f4014a08a1
commit d07b17e03e
12 changed files with 625 additions and 6 deletions
@@ -25,12 +25,33 @@ class TLEController {
private lateinit var celestrakService: CelesTrakService
@GetMapping()
fun all() = tleRepository.findAll().map { tle ->
val t = tle.tle.split("\r\n")
TLEExtensionDTO(
tle.satelliteId,
tle.revolution,
TLEDTO(t[0], t[1], t[2])
fun all() = tleRepository.findAll().map { tle -> tle.toDto() }
@GetMapping("/satellite/{satelliteId}")
fun bySatellite(@PathVariable satelliteId: Long) =
tleRepository.findAllBySatelliteIdOrderByTimeTleAsc(satelliteId).map { tle -> tle.toDto() }
private fun space.nstart.pcp.tle_monitoring_service.entity.TLEEntity.toDto(): TLEExtensionDTO {
val lines = tle.lines().map { it.trimEnd() }.filter { it.isNotBlank() }
val header = when {
lines.size >= 3 -> lines[0]
else -> null
}
val first = when {
lines.size >= 3 -> lines[1]
lines.size >= 2 -> lines[0]
else -> " ".repeat(69)
}
val second = when {
lines.size >= 3 -> lines[2]
lines.size >= 2 -> lines[1]
else -> " ".repeat(69)
}
return TLEExtensionDTO(
satelliteId,
revolution,
TLEDTO(header, first, second)
)
}
@@ -9,6 +9,8 @@ interface TLERepository : JpaRepository<TLEEntity, Long> {
fun findAllBySatelliteId(id : Long) : List<TLEEntity>
fun findAllBySatelliteIdOrderByTimeTleAsc(id: Long): List<TLEEntity>
fun countBySatelliteId(id: Long): Long
fun deleteAllBySatelliteId(id: Long): Long