Commit 6be0612d authored by Eric - kg6wxc's avatar Eric - kg6wxc
Browse files

Fixes to checkDB.inc (which was also moved to it's own file)

If the SQL server has binary logging enabled then this will not work.
(by default it does not, you usually only need that for replication and other advanced features.)
parent 02d4dc55
<?php
function wxc_checkDB () {
//this function should probably be in it's own file
//this function is now in its own file
//removing the olsrinfo_json binary blob from the database tables
//it's just taking up space and never getting used...
......@@ -101,6 +101,7 @@ function wxc_checkDB () {
unset($nodeFieldsQuery);
unset($nodeFieldsNum);
}
//Just like above (and for the same reasons)
//there are 1 or 2 columns called "name" that are used also
//This will also allow for longer names in the non-mesh markers area
......@@ -180,5 +181,39 @@ function wxc_checkDB () {
}
unset($newColumns1dot2);
unset($newColumns1dot3);
//check for old trigger based on miles and update to new trigger based on kilometers.
//the conversion to miles will be done later in the code.
$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);
$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
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;";
wxc_putMySql($sql);
unset($oldDistanceTriggerQuery);
unset($sql);
$mesg = "Changed database to have default distance in Kilometers.";
wxc_echoWithColor($mesg, "green");
echo "\n\n";
}
}
?>
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