Skip to content

Commit

Permalink
Merge pull request #512 from Maprunner/dev
Browse files Browse the repository at this point in the history
Version 1.8.0
  • Loading branch information
Maprunner authored Mar 4, 2022
2 parents bd0d3a5 + a87726e commit 36097d0
Show file tree
Hide file tree
Showing 32 changed files with 1,440 additions and 3,079 deletions.
2 changes: 2 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ var clubs = [
"cvfr",
"darkandwhite",
"dee",
"dfok",
"devonoc",
"ebor",
"ecko",
Expand Down Expand Up @@ -227,6 +228,7 @@ var clubs = [
"nato",
"ngoc",
"noroc",
"nn",
"nwo",
"od",
"omm",
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Routegadget 2

## Latest news
Version 1.7.0 was released on 14th February 2022 and is installed on all routegadget.co.uk sites. This includes two new functions to help with race analysis:
* A new "Measure" icon has been added to the toolbar. If you click on this you can then measure different route options by drawing directly on the map. Distances are shown in metres for georeferenced maps and pixels for other maps.
* The "Courses" tab now has a slider for each course. This allows you to view only part of a course and route display and makes things much easier when analysing convoluted courses with a lot of crossovers.
Version 1.8.0 was released on 4th March 2022 and is installed on all routegadget.co.uk sites. This includes:
* Enhancements to the "Measure" function following use at HH Zoom meetings. Route nodes can be dragged to adjust them, overlays are only visible when dialog window is open, and "Delete all" button added.
* New manager function added to allow deletion of unused maps.
* Enhancement to course sliders so that they handle relay and score courses better.

## User Guide and Introductory Videos

Expand Down
38 changes: 29 additions & 9 deletions app/course.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,33 @@ public static function getCoursesForEvent($eventid)
$xpos = array();
$ypos = array();
$dummycontrols = array();
$excludedControls = array();
// @ suppresses error report if file does not exist
// read excluded controls for each course
// allows for road crossings with 0 splits
if (($handle = @fopen(KARTAT_DIRECTORY."exclude_".$eventid.".txt", "r")) !== false) {
while (($data = fgetcsv($handle, 0, "|")) !== false) {
$detail = array();
$detail["courseid"] = intval($data[0]);
$detail["controls"] = $data[1];
$excludedControls[] = $detail;
}
fclose($handle);
}

// read control codes for each course
if (($handle = @fopen(KARTAT_DIRECTORY."sarjojenkoodit_".$eventid.".txt", "r")) !== false) {
if (($handle = @fopen(KARTAT_DIRECTORY."sarjojenkoodit_".$eventid.".txt", "r")) !== false) {
$controlsFound = true;
while (($data = fgetcsv($handle, 0, "|")) !== false) {
// ignore first field: it is an index
$codes = array();
for ($j = 1; $j < count($data); $j++) {
$codes[$j - 1] = $data[$j];
}
$controls[$row] = $codes;
$row++;
// ignore first field: it is an index
$codes = array();
for ($j = 1; $j < count($data); $j++) {
$codes[$j - 1] = $data[$j];
}
$controls[$row] = $codes;
$row++;
}
fclose($handle);
fclose($handle);
}

// extract control locations based on map co-ords
Expand Down Expand Up @@ -85,6 +98,13 @@ public static function getCoursesForEvent($eventid)
$detail["xpos"] = array();
$detail["ypos"] = array();
}
$exclude = "";
for ($j = 0; $j < count($excludedControls); $j++) {
if ($excludedControls[$j]["courseid"] === intval($data[0])) {
$exclude = $excludedControls[$j]["controls"];
}
}
$detail["exclude"] = $exclude;
$output[$row] = $detail;
$row++;
}
Expand Down
61 changes: 60 additions & 1 deletion app/map.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public static function generateWorldFile($data)
}
// assumes various things about the three points
// works for RG2, may not work for the original, but we can live with that
// idealy we would have saved the world file rather than three points
// ideally we would have saved the world file rather than three points
if (($x[0]!== 0) || ($y[0] !== 0) || ($y[2] !== 0) || ($x[2] === 0)) {
return array(0, 0, 0, 0, 0, 0);
}
Expand All @@ -203,4 +203,63 @@ public static function generateWorldFile($data)

return array($A, $B, $C, $D, $E, $F);
}

public static function deleteUnusedMaps($data)
{
$write["status_msg"] = "";
$usedmapids = array();
$requestedids = $data->maps;

// extract list of used map ids
if (($handle = @fopen(KARTAT_DIRECTORY."kisat.txt", "r+")) !== false) {
while (($eventdata = fgetcsv($handle, 0, "|")) !== false) {
if (count($eventdata) > 2) {
$usedmapids[] = $eventdata[1];
}
}
}
@fclose($handle);

$dodelete = array();
// only delete requested list if they are really unused
for ($i = 0; $i < count($requestedids); $i++) {
if (!in_array($requestedids[$i], $usedmapids)) {
$dodelete[] = $requestedids[$i];
}
}

// delete maps from kartat file
$filename = KARTAT_DIRECTORY."kartat.txt";
$oldfile = file($filename);
$updatedfile = array();
foreach ($oldfile as $row) {
$data = explode("|", $row);
if (count($data) > 0) {
if (!in_array($data[0], $dodelete)) {
$updatedfile[] = $row;
}
}
}
$status = file_put_contents($filename, $updatedfile);
if ($status === false) {
$write["status_msg"] .= "Save error for kartat. ";
}

// delete associated map files
for ($i = 0; $i < count($dodelete); $i++) {
@unlink(KARTAT_DIRECTORY.$dodelete[$i].".jpg");
@unlink(KARTAT_DIRECTORY.$dodelete[$i].".gif");
@unlink(KARTAT_DIRECTORY."worldfile_".$dodelete[$i].".txt");
}

if ($write["status_msg"] == "") {
$write["ok"] = true;
$write["status_msg"] = "Unused maps deleted";
utils::rg2log("Unused maps deleted");
} else {
$write["ok"] = false;
}

return $write;
}
}
1 change: 0 additions & 1 deletion css/rg2-1.7.0.min.css

This file was deleted.

Loading

0 comments on commit 36097d0

Please sign in to comment.