Skip to content

Commit

Permalink
Merge pull request #467 from Maprunner/dev
Browse files Browse the repository at this point in the history
Release 1.5.9
  • Loading branch information
Maprunner authored Apr 27, 2020
2 parents 138d114 + e9d1ed0 commit 9e2948c
Show file tree
Hide file tree
Showing 23 changed files with 420 additions and 1,116 deletions.
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [

{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000
}
]
}
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function (grunt) {
'gmoa', 'gramp', 'go', 'halo', 'happyherts', 'havoc', 'hoc', 'interlopers', 'invoc', 'jk', 'kerno', 'kfo', 'kongmmm',
'lamm', 'leioc', 'loc', 'log', 'lok', 'lvo', 'maroc', 'masterplanadventure', 'mdoc', 'mid-wales', 'moravian', 'mvoc',
'nato', 'ngoc', 'noroc', 'nwo', 'od', 'omm', 'orox', 'ouoc', 'oureaevents', 'pfo', 'potoc', 'quantock', 'rafo',
'roxburghreivers', 'run-herts', 'sa', 'sarum', 'saxons', 'sboc', 'scottish6days', 'seloc', 'slow', 'slmm', 'smbo',
'roxburghreivers', 'run-herts', 'sa', 'sarum', 'saxons', 'sboc', 'scottish6days', 'seloc', 'sl_2020', 'slow', 'slmm', 'smbo',
'smoc', 'sn', 'so', 'soa', 'soc', 'solway', 'sportident', 'sroc', 'stag', 'start', 'suffoc', 'swoc', 'syo', 'tay',
'test', 'purple-thistle', 'tinto', 'tvoc', 'walton', 'waoc', 'wcoc', 'wim', 'wmoc', 'wrekin', 'wsco2008', 'wsx'];

Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Routegadget 2

## Latest news
Version 1.5.8 was released on 11th January 2020 and is installed on all routegadget.co.uk sites. This includes several enhancements.

* The statistics display (accessed by double clicking on a runner on the results tab) has been further updated and now includes "performance" and "consistency" values. Performance represents how well you did against the average of the top 25% of splits for each leg. A higher score is better. Consistency gives an indication of how your performance on each leg varied. A lower score is better.

* Colour-coding of GPS routes for georeferenced maps is now based on minutes per kilometer. You can configure the speed range by setting the fast (green) and slow (red) speeds from the configuration dialog. Points below the slow setting are displayed in blue.

* Various minor changes have been made to improve the handling of incomplete results (e.g. missing punches).
Version 1.5.9 was released on 27th April 2020 and is installed on all routegadget.co.uk sites. This includes various minor enhancements to support events that are set up with no results.

## User Guide and Introductory Videos

Expand Down
18 changes: 17 additions & 1 deletion app/event.php
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,22 @@ public static function isScoreEvent($eventid)
return false;
}

public static function hasResults($eventid)
{
if (($handle = @fopen(KARTAT_DIRECTORY."kisat.txt", "r")) !== false) {
while (($data = fgetcsv($handle, 0, "|")) !== false) {
if ($data[0] == $eventid) {
if ($data[2] == 2) {
return false;
} else {
return true;
}
}
}
}
return false;
}

private static function sortEventsByDate($a, $b)
{
return strcmp($a["date"], $b["date"]);
Expand Down Expand Up @@ -532,4 +548,4 @@ public static function fixResults($id) {
utils::unlockDatabase();
}
}
}
}
44 changes: 40 additions & 4 deletions app/result.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static function getResultsForEvent($eventid)
$detail["name"] = trim(utils::encode_rg_input($data[3]));
$detail["starttime"] = intval($data[4]);
$detail["position"] = '';
$detail["status"] = '';
$detail["status"] = 'ok';
// look for RG2 extra fields in dbid
$databaseid = utils::encode_rg_input($data[5]);
$pos = strpos($databaseid, "_#");
Expand All @@ -116,8 +116,7 @@ public static function getResultsForEvent($eventid)
}
}
}
$detail["time"] = utils::tidyTime($data[7]);
;
list($detail["time"], $detail["secs"]) = utils::tidyTime($data[7]);
// trim trailing ;which create null fields when expanded
$temp = rtrim($data[8], ";");
// split array at ;and force to integers
Expand All @@ -133,6 +132,35 @@ public static function getResultsForEvent($eventid)
}
fclose($handle);
}

