Changeset 7692


Ignore:
Timestamp:
Apr 7, 2010, 12:24:40 PM (13 years ago)
Author:
Pieter Naber
Message:

Fixed KML output, it's now valid. Added ID's to the placemarkers.

Location:
trunk/src
Files:
3 edited

Legend:

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

    r7661 r7692  
    1212class KMLFile {
    1313        private $template = '
    14                 <?xml version="1.0" encoding="UTF-8"?>
     14                <\?xml version="1.0" encoding="UTF-8"?>
    1515                <kml xmlns="http://www.opengis.net/kml/2.2">
    1616                        <Document>
     
    135135                        } else {
    136136                                $placemark = new KMLPlacemark();
     137                                $placemark->setID($name);
    137138                                $placemark->setName($name);
    138139                                $placemark->setDescriptionLocation($descriptionLocation);
     
    196197                        } else {
    197198                                $placemark = new KMLPlacemark();
     199                                $placemark->setID($host_name);
    198200                                $placemark->setName($host_name);
    199201                                $placemark->setDescriptionStatus($descriptionStatus);
  • trunk/src/inc/KMLPlacemark.class.php

    r7661 r7692  
    88class KMLPlacemark {
    99        private $template = '
    10                 <Placemark>
     10                <Placemark id="%ID%">
    1111                        <name>%NAME%</name>
    12                         <visibility>0</visibility>
    13                         <description>%DESCRIPTION%</description>
     12                        <description>
     13                                <![CDATA[
     14                                        <img src="http://www.wirelessleiden.nl/sites/wirelessleiden.nl/files/garland-wl_logo.png" alt="Wireless Leiden" title="Wireless Leiden" style="float: right;"/>
     15                                        %DESCRIPTION%
     16                                ]]>
     17                        </description>
    1418                        <LookAt>
    1519                                <longitude>%LONGITUDE%</longitude>
     
    2731                </Placemark>';
    2832
     33        private $id;                                    // ID of the node
    2934        private $name;                                  // Name of the node
    3035        private $descriptionLocation;   // Location information of the node
     
    4045         */
    4146        function __construct() {
     47                $this->id = '';
    4248                $this->name = '';
    4349                $this->descriptionLocation = '';
     
    4652                $this->latitude = 0;
    4753                $this->style = 'orangeArrowIcon';
     54        }
     55
     56        function setID($newID) {
     57                $this->id = $newID;
    4858        }
    4959
     
    7989                $toString = $this->template;
    8090
     91                $toString = str_replace('%ID%', $this->id, $toString);
    8192                $toString = str_replace('%NAME%', $this->name, $toString);
    8293                $toString = str_replace('%DESCRIPTION%', $this->descriptionLocation . $this->descriptionStatus, $toString);
  • trunk/src/index.php

    r7661 r7692  
    3131$kml->addPlacemark($kmlPlacemark1);
    3232$kml->addPlacemark($kmlPlacemark2);
    33 echo $kml->toString();
    34 
    35 echo "\r\n\r\n\r\n\r\n\r\n -------------------------------------------------- \r\n\r\n\r\n\r\n\r\n";
     33/*
     34 * For testing, echo the example KML file
     35 * echo $kml->toString();
     36 * echo "\r\n\r\n\r\n\r\n\r\n -------------------------------------------------- \r\n\r\n\r\n\r\n\r\n";
     37 */
    3638
    3739// Now let's try reading from files and parsing the data in the files.
     
    4244$nodeLocation = new FileHandler($config['node_location_file']);
    4345$kmlFile->parseLocationFile($nodeLocation->getFile());
    44 echo $kmlFile->toString();
    45 
    46 echo "\r\n\r\n\r\n\r\n\r\n -------------------------------------------------- \r\n\r\n\r\n\r\n\r\n";
     46/*
     47 * For testing, echo the example KML file
     48 * echo $kmlFile->toString();
     49 * echo "\r\n\r\n\r\n\r\n\r\n -------------------------------------------------- \r\n\r\n\r\n\r\n\r\n";
     50 */
    4751
    4852// Let's try to read the node status file
     
    5054$kmlFile->parseStatusFile($nodeStatus->getFile());
    5155echo $kmlFile->toString();
    52 /*
    53  * TODO: Needs better parsing of the file now we have two seperate
    54  * files for the location and the status of the nodes
    55  */
    5656?>
Note: See TracChangeset for help on using the changeset viewer.