LukeWoodward / SplitsBrowser

Orienteering results analysis
GNU General Public License v2.0
13 stars 9 forks source link

Enhancement for generating courseID #34

Closed dfgeorge closed 9 years ago

dfgeorge commented 9 years ago

I am using IOF 2.0.3 files, which dont contain course identifiers, so splitsbrowser does not provide the option to compare with other classes which ran the same course. To allow this I have generated a courseID based on the controlID's for the class, basically just concatinate all controlID's to make a courseID.

I have added the following to the end of Version2Reader.readCourseFromClass

var splitTimes = $("> SplitTime", firstResult).toArray();
    var courseID = "";
    if(splitTimes.length > 0)
{
  var arrayLength = splitTimes.length;
  for (var i = 0; i < arrayLength; i++) {
    courseID = courseID.concat($("> ControlCode", splitTimes[i]).text());
  }
}

    if (courseID.length == 0) {
       courseID = null;
    }
    // Climb does not appear in the per-competitor results.
    return {id: courseID, name: courseName, length: length, climb: null};

The IOF files I am using have all controls for all competitors, and the results are ordered (winner first) so I havn't put any additional code in to check I have the class winner.

This maybe usefull for other file types too.

LukeWoodward commented 9 years ago

That's an interesting idea I hadn't thought of before.

My only comment is that it might be an idea to comma-separate the control codes. For example. if one course has control 123 followed by control 45, and the other has control 12 followed by control 345, then there's a possibility they may be interpreted as the same course. (Admittedly this situation is highly unlikely.)

I'll think about it.