Skip to content

Commit

Permalink
circling accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
jmlich committed Jun 7, 2020
1 parent 88f13f5 commit 9f0bf85
Show file tree
Hide file tree
Showing 6 changed files with 136 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CirclingResultsTableItemDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ Item {
case "distanceprev":
return parseFloat(value).toFixed(0);
case "azimuth":
case "minDistance":
case "maxDistance":
return parseFloat(value).toFixed(2);
case "minTime":
case "maxTime":
return F.addTimeStrFormat(F.timeToUnix(value));
default:
return value;
}
Expand Down
76 changes: 76 additions & 0 deletions PinchMap.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,82 @@ Rectangle {

function triggerSelectPosition() {
selectPosition(currentPositionIndex, currentPositionLat, currentPositionLon, currentPositionTime, currentPositionAltitude, currentPositionAzimuth)
console.log(selectedPoints.count)

for (var i = 1 ; i < selectedPoints.count; i++) {
var first = selectedPoints.get(i-1);
var second = selectedPoints.get(i);
if (first.gpsindex > second.gpsindex) {
computeCirclingAccuracy(i-1, second, first)
} else {
computeCirclingAccuracy(i-1, first, second)
}
}
}

function computeCirclingAccuracy(spi, first, second) {
var first_index = first.gpsindex
var second_index = second.gpsindex

var fixes = Math.abs(first_index - second_index);
if (fixes > 600) {
console.log("Fixes " + fixes + " > 600: too long");
return;
}

var points = trackModel.points;
if (points.length <= 0) {
console.log("Track doesn't have points?")
return;
}


var maxPtDist = 1000000;
var maxPtIndex = 0;
for (var p = 0; p < points.length; p++) {
var pt = points[p];
var distance = igc.getDistanceTo(first.lat, first.lon, pt.lat, pt.lon)
if (distance < maxPtDist) {
maxPtDist = distance;
maxPtIndex = p;
}
}

if (maxPtDist > 10000) {
console.log(pt.name + " to far from " + first_index + ": 10000 < "+maxPtDist)
return;
}

pt = points[maxPtIndex];

var minDistance = 100000;
var maxDistance = 0;
var minTime = first.time;
var maxTime = minTime;

for (var i = first_index; i <= second_index; i++) {
var fix = gpsModel.get(i);
// gps {"alt":"791","lat":"49.557199999999995","lon":"16.266216666666665","pressureAlt":"791","time":"10:33:11.000","type":"1","valid":"true"}
// first {"gpsindex":1991,"lat":49.557199999999995,"lon":16.266216666666665,"time":"10:33:11.000","alt":791,"azimuth":307.6247367272202,"distanceprev":0,"timetoprev":0,"timetoprev_str":"00:00:00"}

distance = igc.getDistanceTo(fix.lat, fix.lon, pt.lat, pt.lon);
// console.log("[" + i + "]: " + fix.time + " " + distance)
if (distance > maxDistance) {
maxDistance = distance
maxTime = fix.time;
}
if (distance < minDistance) {
minDistance = distance;
minTime = fix.time;
}
}
selectedPoints.setProperty(spi, "pointName", pt.name)
selectedPoints.setProperty(spi, "minDistance", minDistance);
selectedPoints.setProperty(spi, "minTime", minTime);
selectedPoints.setProperty(spi, "maxDistance", maxDistance);
selectedPoints.setProperty(spi, "maxTime", maxTime);

// circlingAccuracyResults(pt.name, minDistance, minTime, maxDistance, maxTime)
}

FileReader {
Expand Down
11 changes: 10 additions & 1 deletion ResultsDetailComponent.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,6 @@ Rectangle {
//% "Speed sections score points"
TableViewColumn {title: qsTrId("speed-sections-score-table-score"); role: "speedSecScore"; width: 80;}


// TableViewColumn {title: "calculatedSpeed"; role: "calculatedSpeed"; width: 50; }
// TableViewColumn {title: "maxScore"; role: "maxScore"; width: 50; }
// TableViewColumn {title: "speedPenaly"; role: "speedPenaly"; width: 50; }
Expand Down Expand Up @@ -1738,6 +1737,16 @@ Rectangle {
//% "Time to previous"
TableViewColumn {title: qsTrId("results-window-dialog-selected-position-time-previous"); role: "timetoprev_str"; width: 90;}

//% "Circling point"
TableViewColumn {title: qsTrId("results-window-dialog-selected-position-pointName"); role: "pointName"; width: 90; }
//% "d_min"
TableViewColumn {title: qsTrId("results-window-dialog-selected-position-minDistance"); role: "minDistance"; width: 60; }
//% "t_min"
TableViewColumn {title: qsTrId("results-window-dialog-selected-position-minTime"); role: "minTime"; width: 90; }
//% "d_max"
TableViewColumn {title: qsTrId("results-window-dialog-selected-position-maxDistance"); role: "maxDistance"; width: 60; }
//% "t_max"
TableViewColumn {title: qsTrId("results-window-dialog-selected-position-maxTime"); role: "maxTime"; width: 90; }


Component.onCompleted: {
Expand Down
20 changes: 20 additions & 0 deletions i18n/viewer_cs_CZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1972,6 +1972,26 @@
<source>Unable to complete the results upload. Please check the api key, destination competition, uploaded files and try it again.</source>
<translation>Nelze dokončit upload výsledků. Zkontrolujte prosím API klíč, zvolenou soutěž, nahrané soubory a zkuste to znovu.</translation>
</message>
<message id="results-window-dialog-selected-position-pointName">
<source>Circling point</source>
<translation>Bod kroužení</translation>
</message>
<message id="results-window-dialog-selected-position-minDistance">
<source>d_min</source>
<translation>d_min</translation>
</message>
<message id="results-window-dialog-selected-position-minTime">
<source>t_min</source>
<translation>t_min</translation>
</message>
<message id="results-window-dialog-selected-position-maxDistance">
<source>d_max</source>
<translation>d_max</translation>
</message>
<message id="results-window-dialog-selected-position-maxTime">
<source>t_max</source>
<translation>t_max</translation>
</message>
</context>
<context>
<name>CalendarWindow</name>
Expand Down
20 changes: 20 additions & 0 deletions i18n/viewer_en_US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1968,6 +1968,26 @@
<source>Unable to complete the results upload. Please check the api key, destination competition, uploaded files and try it again.</source>
<translation>Unable to complete the results upload. Please check the api key, destination competition, uploaded files and try it again.</translation>
</message>
<message id="results-window-dialog-selected-position-pointName">
<source>Circling point</source>
<translation>Circling point</translation>
</message>
<message id="results-window-dialog-selected-position-minDistance">
<source>d_min</source>
<translation>d_min</translation>
</message>
<message id="results-window-dialog-selected-position-minTime">
<source>t_min</source>
<translation>t_min</translation>
</message>
<message id="results-window-dialog-selected-position-maxDistance">
<source>d_max</source>
<translation>d_max</translation>
</message>
<message id="results-window-dialog-selected-position-maxTime">
<source>t_max</source>
<translation>t_max</translation>
</message>
</context>
<context>
<name>CalendarWindow</name>
Expand Down
5 changes: 5 additions & 0 deletions main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,11 @@ ApplicationWindow {
"distanceprev": 0,
"timetoprev": 0,
"timetoprev_str": "00:00:00",
"pointName": "",
"minDistance": 0,
"minTime": "",
"maxDistance": 0,
"maxTime": "",
}
positions.push(item);
console.log("positions added " + positions.length)
Expand Down

0 comments on commit 9f0bf85

Please sign in to comment.