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