From 34bd39006e091b7a848143acd20904d015e086c1 Mon Sep 17 00:00:00 2001 From: Jen Herting Date: Fri, 5 Aug 2022 15:22:16 -0400 Subject: [PATCH] New feature: Creation of additional non-mesh layers Non-mesh layers (marker types) are no longer limited to 6 preset types. New layers can be specified in the meshmap-settings.ini file. --- scripts/map_functions.inc | 143 ++++++++++----------------- scripts/meshmap-settings.ini-default | 36 +++++-- webpage/admin/non_mesh_stations.php | 19 ++-- webpage/map_display.php | 4 +- webpage/node_report.php | 2 +- 5 files changed, 96 insertions(+), 108 deletions(-) diff --git a/scripts/map_functions.inc b/scripts/map_functions.inc index bd843b0..4717eed 100644 --- a/scripts/map_functions.inc +++ b/scripts/map_functions.inc @@ -240,7 +240,7 @@ function load_LinkList($NodeList, $TopoList) $tunnel = 1; $nodeHasTunnel = 0; $linkHasTunnel = 0; - $display_color = $MESH_SETTINGS['Link_Tunnel']; + $display_color = $MESH_SETTINGS['meshmap-settings']['Link_Tunnel']; $dtd = 1; $display_opacity = 0.5; $map_LayerAssigned = 'tunnelLinks'; @@ -250,7 +250,7 @@ function load_LinkList($NodeList, $TopoList) if ($value['cost'] == 0.1 && $value['distance'] <= 0.7) //find DTD links (always a cost of 0.1) { - $display_color = $MESH_SETTINGS['DTD_Link_Minus']; + $display_color = $MESH_SETTINGS['meshmap-settings']['DTD_Link_Minus']; $dtd = 1; $display_opacity = 0.2; $map_LayerAssigned = 'dtdLinks'; @@ -262,7 +262,7 @@ function load_LinkList($NodeList, $TopoList) // TODO: check this! if ($value['cost'] == 0.1 && $value['distance'] > 0.7) { - $display_color = $MESH_SETTINGS['DTD_Link_Plus']; + $display_color = $MESH_SETTINGS['meshmap-settings']['DTD_Link_Plus']; $dtd = 1; //$display_opacity = 0.3; $display_opacity = 1.0; @@ -273,7 +273,7 @@ function load_LinkList($NodeList, $TopoList) //find the "infinite cost" links (they show as "INFINITE" in the olsr files the other script changes that to 99.99) if ($value['cost'] == 99.99) { - $display_color = $MESH_SETTINGS['Link_Infinite']; + $display_color = $MESH_SETTINGS['meshmap-settings']['Link_Infinite']; $infinite = 1; $display_opacity = 0.2; $map_LayerAssigned = 'infiniteLinks'; @@ -283,14 +283,14 @@ function load_LinkList($NodeList, $TopoList) if (($value['cost'] <= 1.000) && ($value['cost'] != 0.1) && !($tunnel)) { //these will always be a solid green - $display_color = $MESH_SETTINGS['Link_GOOD']; + $display_color = $MESH_SETTINGS['meshmap-settings']['Link_GOOD']; $display_opacity = 0.5; $map_LayerAssigned = 'rfLinks'; } //links of greater than 10.000 ETX, but not "INFINITE" (these links are always red) if ($value['cost'] > 14.000 && $value['cost'] != 99.99) { - $display_color = $MESH_SETTINGS['Link_BAD']; + $display_color = $MESH_SETTINGS['meshmap-settings']['Link_BAD']; $moreThanTen = 1; $display_opacity = 0.3; $map_LayerAssigned = 'rfLinks'; @@ -620,40 +620,20 @@ function build_Marker($node_info, $node_ServiceList, $node_LinkedList, $node_Fir */ function buildStationMarker($Marker) { + global $MESH_SETTINGS; //Now we look at the 'channel' value, for each node, from the node_info database. //Then compare it to what we know about each bands channels //if we find a match, we assume we're in that band... - switch ($Marker['type']) - { - case "operator": - // Operator Home Station - $icon = "operatorIcon"; - $AssignedLayer = 'operatorsElements'; - break; - case "police": - $icon = "policeIcon"; - $AssignedLayer = 'policeElements'; - break; - case "eoc": - $icon = "eocIcon"; - $AssignedLayer = 'racesElements'; - break; - case "firedepartment": - $icon = "fireIcon"; - $AssignedLayer = 'fireElements'; - break; - case "hospital": - $icon = "hospitalIcon"; - $AssignedLayer = 'hospitalElements'; - break; - default: - // unknown - $icon = "Red_Marker"; - $AssignedLayer = 'otherElements'; + if (!in_array($Marker['type'], $MESH_SETTINGS['meshmap-settings']['Layers'], true)){ + // Marker type not registered in settings file. Don't create marker. + return; } + $icon = $Marker['type'] . "Icon"; + $AssignedLayer = $Marker['type'] . "Elements"; + /* * Now build the marker */ @@ -871,79 +851,62 @@ function add_MapImages($numNodes, $numLinks, $numMarkers) $Content = " // Node and Link Icons var greenRadioCircle = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Device_Default'] . "', + iconUrl: '" . $MESH_SETTINGS['meshmap-settings']['Device_Default'] . "', iconSize: [18, 18], iconAnchor: [9, 9], popupAnchor: [0, -9] }); // Out of Date node software var redCircle = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Device_OOD'] . "', + iconUrl: '" . $MESH_SETTINGS['meshmap-settings']['Device_OOD'] . "', iconSize: [22, 22], iconAnchor: [11, 11], popupAnchor: [0, -9] }); // Experiment node software var orangeCircle = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Device_Experimental'] . "', + iconUrl: '" . $MESH_SETTINGS['meshmap-settings']['Device_Experimental'] . "', iconSize: [22, 22], iconAnchor: [11, 11], popupAnchor: [0, -9] }); // 900 Mhz var nineRadioCircle = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Device_900MHz'] . "', + iconUrl: '" . $MESH_SETTINGS['meshmap-settings']['Device_900MHz'] . "', iconSize: [18, 18], iconAnchor: [9, 9], popupAnchor: [0, -9] }); //2.4GHz var twoRadioCircle = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Device_24GHz'] . "', + iconUrl: '" . $MESH_SETTINGS['meshmap-settings']['Device_24GHz'] . "', iconSize: [18, 18], iconAnchor: [9, 9], popupAnchor: [0, -9] }); //3GHz var threeRadioCircle = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Device_3GHz'] . "', + iconUrl: '" . $MESH_SETTINGS['meshmap-settings']['Device_3GHz'] . "', iconSize: [18, 18], iconAnchor: [9, 9], popupAnchor: [0, -9] }); //5GHz var fiveRadioCircle = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Device_5GHz'] . "', + iconUrl: '" . $MESH_SETTINGS['meshmap-settings']['Device_5GHz'] . "', iconSize: [18, 18], iconAnchor: [9, 9], popupAnchor: [0, -9] }); //Unknown var unknownRadioCircle = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Device_Unknown'] . "', + iconUrl: '" . $MESH_SETTINGS['meshmap-settings']['Device_Unknown'] . "', iconSize: [18, 18], iconAnchor: [9, 9], popupAnchor: [0, -9] }); //a special one var linuxCircle = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Device_Linux'] . "', + iconUrl: '" . $MESH_SETTINGS['meshmap-settings']['Device_Linux'] . "', iconSize: [18, 18], iconAnchor: [9, 9], popupAnchor: [0, -9] });\n"; if ($numMarkers > 0) { - $Content .= " - // Marker Icons - var policeIcon = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Marker_Police'] . "', - iconSize: [25, 25], iconAnchor: [9, 9], popupAnchor: [0, -9] - }); - var fireIcon = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Marker_Fire'] . "', - iconSize: [25, 25], iconAnchor: [9, 9], popupAnchor: [0, -9] - }); - var operatorIcon = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Marker_Operator'] . "', - iconSize: [25, 25], iconAnchor: [9, 9], popupAnchor: [0, -9] - }); - var hospitalIcon = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Marker_Hospital'] . "', - iconSize: [25, 25], iconAnchor: [9, 9], popupAnchor: [0, -9] - }); - var eocIcon = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Marker_EOC'] . "', - iconSize: [25, 25], iconAnchor: [9, 9], popupAnchor: [0, -9] - }); - var Red_Marker = L.icon({ - iconUrl: '" . $MESH_SETTINGS['Marker_Future'] . "', - iconSize: [25, 25], iconAnchor: [9, 9], popupAnchor: [0, -9] - });\n\n"; + $Content .= "// Marker Icons\n"; + foreach ($MESH_SETTINGS['meshmap-settings']['Layers'] as &$layer) { + $Content .= " + var " . $layer . "Icon = L.icon({ + iconUrl: '" . $MESH_SETTINGS['layer-' . $layer]['Marker'] . "', + iconSize: [25, 25], iconAnchor: [9, 9], popupAnchor: [0, -9] + });\n"; + } + $content .= "\n\n"; } return $Content; } @@ -958,6 +921,7 @@ function add_MapImages($numNodes, $numLinks, $numMarkers) */ function create_MapLayers($numNodes, $numLinks, $numMarkers) { + global $MESH_SETTINGS; //overlay groups to help superposition order $Content = " // Node Groups @@ -992,16 +956,13 @@ function create_MapLayers($numNodes, $numLinks, $numMarkers) if ($numMarkers > 0) { $Content .= " - // Marker Groups - var otherElements = new L . LayerGroup(); - var policeElements = new L . LayerGroup(); - var fireElements = new L . LayerGroup(); - var hospitalElements = new L . LayerGroup(); - var racesElements = new L . LayerGroup(); - var operatorsElements = new L . LayerGroup(); - var otherElements = new L . LayerGroup(); - \n\n -"; + // Marker Groups\n"; + + foreach ($MESH_SETTINGS['meshmap-settings']['Layers'] as &$layer) { + $Content .= "var " . $layer . "Elements = new L . LayerGroup();\n"; + } + + $Content .= "\n\n"; } return $Content; @@ -1021,12 +982,12 @@ function create_MapOverlays($numNodes, $numLinks, $numMarkers) $Content = "// Node Overlays var groupedOverlays = { \"Stations\": { - \"2.4GHz\": twoGHzStations, - \"3.4GHz\": threeGHzStations, - \"5.8GHz\": fiveGHzStations, - \"900MHz\": nineHundredMHzStations, - \"Additional Mesh\": otherStations, - \"Check Versions\": upgradeStations + \"2.4GHz\": twoGHzStations, + \"3.4GHz\": threeGHzStations, + \"5.8GHz\": fiveGHzStations, + \"900MHz\": nineHundredMHzStations, + \"Additional Mesh\": otherStations, + \"Check Versions\": upgradeStations }"; if ($numLinks > 0) @@ -1047,14 +1008,12 @@ function create_MapOverlays($numNodes, $numLinks, $numMarkers) $Content .= " ,\n // Marker Layers - \"Additional\": { - \"Police\": policeElements, - \"Fire Dept\": fireElements, - \"Hospital\": hospitalElements, - \"EOC\": racesElements, - \"Operators\": operatorsElements, - \"Future Mesh\": otherElements - }\n"; + \"Additional\": {\n"; + + foreach ($MESH_SETTINGS['meshmap-settings']['Layers'] as &$layer) { + $Content .= "\"" . $MESH_SETTINGS['layer-' . $layer]['Label'] . "\": " . $layer . "Elements,\n"; + } + $Content .= "}\n"; } $Content .= "};\n\n"; diff --git a/scripts/meshmap-settings.ini-default b/scripts/meshmap-settings.ini-default index fa6c853..7e8e303 100644 --- a/scripts/meshmap-settings.ini-default +++ b/scripts/meshmap-settings.ini-default @@ -21,9 +21,33 @@ Link_Infinite = "black"; Link_GOOD = "#00FF00"; Link_BAD = "#00FF00"; ; Additional Markers -Marker_Police ='images/mapMarkers/police.png'; -Marker_Fire ='images/mapMarkers/fire.png'; -Marker_Hospital='images/mapMarkers/hospital.png'; -Marker_EOC ='images/mapMarkers/EOC.png'; -Marker_Operator ='images/mapMarkers/operator.png'; -Marker_Future ='images/mapMarkers/Red_Marker.png'; +Layers[] = police +Layers[] = firedepartment +Layers[] = hospital +Layers[] = eoc +Layers[] = operator +Layers[] = futuremesh + +[layer-police] +Marker = 'images/mapMarkers/police.png'; +Label = Police + +[layer-firedepartment] +Marker = 'images/mapMarkers/fire.png'; +Label = 'Fire Dept' + +[layer-hospital] +Marker = 'images/mapMarkers/hospital.png'; +Label = Hospital + +[layer-eoc] +Marker = 'images/mapMarkers/EOC.png'; +Label = EOC + +[layer-operator] +Marker = 'images/mapMarkers/Blue_Station.png'; +Label = Operator + +[layer-futuremesh] +Marker = 'images/mapMarkers/Red_Marker.png'; +Label = 'Future Mesh' diff --git a/webpage/admin/non_mesh_stations.php b/webpage/admin/non_mesh_stations.php index 9d200e8..631761a 100644 --- a/webpage/admin/non_mesh_stations.php +++ b/webpage/admin/non_mesh_stations.php @@ -8,6 +8,14 @@ $INCLUDE_DIR = "../.."; $USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini"); require $INCLUDE_DIR . "/scripts/wxc_functions.inc"; @include $INCLUDE_DIR . "/custom.inc"; +global $MESH_SETTINGS; +//check for users user-settings.ini file and use it if it exists +//use the default one if it does not +if (file_exists($INCLUDE_DIR . "/scripts/meshmap-settings.ini")) { + $MESH_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/meshmap-settings.ini", true); +}else { + $MESH_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/meshmap-settings.ini-default", true); +} $sql_connection = wxc_connectToMySQL(); @@ -174,12 +182,9 @@ function sortTable(n) { Name: Description: Type: Lat: Lon: @@ -346,4 +351,4 @@ EOD; echo $jsEditing . "\n"; } -?> \ No newline at end of file +?> diff --git a/webpage/map_display.php b/webpage/map_display.php index ca99b26..e6315b3 100644 --- a/webpage/map_display.php +++ b/webpage/map_display.php @@ -68,9 +68,9 @@ global $MESH_SETTINGS; //check for users user-settings.ini file and use it if it exists //use the default one if it does not if (file_exists($INCLUDE_DIR . "/scripts/meshmap-settings.ini")) { - $MESH_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/meshmap-settings.ini"); + $MESH_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/meshmap-settings.ini", true); }else { - $MESH_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/meshmap-settings.ini-default"); + $MESH_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/meshmap-settings.ini-default", true); } diff --git a/webpage/node_report.php b/webpage/node_report.php index b135050..510ada0 100644 --- a/webpage/node_report.php +++ b/webpage/node_report.php @@ -42,7 +42,7 @@ $INCLUDE_DIR = ".."; $USER_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/user-settings.ini"); global $MESH_SETTINGS; -$MESH_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/meshmap-settings.ini"); +$MESH_SETTINGS = parse_ini_file($INCLUDE_DIR . "/scripts/meshmap-settings.ini", true); require $INCLUDE_DIR . "/scripts/wxc_functions.inc"; require $INCLUDE_DIR . "/scripts/map_functions.inc"; -- GitLab