Changeset 7775 for trunk/src/inc/KMLFile.class.php
- Timestamp:
- Apr 16, 2010, 12:27:16 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/inc/KMLFile.class.php
r7773 r7775 5 5 * Purpose: Creating of editing KML files 6 6 */ 7 8 define('NODE_STATUS_UP', 0); 9 define('NODE_STATUS_ERROR', 1); 10 define('NODE_STATUS_UNREACHABLE', 2); 7 11 8 12 class KMLFile { … … 13 17 <open>1</open> 14 18 <description>Wireless Leiden Interactive Nodemap 2.0</description> 19 <LookAt> 20 <longitude>%OVERALL_LONGITUDE%</longitude> 21 <latitude>%OVERALL_LATITUDE%</latitude> 22 <altitude>%OVERALL_ALTITUDE%</altitude> 23 <heading>%OVERALL_HEADING%</heading> 24 <tilt>%OVERALL_TILT%</tilt> 25 <range>%OVERALL_RANGE%</range> 26 </LookAt> 27 <Style id="blackLine"> 28 <LineStyle> 29 <color>%LINE_BLACK%</color> 30 <width>3</width> 31 </LineStyle> 32 </Style> 15 33 <Style id="greenArrowIcon"> 16 34 <IconStyle> … … 34 52 </IconStyle> 35 53 </Style> 36 <Style id="blackLine">37 <LineStyle>38 <color>%LINE_BLACK%</color>39 <width>3</width>40 </LineStyle>41 </Style>42 54 <Folder id="nodes"> 43 55 <name>Nodes</name> 44 56 <description>Nodes from the Wireless Leiden network</description> 45 57 <LookAt> 46 <longitude> 4.490153</longitude>47 <latitude> 52.161087</latitude>48 <altitude> 5</altitude>49 <heading> 0</heading>50 <tilt> 0</tilt>51 <range> 500</range>58 <longitude>%OVERALL_LONGITUDE%</longitude> 59 <latitude>%OVERALL_LATITUDE%</latitude> 60 <altitude>%OVERALL_ALTITUDE%</altitude> 61 <heading>%OVERALL_HEADING%</heading> 62 <tilt>%OVERALL_TILT%</tilt> 63 <range>%OVERALL_RANGE%</range> 52 64 </LookAt> 53 65 %NODESCONTENT% … … 57 69 <description>Lines from nodes to nodes from the Wireless Leiden network</description> 58 70 <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>71 <longitude>%OVERALL_LONGITUDE%</longitude> 72 <latitude>%OVERALL_LATITUDE%</latitude> 73 <altitude>%OVERALL_ALTITUDE%</altitude> 74 <heading>%OVERALL_HEADING%</heading> 75 <tilt>%OVERALL_TILT%</tilt> 76 <range>%OVERALL_RANGE%</range> 65 77 </LookAt> 66 78 %LINESCONTENT% … … 146 158 $toString = str_replace('%LINESCONTENT%', $lineString, $toString); 147 159 160 $toString = str_replace('%OVERALL_LONGITUDE%', $config['overall_longitude'], $toString); 161 $toString = str_replace('%OVERALL_LATITUDE%', $config['overall_latitude'], $toString); 162 $toString = str_replace('%OVERALL_ALTITUDE%', $config['overall_altitude'], $toString); 163 $toString = str_replace('%OVERALL_HEADING%', $config['overall_heading'], $toString); 164 $toString = str_replace('%OVERALL_TILT%', $config['overall_tilt'], $toString); 165 $toString = str_replace('%OVERALL_RANGE%', $config['overall_range'], $toString); 166 148 167 return $toString; 149 168 } … … 218 237 219 238 // Creating a string with the complete description of the node using all data in the location file 220 $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/>'; 239 $dataLocation = ' 240 <Data name="location"> 241 <value> 242 <![CDATA[ 243 ' . $location . ' 244 ]]> 245 </value> 246 </Data> 247 <Data name="status"> 248 <value>' . $status . '</value> 249 </Data> 250 <Data name="interfaces"> 251 <value>' . $interfaces . '</value> 252 </Data> 253 <Data name="masterIP"> 254 <value>' . $masterip . '</value> 255 </Data> 256 <Data name="nodeType"> 257 <value>' . $nodetype . '</value> 258 </Data>'; 221 259 222 260 if ($placemarkPosition = $this->getNodeByName($name)) { 223 261 // Updating an excisting placemark 224 $this->KMLNodes[$placemarkPosition]->setD escriptionLocation($descriptionLocation);262 $this->KMLNodes[$placemarkPosition]->setDataLocation($dataLocation); 225 263 $this->KMLNodes[$placemarkPosition]->setLongitude($longitude); 226 264 $this->KMLNodes[$placemarkPosition]->setLatitude($latitude); … … 230 268 $placemark->setID($name); 231 269 $placemark->setName($name); 232 $placemark->setD escriptionLocation($descriptionLocation);270 $placemark->setDataLocation($dataLocation); 233 271 $placemark->setLongitude($longitude); 234 272 $placemark->setLatitude($latitude); … … 259 297 $this->NetworkList->add($network); 260 298 299 $data = ' 300 <Data name="netmaskDecimal"> 301 <value>' . $network->netmaskDecimal . '</value> 302 </Data> 303 <Data name="netmaskBinary"> 304 <value>' . $network->netmaskBinary . '</value> 305 </Data> 306 <Data name="wildcardDecimal"> 307 <value>' . $network->wildcardDecimal . '</value> 308 </Data> 309 <Data name="wildcardBinary"> 310 <value>' . $network->wildcardBinary . '</value> 311 </Data> 312 <Data name="networkDecimal"> 313 <value>' . $network->networkDecimal . '</value> 314 </Data> 315 <Data name="networkBinary"> 316 <value>' . $network->networkBinary . '</value> 317 </Data> 318 <Data name="broadcastDecimal"> 319 <value>' . $network->broadcastDecimal . '</value> 320 </Data> 321 <Data name="broadcastBinary"> 322 <value>' . $network->broadcastBinary . '</value> 323 </Data> 324 <Data name="hostMinDecimal"> 325 <value>' . $network->hostminDecimal . '</value> 326 </Data> 327 <Data name="hostMinBinary"> 328 <value>' . $network->hostminBinary . '</value> 329 </Data> 330 <Data name="hostMaxDecimal"> 331 <value>' . $network->hostmaxDecimal . '</value> 332 </Data> 333 <Data name="hostMaxBinary"> 334 <value>' . $network->hostmaxBinary . '</value> 335 </Data> 336 <Data name="hosts"> 337 <value>' . $network->numberHosts . '</value> 338 </Data>'; 339 261 340 $line = new KMLLine(); 262 $line->setID( $network->networkDecimal);341 $line->setID(str_replace('.', '', $network->networkDecimal)); 263 342 $line->setName('Link: Van ' . $name . ' naar '); 264 $line->setD escription($network->toString());343 $line->setData($data); 265 344 $line->setLongitude1($longitude); 266 345 $line->setLatitude1($latitude); … … 334 413 335 414 // Creating a string with the complete description of the node using all data in the status file 336 $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/>'; 415 $dataStatus = ' 416 <Data name="type"> 417 <value>' . $lineContent[0] . '</value> 418 </Data> 419 <Data name="hostName"> 420 <value>' . $lineContent[1] . '</value> 421 </Data> 422 <Data name="hasBeenChecked"> 423 <value>' . $lineContent[2] . '</value> 424 </Data> 425 <Data name="checkExecutionTime"> 426 <value>' . $lineContent[3] . '</value> 427 </Data> 428 <Data name="currentState"> 429 <value>' . $lineContent[4] . '</value> 430 </Data> 431 <Data name="lastHardState"> 432 <value>' . $lineContent[5] . '</value> 433 </Data> 434 <Data name="lastCheck"> 435 <value>' . $lineContent[6] . '</value> 436 </Data> 437 <Data name="problemHasBeenAcknowledged"> 438 <value>' . $lineContent[7] . '</value> 439 </Data>'; 440 441 $style = NODE_RED; 442 if ($lineContent[4] == NODE_STATUS_ERROR) { 443 $style = NODE_ORANGE; 444 } elseif ($lineContent[4] == NODE_STATUS_UP) { 445 $style = NODE_GREEN; 446 } 337 447 338 448 if ($placemarkPosition = $this->getNodeByName($lineContent[1])) { 339 449 // Updating an excisting placemark 340 $this->KMLNodes[$placemarkPosition]->setDescriptionStatus($descriptionStatus); 450 $this->KMLNodes[$placemarkPosition]->setDataStatus($dataStatus); 451 $this->KMLNodes[$placemarkPosition]->setStyle($style); 341 452 } else { 342 453 // Adding a new placemark … … 344 455 $placemark->setID($lineContent[1]); 345 456 $placemark->setName($lineContent[1]); 346 $placemark->setDescriptionStatus($descriptionStatus); 457 $placemark->setDataStatus($dataStatus); 458 $placemark->setStyle($style); 347 459 $this->addNode($placemark); 348 460 }
Note:
See TracChangeset
for help on using the changeset viewer.