Changeset 7775 for trunk/src/inc


Ignore:
Timestamp:
Apr 16, 2010, 12:27:16 AM (15 years ago)
Author:
Pieter Naber
Message:

Something's still wrong with the colors of nodes... Green nodes are placed in the middle of the ocean... However it's bedtime, so bye bye :-)

Location:
trunk/src/inc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/inc/KMLFile.class.php

    r7773 r7775  
    55 * Purpose: Creating of editing KML files
    66 */
     7
     8define('NODE_STATUS_UP', 0);
     9define('NODE_STATUS_ERROR', 1);
     10define('NODE_STATUS_UNREACHABLE', 2);
    711
    812class KMLFile {
     
    1317                                <open>1</open>
    1418                                <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>
    1533                                <Style id="greenArrowIcon">
    1634                                        <IconStyle>
     
    3452                                        </IconStyle>
    3553                                </Style>
    36                                 <Style id="blackLine">
    37                                         <LineStyle>
    38                                                 <color>%LINE_BLACK%</color>
    39                                                 <width>3</width>
    40                                         </LineStyle>
    41                                 </Style>
    4254                                <Folder id="nodes">
    4355                                        <name>Nodes</name>
    4456                                        <description>Nodes from the Wireless Leiden network</description>
    4557                                        <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>
    5264                                        </LookAt>
    5365                                        %NODESCONTENT%
     
    5769                                        <description>Lines from nodes to nodes from the Wireless Leiden network</description>
    5870                                        <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>
    6577                                        </LookAt>
    6678                                        %LINESCONTENT%
     
    146158                $toString = str_replace('%LINESCONTENT%', $lineString, $toString);
    147159
     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
    148167                return $toString;
    149168        }
     
    218237
    219238                        // 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>';
    221259
    222260                        if ($placemarkPosition = $this->getNodeByName($name)) {
    223261                                // Updating an excisting placemark
    224                                 $this->KMLNodes[$placemarkPosition]->setDescriptionLocation($descriptionLocation);
     262                                $this->KMLNodes[$placemarkPosition]->setDataLocation($dataLocation);
    225263                                $this->KMLNodes[$placemarkPosition]->setLongitude($longitude);
    226264                                $this->KMLNodes[$placemarkPosition]->setLatitude($latitude);
     
    230268                                $placemark->setID($name);
    231269                                $placemark->setName($name);
    232                                 $placemark->setDescriptionLocation($descriptionLocation);
     270                                $placemark->setDataLocation($dataLocation);
    233271                                $placemark->setLongitude($longitude);
    234272                                $placemark->setLatitude($latitude);
     
    259297                                        $this->NetworkList->add($network);
    260298
     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
    261340                                        $line = new KMLLine();
    262                                         $line->setID($network->networkDecimal);
     341                                        $line->setID(str_replace('.', '', $network->networkDecimal));
    263342                                        $line->setName('Link: Van ' . $name . ' naar ');
    264                                         $line->setDescription($network->toString());
     343                                        $line->setData($data);
    265344                                        $line->setLongitude1($longitude);
    266345                                        $line->setLatitude1($latitude);
     
    334413
    335414                        // 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                        }
    337447
    338448                        if ($placemarkPosition = $this->getNodeByName($lineContent[1])) {
    339449                                // Updating an excisting placemark
    340                                 $this->KMLNodes[$placemarkPosition]->setDescriptionStatus($descriptionStatus);
     450                                $this->KMLNodes[$placemarkPosition]->setDataStatus($dataStatus);
     451                                $this->KMLNodes[$placemarkPosition]->setStyle($style);
    341452                        } else {
    342453                                // Adding a new placemark
     
    344455                                $placemark->setID($lineContent[1]);
    345456                                $placemark->setName($lineContent[1]);
    346                                 $placemark->setDescriptionStatus($descriptionStatus);
     457                                $placemark->setDataStatus($dataStatus);
     458                                $placemark->setStyle($style);
    347459                                $this->addNode($placemark);
    348460                        }
  • trunk/src/inc/KMLLine.class.php

    r7773 r7775  
    66 */
    77
    8 define('LINE_BLACK', 'blackLine');
     8define('LINE_BLACK', '#blackLine');
    99
    1010class KMLLine {
     
    1212                <Placemark id="%ID%">
    1313                        <name>%NAME%</name>
    14                         <description>
    15                                 <![CDATA[
    16                                         <img src="http://www.wirelessleiden.nl/sites/wirelessleiden.nl/files/garland-wl_logo.png" alt="Wireless Leiden" title="Wireless Leiden" style="float: right;"/>
    17                                         %DESCRIPTION%
    18                                 ]]>
    19                         </description>
     14                        <description>%NAME%</description>
    2015                        <LookAt>
    2116                                <longitude>%LONGITUDE1%</longitude>
    2217                                <latitude>%LATITUDE1%</latitude>
    23                                 <altitude>0</altitude>
    24                                 <heading>0</heading>
    25                                 <tilt>0</tilt>
    26                                 <range>500</range>
     18                                <altitude>%OVERALL_ALTITUDE%</altitude>
     19                                <heading>%OVERALL_HEADING%</heading>
     20                                <tilt>%OVERALL_TILT%</tilt>
     21                                <range>%OVERALL_RANGE%</range>
    2722                        </LookAt>
     23                        <ExtendedData>                       
     24                                %EXTENDEDDATA%
     25                        </ExtendedData>
    2826                        <styleUrl>%STYLE%</styleUrl>
    2927                        <LineString>
    3028                                <coordinates>
    31                                         %LONGITUDE1%, %LATITUDE1%, 0.
    32                                         %LONGITUDE2%, %LATITUDE2%, 0.
     29                                        %LONGITUDE1%,%LATITUDE1%,0.
     30                                        %LONGITUDE2%,%LATITUDE2%,0.
    3331                                </coordinates>
    3432                        </LineString>
     
    3735        private $id;                                    // ID of the line
    3836        private $name;                                  // Name of the line
    39         private $description;                   // Description of the line
     37        private $data;                                  // Extra information of the line
    4038        private $style;                                 // Style of the line
    4139        private $longitude1;                    // Start longitude of line
     
    9492
    9593        /*
    96          * Function: setDescription
    97          * Description: Setting the description of the placemark
    98          * Parameters: string $newDescription
     94         * Function: setData
     95         * Description: Setting the extra data of the placemark
     96         * Parameters: string $newData
    9997         * Returns: -
    10098         */
    101         function setDescription($newDescription) {
    102                 $this->description = (string) $newDescription;
     99        function setData($newData) {
     100                $this->data = (string) $newData;
    103101        }
    104102
     
    179177                $toString = str_replace('%ID%', $this->id, $toString);
    180178                $toString = str_replace('%NAME%', $this->name, $toString);
    181                 $toString = str_replace('%DESCRIPTION%', $this->description, $toString);
     179                $toString = str_replace('%EXTENDEDDATA%', $this->data, $toString);
    182180                $toString = str_replace('%STYLE%', $this->style, $toString);
    183181                $toString = str_replace('%LONGITUDE1%', $this->longitude1, $toString);
  • trunk/src/inc/KMLNode.class.php

    r7765 r7775  
    66 */
    77
    8 define('NODE_GREEN', 'greenArrowIcon');
    9 define('NODE_ORANGE', 'orangeArrowIcon');
    10 define('NODE_RED', 'redArrowIcon');
     8define('NODE_GREEN', '#greenArrowIcon');
     9define('NODE_ORANGE', '#orangeArrowIcon');
     10define('NODE_RED', '#redArrowIcon');
    1111
    1212class KMLNode {
     
    1414                <Placemark id="%ID%">
    1515                        <name>%NAME%</name>
    16                         <description>
    17                                 <![CDATA[
    18                                         <img src="http://www.wirelessleiden.nl/sites/wirelessleiden.nl/files/garland-wl_logo.png" alt="Wireless Leiden" title="Wireless Leiden" style="float: right;"/>
    19                                         %DESCRIPTION%
    20                                 ]]>
    21                         </description>
     16                        <description>%NAME%</description>
    2217                        <LookAt>
    2318                                <longitude>%LONGITUDE%</longitude>
    2419                                <latitude>%LATITUDE%</latitude>
    25                                 <altitude>0</altitude>
    26                                 <heading>0</heading>
    27                                 <tilt>0</tilt>
    28                                 <range>500</range>
     20                                <altitude>%OVERALL_ALTITUDE%</altitude>
     21                                <heading>%OVERALL_HEADING%</heading>
     22                                <tilt>%OVERALL_TILT%</tilt>
     23                                <range>%OVERALL_RANGE%</range>
    2924                        </LookAt>
     25                        <ExtendedData>                       
     26                                %EXTENDEDDATA%
     27                        </ExtendedData>
    3028                        <styleUrl>%STYLE%</styleUrl>
    3129                        <Point>
     
    3533                </Placemark>';
    3634
    37         private $id;                                    // ID of the node
    38         private $name;                                  // Name of the node
    39         private $descriptionLocation;   // Location information of the node
    40         private $descriptionStatus;             // Status information of the node
    41         private $longitude;                             // Longitude of the node
    42         private $latitude;                              // Latitude of the node
    43         private $style;                                 // Style of the node
     35        private $id;                            // ID of the node
     36        private $name;                          // Name of the node
     37        private $dataLocation;          // Location information of the node
     38        private $dataStatus;            // Status information of the node
     39        private $longitude;                     // Longitude of the node
     40        private $latitude;                      // Latitude of the node
     41        private $style;                         // Style of the node
    4442
    4543        /*
     
    5250                $this->id = '';
    5351                $this->name = '';
    54                 $this->descriptionLocation = '';
    55                 $this->descriptionStatus = '';
     52                $this->dataLocation = '';
     53                $this->dataStatus = '';
    5654                $this->longitude = 0;
    5755                $this->latitude = 0;
    58                 $this->style = 'orangeArrowIcon';
     56                $this->style = NODE_RED;
    5957        }
    6058
     
    9593         * Returns: -
    9694         */
    97         function setDescriptionLocation($newDescriptionLocation) {
    98                 $this->descriptionLocation = (string) $newDescriptionLocation;
     95        function setDataLocation($newDataLocation) {
     96                $this->dataLocation = (string) $newDataLocation;
    9997        }
    10098
     
    105103         * Returns: -
    106104         */
    107         function setDescriptionStatus($newDescriptionStatus) {
    108                 $this->descriptionStatus = (string) $newDescriptionStatus;
     105        function setDataStatus($newDataStatus) {
     106                $this->dataStatus = (string) $newDataStatus;
    109107        }
    110108
     
    150148                $toString = str_replace('%ID%', $this->id, $toString);
    151149                $toString = str_replace('%NAME%', $this->name, $toString);
    152                 $toString = str_replace('%DESCRIPTION%', $this->descriptionLocation . $this->descriptionStatus, $toString);
     150                $toString = str_replace('%EXTENDEDDATA%', $this->dataLocation . $this->dataStatus, $toString);
    153151                $toString = str_replace('%LONGITUDE%', $this->longitude, $toString);
    154152                $toString = str_replace('%LATITUDE%', $this->latitude, $toString);
Note: See TracChangeset for help on using the changeset viewer.