Skip to content

Commit

Permalink
Adds time of day and better qso mapping to statistics (reporting) window
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleboyle committed Nov 13, 2024
1 parent eb4cf37 commit 851c6b7
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 51 deletions.
33 changes: 29 additions & 4 deletions res/map/onlinemap.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@
popupAnchor: [1, -34],
shadowSize: [41, 41]
});
const greenIconSmall = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-green.png',
shadowUrl: 'https://unpkg.com/leaflet@1.7.1/dist/images/marker-shadow.png',
iconSize: [14, 23],
iconAnchor: [7, 23],
popupAnchor: [1, -18],
shadowSize: [23, 23]
});

// yellow Icon definition. It is usually used for generic QSOs or generic point
const yellowIcon = new L.Icon({
Expand All @@ -100,12 +108,21 @@
shadowSize: [41, 41]
});

const yellowIconSmall = new L.Icon({
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-gold.png',
shadowUrl: 'https://unpkg.com/leaflet@1.7.1/dist/images/marker-shadow.png',
iconSize: [14, 23],
iconAnchor: [7, 23],
popupAnchor: [1, -18],
shadowSize: [23, 23]
});

// home Icon definition. It is usually used for own location
const homeIcon = new L.Icon({
iconUrl: 'https://img.icons8.com/officel/30/000000/radio-tower.png',
iconSize: [50, 50],
iconAnchor: [12, 41],
popupAnchor: [1, -34]
iconSize: [30, 30],
iconAnchor: [15, 25],
popupAnchor: [1, -14]
});


Expand Down Expand Up @@ -178,7 +195,15 @@
return;
geodesic.setLatLngs([points[0], points[1]]);
map.fitBounds(geodesic.getBounds(), {animate:false});
//map.panTo(geodesic.getBounds().getCenter(), {animate:false});
}

function drawShortPaths(coords) {
pathLayer.clearLayers();
coords.forEach(function(coord) {
let geodesic = new L.Geodesic([],{ wrap: true, color: "#cc2e41", steps: 5, opacity: 0.7, weight: 1});
pathLayer.addLayer(geodesic);
geodesic.setLatLngs([{lat: coord[0], lng: coord[1]}, {lat: coord[2], lng: coord[3]}]);
});
}

// function computes a destination point based on distance and azimuth
Expand Down
12 changes: 11 additions & 1 deletion ui/MapWebChannelHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ void MapWebChannelHandler::connectWebChannel(QWebEnginePage *page)
" case '" + tr("WSJTX - CQ") + "': "
" foo.handleLayerSelectionChanged('wsjtxStationsLayer', 'on'); "
" break; "
" case '" + tr("Paths") + "': "
" foo.handleLayerSelectionChanged('pathLayer', 'on'); "
" break; "
" } "
"});"
"map.on('overlayremove', function(e){ "
Expand Down Expand Up @@ -87,6 +90,9 @@ void MapWebChannelHandler::connectWebChannel(QWebEnginePage *page)
" case '" + tr("WSJTX - CQ") + "': "
" foo.handleLayerSelectionChanged('wsjtxStationsLayer', 'off'); "
" break; "
" case '" + tr("Paths") + "': "
" foo.handleLayerSelectionChanged('pathLayer', 'off'); "
" break; "
" } "
"});";
page->runJavaScript(js);
Expand Down Expand Up @@ -124,7 +130,8 @@ QString MapWebChannelHandler::generateMapMenuJS(bool gridLayer,
bool ibp,
bool antpath,
bool chatStations,
bool wsjtxStations)
bool wsjtxStations,
bool paths)
{
FCT_IDENTIFICATION;
QStringList options;
Expand Down Expand Up @@ -153,6 +160,9 @@ QString MapWebChannelHandler::generateMapMenuJS(bool gridLayer,
if ( wsjtxStations )
options << "\"" + tr("WSJTX - CQ") + "\": wsjtxStationsLayer";

if ( paths )
options << "\"" + tr("Paths") + "\": pathLayer";

QString ret = QString("var layerControl = new L.Control.Layers(null,"
"{ %1 },{}).addTo(map);").arg(options.join(","));

Expand Down
3 changes: 2 additions & 1 deletion ui/MapWebChannelHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class MapWebChannelHandler : public QObject
bool ibp = false,
bool antpath = false,
bool chatStations = false,
bool wsjtxStations = false);
bool wsjtxStations = false,
bool paths = false);

signals:
void chatCallsignPressed(QString);
Expand Down
32 changes: 21 additions & 11 deletions ui/StatisticsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ void StatisticsWidget::refreshGraph()
genericFilter << " (band = '" + ui->bandCombo->currentText() + "') ";

if ( ui->useDateRangeCheckBox->isChecked() )
genericFilter << " (date(start_time) BETWEEN date('" + ui->startDateEdit->date().toString("yyyy-MM-dd")
+ " 00:00:00') AND date('" + ui->endDateEdit->date().toString("yyyy-MM-dd") + " 23:59:59') ) ";
genericFilter << " (datetime(start_time) BETWEEN datetime('" + ui->startDateEdit->dateTime().toString("yyyy-MM-dd HH:mm:ss")
+ "') AND datetime('" + ui->endDateEdit->dateTime().toString("yyyy-MM-dd HH:mm:ss") + "') ) ";

