Commit 53b87c03 authored by Eric - kg6wxc's avatar Eric - kg6wxc
Browse files

more additions for changing to kilometers by default

additional .sql file in case automatic change over does not work.
parent 6be0612d
...@@ -402,7 +402,11 @@ function load_LinkedTO($node_info, $TopoList) ...@@ -402,7 +402,11 @@ function load_LinkedTO($node_info, $TopoList)
}else { }else {
$display_cost = ' (' . $costArray['costTo'] . '/' . $costArray['costFrom'] . ') '; $display_cost = ' (' . $costArray['costTo'] . '/' . $costArray['costFrom'] . ') ';
} }
$linkedToList .= $linkedNodeName . $display_cost . $costArray['distance'] . ' mi ' . $costArray['bearing'] . '&deg;<br>'; if ($GLOBALS['USER_SETTINGS']['kilometers']) {
$linkedToList .= $linkedNodeName . $display_cost . round($costArray['distance'], 2) . 'km (' . round($costArray['distance'] * 0.62137, 2) . 'mi) ' . $costArray['bearing'] . '&deg;<br>';
}else {
$linkedToList .= $linkedNodeName . $display_cost . round($costArray['distance'] * 0.62137, 2) . 'mi (' . round($costArray['distance'], 2) . 'km) ' . $costArray['bearing'] . '&deg;<br>';
}
} }
} }
} }
...@@ -526,7 +530,7 @@ function build_Marker($node_info, $node_ServiceList, $node_LinkedList, $node_Fir ...@@ -526,7 +530,7 @@ function build_Marker($node_info, $node_ServiceList, $node_LinkedList, $node_Fir
//var_dump($loadavgs); //var_dump($loadavgs);
$markerList .= 'LoadAvg: 1 min ' . $loadavgs[0] . ', 5 min ' . $loadavgs[1] . ', 15 min ' . $loadavgs[2] . "<br>"; $markerList .= 'LoadAvg: 1 min ' . $loadavgs[0] . ', 5 min ' . $loadavgs[1] . ', 15 min ' . $loadavgs[2] . "<br>";
} }
$markerList .= $node_ServiceList . $node_LinkedList . "\").addTo(" . $AssignedLayer . ") ,\n"; // Close out this node $markerList .= $node_ServiceList . $node_LinkedList . "\",{ maxWidth: 500 } ).addTo(" . $AssignedLayer . ") ,\n"; // Close out this node
/* /*
* If Upgrade Suggested add Node to that layer * If Upgrade Suggested add Node to that layer
*/ */
......
-- drop old trigger
DROP TRIGGER topology_get_latlons_brg_dist;
-- create new trigger based on Km instead of miles.
SET @OLDTMP_SQL_MODE=@@SQL_MODE, SQL_MODE='';
DELIMITER //
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
IF NEW.node IS NOT NULL THEN
SET NEW.nodelat = (SELECT lat FROM node_info WHERE wlan_ip = NEW.node AND (lat IS NOT NULL && lat != 0 && lat != 0.00));
SET NEW.nodelon = (SELECT lon FROM node_info WHERE wlan_ip = NEW.node AND (lon IS NOT NULL && lon != 0 && lon != 0.00));
SET NEW.node = (SELECT node FROM node_info WHERE wlan_ip = NEW.node);
END IF;
IF NEW.linkto IS NOT NULL THEN
SET NEW.linklat = (SELECT lat FROM node_info WHERE wlan_ip = NEW.linkto AND (lat IS NOT NULL && lat != 0 && lat != 0.00));
SET NEW.linklon = (SELECT lon FROM node_info WHERE wlan_ip = NEW.linkto AND (lon IS NOT NULL && lon != 0 && lon != 0.00));
SET NEW.linkto = (SELECT node FROM node_info WHERE wlan_ip = NEW.linkto);
END IF;
-- figure out distance and bearing
SET NEW.bearing = round(mod(degrees(atan2(sin(radians(NEW.linklon)-radians(NEW.nodelon))*cos(radians(NEW.linklat)), cos(radians(NEW.nodelat))*sin(radians(NEW.linklat))-sin(radians(NEW.nodelat))*cos(radians(NEW.linklat))*cos(radians(NEW.linklon)-radians(NEW.nodelon)))) + 360,360),1);
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//
DELIMITER ;
SET SQL_MODE=@OLDTMP_SQL_MODE;
Supports Markdown
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