|
From: <le...@pr...> - 2005-01-23 11:26:52
|
Update of /cvsroot/meshdb/www/db2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13660 Modified Files: Tag: leonard-dev view.php Log Message: initial work on integrated (blended) maps Index: view.php =================================================================== RCS file: /cvsroot/meshdb/www/db2/view.php,v retrieving revision 1.16.2.3 retrieving revision 1.16.2.4 diff -u -d -r1.16.2.3 -r1.16.2.4 --- view.php 8 Nov 2004 14:16:15 -0000 1.16.2.3 +++ view.php 23 Jan 2005 11:26:29 -0000 1.16.2.4 @@ -15,6 +15,10 @@ if ($nodeid == "") die("no nodeid"); + /* + * Returns an URL to this page, merging the array $a + * into the current _GET array + */ function selfurl($a) { $oa = array(); $defvars = array("nodeid", "peerid", "zoom"); @@ -31,6 +35,8 @@ return "view.php?" . $url; } + /* Returns a global value, named as "<name>[<key>]" or "name". + * This is called by every val* function below. */ function valof($name) { if (substr($name, strlen($name) - 1, 1) == "]") { $zz = split('\[', substr($name, 0, strlen($name) - 1)); @@ -38,35 +44,41 @@ $kn = $zz[1]; return $GLOBALS[$an][$kn]; } else - return $$name; + return $$name; /* XXX $GLOBALS[$name] ? */ } + + /* Protects and returns a normal variable in HTML */ function val($name, $attr = "") { /* convert @ to @ as spam bots mightn't see them */ return str_replace("@", "@", htmlspecialchars(valof($name))); } + /* Returns a plain URL variable as HTML */ function valurl($name, $attr = "") { $v = valof($name); if ($v == "") return ""; return "<a href=\"$v\">". htmlspecialchars($v) . "</a>"; } - function valimgurl($name, $attr = "") { + /* Returns an image URL variable as HTML */ + function valimgurl($name, $attr = "", $alt="Site image") { $v = valof($name); if ($v == "") return ""; - return "<a href=\"$v\"><img src=\"$v\" alt=\"Site image\"></a>"; + return "<a href=\"$v\"><img src=\"$v\" alt=\"" + .htmlspecialchars($alt)."\"></a>"; } - + /* Return a multiline text variable in HTML */ function valtext($name, $attr = "") { + /* Replace 'node #nn' with a hyperlink */ $markeduptext = eregi_replace("(node #?([0-9]+))", "<a href=\"view.php?nodeid=\\2\">\\1</a>", htmlspecialchars(valof($name))); return "<span class=\"text\">$markeduptext</span>"; } - + /* Return a code-like variable in HTML */ function valcode($name, $attr = "") { return "<code>".htmlspecialchars(valof($name))."</code>"; } - + /* Return a nodeid variable as a pull-down HTML */ function valnodeid($name, $attr = "") { global $db; global $PREF; @@ -89,14 +101,13 @@ $v .= " <strong>(invalid)</strong>"; return $v; } - + /* Return a boolean variable as Yes or No */ function valyesno($name, $attr = "") { if (valof($name)) return "Yes"; else return "No"; } - function selectval($name, $options, $attr = "") { return htmlspecialchars($options[valof($name)]); } @@ -107,8 +118,9 @@ return ("x".strtolower($s) == "xnan"); } + /* Computes a map of useful calculations about two physloc records */ function elev($loc1, $loc2) { - global $ZONE, $SHIFTFILE, $ALTFILE; + global $ZONE, $SHIFTFILE, $ALTFILE, $BINDIR; $e1 = doubleval($loc1["e"]); $n1 = doubleval($loc1["n"]); @@ -151,6 +163,7 @@ "isclear" => $isclear); } + /* Returns an URL to an elevation diagram for two locs */ function elevurl($loc1, $loc2, $w, $h) { $e1 = doubleval($loc1["e"]); $n1 = doubleval($loc1["n"]); @@ -212,6 +225,32 @@ <link rel="start" href="index.php"> <link rel="icon" href="favicon.ico"> <title>View node #<?=$nodeid?>: <?=val("admin[nodename]")?></title> + + <script lang="javascript"> + function getVisString(b) { + return b ? "visible" : "hidden"; + } + var setMapLayerVisibility; + if (document.getElementById) setMapLayerVisibility = + function(n,b) { + document.getElementById(n).style.visibility = getVisString(b); + }; + else if (document.all) setMapLayerVisibility = + function(n,b) { document.all[n].style.visibility = getVisString(b); }; + else if (document.layers) setMapLayerVisibility = + function(n,b) { document[n].visibility = getVisString(b); }; + else setMapLayerVisibility = + function(n,b) { + alert("Can't figure out how to change visibility; report this error!"); + }; + + function blah(chk) { + var name = chk.name.substring(3); + setMapLayerVisibility("MAP"+name, chk.checked); + return false; + } + </script> + </head> <body> <h1>View node #<?=$nodeid?>: <?=val("admin[nodename]")?></h1> @@ -356,24 +395,17 @@ $paramb .= "&t[$nodeid]=X"; if ($peerid) $paramb .= "&t[$peerid]=o"; $paramb .= "&maxage=".$PREF["maxnodeage"]; - if ($s < 0.008) $paramb .= "&nonumbers=1"; $param = htmlspecialchars($param); $paramb = htmlspecialchars($paramb); ?> <td> + <map name="nodes"><?=$mapdef?></map> <table class="maps"> <tr><th class="major">Maps</th></tr> <? - foreach ($maps as $maptype) { - if ($maptype == "net") { ?> - <tr><th class="minor">Network</th></tr> - <tr><td class="figure"><img width=<?=$w?> height=<?=$h?> - usemap="#nodes" - src="map4b.php?<?=$paramb?>" - alt="Network connection map"></td></tr> - <tr><td class="caption"> -<? + + /* Returns an URL that zooms in/out */ function zoomlink($desired, $current) { if ($desired < 1) $desiredtext = round(1 / -$desired); @@ -384,6 +416,7 @@ else print $desiredtext . "x"; } + /* Prints HTML that provides zoom in/out choices */ function zoomlinks($current) { ?> zoom: @@ -398,40 +431,93 @@ <a href="<?=selfurl(array("zoom"=>$current/2))?>">out</a> <? } - zoomlinks($zoom); -?> - <br> - <font color=blue>-</font> active, - <font color=gray>-</font> inactive, - <font color=gray>O</font> multipeer - </td></tr> - <? } else if ($maptype == "loc") { ?> - <tr><th class="minor">Location</th></tr> - <tr><td class="figure"><map name="nodes"><?=$mapdef?> - </map><img width=<?=$w?> height=<?=$h?> - usemap="#nodes" - src="map2b.php?<?=$paramb?>" - alt="location map"></td></tr> - <tr><td class="caption"> - <?=zoomlinks($zoom)?> - <br> - </td></tr> - <? } else if ($maptype == "ter") { ?> - <tr><th class="minor">Terrain</th></tr> - <tr><td class="figure"><img width=<?=$w?> height=<?=$h?> - usemap="#nodes" - src="map3b.php?<?=$paramb?>" - alt="terrain map"></td></tr> - <tr><td class="caption"> - <?=zoomlinks($zoom)?> - <br> - Ground height at site: - <strong><?=$localt?></strong> AHD est.<br> - Map range: low <font color=blue><?=$minalt?></font>m, - high <font color=green><?=$maxalt?></font>m - </td></tr> - <? } else if ($maptype == "elev") { ?> + $layers = array(); + + function printlayeredmaps($layers,$w,$h) { + if (count($layers)) { ?> + <tr><th class="minor">Integrated maps</th></tr> + <tr><th class="figure"><table><tr><td><div id=integrated style="position: relative"><? + foreach ($layers as $l) { + print "<div id=\"MAP". $l["name"] ."\" style=\"position: absolute\">" + ."<img src=\"".$l["url"]."\" width=$w height=$h></div>\n"; + } + print "</div><img src=\"white.gif\" width=$w height=$h></td><td>"; + print "<form name=\"FORM1\">"; + foreach ($layers as $l) { + print "<nobr>" + ."<input type=checkbox name=\"BOX".$l["name"]."\" checked" + ." onchange=\"return blah(this)\"" + /* + ." onChange=\"setMapLayerVisibility(" + ."'FORM1', '" + . $l["name"] . "');return false;\" + */ + .">" . $l["name"] . "</nobr><br>"; + } + print "</form></td></tr></table></td></tr>"; ?> + <tr><td class="caption"><? + zoomlinks($zoom); + foreach ($layers as $l) { + print "<br>". $l["info"]; + } ?> + </td></tr> <? + } + } + + foreach ($maps as $maptype) { + $mapname = ""; + $mapdesc = ""; + $mapurl = ""; + $mapinfo = ""; + + if ($maptype == "net") { + $mapname = "Network"; + $mapdesc = "Active node-to-node links"; + $mapurl = "map4b.php?$paramb"; + $mapinfo = "Key: <font color=blue>-</font> active," + ." <font color=gray>-</font> inactive," + ."<font color=gray>O</font> multipeer"; + + } else if ($maptype == "loc") { + $mapname = "Location"; + $mapdesc = "Street directory features"; + $mapurl = "map2b.php?$paramb"; + + } else if ($maptype == "ter") { + $mapname = "Terrain"; + $mapdesc = "Surface altitude and visibility"; + $mapurl = "map3b.php?$paramb&nodeid=$nodeid"; + $mapinfo = "Ground height at site: " + . "<strong>$localt</strong> AHD est.<br>" + . "Range: low <font color=blue>$minalt</font>m" + . " high <font color=green>$maxalt</font>m"; + } + + + if ($mapname) { + if ($nolayers) { + ?> + <tr><th class="minor"><?=$mapname?></th></tr> + <tr><td class="figure"><img width=<?=$w?> height=<?=$h?> + usemap="$nodes" src="<?=$mapurl?>" title="<?=$mapdesc?>"</td></tr> + <tr><td class="caption"><?=zoomlinks($zoom)?> + <? if ($mapinfo) { print "<br>".$mapinfo; } ?> + </td></tr> + <? + } else { + array_push($layers, array( + "name" => $mapname, + "desc" => $mapdesc, + "url" => $mapurl, + "info" => $mapinfo)); + } + } else { + printlayeredmaps($layers,$w,$h); + $layers = array(); + } + + if ($maptype == "elev") { ?> <tr><th class="minor">Elevation diagram</th></tr> <tr><td><form action="view.php"> Peer node: @@ -566,6 +652,7 @@ <? } } /* foreach maptype */ + printlayeredmaps($layers,$w,$h); ?> </table> </td> |