[7725] | 1 | <?php
|
---|
| 2 | /*
|
---|
| 3 | * Project: NodeMap2.0
|
---|
[7765] | 4 | * File: KMLNode.class.php
|
---|
| 5 | * Purpose: Node placemark used in KMLFile
|
---|
[7725] | 6 | */
|
---|
| 7 |
|
---|
[7765] | 8 | define('NODE_GREEN', 'greenArrowIcon');
|
---|
| 9 | define('NODE_ORANGE', 'orangeArrowIcon');
|
---|
| 10 | define('NODE_RED', 'redArrowIcon');
|
---|
[7725] | 11 |
|
---|
[7765] | 12 | class KMLNode {
|
---|
[7725] | 13 | private $template = '
|
---|
| 14 | <Placemark id="%ID%">
|
---|
| 15 | <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>
|
---|
| 22 | <LookAt>
|
---|
| 23 | <longitude>%LONGITUDE%</longitude>
|
---|
| 24 | <latitude>%LATITUDE%</latitude>
|
---|
| 25 | <altitude>0</altitude>
|
---|
| 26 | <heading>0</heading>
|
---|
| 27 | <tilt>0</tilt>
|
---|
| 28 | <range>500</range>
|
---|
| 29 | </LookAt>
|
---|
| 30 | <styleUrl>%STYLE%</styleUrl>
|
---|
| 31 | <Point>
|
---|
| 32 | <altitudeMode>relativeToGround</altitudeMode>
|
---|
| 33 | <coordinates>%LONGITUDE%,%LATITUDE%</coordinates>
|
---|
| 34 | </Point>
|
---|
| 35 | </Placemark>';
|
---|
| 36 |
|
---|
| 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
|
---|
[7765] | 43 | private $style; // Style of the node
|
---|
[7725] | 44 |
|
---|
| 45 | /*
|
---|
| 46 | * Function: __construct (constructor)
|
---|
[7765] | 47 | * Description: Creating a new KMLNode
|
---|
[7725] | 48 | * Parameters: -
|
---|
| 49 | * Returns: -
|
---|
| 50 | */
|
---|
| 51 | function __construct() {
|
---|
| 52 | $this->id = '';
|
---|
| 53 | $this->name = '';
|
---|
| 54 | $this->descriptionLocation = '';
|
---|
| 55 | $this->descriptionStatus = '';
|
---|
| 56 | $this->longitude = 0;
|
---|
| 57 | $this->latitude = 0;
|
---|
| 58 | $this->style = 'orangeArrowIcon';
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | /*
|
---|
| 62 | * Function: setID
|
---|
[7765] | 63 | * Description: Setting the ID of the node
|
---|
[7725] | 64 | * Parameters: string $newID
|
---|
| 65 | * Returns: -
|
---|
| 66 | */
|
---|
| 67 | function setID($newID) {
|
---|
| 68 | $this->id = $newID;
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | /*
|
---|
| 72 | * Function: setName
|
---|
[7765] | 73 | * Description: Setting the name of the node
|
---|
[7725] | 74 | * Parameters: string $newName
|
---|
| 75 | * Returns: -
|
---|
| 76 | */
|
---|
| 77 | function setName($newName) {
|
---|
| 78 | $this->name = $newName;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | /*
|
---|
| 82 | * Function: getName
|
---|
[7765] | 83 | * Description: Getting the name of the node
|
---|
[7725] | 84 | * Parameters: -
|
---|
[7765] | 85 | * Returns: The name of the node
|
---|
[7725] | 86 | */
|
---|
| 87 | function getName() {
|
---|
| 88 | return $this->name;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | /*
|
---|
| 92 | * Function: setDescriptionLocation
|
---|
[7765] | 93 | * Description: Setting the location description of the node
|
---|
[7725] | 94 | * Parameters: string $newDescriptionLocation
|
---|
| 95 | * Returns: -
|
---|
| 96 | */
|
---|
| 97 | function setDescriptionLocation($newDescriptionLocation) {
|
---|
| 98 | $this->descriptionLocation = (string) $newDescriptionLocation;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | /*
|
---|
| 102 | * Function: setDescriptionStatus
|
---|
[7765] | 103 | * Description: Setting the status description of the node
|
---|
[7725] | 104 | * Parameters: string $newDescriptionStatus
|
---|
| 105 | * Returns: -
|
---|
| 106 | */
|
---|
| 107 | function setDescriptionStatus($newDescriptionStatus) {
|
---|
| 108 | $this->descriptionStatus = (string) $newDescriptionStatus;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /*
|
---|
| 112 | * Function: setLongitude
|
---|
[7765] | 113 | * Description: Setting the longitude of the node
|
---|
[7725] | 114 | * Parameters: string $newLongitude
|
---|
| 115 | * Returns: -
|
---|
| 116 | */
|
---|
| 117 | function setLongitude($newLongitude) {
|
---|
| 118 | $this->longitude = (double) $newLongitude;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | /*
|
---|
| 122 | * Function: setLatitude
|
---|
[7765] | 123 | * Description: Setting the latitude of the node
|
---|
[7725] | 124 | * Parameters: string $newLatitude
|
---|
| 125 | * Returns: -
|
---|
| 126 | */
|
---|
| 127 | function setLatitude($newLatitude) {
|
---|
| 128 | $this->latitude = (double) $newLatitude;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | /*
|
---|
| 132 | * Function: setStyle
|
---|
[7765] | 133 | * Description: Setting the style of the node
|
---|
[7725] | 134 | * Parameters: string $newStyle
|
---|
| 135 | * Returns: -
|
---|
| 136 | */
|
---|
| 137 | function setStyle($newStyle) {
|
---|
| 138 | $this->style = (string) $newStyle;
|
---|
| 139 | }
|
---|
| 140 |
|
---|
| 141 | /*
|
---|
| 142 | * Function: toString
|
---|
[7765] | 143 | * Description: Converts the content of this node to a KML valid string
|
---|
[7725] | 144 | * Parameters: -
|
---|
| 145 | * Returns: KML valid string
|
---|
| 146 | */
|
---|
| 147 | function toString() {
|
---|
| 148 | $toString = $this->template;
|
---|
| 149 |
|
---|
| 150 | $toString = str_replace('%ID%', $this->id, $toString);
|
---|
| 151 | $toString = str_replace('%NAME%', $this->name, $toString);
|
---|
| 152 | $toString = str_replace('%DESCRIPTION%', $this->descriptionLocation . $this->descriptionStatus, $toString);
|
---|
| 153 | $toString = str_replace('%LONGITUDE%', $this->longitude, $toString);
|
---|
| 154 | $toString = str_replace('%LATITUDE%', $this->latitude, $toString);
|
---|
| 155 | $toString = str_replace('%STYLE%', $this->style, $toString);
|
---|
| 156 |
|
---|
| 157 | return $toString;
|
---|
| 158 | }
|
---|
| 159 | }
|
---|
[7627] | 160 | ?>
|
---|