исправлен расчет витка для tle

This commit is contained in:
emelianov
2026-06-16 12:26:24 +03:00
parent 1790192e06
commit 6938700218
4 changed files with 205 additions and 2 deletions
@@ -23,7 +23,7 @@ class SurveyContourCalculator(
fun calculate(result: AngularMotionResult, y: Double,z: Double,focus: Double): String {
val sourcePoints = result.points
val sourcePoints = decimateContourSourcePoints(result.points)
require(sourcePoints.size >= MIN_CONTOUR_POINTS) {
"Для построения контура съемки требуется не менее $MIN_CONTOUR_POINTS точек ПУУД"
}
@@ -62,6 +62,43 @@ class SurveyContourCalculator(
return toWkt(shell)
}
private fun decimateContourSourcePoints(points: List<AngularMotionPoint>): List<AngularMotionPoint> {
if (points.size <= MIN_CONTOUR_POINTS) {
return points
}
val startTime = points.first().t
val stopTime = points.last().t
val duration = stopTime - startTime
if (duration <= 0.0) {
return listOf(points.first(), points.last()).distinct()
}
val step = maxOf(
DEFAULT_CONTOUR_SOURCE_STEP_SEC,
duration / (MAX_CONTOUR_BOUNDARY_POINTS - 1),
)
val selected = ArrayList<AngularMotionPoint>(MAX_CONTOUR_BOUNDARY_POINTS)
selected += points.first()
var nextTime = startTime + step
for (index in 1 until points.lastIndex) {
val point = points[index]
if (point.t + TIME_EPS >= nextTime) {
selected += point
nextTime += step
}
}
if (selected.last() !== points.last()) {
selected += points.last()
}
return selected
}
private fun toWkt(points: List<SurveyContourPoint>): String {
val coordinates = points.joinToString(", ") { point ->
String.format(Locale.US, "%.8f %.8f", point.longitudeDeg, point.latitudeDeg)
@@ -85,5 +122,8 @@ class SurveyContourCalculator(
private companion object {
const val MIN_CONTOUR_POINTS = 2
const val DEFAULT_CONTOUR_SOURCE_STEP_SEC = 2.0
const val MAX_CONTOUR_BOUNDARY_POINTS = 10
const val TIME_EPS = 1.0e-9
}
}