source: trunk/src/inc/KMLLine.class.php@ 7777

Last change on this file since 7777 was 7775, checked in by Pieter Naber, 15 years ago

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 :-)

File size: 4.6 KB
Line 
1<?php
2/*
3 * Project: NodeMap2.0
4 * File: KMLPlacemark.class.php
5 * Purpose: Placemark used in KMLFile
6 */
7
8define('LINE_BLACK', '#blackLine');
9
10class KMLLine {
11 private $template = '
12 <Placemark id="%ID%">
13 <name>%NAME%</name>
14 <description>%NAME%</description>
15 <LookAt>
16 <longitude>%LONGITUDE1%</longitude>
17 <latitude>%LATITUDE1%</latitude>
18 <altitude>%OVERALL_ALTITUDE%</altitude>
19 <heading>%OVERALL_HEADING%</heading>
20 <tilt>%OVERALL_TILT%</tilt>
21 <range>%OVERALL_RANGE%</range>
22 </LookAt>
23 <ExtendedData>
24 %EXTENDEDDATA%
25 </ExtendedData>
26 <styleUrl>%STYLE%</styleUrl>
27 <LineString>
28 <coordinates>
29 %LONGITUDE1%,%LATITUDE1%,0.
30 %LONGITUDE2%,%LATITUDE2%,0.
31 </coordinates>
32 </LineString>
33 </Placemark>';
34
35 private $id; // ID of the line
36 private $name; // Name of the line
37 private $data; // Extra information of the line
38 private $style; // Style of the line
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
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;
57 $this->longitude1 = 0;
58 $this->latitude1 = 0;
59 $this->longitude2 = 0;
60 $this->latitude2 = 0;
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 /*
94 * Function: setData
95 * Description: Setting the extra data of the placemark
96 * Parameters: string $newData
97 * Returns: -
98 */
99 function setData($newData) {
100 $this->data = (string) $newData;
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 /*
114 * Function: setLongitude1
115 * Description: Setting the longitude1 of the placemark
116 * Parameters: double $newLongitude
117 * Returns: -
118 */
119 function setLongitude1($newLongitude) {
120 $this->longitude1 = (double) $newLongitude;
121 }
122
123 /*
124 * Function: setLatitude1
125 * Description: Setting the latitude1 of the placemark
126 * Parameters: double $newLatitude
127 * Returns: -
128 */
129 function setLatitude1($newLatitude) {
130 $this->latitude1 = (double) $newLatitude;
131 }
132
133 /*
134 * Function: setLongitude2
135 * Description: Setting the longitude2 of the placemark
136 * Parameters: double $newLongitude
137 * Returns: -
138 */
139 function setLongitude2($newLongitude) {
140 $this->longitude2 = (double) $newLongitude;
141 }
142
143 /*
144 * Function: setLatitude2
145 * Description: Setting the latitude2 of the placemark
146 * Parameters: double $newLatitude
147 * Returns: -
148 */
149 function setLatitude2($newLatitude) {
150 $this->latitude2 = (double) $newLatitude;
151 }
152
153 /*
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 /*
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);
179 $toString = str_replace('%EXTENDEDDATA%', $this->data, $toString);
180 $toString = str_replace('%STYLE%', $this->style, $toString);
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);
185
186 return $toString;
187 }
188}
189?>
Note: See TracBrowser for help on using the repository browser.