1 |
<?php |
---|
2 |
|
---|
3 |
|
---|
4 |
|
---|
5 |
|
---|
6 |
|
---|
7 |
|
---|
8 |
|
---|
9 |
|
---|
10 |
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 |
|
---|
15 |
|
---|
16 |
|
---|
17 |
|
---|
18 |
|
---|
19 |
|
---|
20 |
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 |
|
---|
25 |
|
---|
26 |
|
---|
27 |
|
---|
28 |
|
---|
29 |
|
---|
30 |
|
---|
31 |
include_once(dirname(__FILE__)."/../Widget.php"); |
---|
32 |
include_once(dirname(__FILE__)."/../Button.php"); |
---|
33 |
include_once(dirname(__FILE__)."/../Popup.php"); |
---|
34 |
include_once ( COMMON."wrapper/map_navigator.php" ); |
---|
35 |
|
---|
36 |
|
---|
37 |
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
class BoundingBoxPopup extends CWCWidget |
---|
42 |
{ |
---|
43 |
var $moButton; |
---|
44 |
var $moPopup; |
---|
45 |
var $moMapNavigator; |
---|
46 |
|
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
function BoundingBoxPopup() |
---|
53 |
{ |
---|
54 |
$this->mszLanguageResource = str_replace("\\","/",dirname(__FILE__))."/BoundingBoxPopup.dbf"; |
---|
55 |
parent::CWCWidget(); |
---|
56 |
|
---|
57 |
$this->moButton = new CWCButton( $this ); |
---|
58 |
|
---|
59 |
$this->moPopup = new CWCPopup( $this ); |
---|
60 |
$this->moPopup->mszLink = $_SESSION['gszCoreWebPath']."/widgets/BoundingBoxPopup/BoundingBoxPopup.phtml"; |
---|
61 |
|
---|
62 |
|
---|
63 |
$this->szWidgetDescription = <<<EOT |
---|
64 |
The BoundingBoxPopupWidget displays a popup dialog box that allows the user |
---|
65 |
to enter bounding box coordinates to zoom to (either rectangle or point) |
---|
66 |
EOT; |
---|
67 |
$this->mnMaturityLevel = MATURITY_BETA; |
---|
68 |
|
---|
69 |
} |
---|
70 |
|
---|
71 |
function InitDefaults() |
---|
72 |
{ |
---|
73 |
parent::InitDefaults(); |
---|
74 |
|
---|
75 |
|
---|
76 |
$this->maParams["TOOLSET"] = ""; |
---|
77 |
$this->moButton->InitDefaults(); |
---|
78 |
$this->moButton->SetOnClick('clickBoundingBoxPopup'); |
---|
79 |
} |
---|
80 |
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 |
function SetMap($oMapSession) |
---|
87 |
{ |
---|
88 |
$this->moMapObject = $oMapSession; |
---|
89 |
|
---|
90 |
$this->moMapNavigator = new MapNavigator( $oMapSession ); |
---|
91 |
} |
---|
92 |
|
---|
93 |
|
---|
94 |
function GetJavascriptInitFunctions() |
---|
95 |
{ |
---|
96 |
return $this->moButton->GetJavascriptInitFunctions(); |
---|
97 |
} |
---|
98 |
|
---|
99 |
function GetJavascriptVariables() |
---|
100 |
{ |
---|
101 |
return $this->moButton->GetJavascriptVariables(); |
---|
102 |
} |
---|
103 |
|
---|
104 |
function GetJavascriptOnLoadFunctions() |
---|
105 |
{ |
---|
106 |
return $this->moButton->GetJavascriptOnLoadFunctions(); |
---|
107 |
} |
---|
108 |
|
---|
109 |
function GetJavascriptIncludeFunctions() |
---|
110 |
{ |
---|
111 |
return $this->moButton->GetJavascriptIncludeFunctions(); |
---|
112 |
} |
---|
113 |
|
---|
114 |
|
---|
115 |
|
---|
116 |
|
---|
117 |
|
---|
118 |
|
---|
119 |
function GetHTMLHiddenVariables() |
---|
120 |
{ |
---|
121 |
$aReturn = $this->moButton->GetHTMLHiddenVariables(); |
---|
122 |
|
---|
123 |
$szCmd = ''; |
---|
124 |
if ($this->isVarSet('NAV_CMD')) |
---|
125 |
$szCmd = $this->getVar('NAV_CMD'); |
---|
126 |
$szVariable = "NAV_CMD"; |
---|
127 |
$szValue = " <INPUT TYPE=HIDDEN NAME=$szVariable VALUE=\"\">\n"; |
---|
128 |
$aReturn[$szVariable] = $szValue; |
---|
129 |
|
---|
130 |
$szVariable = "NAV_INPUT_TYPE"; |
---|
131 |
$szValue = " <INPUT TYPE=HIDDEN NAME=$szVariable VALUE=\"\">"; |
---|
132 |
$aReturn[$szVariable] = $szValue; |
---|
133 |
|
---|
134 |
$szVariable = "NAV_INPUT_COORDINATES"; |
---|
135 |
$szValue = " <INPUT TYPE=HIDDEN NAME=$szVariable VALUE=\"\">\n"; |
---|
136 |
$aReturn[$szVariable] = $szValue; |
---|
137 |
|
---|
138 |
$szVariable = "NAV_INPUT_SRS"; |
---|
139 |
$szValue = " <INPUT TYPE=HIDDEN NAME=$szVariable VALUE=\"\">\n"; |
---|
140 |
$aReturn[$szVariable] = $szValue; |
---|
141 |
|
---|
142 |
return $aReturn; |
---|
143 |
} |
---|
144 |
|
---|
145 |
|
---|
146 |
|
---|
147 |
|
---|
148 |
|
---|
149 |
|
---|
150 |
|
---|
151 |
|
---|
152 |
function ParseURL() |
---|
153 |
{ |
---|
154 |
$szCmd = ""; |
---|
155 |
if ($this->isVarSet("NAV_CMD")) |
---|
156 |
$szCmd = $this->getVar("NAV_CMD"); |
---|
157 |
|
---|
158 |
if ($szCmd == "ZOOM_BBOX") |
---|
159 |
{ |
---|
160 |
|
---|
161 |
$szInputCoords = ""; |
---|
162 |
$szInputCoords = $this->getVar("NAV_INPUT_COORDINATES"); |
---|
163 |
$szInputType = $this->getVar("NAV_INPUT_TYPE"); |
---|
164 |
|
---|
165 |
if(strlen($szInputCoords) <= 0) |
---|
166 |
{ |
---|
167 |
$_SESSION['gErrorManager']->setError(ERR_WARNING, |
---|
168 |
trim($this->moMLT->get("7", "ERROR: No input coordinates specified in BoundingBoxPopup.php."))); |
---|
169 |
return; |
---|
170 |
} |
---|
171 |
if (strlen($szInputType) <= 0) |
---|
172 |
{ |
---|
173 |
$_SESSION['gErrorManager']->setError(ERR_WARNING, |
---|
174 |
trim($this->moMLT->get("8", "ERROR: No input type specified in BoundingBoxPopup.php."))); |
---|
175 |
return; |
---|
176 |
} |
---|
177 |
|
---|
178 |
$aPixPos = explode(",", $szInputCoords); |
---|
179 |
|
---|
180 |
$szSRS = ''; |
---|
181 |
if ($this->isVarSet('NAV_INPUT_SRS') && $this->getVar('NAV_INPUT_SRS') != "") |
---|
182 |
{ |
---|
183 |
$szSRS = trim($this->getVar('NAV_INPUT_SRS')); |
---|
184 |
if (strcasecmp( substr( $szSRS, 0, 4 ), 'epsg') == 0) |
---|
185 |
{ |
---|
186 |
$szSRS = "init=".strtolower($szSRS); |
---|
187 |
} |
---|
188 |
$oProjIn = ms_newProjectionObj( $szSRS ); |
---|
189 |
$oProjOut = ms_newProjectionObj( $this->moMapObject->oMap->getProjection() ); |
---|
190 |
if ($szInputType == "POINT") |
---|
191 |
{ |
---|
192 |
$oPoint = ms_newPointObj(); |
---|
193 |
$oPoint->setXY( $aPixPos[0], $aPixPos[1] ); |
---|
194 |
$oPoint->project( $oProjIn, $oProjOut ); |
---|
195 |
$aPixPos[0] = $oPoint->x; |
---|
196 |
$aPixPos[1] = $oPoint->y; |
---|
197 |
} |
---|
198 |
else |
---|
199 |
{ |
---|
200 |
$oRect = ms_newRectObj(); |
---|
201 |
$oRect->setExtent( $aPixPos[0], $aPixPos[1], $aPixPos[2], $aPixPos[3] ); |
---|
202 |
$oRect->project( $oProjIn, $oProjOut ); |
---|
203 |
$aPixPos[0] = $oRect->minx; |
---|
204 |
$aPixPos[1] = $oRect->miny; |
---|
205 |
$aPixPos[2] = $oRect->maxx; |
---|
206 |
$aPixPos[3] = $oRect->maxy; |
---|
207 |
} |
---|
208 |
} |
---|
209 |
|
---|
210 |
if ($szInputType == "POINT") |
---|
211 |
{ |
---|
212 |
|
---|
213 |
$oRect = $this->moMapObject->oMap->extent; |
---|
214 |
$nX = $oRect->minx + ($oRect->maxx - $oRect->minx)/2; |
---|
215 |
$nY = $oRect->miny + ($oRect->maxy - $oRect->miny)/2; |
---|
216 |
$nOffX = $aPixPos[0] - $nX; |
---|
217 |
$nOffY = $aPixPos[1] - $nY; |
---|
218 |
|
---|
219 |
$this->moMapObject->oMap->setextent( $oRect->minx + $nOffX, |
---|
220 |
$oRect->miny + $nOffY, |
---|
221 |
$oRect->maxx + $nOffX, |
---|
222 |
$oRect->maxy + $nOffY ); |
---|
223 |
} |
---|
224 |
else |
---|
225 |
{ |
---|
226 |
$this->moMapObject->oMap->setextent( $aPixPos[0], $aPixPos[1], $aPixPos[2], $aPixPos[3] ); |
---|
227 |
} |
---|
228 |
|
---|
229 |
|
---|
230 |
|
---|
231 |
|
---|
232 |
|
---|
233 |
$this->ReprojectAuto(); |
---|
234 |
|
---|
235 |
} |
---|
236 |
|
---|
237 |
|
---|
238 |
return true; |
---|
239 |
} |
---|
240 |
|
---|
241 |
|
---|
242 |
|
---|
243 |
|
---|
244 |
|
---|
245 |
|
---|
246 |
|
---|
247 |
function GetJavascriptFunctions() |
---|
248 |
{ |
---|
249 |
if (isset($this->maSharedResourceWidgets["CWCJSAPI"])) |
---|
250 |
$bCWCJSAPI = 1; |
---|
251 |
else |
---|
252 |
$bCWCJSAPI = 0; |
---|
253 |
|
---|
254 |
$aReturn = $this->moButton->GetJavascriptFunctions(); |
---|
255 |
$szJsFunctionName = "clickBoundingBoxPopup"; |
---|
256 |
$szButtonJS = $this->moPopup->DrawPublish(); |
---|
257 |
$szFunction = <<<EOT |
---|
258 |
/** |
---|
259 |
* {$szJsFunctionName} |
---|
260 |
* popup a Bounding Box dialog |
---|
261 |
*/ |
---|
262 |
function {$szJsFunctionName}() |
---|
263 |
{ |
---|
264 |
{$szButtonJS} |
---|
265 |
return; |
---|
266 |
} |
---|
267 |
EOT; |
---|
268 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
269 |
|
---|
270 |
$szJsFunctionName = "applyBoundingBox"; |
---|
271 |
$szFunction = <<<EOT |
---|
272 |
/** |
---|
273 |
* {$szJsFunctionName} |
---|
274 |
* popup a Bounding Box dialog |
---|
275 |
*/ |
---|
276 |
function {$szJsFunctionName}(nMinX, nMinY, nMaxX, nMaxY) |
---|
277 |
{ |
---|
278 |
szCoords = "" + nMinX + "," + nMinY; |
---|
279 |
if (nMaxX != "" && nMaxY != "") |
---|
280 |
{ |
---|
281 |
szType = "RECTANGLE"; |
---|
282 |
szCoords = szCoords + "," + nMaxX + "," + nMaxY; |
---|
283 |
} |
---|
284 |
else |
---|
285 |
{ |
---|
286 |
szType = "POINT"; |
---|
287 |
} |
---|
288 |
{$this->mszHTMLForm}.NAV_CMD.value="ZOOM_BBOX"; |
---|
289 |
{$this->mszHTMLForm}.NAV_INPUT_TYPE.value=szType; |
---|
290 |
{$this->mszHTMLForm}.NAV_INPUT_COORDINATES.value=szCoords; |
---|
291 |
|
---|
292 |
if (arguments.length == 5) |
---|
293 |
{ |
---|
294 |
{$this->mszHTMLForm}.NAV_INPUT_SRS.value=arguments[4]; |
---|
295 |
} |
---|
296 |
|
---|
297 |
if ({$bCWCJSAPI}) |
---|
298 |
{ |
---|
299 |
goCWCJSAPI.NAV_CMD="ZOOM_BBOX"; |
---|
300 |
goCWCJSAPI.NAV_INPUT_TYPE = szType; |
---|
301 |
goCWCJSAPI.NAV_INPUT_COORDINATES=szCoords; |
---|
302 |
if (arguments.length == 5) |
---|
303 |
{ |
---|
304 |
goCWCJSAPI.NAV_INPUT_SRS=arguments[4]; |
---|
305 |
} |
---|
306 |
goCWCJSAPI.UpdateNavTools(); |
---|
307 |
} |
---|
308 |
else |
---|
309 |
{ |
---|
310 |
{$this->mszHTMLForm}.submit(); |
---|
311 |
} |
---|
312 |
return; |
---|
313 |
} |
---|
314 |
EOT; |
---|
315 |
|
---|
316 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
317 |
|
---|
318 |
if (is_object($this->moMapObject)) |
---|
319 |
{ |
---|
320 |
$nPixWidth = $this->moMapObject->oMap->width; |
---|
321 |
$nGeoWidth = $this->moMapObject->oMap->extent->minx - |
---|
322 |
$this->moMapObject->oMap->extent->maxx; |
---|
323 |
|
---|
324 |
$nPixelWidth = abs($nPixWidth / $nGeoWidth); |
---|
325 |
|
---|
326 |
if ($nPixelWidth > 1) |
---|
327 |
$nNbDecimal = abs(log($nPixelWidth))/log(10)+1; |
---|
328 |
else |
---|
329 |
$nNbDecimal = 0; |
---|
330 |
|
---|
331 |
$nMinX = number_format($this->moMapObject->oMap->extent->minx, $nNbDecimal, ".", ""); |
---|
332 |
$nMinY = number_format($this->moMapObject->oMap->extent->miny, $nNbDecimal, ".", ""); |
---|
333 |
$nMaxX = number_format($this->moMapObject->oMap->extent->maxx, $nNbDecimal, ".", ""); |
---|
334 |
$nMaxY = number_format($this->moMapObject->oMap->extent->maxy, $nNbDecimal, ".", ""); |
---|
335 |
} |
---|
336 |
else |
---|
337 |
{ |
---|
338 |
$nMinX = 0; |
---|
339 |
$nMinY = 0; |
---|
340 |
$nMaxX = 1; |
---|
341 |
$nMaxY = 1; |
---|
342 |
} |
---|
343 |
|
---|
344 |
$szJsFunctionName = "getMapExtents"; |
---|
345 |
$szFunction = <<<EOT |
---|
346 |
/** |
---|
347 |
* {$szJsFunctionName} |
---|
348 |
* return the current extents as an array (minx, miny, maxx, maxy) |
---|
349 |
*/ |
---|
350 |
function {$szJsFunctionName}() |
---|
351 |
{ |
---|
352 |
return new Array( {$nMinX}, {$nMinY}, {$nMaxX}, {$nMaxY} ); |
---|
353 |
} |
---|
354 |
EOT; |
---|
355 |
|
---|
356 |
$aReturn[$szJsFunctionName] = $szFunction; |
---|
357 |
|
---|
358 |
return $aReturn; |
---|
359 |
} |
---|
360 |
|
---|
361 |
|
---|
362 |
|
---|
363 |
|
---|
364 |
|
---|
365 |
|
---|
366 |
|
---|
367 |
function DrawPublish() |
---|
368 |
{ |
---|
369 |
if (!$this->mbVisible) |
---|
370 |
return "<!-- BoundingBox popup widget hidden -->"; |
---|
371 |
|
---|
372 |
$szResult = $this->moButton->DrawPublish(); |
---|
373 |
|
---|
374 |
return $szResult; |
---|
375 |
} |
---|
376 |
} |
---|
377 |
?> |
---|
378 |
|
---|