1 |
<?php |
---|
2 |
/** |
---|
3 |
* ZoomIn Widget class |
---|
4 |
* |
---|
5 |
* @project CWC2 |
---|
6 |
* @revision $Id: ZoomIn.widget.php,v 1.8 2005/03/23 03:28:44 wbronsema Exp $ |
---|
7 |
* @purpose Zoom In Widget class |
---|
8 |
* @author DM Solutions Group (assefa@dmsolutions.ca) |
---|
9 |
* @copyright |
---|
10 |
* <b>Copyright (c) 2002, DM Solutions Group Inc.</b> |
---|
11 |
* Permission is hereby granted, free of charge, to any person obtaining a |
---|
12 |
* copy of this software and associated documentation files (the "Software"), |
---|
13 |
* to deal in the Software without restriction, including without limitation |
---|
14 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
---|
15 |
* and/or sell copies of the Software, and to permit persons to whom the |
---|
16 |
* Software is furnished to do so, subject to the following conditions: |
---|
17 |
* |
---|
18 |
* The above copyright notice and this permission notice shall be included |
---|
19 |
* in all copies or substantial portions of the Software. |
---|
20 |
* |
---|
21 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
22 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
23 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
---|
24 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
---|
25 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
---|
26 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
---|
27 |
* DEALINGS IN THE SOFTWARE. |
---|
28 |
*/ |
---|
29 |
|
---|
30 |
|
---|
31 |
include_once(dirname(__FILE__)."/../NavTool.php"); |
---|
32 |
|
---|
33 |
/** |
---|
34 |
* ZoomIn |
---|
35 |
* |
---|
36 |
* @desc Zoomin widget. |
---|
37 |
*/ |
---|
38 |
class ZoomIn extends NavTool |
---|
39 |
{ |
---|
40 |
var $mszImageTip = "Zoom In"; |
---|
41 |
var $mdfZoomMin = 4; |
---|
42 |
|
---|
43 |
/** |
---|
44 |
* ZoomIn |
---|
45 |
* |
---|
46 |
* Constructor. Set the default values. |
---|
47 |
*/ |
---|
48 |
function ZoomIn() |
---|
49 |
{ |
---|
50 |
// invoke constructor of parent |
---|
51 |
parent::NavTool(); |
---|
52 |
|
---|
53 |
$this->SetNavCommand("ZOOM_IN"); |
---|
54 |
$this->mnAllowRectangle = 1; |
---|
55 |
$this->maAttributes["MINIMUMZOOMRECTANGLE"] = new IntegerAttribute( "MINIMUMZOOMRECTANGLE", false, 1 ); |
---|
56 |
|
---|
57 |
// set the description for this widget |
---|
58 |
$this->szWidgetDescription = <<<EOT |
---|
59 |
The ZoomIn widget is a navigation tool that allows the user to zoom in |
---|
60 |
on the map image using either a single point click or by dragging a |
---|
61 |
zooming box on the map. |
---|
62 |
EOT; |
---|
63 |
$this->mnMaturityLevel = MATURITY_TECHNICALRELEASE; |
---|
64 |
|
---|
65 |
} |
---|
66 |
|
---|
67 |
function InitDefaults() |
---|
68 |
{ |
---|
69 |
parent::InitDefaults(); |
---|
70 |
if (isset( $this->maParams["MINIMUMZOOMRECTANGLE"] )) |
---|
71 |
$this->mdfZoomMin = $this->maParams["MINIMUMZOOMRECTANGLE"]; |
---|
72 |
|
---|
73 |
|
---|
74 |
} |
---|
75 |
/** |
---|
76 |
* ParseURL |
---|
77 |
* |
---|
78 |
* Look for the ZOOM_IN command and if founddo the zooming |
---|
79 |
* according to the other NAV paramaters. |
---|
80 |
*/ |
---|
81 |
function ParseURL() |
---|
82 |
{ |
---|
83 |
parent::ParseURL(); |
---|
84 |
|
---|
85 |
$szCmd = ""; |
---|
86 |
if ($this->isVarSet( "NAV_CMD" )) |
---|
87 |
$szCmd = $this->getVar( "NAV_CMD" ); |
---|
88 |
|
---|
89 |
if ($szCmd == "ZOOM_IN") |
---|
90 |
{ |
---|
91 |
|
---|
92 |
$szInputCoords = ""; |
---|
93 |
$szInputCoords = $this->getVar( "NAV_INPUT_COORDINATES" ); |
---|
94 |
$szInputType = $this->getVar( "NAV_INPUT_TYPE" ); |
---|
95 |
|
---|
96 |
if(strlen($szInputCoords) <= 0) |
---|
97 |
{ |
---|
98 |
//The nav tool could be set to zoomin and the page submitted |
---|
99 |
//using other tools so this message is invalid. |
---|
100 |
|
---|
101 |
//$_SESSION['gErrorManager']->setError(ERR_WARNING, |
---|
102 |
// "ERROR: No input coordinates specified in ZoomIn.php."); |
---|
103 |
//return true; |
---|
104 |
$szInputCoords = ($this->moMapObject->oMap->width/2).','.($this->moMapObject->oMap->height/2); |
---|
105 |
$szInputType = 'POINT'; |
---|
106 |
} |
---|
107 |
if (strlen($szInputType) <= 0) |
---|
108 |
{ |
---|
109 |
$_SESSION['gErrorManager']->setError(ERR_WARNING, |
---|
110 |
trim($this->moMLT->get("0", "ERROR: No input type specified in "))."ZoomIn.php."); |
---|
111 |
return false; |
---|
112 |
} |
---|
113 |
$nZoomFactor = 2; |
---|
114 |
if ($this->isVarSet( "ZOOMFACTOR" )) |
---|
115 |
$nZoomFactor = intval($this->getVar( "ZOOMFACTOR" )); |
---|
116 |
if ($nZoomFactor <= 0) |
---|
117 |
$nZoomFactor = 2; |
---|
118 |
|
---|
119 |
if ($szInputType == "POINT") |
---|
120 |
{ |
---|
121 |
$aPixPos = explode(",", $szInputCoords); |
---|
122 |
$this->moMapNavigator->zoomPoint($nZoomFactor, $aPixPos[0], |
---|
123 |
$aPixPos[1]); |
---|
124 |
} |
---|
125 |
else if ($szInputType == "RECTANGLE") |
---|
126 |
{ |
---|
127 |
$aPixPos = explode(";", $szInputCoords); |
---|
128 |
$aPixMin = explode(",", $aPixPos[0]); |
---|
129 |
$aPixMax = explode(",", $aPixPos[1]); |
---|
130 |
/* -------------------------------------------------------------------- */ |
---|
131 |
/* check if the rectangle is bigger than the minmum size allowed. */ |
---|
132 |
/* -------------------------------------------------------------------- */ |
---|
133 |
|
---|
134 |
if (abs($aPixMax[0] - $aPixMin[0]) < $this->mdfZoomMin && |
---|
135 |
abs($aPixMax[1] - $aPixMin[1]) < $this->mdfZoomMin) |
---|
136 |
{ |
---|
137 |
$this->moMapNavigator->zoomPoint($nZoomFactor, $aPixMin[0], |
---|
138 |
$aPixMin[1]); |
---|
139 |
} |
---|
140 |
else |
---|
141 |
$this->moMapNavigator->zoomRectangle($aPixMin[0], $aPixMin[1], |
---|
142 |
$aPixMax[0], $aPixMax[1]); |
---|
143 |
/* -------------------------------------------------------------------- */ |
---|
144 |
/* Call the reporjectauto function in case the map projection */ |
---|
145 |
/* is set to AUTO:XXX. If it is not, the function will do */ |
---|
146 |
/* nothing. */ |
---|
147 |
/* -------------------------------------------------------------------- */ |
---|
148 |
$this->ReprojectAuto(); |
---|
149 |
} |
---|
150 |
else |
---|
151 |
{ |
---|
152 |
$_SESSION['gErrorManager']->setError(ERR_WARNING, |
---|
153 |
trim($this->moMLT->get("1", "ERROR: Invalid input type specified in "))."ZoomIn.php."); |
---|
154 |
return false; |
---|
155 |
} |
---|
156 |
} |
---|
157 |
|
---|
158 |
// return success |
---|
159 |
return true; |
---|
160 |
} |
---|
161 |
} |
---|
162 |
?> |
---|