Changeset 7765 for trunk/src/inc/KMLFile.class.php
- Timestamp:
- Apr 15, 2010, 12:00:44 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/inc/KMLFile.class.php
r7758 r7765 16 16 <IconStyle> 17 17 <Icon> 18 <href>% PLACEMARK_GREEN%</href>18 <href>%NODE_GREEN%</href> 19 19 </Icon> 20 20 </IconStyle> … … 23 23 <IconStyle> 24 24 <Icon> 25 <href>% PLACEMARK_ORANGE%</href>25 <href>%NODE_ORANGE%</href> 26 26 </Icon> 27 27 </IconStyle> … … 30 30 <IconStyle> 31 31 <Icon> 32 <href>% PLACEMARK_RED%</href>32 <href>%NODE_RED%</href> 33 33 </Icon> 34 34 </IconStyle> 35 35 </Style> 36 <Folder> 36 <Style id="blackLine"> 37 <LineStyle> 38 <color>%LINE_BLACK%</color> 39 <width>3</width> 40 </LineStyle> 41 </Style> 42 <Folder id="nodes"> 37 43 <name>Nodes</name> 38 44 <description>Nodes from the Wireless Leiden network</description> … … 40 46 <longitude>4.490153</longitude> 41 47 <latitude>52.161087</latitude> 42 <altitude> 0</altitude>48 <altitude>5</altitude> 43 49 <heading>0</heading> 44 50 <tilt>0</tilt> 45 51 <range>500</range> 46 52 </LookAt> 47 % CONTENT%53 %NODESCONTENT% 48 54 </Folder> 49 </Document> 55 <Folder id="lines"> 56 <name>Lines</name> 57 <description>Lines from nodes to nodes from the Wireless Leiden network</description> 58 <LookAt> 59 <longitude>4.490153</longitude> 60 <latitude>52.161087</latitude> 61 <altitude>5</altitude> 62 <heading>0</heading> 63 <tilt>0</tilt> 64 <range>500</range> 65 </LookAt> 66 %LINESCONTENT% 67 </Folder> 68 </Document> 50 69 </kml>'; 51 70 … … 55 74 private $fileContent = array('string', 'string', 'int', 'double', 'int', 'int', 'int', 'int'); 56 75 57 private $KMLPlacemarks; 58 76 private $KMLNodes; 77 private $KMLLines; 78 59 79 /* 60 80 * Function: __construct (constructor) … … 64 84 */ 65 85 public function __construct() { 66 $this->KMLPlacemarks = array(); 67 } 68 69 /* 70 * Function: addPlacemark 71 * Description: Add a placemark to the local placemark array 72 * Parameters: KMLPlacemark $placemark 86 $this->KMLNodes = array(); 87 $this->KMLLines = array(); 88 } 89 90 /* 91 * Function: addNode 92 * Description: Add a node to the local node array 93 * Parameters: KMLNode $node 73 94 * Returns: - 74 95 */ 75 public function addPlacemark(KMLPlacemark $placemark) { 76 $this->KMLPlacemarks[] = $placemark; 96 public function addNode(KMLNode $node) { 97 $this->KMLNodes[] = $node; 98 } 99 100 /* 101 * Function: addLIne 102 * Description: Add a line to the local line array 103 * Parameters: KMLLine $line 104 * Returns: - 105 */ 106 public function addLine(KMLLine $line) { 107 $this->KMLLines[] = $line; 77 108 } 78 109 … … 88 119 $toString = $this->template; 89 120 90 $placemarkString = ''; 91 $placemarkCount = count($this->KMLPlacemarks); 92 for ($i = 0; $i < $placemarkCount; $i++) { 93 $placemarkString .= $this->KMLPlacemarks[$i]->toString(); 94 } 95 96 $toString = str_replace('%PLACEMARK_GREEN%', $config['placemark_green'], $toString); 97 $toString = str_replace('%PLACEMARK_ORANGE%', $config['placemark_orange'], $toString); 98 $toString = str_replace('%PLACEMARK_RED%', $config['placemark_red'], $toString); 99 $toString = str_replace('%CONTENT%', $placemarkString, $toString); 100 121 $nodeString = ''; 122 $nodeCount = count($this->KMLNodes); 123 for ($i = 0; $i < $nodeCount; $i++) { 124 $nodeString .= $this->KMLNodes[$i]->toString(); 125 } 126 127 $lineString = ''; 128 $lineCount = count($this->KMLLines); 129 for ($i = 0; $i < $lineCount; $i++) { 130 $lineString .= $this->KMLLines[$i]->toString(); 131 } 132 133 $toString = str_replace('%NODE_GREEN%', $config['node_green'], $toString); 134 $toString = str_replace('%NODE_ORANGE%', $config['node_orange'], $toString); 135 $toString = str_replace('%NODE_RED%', $config['node_red'], $toString); 136 $toString = str_replace('%LINE_BLACK%', $config['line_black'], $toString); 137 $toString = str_replace('%NODESCONTENT%', $nodeString, $toString); 138 $toString = str_replace('%LINESCONTENT%', $lineString, $toString); 139 101 140 return $toString; 102 141 } … … 123 162 124 163 /* 125 * Function: get PlacemarkByName126 * Description: Find the first KML Placemarkwith the name $name and return its position. If not found, return false164 * Function: getNodeByName 165 * Description: Find the first KMLNode with the name $name and return its position. If not found, return false 127 166 * Parameters: string $name 128 * Returns: Position of placemarkin our array, if not found false129 */ 130 public function get PlacemarkByName($name) {131 $nodesCount = count($this->KML Placemarks);167 * Returns: Position of node in our array, if not found false 168 */ 169 public function getNodeByName($name) { 170 $nodesCount = count($this->KMLNodes); 132 171 for ($i = 0; $i < $nodesCount; $i++) { 133 if ($this->KML Placemarks[$i]->getName() == $name) {172 if ($this->KMLNodes[$i]->getName() == $name) { 134 173 return $i; 135 174 } … … 141 180 /* 142 181 * Function: parseLocationFile 143 * Description: Parse the node location file updating or adding KML Placemarkobjects to the current KMLFile object182 * Description: Parse the node location file updating or adding KMLNode objects to the current KMLFile object 144 183 * Parameters: string $file 145 184 * Returns: true is successfull, otherwise false … … 192 231 $descriptionLocation = 'Naam: ' . $name . '<br/>Locatie: ' . $location . '<br/>Status: ' . $status . '<br/>Latitude: ' . $latitude . '<br/>Longitude: ' . $longitude . '<br/>Interfaces: ' . $interfaces . '<br/>Master IP: ' . $masterip . '<br/>Node type: ' . $nodetype . '<br/><br/>'; 193 232 194 if ($placemarkPosition = $this->get PlacemarkByName($name)) {233 if ($placemarkPosition = $this->getNodeByName($name)) { 195 234 // Updating an excisting placemark 196 $this->KML Placemarks[$placemarkPosition]->setDescriptionLocation($descriptionLocation);197 $this->KML Placemarks[$placemarkPosition]->setLongitude($longitude);198 $this->KML Placemarks[$placemarkPosition]->setLatitude($latitude);235 $this->KMLNodes[$placemarkPosition]->setDescriptionLocation($descriptionLocation); 236 $this->KMLNodes[$placemarkPosition]->setLongitude($longitude); 237 $this->KMLNodes[$placemarkPosition]->setLatitude($latitude); 199 238 } else { 200 239 // Adding a new placemark 201 $placemark = new KML Placemark();240 $placemark = new KMLNode(); 202 241 $placemark->setID($name); 203 242 $placemark->setName($name); … … 205 244 $placemark->setLongitude($longitude); 206 245 $placemark->setLatitude($latitude); 207 $this->add Placemark($placemark);246 $this->addNode($placemark); 208 247 } 209 248 } … … 229 268 /* 230 269 * Function: parseStatusFile 231 * Description: Parse the node status file updating or adding KML Placemarkobjects to the current KMLFile object270 * Description: Parse the node status file updating or adding KMLNode objects to the current KMLFile object 232 271 * Parameters: string $file 233 272 * Returns: true is successfull, otherwise false … … 275 314 $descriptionStatus = 'Type: ' . $lineContent[0] . '<br/>Host name: ' . $lineContent[1] . '<br/>Has been checked: ' . $lineContent[2] . '<br/>Check execution time: ' . $lineContent[3] . '<br/>Currenr state: ' . $lineContent[4] . '<br/>Last hard state: ' . $lineContent[5] . '<br/>Last check: ' . $lineContent[6] . '<br/>Problem has been acknowledged: ' . $lineContent[7] . '<br/><br/>'; 276 315 277 if ($placemarkPosition = $this->get PlacemarkByName($lineContent[1])) {316 if ($placemarkPosition = $this->getNodeByName($lineContent[1])) { 278 317 // Updating an excisting placemark 279 $this->KML Placemarks[$placemarkPosition]->setDescriptionStatus($descriptionStatus);318 $this->KMLNodes[$placemarkPosition]->setDescriptionStatus($descriptionStatus); 280 319 } else { 281 320 // Adding a new placemark 282 $placemark = new KML Placemark();321 $placemark = new KMLNode(); 283 322 $placemark->setID($lineContent[1]); 284 323 $placemark->setName($lineContent[1]); 285 324 $placemark->setDescriptionStatus($descriptionStatus); 286 $this->add Placemark($placemark);325 $this->addNode($placemark); 287 326 } 288 327 }
Note:
See TracChangeset
for help on using the changeset viewer.