diff options
author | Christian Pointner <equinox@ffgraz.net> | 2008-12-07 00:26:18 +0000 |
---|---|---|
committer | Christian Pointner <equinox@ffgraz.net> | 2008-12-07 00:26:18 +0000 |
commit | 3d4bdf9088184500442c451b237fcc2e954a7b21 (patch) | |
tree | 4b96fc2326710261aca364365564876b0f5600db | |
parent | f3902147657cf2773e73f76f7e5fe810d0db6c78 (diff) |
drawing links now
-rw-r--r-- | data.php | 15 | ||||
-rw-r--r-- | index.php | 22 | ||||
-rw-r--r-- | map.js | 89 |
3 files changed, 118 insertions, 8 deletions
@@ -85,19 +85,22 @@ foreach ($lines as $num => $line) if($already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->used == true) {
$jot = $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->i;
- $links[$jot]->label = ($links[$jot]->label + $label)/2;
+ if($links[$jot]->label != -1)
+ $links[$jot]->label = ($links[$jot]->label + $label)/2;
}
elseif($already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid]->used == true) {
$jot = $already[$locations[$locids[$iptoLoc]]->locid . '-' . $locations[$locids[$ipfromLoc]]->locid]->i;
- $links[$jot]->label = ($links[$jot]->label + $label)/2;
+ if($links[$jot]->label != -1)
+ $links[$jot]->label = ($links[$jot]->label + $label)/2;
}
else {
- $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->used =true;
+ $already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->used = true;
$already[$locations[$locids[$ipfromLoc]]->locid . '-' . $locations[$locids[$iptoLoc]]->locid]->i = $i;
$links[$i]->ipfromLoc = $ipfromLoc;
$links[$i]->iptoLoc = $iptoLoc;
- $links[$i]->label = $label;
+ if($links[$i]->label != -1)
+ $links[$i]->label = $label;
if($locations[$locids[$ipfromLoc]]->state == "offline")
$locations[$locids[$ipfromLoc]]->state = "online";
if($locations[$locids[$iptoLoc]]->state == "offline")
@@ -106,7 +109,7 @@ foreach ($lines as $num => $line) if (($nodename[$ipfromLoc] == "tunnel" && $locations[$locids[$ipfromLoc]]->locname=="housing") ||
($nodename[$iptoLoc] == "tunnel" && $locations[$locids[$iptoLoc]]->locname=="housing" ) ||
($locations[$locids[$iptoLoc]]->hastinc && $locations[$locids[$ipfromLoc]]->hastinc)) {
- $link->label = -1;
+ $links[$i]->label = -1;
$locations[$locids[$ipfromLoc]]->state = "tunnel";
$locations[$locids[$iptoLoc]]->state = "tunnel";
}
@@ -136,7 +139,7 @@ foreach ($links as $link) $count[$data1->locid]=true;
$count[$data2->locid]=true;
- printf("\t" . '<link fromid="%s" from="%s" latfrom="%s" lngfrom="%s" toid="%s" to="%s" latto="%s" lngto="%s" color="%s" />' . "\n",
+ printf("\t" . '<link fromid="%s" from="%s" latfrom="%s" lngfrom="%s" toid="%s" to="%s" latto="%s" lngto="%s" value="%s" />' . "\n",
$data1->locid, $data1->locname, $data1->lat,$data1->lng,$data2->locid, $data2->locname, $data2->lat, $data2->lng, $link->label);
}
echo "</links>\n";
@@ -53,7 +53,27 @@ if(empty($marker)) $marker="online"; <table class="legend">
<tr>
<td><input type="checkbox" name="offline" value="true" onclick="javascript:toggleVisible('offline')" <?php if($marker == "online") printf(' checked="checked"'); ?> ></td>
- <td> </td><td><img src="./img/marker_offline.png" /> Offline</td>
+ <td> </td><td align="center"><img src="./img/marker_offline.png" /></td><td>Offline</td>
+ </tr>
+ <tr>
+ <td><input type="checkbox" name="online" value="true" onclick="javascript:toggleVisible('online')");></td>
+ <td> </td><td align="center"><img src="./img/marker_online.png" /> <img src="./img/marker_tunnel.png" /></td><td>Online</td>
+ </tr>
+ <tr>
+ <td><input type="checkbox" name="bad" value="true" onclick="javascript:toggleVisible('bad')" checked="checked"></td>
+ <td> </td><td align="center"><img src="./img/link_red.png" /></td><td>Schlecht</td>
+ </tr>
+ <tr>
+ <td><input type="checkbox" name="middle" value="true" onclick="javascript:toggleVisible('middle')"></td>
+ <td> </td><td align="center"><img src="./img/link_yellow.png" /></td><td>Mittel</td>
+ </tr>
+ <tr>
+ <td><input type="checkbox" name="good" value="true" onclick="javascript:toggleVisible('good')"></td>
+ <td> </td><td align="center"><img src="./img/link_green.png" /></td><td>Gut</td>
+ </tr>
+ <tr>
+ <td><input type="checkbox" name="tunnel" value="true" onclick="javascript:toggleVisible('tunnel')"></td>
+ <td> </td><td align="center"><img src="./img/link_blue.png" /></td><td>Tunnel</td>
</tr>
</table>
</from>
@@ -1,13 +1,15 @@ var map = null; var physicalMaxLevel; var geocoder = null; +var reloadcon = null; var countboxText = null; var overlays = new Array(); overlays["newmarker"] = null; overlays["ruler"] = new Array(); overlays["locations"] = new Array(); +overlays["links"] = new Array(); var locations = new Array(); -var reloadcon = null; +var links = new Array(); function initialize(lat, lng, res) { if (!checkBrowser()) { @@ -69,6 +71,7 @@ function checkBrowser() { function onAddOverlay(overlay) { switch(overlay.overlaytype) { case "location": overlays["locations"].push(overlay); break; + case "link": overlays["links"].push(overlay); break; case "newmarker": { if(overlays["newmarker"]) { map.removeOverlay(overlays["newmarker"]); @@ -114,6 +117,13 @@ function onData(data, responseCode) { locations = []; drawLocations(xmlData); + for(var link in overlays["links"]) { + map.removeOverlay(overlays["links"][link]); + } + overlays["links"] = []; + links = []; + drawLinks(xmlData); + var element = xmlData.getElementsByTagName("count"); var count = element[0].getAttribute("number"); countboxText.data = "Aktiv: " + count; @@ -136,6 +146,9 @@ function drawLocations(xmlData) { if(document.visibleform.elements["offline"].checked) { toggleVisible("offline"); } + if(document.visibleform.elements["online"].checked) { + toggleVisible("online"); + } } function Location(element) { @@ -177,6 +190,75 @@ function convertCoords(x) { return deg + "° " + Math.floor(min) + "' " + sec.toFixed(0) + "\""; } +function drawLinks(xmlData) { + var element = xmlData.getElementsByTagName("link"); + for (var i = 0; i< element.length; i++) { + var id = element[i].getAttribute("from") + "-" + element[i].getAttribute("to"); + links[id] = new Link(element[i]); + + var line = new GPolyline([links[id].frompoint, links[id].topoint], makeColor(Math.floor(links[id].value)), makeWeight(Math.floor(links[id].value))); + line.overlaytype = "link"; + line.linkid = id; + map.addOverlay(line); + } + if(document.visibleform.elements["bad"].checked) { + toggleVisible("bad"); + } + if(document.visibleform.elements["middle"].checked) { + toggleVisible("middle"); + } + if(document.visibleform.elements["good"].checked) { + toggleVisible("good"); + } + if(document.visibleform.elements["tunnel"].checked) { + toggleVisible("tunnel"); + } +} + +function Link(element) { + var link = new Object(); + link.from = element.getAttribute("from"); + link.fromid = parseInt(element.getAttribute("fromid")); + var lat = parseFloat(element.getAttribute("latfrom")); + var lng = parseFloat(element.getAttribute("lngfrom")); + link.frompoint = new GLatLng(lat, lng); + + link.to = element.getAttribute("to"); + link.toid = parseInt(element.getAttribute("toid")); + lat = parseFloat(element.getAttribute("latto")); + lng = parseFloat(element.getAttribute("lngto")); + link.topoint = new GLatLng(lat, lng); + + link.value = parseFloat(element.getAttribute("value")); + + return link; +} + +function makeColor(value) { + switch(value) { + case -1: return '#0000FF'; + case 0: return '#FF0000'; + case 1: return '#33bb33'; + case 2: return '#66bb33'; + case 3: return '#ff9900'; + case 4: return '#ffcc00'; + case 5: return '#cccc33'; + default: return '#000000' + } +} + +function makeWeight(value) { + switch(value) { + case -1: return 1; + case 0: return 3; + case 1: return 3; + case 3: return 1; + case 4: return 1; + case 5: return 1; + default: return 1; + } +} + function addNewNodeText(point) { var html = "adding location at: <br />\n" + point; return html; @@ -202,6 +284,11 @@ function toggleVisible(element) { var elements = Object(); switch(element) { case 'offline': elements.overlays = overlays["locations"]; elements.select = new Function("id", "return (locations[overlays['locations'][id].locid].state == 'offline');"); break; + case 'online': elements.overlays = overlays["locations"]; elements.select = new Function("id", "return (locations[overlays['locations'][id].locid].state != 'offline');"); break; + case 'bad': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value >= 6);"); break; + case 'middle': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value >= 3 && links[overlays['links'][id].linkid].value < 6);"); break; + case 'good': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value >= 0 && links[overlays['links'][id].linkid].value < 3);"); break; + case 'tunnel': elements.overlays = overlays["links"]; elements.select = new Function("id", "return (links[overlays['links'][id].linkid].value == -1);"); break; } if(document.visibleform.elements[element].checked) { |