[7765] | 1 | <?php
|
---|
| 2 | /*
|
---|
| 3 | * Project: NodeMap2.0
|
---|
| 4 | * File: KMLPlacemark.class.php
|
---|
| 5 | * Purpose: Placemark used in KMLFile
|
---|
| 6 | */
|
---|
| 7 |
|
---|
[7775] | 8 | define('LINE_BLACK', '#blackLine');
|
---|
[7765] | 9 |
|
---|
| 10 | class KMLLine {
|
---|
| 11 | private $template = '
|
---|
| 12 | <Placemark id="%ID%">
|
---|
| 13 | <name>%NAME%</name>
|
---|
[7775] | 14 | <description>%NAME%</description>
|
---|
[7765] | 15 | <LookAt>
|
---|
[7773] | 16 | <longitude>%LONGITUDE1%</longitude>
|
---|
| 17 | <latitude>%LATITUDE1%</latitude>
|
---|
[7775] | 18 | <altitude>%OVERALL_ALTITUDE%</altitude>
|
---|
| 19 | <heading>%OVERALL_HEADING%</heading>
|
---|
| 20 | <tilt>%OVERALL_TILT%</tilt>
|
---|
| 21 | <range>%OVERALL_RANGE%</range>
|
---|
[7765] | 22 | </LookAt>
|
---|
[7775] | 23 | <ExtendedData>
|
---|
| 24 | %EXTENDEDDATA%
|
---|
| 25 | </ExtendedData>
|
---|
[7765] | 26 | <styleUrl>%STYLE%</styleUrl>
|
---|
| 27 | <LineString>
|
---|
| 28 | <coordinates>
|
---|
[7775] | 29 | %LONGITUDE1%,%LATITUDE1%,0.
|
---|
| 30 | %LONGITUDE2%,%LATITUDE2%,0.
|
---|
[7765] | 31 | </coordinates>
|
---|
| 32 | </LineString>
|
---|
| 33 | </Placemark>';
|
---|
| 34 |
|
---|
| 35 | private $id; // ID of the line
|
---|
| 36 | private $name; // Name of the line
|
---|
[7775] | 37 | private $data; // Extra information of the line
|
---|
[7765] | 38 | private $style; // Style of the line
|
---|
[7773] | 39 | private $longitude1; // Start longitude of line
|
---|
| 40 | private $latitude1; // Start latitude of line
|
---|
| 41 | private $longitude2; // End longitude of line
|
---|
| 42 | private $latitude2; // End latitude of line
|
---|
[7765] | 43 |
|
---|
| 44 | /*
|
---|
| 45 | * Function: __construct (constructor)
|
---|
| 46 | * Description: Creating a new KMLLine
|
---|
| 47 | * Parameters: -
|
---|
| 48 | * Returns: -
|
---|
| 49 | */
|
---|
| 50 | function __construct() {
|
---|
| 51 | $this->id = '';
|
---|
| 52 | $this->name = '';
|
---|
| 53 | $this->description = '';
|
---|
| 54 | $this->longitude = 0;
|
---|
| 55 | $this->latitude = 0;
|
---|
| 56 | $this->style = LINE_BLACK;
|
---|
[7773] | 57 | $this->longitude1 = 0;
|
---|
| 58 | $this->latitude1 = 0;
|
---|
| 59 | $this->longitude2 = 0;
|
---|
| 60 | $this->latitude2 = 0;
|
---|
[7765] | 61 | }
|
---|
| 62 |
|
---|
| 63 | /*
|
---|
| 64 | * Function: setID
|
---|
| 65 | * Description: Setting the ID of the placemark
|
---|
| 66 | * Parameters: string $newID
|
---|
| 67 | * Returns: -
|
---|
| 68 | */
|
---|
| 69 | function setID($newID) {
|
---|
| 70 | $this->id = $newID;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | * Function: setName
|
---|
| 75 | * Description: Setting the name of the placemark
|
---|
| 76 | * Parameters: string $newName
|
---|
| 77 | * Returns: -
|
---|
| 78 | */
|
---|
| 79 | function setName($newName) {
|
---|
| 80 | $this->name = $newName;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | /*
|
---|
| 84 | * Function: getName
|
---|
| 85 | * Description: Getting the name of the placemark
|
---|
| 86 | * Parameters: -
|
---|
| 87 | * Returns: The name of the placemark
|
---|
| 88 | */
|
---|
| 89 | function getName() {
|
---|
| 90 | return $this->name;
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | /*
|
---|
[7775] | 94 | * Function: setData
|
---|
| 95 | * Description: Setting the extra data of the placemark
|
---|
| 96 | * Parameters: string $newData
|
---|
[7765] | 97 | * Returns: -
|
---|
| 98 | */
|
---|
[7775] | 99 | function setData($newData) {
|
---|
| 100 | $this->data = (string) $newData;
|
---|
[7765] | 101 | }
|
---|
| 102 |
|
---|
| 103 | /*
|
---|
| 104 | * Function: setStyle
|
---|
| 105 | * Description: Setting the style of the placemark
|
---|
| 106 | * Parameters: string $newStyle
|
---|
| 107 | * Returns: -
|
---|
| 108 | */
|
---|
| 109 | function setStyle($newStyle) {
|
---|
| 110 | $this->style = (string) $newStyle;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | /*
|
---|
[7773] | 114 | * Function: setLongitude1
|
---|
| 115 | * Description: Setting the longitude1 of the placemark
|
---|
| 116 | * Parameters: double $newLongitude
|
---|
[7765] | 117 | * Returns: -
|
---|
| 118 | */
|
---|
[7773] | 119 | function setLongitude1($newLongitude) {
|
---|
| 120 | $this->longitude1 = (double) $newLongitude;
|
---|
[7765] | 121 | }
|
---|
[7773] | 122 |
|
---|
[7765] | 123 | /*
|
---|
[7773] | 124 | * Function: setLatitude1
|
---|
| 125 | * Description: Setting the latitude1 of the placemark
|
---|
| 126 | * Parameters: double $newLatitude
|
---|
[7765] | 127 | * Returns: -
|
---|
| 128 | */
|
---|
[7773] | 129 | function setLatitude1($newLatitude) {
|
---|
| 130 | $this->latitude1 = (double) $newLatitude;
|
---|
[7765] | 131 | }
|
---|
| 132 |
|
---|
| 133 | /*
|
---|
[7773] | 134 | * Function: setLongitude2
|
---|
| 135 | * Description: Setting the longitude2 of the placemark
|
---|
| 136 | * Parameters: double $newLongitude
|
---|
[7765] | 137 | * Returns: -
|
---|
| 138 | */
|
---|
[7773] | 139 | function setLongitude2($newLongitude) {
|
---|
| 140 | $this->longitude2 = (double) $newLongitude;
|
---|
[7765] | 141 | }
|
---|
[7773] | 142 |
|
---|
[7765] | 143 | /*
|
---|
[7773] | 144 | * Function: setLatitude2
|
---|
| 145 | * Description: Setting the latitude2 of the placemark
|
---|
| 146 | * Parameters: double $newLatitude
|
---|
[7765] | 147 | * Returns: -
|
---|
| 148 | */
|
---|
[7773] | 149 | function setLatitude2($newLatitude) {
|
---|
| 150 | $this->latitude2 = (double) $newLatitude;
|
---|
[7765] | 151 | }
|
---|
| 152 |
|
---|
| 153 | /*
|
---|
[7773] | 154 | * Function: isConnected
|
---|
| 155 | * Description: Check if it is really a line or just a dot
|
---|
| 156 | * Parameters: -
|
---|
| 157 | * Returns: true if the line is connected, otherwise false
|
---|
| 158 | */
|
---|
| 159 | function isConnected() {
|
---|
| 160 | if (($this->latitude2 == 0) || ($this->longitude2 == 0)) {
|
---|
| 161 | return false;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | // This is a line!
|
---|
| 165 | return true;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | /*
|
---|
[7765] | 169 | * Function: toString
|
---|
| 170 | * Description: Converts the content of this placemark to a KML valid string
|
---|
| 171 | * Parameters: -
|
---|
| 172 | * Returns: KML valid string
|
---|
| 173 | */
|
---|
| 174 | function toString() {
|
---|
| 175 | $toString = $this->template;
|
---|
| 176 |
|
---|
| 177 | $toString = str_replace('%ID%', $this->id, $toString);
|
---|
| 178 | $toString = str_replace('%NAME%', $this->name, $toString);
|
---|
[7775] | 179 | $toString = str_replace('%EXTENDEDDATA%', $this->data, $toString);
|
---|
[7765] | 180 | $toString = str_replace('%STYLE%', $this->style, $toString);
|
---|
[7773] | 181 | $toString = str_replace('%LONGITUDE1%', $this->longitude1, $toString);
|
---|
| 182 | $toString = str_replace('%LATITUDE1%', $this->latitude1, $toString);
|
---|
| 183 | $toString = str_replace('%LONGITUDE2%', $this->longitude2, $toString);
|
---|
| 184 | $toString = str_replace('%LATITUDE2%', $this->latitude2, $toString);
|
---|
[7765] | 185 |
|
---|
| 186 | return $toString;
|
---|
| 187 | }
|
---|
| 188 | }
|
---|
| 189 | ?>
|
---|