Усредение точек в проекции ГК

This commit is contained in:
2025-12-01 09:54:22 +03:00
parent d521b6baad
commit 01871c3e13
7 changed files with 437 additions and 154 deletions

View File

@@ -40,9 +40,6 @@
<li class="nav-item">
<a class="nav-link" href="{% url 'mainapp:kubsat' %}">Кубсат</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'mainapp:points_averaging' %}">Усреднение</a>
</li>
<!-- <li class="nav-item">
<a class="nav-link" href="{% url 'mapsapp:3dmap' %}">3D карта</a>
</li> -->

View File

@@ -280,7 +280,6 @@ document.addEventListener('DOMContentLoaded', function() {
headerWordWrap: true,
columns: [
{title: "Объект наблюдения", field: "source_name", minWidth: 180, widthGrow: 2},
{title: "Интервал", field: "interval_label", minWidth: 150, widthGrow: 1.5},
{title: "Частота, МГц", field: "frequency", minWidth: 100, widthGrow: 1},
{title: "Полоса, МГц", field: "freq_range", minWidth: 100, widthGrow: 1},
{title: "Символьная скорость, БОД", field: "bod_velocity", minWidth: 120, widthGrow: 1.5},
@@ -288,20 +287,8 @@ document.addEventListener('DOMContentLoaded', function() {
{title: "ОСШ", field: "snr", minWidth: 70, widthGrow: 0.8},
{title: "Зеркала", field: "mirrors", minWidth: 130, widthGrow: 1.5},
{title: "Усреднённые координаты", field: "avg_coordinates", minWidth: 150, widthGrow: 2},
{title: "Медианное время", field: "avg_time", minWidth: 120, widthGrow: 1},
{title: "Кол-во точек", field: "total_points", minWidth: 80, widthGrow: 0.8, hozAlign: "center"},
{
title: "Статус",
field: "status",
minWidth: 120,
widthGrow: 1,
formatter: function(cell, formatterParams, onRendered) {
const data = cell.getRow().getData();
if (data.has_outliers) {
return `<span class="outlier-warning"><i class="bi bi-exclamation-triangle"></i> Выбросы (${data.outliers_count})</span>`;
}
return '<span class="text-success"><i class="bi bi-check-circle"></i> OK</span>';
}
},
{
title: "Действия",
field: "actions",
@@ -504,7 +491,8 @@ document.addEventListener('DOMContentLoaded', function() {
});
// Show group details modal
function showGroupDetails(groupIndex) {
// skipShow=true means just update content without calling modal.show()
function showGroupDetails(groupIndex, skipShow = false) {
currentGroupIndex = groupIndex;
const group = allGroupsData[groupIndex];
@@ -637,9 +625,15 @@ document.addEventListener('DOMContentLoaded', function() {
});
});
// Show modal
const modal = new bootstrap.Modal(document.getElementById('groupDetailsModal'));
modal.show();
// Show modal - use getOrCreateInstance to avoid creating multiple instances
if (!skipShow) {
const modalElement = document.getElementById('groupDetailsModal');
let modal = bootstrap.Modal.getInstance(modalElement);
if (!modal) {
modal = new bootstrap.Modal(modalElement);
}
modal.show();
}
}
// Remove point from group and recalculate
@@ -653,6 +647,10 @@ document.addEventListener('DOMContentLoaded', function() {
return;
}
if (!confirm('Удалить эту точку из выборки и пересчитать усреднение?')) {
return;
}
// Remove point
group.points.splice(pointIndex, 1);
@@ -664,14 +662,12 @@ document.addEventListener('DOMContentLoaded', function() {
async function recalculateGroup(groupIndex, includeAll) {
const group = allGroupsData[groupIndex];
if (!group) {
hideLoading();
return;
}
// Check if there are points to process
if (!group.points || group.points.length === 0) {
alert('Нет точек для пересчёта');
hideLoading();
return;
}
@@ -694,7 +690,6 @@ document.addEventListener('DOMContentLoaded', function() {
if (!response.ok) {
alert(data.error || 'Ошибка при пересчёте');
hideLoading();
return;
}
@@ -705,6 +700,8 @@ document.addEventListener('DOMContentLoaded', function() {
group.valid_points_count = data.valid_points_count;
group.outliers_count = data.outliers_count;
group.has_outliers = data.has_outliers;
group.mirrors = data.mirrors || group.mirrors;
group.avg_time = data.avg_time || group.avg_time;
group.points = data.points;
// Update table
@@ -716,9 +713,9 @@ document.addEventListener('DOMContentLoaded', function() {
// Update all points table
updateAllPointsTable();
// Update modal if open
// Update modal content without calling show() again
if (currentGroupIndex === groupIndex) {
showGroupDetails(groupIndex);
showGroupDetails(groupIndex, true);
}
} catch (error) {
@@ -730,16 +727,16 @@ document.addEventListener('DOMContentLoaded', function() {
}
// Average all points button
document.getElementById('btn-average-all').addEventListener('click', function() {
document.getElementById('btn-average-all').addEventListener('click', async function() {
if (currentGroupIndex !== null) {
recalculateGroup(currentGroupIndex, true);
await recalculateGroup(currentGroupIndex, true);
}
});
// Average valid points button
document.getElementById('btn-average-valid').addEventListener('click', function() {
document.getElementById('btn-average-valid').addEventListener('click', async function() {
if (currentGroupIndex !== null) {
recalculateGroup(currentGroupIndex, false);
await recalculateGroup(currentGroupIndex, false);
}
});
@@ -753,7 +750,6 @@ document.addEventListener('DOMContentLoaded', function() {
// Prepare summary data for export
const summaryData = allGroupsData.map(group => ({
'Объект наблюдения': group.source_name,
'Интервал': group.interval_label,
'Частота, МГц': group.frequency,
'Полоса, МГц': group.freq_range,
'Символьная скорость, БОД': group.bod_velocity,
@@ -761,9 +757,8 @@ document.addEventListener('DOMContentLoaded', function() {
'ОСШ': group.snr,
'Зеркала': group.mirrors,
'Усреднённые координаты': group.avg_coordinates,
'Кол-во точек': group.total_points,
'Выбросов': group.outliers_count,
'Статус': group.has_outliers ? 'Есть выбросы' : 'OK'
'Медианное время': group.avg_time || '-',
'Кол-во точек': group.total_points
}));
// Prepare all points data for export

View File

@@ -98,6 +98,9 @@
onclick="showSelectedOnMap()">
<i class="bi bi-map"></i> Карта
</button>
<a href="{% url 'mainapp:points_averaging' %}" class="btn btn-warning btn-sm" title="Усреднение точек">
<i class="bi bi-calculator"></i> Усреднение
</a>
</div>
<!-- Add to List Button -->