if (!event::hasResults($eventid)) {
// event with no results so need to sort times and add positions
// a lot easier to do this here in one place rather than when adding and deleting results
// avoids multiple rewrites of full results file plus need to manage route deletion
usort($output, "self::sortResultsByCourseThenTime");
$pos = 0;
$ties = 0;
$oldsecs = -1;
$courseid = -1;
for ($i = 0; $i < count($output); $i++) {
if ($courseid !== $output[$i]["courseid"]) {
// new course so reset
$pos = 1;
$courseid = $output[$i]["courseid"];
$ties = 0;
$oldsecs = -1;
} else {
// same course so check for ties
if ($oldsecs === $output[$i]["secs"]) {
$ties++;
} else {
$pos = $pos + 1 + $ties;
}
}
$output[$i]["position"] = $pos;
$oldsecs = $output[$i]["secs"];
}
}
return $output;
}

Expand Down Expand Up @@ -164,4 +192,12 @@ private static function isDefaultComment($comment)
}
return false;
}
}

private static function sortResultsByCourseThenTime($a, $b)
{
if (intval($a["courseid"]) !== intval($b["courseid"])) {
return (intval($a["courseid"]) - intval($b["courseid"]));
}
return (intval($a["secs"]) - intval($b["secs"]));
}
}
31 changes: 19 additions & 12 deletions app/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ public static function getRoutesForEvent($eventid)
if (($resultid > 0) && ($resultid < GPS_RESULT_OFFSET) && ($courseid > 0)) {
$detail = array();
$detail["id"] = $resultid;
list($detail["x"], $detail["y"]) = self::expandCoords($data[4]);
$output[] = $detail;
}
list($ok, $detail["x"], $detail["y"]) = self::expandCoords($data[4]);
if ($ok) {
$output[] = $detail;
} else {
utils::rg2log("Invalid route for eventid ".$eventid." for result ".$resultid);
}
}
}
fclose($handle);
}
Expand All @@ -33,8 +37,11 @@ public static function getRoutesForEvent($eventid)
$detail = array();
$detail["id"] = $resultid;
// list allocates return values in an array to the specified variables
list($detail["x"], $detail["y"]) = self::expandCoords($data[9]);
$output[] = $detail;
list($ok, $detail["x"], $detail["y"]) = self::expandCoords($data[9]);
if ($ok) {
$output[] = $detail;
} else {
utils::rg2log("Invalid route for eventid ".$eventid." for result ".$resultid); }
}
}
}
Expand Down Expand Up @@ -345,7 +352,7 @@ private static function expandCoords($coords)
// handle empty coord string: found some examples in Jukola files
// 5 is enough for one coordinate set, but the problem files just had "0"
if (strlen($coords) < 5) {
return array("", "");
return array(false, [], []);
}

// cope with strange zero-filled routes that start with ;
Expand All @@ -357,12 +364,12 @@ private static function expandCoords($coords)
if (count($temp) == 2) {
$x[] = $temp[0];
// strip off trailing ,0 if it exists
$pos = strpos($temp[1], ",");
if ($pos !== false) {
// remove leading - by starting at 1
$y[] = substr($temp[1], 1, $pos - 1);
} else {
$temp[1] = str_replace(",0", "", $temp[1]);
// y value should be negative (apparently...) but sometimes isn't for old files
if ((substr($temp[1], 0, 1) === "-") && (strlen($temp[1]) > 1)) {
$y[] = substr($temp[1], 1);
} else {
return array(false, [], []);
}
}
}
Expand All @@ -374,6 +381,6 @@ private static function expandCoords($coords)

// return the two arrays as comma-separated strings
// used to return as integer arrays, but this caused memory problems in json_encode
return array(implode(",", $x), implode(",", $y));
return array(true, implode(",", $x), implode(",", $y));
}
}
4 changes: 2 additions & 2 deletions app/splitsbrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private static function getResultsCSV($eventid)
foreach ($results as $result) {
$data = explode("|", $result);
// extract time
$t = utils::tidyTime($data[7]);
list($t, $temp) = utils::tidyTime($data[7]);
if (intval($data[0]) < GPS_RESULT_OFFSET) {
if ($first_line) {
$first_line = false;
Expand Down Expand Up @@ -169,4 +169,4 @@ private static function convertSecondsToMMSS($seconds)
return sprintf('%d:%02d', $mins, $secs);
;
}
}
}
13 changes: 12 additions & 1 deletion app/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ public static function tidyNewComments($inputComments)
return $comments;
}

public static function getSecsFromHHMM($t) {
// gets in (H)HH:MM and needs to return seconds
$bits = explode(":", $t);
if (count($bits) === 2) {
return ((intval($bits[0]) * 60) + intval($bits[1]));
} else {
return 0;
}

}

