NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/Chameleon/trunk/Chameleon/ZoomAllLayers/ZoomAllLayers.widget.php

Revision 13 (checked in by jcleary, 17 years ago)

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * ZoomAllLayers Widget class
4  *
5  * @project     CWC2
6  * @revision    $Id: ZoomAllLayers.widget.php,v 1.7 2005/01/11 12:32:21 pspencer Exp $
7  * @purpose     Zoom All Layers Widget class
8  * @author      DM Solutions Group (spencer@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 include_once(dirname(__FILE__)."/../Widget.php");
31 include_once(dirname(__FILE__)."/../Button.php");
32 include_once(dirname(__FILE__)."/../NavTool.php");
33
34 /**
35  * ZoomAllLayers
36  *
37  * @desc ZoomAllLayers widget.
38  */
39 class ZoomAllLayers extends NavTool
40 {
41    /**
42      * ZoomAllLayers
43      *
44      * Constructor. Set the default values.
45      */
46     function ZoomAllLayers()
47     {
48         // invoke constructor of parent
49         parent::NavTool();
50
51         $this->SetNavCommand("ZOOM_FULL");
52         $this->mbSubmitOnClick = 1;
53
54         // set the description for this widget
55         $this->szWidgetDescription = <<<EOT
56 The ZoomAllLayers widget is a navigation tool that allows the user to zoom to
57 the full extents of the original context.
58 EOT;
59
60         $this->mnMaturityLevel = MATURITY_TECHNICALRELEASE;
61
62     }
63     
64     function InitDefaults()
65     {
66         $this->maParams["TOOLSET"] = "";
67         parent::InitDefaults();
68     }
69
70     /**
71      * ParseURL
72      *
73      * Look for the ZOOM_IN command and if founddo the zooming
74      * according to the other NAV paramaters.
75      */
76     function  ParseURL()
77     {
78         parent::ParseURL();
79         
80         $oMap = $this->moMapObject->oMap;
81
82         $szOriginalExtents = trim($oMap->getMetaData( "original_extents" ));
83         if ($szOriginalExtents == "")
84         {
85             $szOriginalExtents = $oMap->extent->minx;
86             $szOriginalExtents .= ",".$oMap->extent->miny;
87             $szOriginalExtents .= ",".$oMap->extent->maxx;
88             $szOriginalExtents .= ",".$oMap->extent->maxy;
89             $oMap->setMetaData( "original_extents", $szOriginalExtents );
90         }
91
92         $szOriginalProjection = trim( $oMap->getMetaData( "original_projection" ));
93         if ($szOriginalProjection == "" && $oMap->getprojection() != "")
94         {
95             $oMap->setMetaData( "original_projection", $oMap->getprojection() );
96         }
97
98         $szCmd = "";
99         if ($this->isVarSet( "NAV_CMD" ))
100           $szCmd = trim($this->getVar( "NAV_CMD" ));
101
102         if ($szCmd == "ZOOM_FULL")
103         {
104             // reproject full_extents metadata if different from projection
105
106             if (strlen($szOriginalExtents) > 0)
107             {
108                 $aszExtents = explode(",", $szOriginalExtents);
109                 if (count($aszExtents) == 4)
110                 {
111                     if ($szOriginalProjection != "" && $szOriginalProjection != $oMap->getprojection())
112                     {
113                         $aszExtents = $this->moMapNavigator->reprojectExtentFromCenter($aszExtents, $oMap->width, $oMap->height, $szOriginalProjection,$oMap->getProjection());
114                     }
115                     $oMap->setMetadata("full_extents", $aszExtents[0].",".$aszExtents[1].",".$aszExtents[2].",".$aszExtents[3]);
116
117 /* -------------------------------------------------------------------- */
118 /*      Call the reporjectauto function in case the map projection      */
119 /*      is set to AUTO:XXX. If it is not, the function will do          */
120 /*      nothing.                                                        */
121 /* -------------------------------------------------------------------- */
122                     $this->ReprojectAuto();
123                 }
124                 else
125                 {
126                     $_SESSION['gErrorManager']->setError(ERR_WARNING,
127                          trim($this->moMLT->get("5", "ERROR: Invalid extent specified in"))." ZoomAllLayers.widget.php on line".__LINE__.".");
128
129                 }
130             }
131             else
132             {
133                 $_SESSION['gErrorManager']->setError(ERR_WARNING,
134                     trim($this->moMLT->get("5", "ERROR: Invalid extent specified in"))." ZoomAllLayers.widget.php on line".__LINE__.".");
135             }
136
137             $szExtents="";
138             $szExtents = $oMap->getMetaData("full_extents");
139
140             if (strlen($szExtents) > 0)
141             {
142                 $aExtents = explode(",", $szExtents);
143                 if (count($aExtents) == 4)
144                 {
145                     $oMap->setextent($aExtents[0], $aExtents[1],
146                                      $aExtents[2], $aExtents[3]);
147                 }
148                 else
149                 {
150                     $_SESSION['gErrorManager']->setError(ERR_WARNING,
151                             trim($this->moMLT->get("5", "ERROR: Invalid extent specified in"))." ZoomAllLayers.widget.php on line".__LINE__.".");
152                 }
153             }
154             else
155             {
156                     $_SESSION['gErrorManager']->setError(ERR_WARNING,
157                         trim($this->moMLT->get("5", "ERROR: Invalid extent specified in"))." ZoomAllLayers.widget.php on line".__LINE__.".");
158             }
159         }
160         
161         // return success
162         return true;
163     }
164 }
165 ?>
166
Note: See TracBrowser for help on using the browser.