source: trunk/src/inc/KMLPlacemark.class.php@ 7754

Last change on this file since 7754 was 7725, checked in by rick, 15 years ago

Made sure the the line style is set to be OS friendly

  • Property svn:eol-style set to native
File size: 4.0 KB
Line 
1<?php
2/*
3 * Project: NodeMap2.0
4 * File: KMLPlacemark.class.php
5 * Purpose: Placemark used in KMLFile
6 */
7
8define('PLACEMARK_GREEN', 'greenArrowIcon');
9define('PLACEMARK_ORANGE', 'orangeArrowIcon');
10define('PLACEMARK_RED', 'redArrowIcon');
11
12class KMLPlacemark {
13 private $template = '
14 <Placemark id="%ID%">
15 <name>%NAME%</name>
16 <description>
17 <![CDATA[
18 <img src="http://www.wirelessleiden.nl/sites/wirelessleiden.nl/files/garland-wl_logo.png" alt="Wireless Leiden" title="Wireless Leiden" style="float: right;"/>
19 %DESCRIPTION%
20 ]]>
21 </description>
22 <LookAt>
23 <longitude>%LONGITUDE%</longitude>
24 <latitude>%LATITUDE%</latitude>
25 <altitude>0</altitude>
26 <heading>0</heading>
27 <tilt>0</tilt>
28 <range>500</range>
29 </LookAt>
30 <styleUrl>%STYLE%</styleUrl>
31 <Point>
32 <altitudeMode>relativeToGround</altitudeMode>
33 <coordinates>%LONGITUDE%,%LATITUDE%</coordinates>
34 </Point>
35 </Placemark>';
36
37 private $id; // ID of the node
38 private $name; // Name of the node
39 private $descriptionLocation; // Location information of the node
40 private $descriptionStatus; // Status information of the node
41 private $longitude; // Longitude of the node
42 private $latitude; // Latitude of the node
43 private $style; // Style of the placemark
44
45 /*
46 * Function: __construct (constructor)
47 * Description: Creating a new KMLFile
48 * Parameters: -
49 * Returns: -
50 */
51 function __construct() {
52 $this->id = '';
53 $this->name = '';
54 $this->descriptionLocation = '';
55 $this->descriptionStatus = '';
56 $this->longitude = 0;
57 $this->latitude = 0;
58 $this->style = 'orangeArrowIcon';
59 }
60
61 /*
62 * Function: setID
63 * Description: Setting the ID of the placemark
64 * Parameters: string $newID
65 * Returns: -
66 */
67 function setID($newID) {
68 $this->id = $newID;
69 }
70
71 /*
72 * Function: setName
73 * Description: Setting the name of the placemark
74 * Parameters: string $newName
75 * Returns: -
76 */
77 function setName($newName) {
78 $this->name = $newName;
79 }
80
81 /*
82 * Function: getName
83 * Description: Getting the name of the placemark
84 * Parameters: -
85 * Returns: The name of the placemark
86 */
87 function getName() {
88 return $this->name;
89 }
90
91 /*
92 * Function: setDescriptionLocation
93 * Description: Setting the location description of the placemark
94 * Parameters: string $newDescriptionLocation
95 * Returns: -
96 */
97 function setDescriptionLocation($newDescriptionLocation) {
98 $this->descriptionLocation = (string) $newDescriptionLocation;
99 }
100
101 /*
102 * Function: setDescriptionStatus
103 * Description: Setting the status description of the placemark
104 * Parameters: string $newDescriptionStatus
105 * Returns: -
106 */
107 function setDescriptionStatus($newDescriptionStatus) {
108 $this->descriptionStatus = (string) $newDescriptionStatus;
109 }
110
111 /*
112 * Function: setLongitude
113 * Description: Setting the longitude of the placemark
114 * Parameters: string $newLongitude
115 * Returns: -
116 */
117 function setLongitude($newLongitude) {
118 $this->longitude = (double) $newLongitude;
119 }
120
121 /*
122 * Function: setLatitude
123 * Description: Setting the latitude of the placemark
124 * Parameters: string $newLatitude
125 * Returns: -
126 */
127 function setLatitude($newLatitude) {
128 $this->latitude = (double) $newLatitude;
129 }
130
131 /*
132 * Function: setStyle
133 * Description: Setting the style of the placemark
134 * Parameters: string $newStyle
135 * Returns: -
136 */
137 function setStyle($newStyle) {
138 $this->style = (string) $newStyle;
139 }
140
141 /*
142 * Function: toString
143 * Description: Converts the content of this placemark to a KML valid string
144 * Parameters: -
145 * Returns: KML valid string
146 */
147 function toString() {
148 $toString = $this->template;
149
150 $toString = str_replace('%ID%', $this->id, $toString);
151 $toString = str_replace('%NAME%', $this->name, $toString);
152 $toString = str_replace('%DESCRIPTION%', $this->descriptionLocation . $this->descriptionStatus, $toString);
153 $toString = str_replace('%LONGITUDE%', $this->longitude, $toString);
154 $toString = str_replace('%LATITUDE%', $this->latitude, $toString);
155 $toString = str_replace('%STYLE%', $this->style, $toString);
156
157 return $toString;
158 }
159}
160?>
Note: See TracBrowser for help on using the repository browser.