public static function tidyTime($in)
{
// takes what should be a time as mm:ss or hh:mm:ss and tidies it up
Expand All @@ -105,7 +116,7 @@ public static function tidyTime($in)
$mins = (intval($bits[0]) * 60) + intval($bits[1]);
$t = $mins.":".$bits[2];
}
return $t;
return array($t, self::getSecsFromHHMM($t));
}

public static function getAngle($x1, $y1, $x2, $y2)
Expand Down
2 changes: 1 addition & 1 deletion css/rg2-1.5.8.min.css → css/rg2-1.5.9.min.css

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions css/rg2.css
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,16 @@ body {
user-select: none;
}

.selectable {
-ms-user-select: all;
-webkit-user-select: all;
-khtml-user-select: all;
-moz-user-select: all;
-webkit-touch-callout: all;
-webkit-user-drag: all;
user-select: all;
}

.manage-input {
margin-top: 3px;
margin-right: 3px;
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
require(dirname(__FILE__) . '/app/utils.php');

// version replaced by Gruntfile as part of release
define('RG2VERSION', '1.5.8');
define('RG2VERSION', '1.5.9');
define("RG_LOG_FILE", dirname(__FILE__)."/log/rg2log.txt");

if (file_exists(dirname(__FILE__) . '/rg2-config.php')) {
Expand Down
2 changes: 1 addition & 1 deletion js/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
EVENT_WITHOUT_RESULTS: 2,
SCORE_EVENT: 3,
// version gets set automatically by grunt file during build process
RG2VERSION: '1.5.8',
RG2VERSION: '1.5.9',
TIME_NOT_FOUND: 9999,
// values for evt.which
RIGHT_CLICK: 3,
Expand Down
4 changes: 4 additions & 0 deletions js/courses.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
return this.courses[courseid].name;
},

isValidCourseId: function (courseid) {
return courseid < this.courses.length;
},

getCoursesForEvent: function () {
var i, course, courses;
courses = [];
Expand Down
33 changes: 22 additions & 11 deletions js/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,20 @@
}
// save each result
for (i = 0; i < l; i += 1) {
if (data[i].resultid > rg2.config.GPS_RESULT_OFFSET && data[i].coursename === '') {
data[i].coursename = rg2.courses.getCourseDetails(data[i].courseid).name;
}
if (isScoreEvent) {
variant = data[i].variant;
result = new rg2.Result(data[i], isScoreEvent, codes[variant], scorex[variant], scorey[variant]);
} else {
result = new rg2.Result(data[i], isScoreEvent);
}
this.results.push(result);
// trap cases where only some courses for an event are set up, but for some reason all the results get saved
// so you end up getting results for courses you don't know about: kust ignore these results
if (rg2.courses.isValidCourseId(data[i].courseid)) {
if (data[i].resultid > rg2.config.GPS_RESULT_OFFSET && data[i].coursename === '') {
data[i].coursename = rg2.courses.getCourseDetails(data[i].courseid).name;
}
if (isScoreEvent) {
variant = data[i].variant;
result = new rg2.Result(data[i], isScoreEvent, codes[variant], scorex[variant], scorey[variant]);
} else {
result = new rg2.Result(data[i], isScoreEvent);
}
this.results.push(result);
}
}
this.setDeletionInfo();
this.setScoreCourseInfo();
Expand Down Expand Up @@ -637,6 +641,11 @@

prepareResults: function () {
var oldID, i, canCombine;
// no concept of combining for events with no initial results
// this also avoids the sort which we don't want
if (!rg2.events.hasResults()) {
return;
}
// want to avoid extra results line for GPS routes if there is no drawn route
// first sort so that GPS routes come after initial result
this.results.sort(this.sortByCourseIDThenResultID);
Expand Down Expand Up @@ -714,7 +723,9 @@
comments = "";
for (i = 0; i < this.results.length; i += 1) {
if (this.results[i].comments !== "") {
comments += "<tr><td><strong>" + this.results[i].name + "</strong></td><td>" + this.results[i].coursename + "</td><td>" + this.results[i].comments + "</td></tr>";
comments += "<tr><td><strong>" + this.results[i].name + "</strong></td><td>";
comments += this.results[i].coursename + "</td><td class='selectable'>" + this.results[i].comments + "</td></tr>";

}
}
return comments;
Expand Down
4 changes: 0 additions & 4 deletions js/rg2-1.5.8.min.js

This file was deleted.

1 change: 0 additions & 1 deletion js/rg2-1.5.8.min.js.map

This file was deleted.

4 changes: 4 additions & 0 deletions js/rg2-1.5.9.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/rg2-1.5.9.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/rg2manager-1.5.8.min.js → js/rg2manager-1.5.9.min.js

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 9e2948c

Please sign in to comment.