Commit e300cde7 authored by Eric - kg6wxc's avatar Eric - kg6wxc
Browse files

more edits for the change to kilometers

parent 2368597c
......@@ -187,7 +187,14 @@ function wxc_checkDB () {
$oldDistanceTriggerQuery = "select action_statement from information_schema.triggers where action_statement like '%3959%'";
if ($oldDistanceTriggerQuery) {
$sql = "drop trigger topology_get_latlons_brg_dist";
wxc_putMySql($sql);
mysqli_query($GLOBALS['sql_connection'], $sql)
or die(wxc_addColor("Could not drop SQL Trigger!", "red") . "\n" .
"Please try to use the \"" . wxc_addColor("updateDBtoKilometers.sql", "bold") . "\" file.\n" .
"Example: " . wxc_addColor("sudo mysql -D node_map < /home/pi/meshmap/updateDBtoKilometers.sql", "bold") . "\n\n" .
"or... try to fix the following,\n" .
wxc_addColor("SQL Error:", "red") . "\n" .
mysqli_error($GLOBALS['sql_connection']) . "\n\n");
$sql = "CREATE TRIGGER `topology_get_latlons_brg_dist` BEFORE INSERT ON `topology` FOR EACH ROW BEGIN
-- get locations and names for each end of the link
......@@ -208,7 +215,16 @@ function wxc_checkDB () {
SET NEW.distance = round(2*asin(sqrt(pow(sin((radians(NEW.linklat)-radians(NEW.nodelat))/2),2)+cos(radians(NEW.nodelat))*cos(radians(NEW. linklat))*pow(sin((radians(NEW.linklon)-radians(NEW.nodelon))/2),2)))*6371,2);
END;";
wxc_putMySql($sql);
mysqli_query($GLOBALS['sql_connection'], $sql)
or die(wxc_addColor("Could not recreate SQL Trigger to use Kilometers.", "red") . "\n" .
wxc_addColor("The Trigger may have already been dropped as well!", "redBold") . "\n" .
"Please try to use the \"". wxc_addColor("updateDBtoKilometers.sql", "bold") . "\" file.\n" .
"Example: " . wxc_addColor("sudo mysql -D node_map < /home/pi/meshmap/updateDBtoKilometers.sql", "bold") . "\n\n" .
"or... try to fix the following,\n" .
wxc_addColor("SQL Error:", "red") . "\n" .
mysqli_error($GLOBALS['sql_connection']) . "\n");
unset($oldDistanceTriggerQuery);
unset($sql);
$mesg = "Changed database to have default distance in Kilometers.";
......
......@@ -391,6 +391,10 @@ function load_LinkedTO($node_info, $TopoList)
}
//now take all that info back out and put into a properly formatted string variable that we'll use later
//this part of the function reformatted by kg6wxc.
//the "kilometers" setting will default to "0"
if (!isset($GLOBALS['USER_SETTINGS']['kilometers'])) {
$GLOBALS['USER_SETTINGS']['kilometers'] = "0";
}
foreach ($linkInfoForStationPopups as $nodeNameLinkArray => $linktoArray) {
if (!empty($linktoArray)) {
foreach ($linktoArray as $linkedNodeName => $costArray) {
......
......@@ -464,6 +464,32 @@ function wxc_echoWithColor ($text, $color) {
if ($color == 'alert') {
echo "\033[41m\033[30m\033[1m" . $text . "\033[0m";
}
if ($color == 'bold') {
echo "\033[1m" . $text . "\033[0m";
}
}
function wxc_addColor ($text, $color) {
if ($color == "red") {
return "\33[31m" . $text . "\033[0m";
}
if ($color == "purple") {
return "\033[35m" . $text . "\033[0m";
}
if ($color == "orange") {
return "\033[33m" . $text . "\033[0m";
}
if ($color == "green") {
return "\033[32m" . $text . "\033[0m";
}
if ($color == 'redBold') {
return "\033[1m\33[31m" . $text . "\033[0m";
}
if ($color == 'alert') {
return "\033[41m\033[30m\033[1m" . $text . "\033[0m";
}
if ($color == 'bold') {
return "\033[1m" . $text . "\033[0m";
}
}
//may use this at some point
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment