[7765] | 1 | <?php
|
---|
| 2 | /*
|
---|
| 3 | * Project: NodeMap2.0
|
---|
| 4 | * File: KMLPlacemark.class.php
|
---|
| 5 | * Purpose: Placemark used in KMLFile
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | define('LINE_BLACK', 'blackLine');
|
---|
| 9 |
|
---|
| 10 | class KMLLine {
|
---|
| 11 | private $template = '
|
---|
| 12 | <Placemark id="%ID%">
|
---|
| 13 | <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>
|
---|
| 20 | <LookAt>
|
---|
| 21 | <longitude>%LONGITUDE%</longitude>
|
---|
| 22 | <latitude>%LATITUDE%</latitude>
|
---|
| 23 | <altitude>0</altitude>
|
---|
| 24 | <heading>0</heading>
|
---|
| 25 | <tilt>0</tilt>
|
---|
| 26 | <range>500</range>
|
---|
| 27 | </LookAt>
|
---|
| 28 | <styleUrl>%STYLE%</styleUrl>
|
---|
| 29 | <LineString>
|
---|
| 30 | <coordinates>
|
---|
| 31 | %X1%, %Y1%, 0.
|
---|
| 32 | %X2%, %Y2%, 0.
|
---|
| 33 | </coordinates>
|
---|
| 34 | </LineString>
|
---|
| 35 | </Placemark>';
|
---|
| 36 |
|
---|
| 37 | private $id; // ID of the line
|
---|
| 38 | private $name; // Name of the line
|
---|
| 39 | private $description; // Description of the line
|
---|
| 40 | private $longitude; // Longitude of the line
|
---|
| 41 | private $latitude; // Latitude of the line
|
---|
| 42 | private $style; // Style of the line
|
---|
| 43 | private $x1; // Start X of line
|
---|
| 44 | private $y1; // Start Y of line
|
---|
| 45 | private $x2; // End X of line
|
---|
| 46 | private $y2; // End Y of line
|
---|
| 47 |
|
---|
| 48 | /*
|
---|
| 49 | * Function: __construct (constructor)
|
---|
| 50 | * Description: Creating a new KMLLine
|
---|
| 51 | * Parameters: -
|
---|
| 52 | * Returns: -
|
---|
| 53 | */
|
---|
| 54 | function __construct() {
|
---|
| 55 | $this->id = '';
|
---|
| 56 | $this->name = '';
|
---|
| 57 | $this->description = '';
|
---|
| 58 | $this->longitude = 0;
|
---|
| 59 | $this->latitude = 0;
|
---|
| 60 | $this->style = LINE_BLACK;
|
---|
| 61 | $this->x1 = 0;
|
---|
| 62 | $this->y1 = 0;
|
---|
| 63 | $this->x2 = 0;
|
---|
| 64 | $this->y2 = 0;
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | /*
|
---|
| 68 | * Function: setID
|
---|
| 69 | * Description: Setting the ID of the placemark
|
---|
| 70 | * Parameters: string $newID
|
---|
| 71 | * Returns: -
|
---|
| 72 | */
|
---|
| 73 | function setID($newID) {
|
---|
| 74 | $this->id = $newID;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /*
|
---|
| 78 | * Function: setName
|
---|
| 79 | * Description: Setting the name of the placemark
|
---|
| 80 | * Parameters: string $newName
|
---|
| 81 | * Returns: -
|
---|
| 82 | */
|
---|
| 83 | function setName($newName) {
|
---|
| 84 | $this->name = $newName;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | /*
|
---|
| 88 | * Function: getName
|
---|
| 89 | * Description: Getting the name of the placemark
|
---|
| 90 | * Parameters: -
|
---|
| 91 | * Returns: The name of the placemark
|
---|
| 92 | */
|
---|
| 93 | function getName() {
|
---|
| 94 | return $this->name;
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | /*
|
---|
| 98 | * Function: setDescription
|
---|
| 99 | * Description: Setting the description of the placemark
|
---|
| 100 | * Parameters: string $newDescription
|
---|
| 101 | * Returns: -
|
---|
| 102 | */
|
---|
| 103 | function setDescription($newDescription) {
|
---|
| 104 | $this->description = (string) $newDescription;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | /*
|
---|
| 108 | * Function: setLongitude
|
---|
| 109 | * Description: Setting the longitude of the placemark
|
---|
| 110 | * Parameters: double $newLongitude
|
---|
| 111 | * Returns: -
|
---|
| 112 | */
|
---|
| 113 | function setLongitude($newLongitude) {
|
---|
| 114 | $this->longitude = (double) $newLongitude;
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | /*
|
---|
| 118 | * Function: setLatitude
|
---|
| 119 | * Description: Setting the latitude of the placemark
|
---|
| 120 | * Parameters: double $newLatitude
|
---|
| 121 | * Returns: -
|
---|
| 122 | */
|
---|
| 123 | function setLatitude($newLatitude) {
|
---|
| 124 | $this->latitude = (double) $newLatitude;
|
---|
| 125 | }
|
---|
| 126 |
|
---|
| 127 | /*
|
---|
| 128 | * Function: setStyle
|
---|
| 129 | * Description: Setting the style of the placemark
|
---|
| 130 | * Parameters: string $newStyle
|
---|
| 131 | * Returns: -
|
---|
| 132 | */
|
---|
| 133 | function setStyle($newStyle) {
|
---|
| 134 | $this->style = (string) $newStyle;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | /*
|
---|
| 138 | * Function: setX1
|
---|
| 139 | * Description: Setting the X1 of the placemark
|
---|
| 140 | * Parameters: double $newX1
|
---|
| 141 | * Returns: -
|
---|
| 142 | */
|
---|
| 143 | function setX1($newX1) {
|
---|
| 144 | $this->x1 = (double) $newX1;
|
---|
| 145 | }
|
---|
| 146 |
|
---|
| 147 | /*
|
---|
| 148 | * Function: setY1
|
---|
| 149 | * Description: Setting the Y1 of the placemark
|
---|
| 150 | * Parameters: double $newY1
|
---|
| 151 | * Returns: -
|
---|
| 152 | */
|
---|
| 153 | function setY1($newY1) {
|
---|
| 154 | $this->y1 = (double) $newY1;
|
---|
| 155 | }
|
---|
| 156 |
|
---|
| 157 | /*
|
---|
| 158 | * Function: setX2
|
---|
| 159 | * Description: Setting the X2 of the placemark
|
---|
| 160 | * Parameters: double $newX2
|
---|
| 161 | * Returns: -
|
---|
| 162 | */
|
---|
| 163 | function setX2($newX2) {
|
---|
| 164 | $this->x2 = (double) $newX2;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | /*
|
---|
| 168 | * Function: setY2
|
---|
| 169 | * Description: Setting the Y2 of the placemark
|
---|
| 170 | * Parameters: double $newY2
|
---|
| 171 | * Returns: -
|
---|
| 172 | */
|
---|
| 173 | function setY2($newY2) {
|
---|
| 174 | $this->y2 = (double) $newY2;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | /*
|
---|
| 178 | * Function: toString
|
---|
| 179 | * Description: Converts the content of this placemark to a KML valid string
|
---|
| 180 | * Parameters: -
|
---|
| 181 | * Returns: KML valid string
|
---|
| 182 | */
|
---|
| 183 | function toString() {
|
---|
| 184 | $toString = $this->template;
|
---|
| 185 |
|
---|
| 186 | $toString = str_replace('%ID%', $this->id, $toString);
|
---|
| 187 | $toString = str_replace('%NAME%', $this->name, $toString);
|
---|
| 188 | $toString = str_replace('%DESCRIPTION%', $this->description, $toString);
|
---|
| 189 | $toString = str_replace('%LONGITUDE%', $this->longitude, $toString);
|
---|
| 190 | $toString = str_replace('%LATITUDE%', $this->latitude, $toString);
|
---|
| 191 | $toString = str_replace('%STYLE%', $this->style, $toString);
|
---|
| 192 | $toString = str_replace('%X1%', $this->x1, $toString);
|
---|
| 193 | $toString = str_replace('%Y1%', $this->y1, $toString);
|
---|
| 194 | $toString = str_replace('%X2%', $this->x2, $toString);
|
---|
| 195 | $toString = str_replace('%Y2%', $this->y2, $toString);
|
---|
| 196 |
|
---|
| 197 | return $toString;
|
---|
| 198 | }
|
---|
| 199 | }
|
---|
| 200 | ?>
|
---|