qCDebug(runtime) << "main " << ui->statTypeMainCombo->currentIndex()
<< " secondary " << ui->statTypeSecCombo->currentIndex();
Expand Down Expand Up @@ -316,15 +316,15 @@ void StatisticsWidget::refreshGraph()
{
case 0:
case 1:
stmt = "SELECT callsign, gridsquare, SUM(confirmed) FROM (SELECT callsign, gridsquare, "
stmt = "SELECT callsign, gridsquare, my_gridsquare, SUM(confirmed) FROM (SELECT callsign, gridsquare, my_gridsquare,"
+ innerCase +" AS confirmed FROM contacts WHERE gridsquare is not NULL AND "
+ genericFilter.join(" AND ") +" ) GROUP BY callsign, gridsquare";
+ genericFilter.join(" AND ") +" ) GROUP BY callsign, gridsquare, my_gridsquare";
break;
case 2:
QString unit;
Gridsquare::distance2localeUnitDistance(0, unit);
QString distCoef = QString::number(Gridsquare::localeDistanceCoef());
QString sel = QString("SELECT callsign || '<br>' || CAST(ROUND(distance * %1,0) AS INT) || ' %2', gridsquare, ").arg(distCoef, unit);
QString sel = QString("SELECT callsign || '<br>' || CAST(ROUND(distance * %1,0) AS INT) || ' %2', gridsquare, my_gridsquare, ").arg(distCoef, unit);

stmt = sel + innerCase + " AS confirmed FROM contacts WHERE "
+ genericFilter.join(" AND ") + " AND distance = (SELECT MAX(distance) FROM contacts WHERE "
Expand Down Expand Up @@ -376,7 +376,7 @@ void StatisticsWidget::mapLoaded(bool)
isMainPageLoaded = true;

/* which layers will be active */
postponedScripts += layerControlHandler.generateMapMenuJS();
postponedScripts += layerControlHandler.generateMapMenuJS(true, false, false, false, false, false, false, false, true);
main_page->runJavaScript(postponedScripts);

layerControlHandler.restoreLayerControlStates(main_page);
Expand Down Expand Up @@ -418,10 +418,12 @@ StatisticsWidget::StatisticsWidget(QWidget *parent) :
ui->myAntennaCombo->setModel(new QStringListModel(this));
ui->bandCombo->setModel(new QStringListModel(this));

ui->startDateEdit->setDisplayFormat(locale.formatDateShortWithYYYY());
ui->startDateEdit->setDisplayFormat(locale.formatDateTimeShortWithYYYY());
ui->startDateEdit->setDate(QDate::currentDate().addDays(DEFAULT_STAT_RANGE));
ui->endDateEdit->setDisplayFormat(locale.formatDateShortWithYYYY());
ui->startDateEdit->setTime(QTime::fromMSecsSinceStartOfDay(0));
ui->endDateEdit->setDisplayFormat(locale.formatDateTimeShortWithYYYY());
ui->endDateEdit->setDate(QDate::currentDate());
ui->endDateEdit->setTime(QTime::fromMSecsSinceStartOfDay(86399999));

ui->graphView->setRenderHint(QPainter::Antialiasing);
ui->graphView->setChart(new QChart());
Expand Down Expand Up @@ -575,13 +577,14 @@ void StatisticsWidget::drawPointsOnMap(QSqlQuery &query)
return;

QList<QString> stations;
QList<QString> shortPaths;

qulonglong count = 0;

while ( query.next() )
{
const Gridsquare stationGrid(query.value(1).toString());

const Gridsquare myStationGrid(query.value(2).toString());
if ( stationGrid.isValid() )
{
count++;
Expand All @@ -590,7 +593,12 @@ void StatisticsWidget::drawPointsOnMap(QSqlQuery &query)
stations.append(QString("[\"%1\", %2, %3, %4]").arg(query.value(0).toString())
.arg(lat)
.arg(lon)
.arg((query.value(2).toInt()) > 0 ? "greenIcon" : "yellowIcon"));
.arg((query.value(3).toInt()) > 0 ? "greenIconSmall" : "yellowIconSmall"));
shortPaths.append(QString("[%1, %2, %3, %4]")
.arg(myStationGrid.getLatitude())
.arg(myStationGrid.getLongitude())
.arg(lat)
.arg(lon));
}
}

Expand All @@ -607,7 +615,8 @@ void StatisticsWidget::drawPointsOnMap(QSqlQuery &query)
QString javaScript = QString("grids_confirmed = [];"
"grids_worked = [];"
"drawPoints([%1]);"
"maidenheadConfWorked.redraw();").arg(stations.join(","));
"drawShortPaths([%2]);"
"maidenheadConfWorked.redraw();").arg(stations.join(",")).arg(shortPaths.join(","));

qCDebug(runtime) << javaScript;

Expand Down Expand Up @@ -639,6 +648,7 @@ void StatisticsWidget::drawFilledGridsOnMap(QSqlQuery &query)
"grids_worked = [ %2 ];"
"mylocations = [];"
"drawPoints([]);"
"drawShortPaths([]);"
"maidenheadConfWorked.redraw();").arg(confirmedGrids.join(","), workedGrids.join(","));

qCDebug(runtime) << javaScript;
Expand Down
Loading

0 comments on commit 851c6b7

Please sign in to comment.