сравнение TLE
This commit is contained in:
+27
-6
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user