source: trunk/src/inc/KMLNode.class.php@ 7787

Last change on this file since 7787 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 :-)

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