[Mapbender-commits] r2344 - in branches/nimix_dev/http: classes javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Apr 4 11:17:29 EDT 2008


Author: nimix
Date: 2008-04-04 11:17:28 -0400 (Fri, 04 Apr 2008)
New Revision: 2344

Added:
   branches/nimix_dev/http/javascripts/mod_openlayers.php
   branches/nimix_dev/http/php/mod_createOlObjFromDB.php
Modified:
   branches/nimix_dev/http/classes/class_wms.php
Log:
rudimentary openlayers integration

Modified: branches/nimix_dev/http/classes/class_wms.php
===================================================================
--- branches/nimix_dev/http/classes/class_wms.php	2008-04-04 12:54:55 UTC (rev 2343)
+++ branches/nimix_dev/http/classes/class_wms.php	2008-04-04 15:17:28 UTC (rev 2344)
@@ -876,6 +876,30 @@
 		}
 	  }
 	  
+		function createOlObjFromWMS($base){
+		 	if(!$this->wms_title || $this->wms_title == ""){
+				echo "alert('Error: no valid capabilities-document !!');";
+				die; exit;
+			}
+			// wms_title and abstract have previously been urlencoded
+			// this solution may not yet be the ultimate one
+			
+			$add_wms_string = "var wms_".$this->wms_id." = new OpenLayers.Layer.WMS.Untiled(" .
+					"'" . addslashes($this->wms_title) . "'," .
+					"'" . $this->wms_getmap ."'," ."{layers:'";
+					for($i=0;$i<count($this->objLayer);$i++){
+						$add_wms_string .= addslashes($this->objLayer[$i]->layer_name);
+						if($i!=count($this->objLayer)-1)
+							$add_wms_string .= ",";
+					}
+					$add_wms_string .= "', transparent: 'true'";
+					$add_wms_string .= ",format: '".$this->gui_wms_mapformat."'});\n";
+					if($base)
+						$add_wms_string .= 	"wms_".$this->wms_id.".isBaseLayer=true;\n";
+					$add_wms_string .= 	"wms_".$this->wms_id.".setVisibility(".($this->gui_wms_visible=="1"?"true":"false").");\n";
+					$add_wms_string .= "ol_map.addLayer(wms_".$this->wms_id.");\n";
+			echo $add_wms_string;
+	  }
 	  
 	/**
 	* writeObjInDB

Added: branches/nimix_dev/http/javascripts/mod_openlayers.php
===================================================================
--- branches/nimix_dev/http/javascripts/mod_openlayers.php	                        (rev 0)
+++ branches/nimix_dev/http/javascripts/mod_openlayers.php	2008-04-04 15:17:28 UTC (rev 2344)
@@ -0,0 +1,71 @@
+<?php
+# $Id$
+# http://www.mapbender.org/index.php/Openlayers
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+?>
+    var ol_options = { scales: [50000000, 30000000, 10000000, 5000000],
+                    resolutions: [1.40625,0.703125,0.3515625,0.17578125,0.087890625,0.0439453125],
+                    minScale: 50000000,
+                    maxResolution: "auto",
+                    maxExtent: new OpenLayers.Bounds(-180, -90, 90, 180),
+                    maxResolution: 0.17578125,
+                    maxScale: 10000000,
+                    minResolution: "auto",
+                    minExtent: new OpenLayers.Bounds(-1, -1, 1, 1),
+                    minResolution: 0.0439453125,
+                    numZoomLevels: 5,
+                    units: "degrees"
+                  };
+
+
+eventInit.register(function (){
+	OpenLayers.ImgPath = "../img/openlayers/";
+            var ol_map = new OpenLayers.Map('<?php echo $e_id;?>', {'maxResolution': 1.40625/2});
+
+//            var ol_wms = new OpenLayers.Layer.WMS( "Germany", 
+//              "http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&", {layers: 'Germany,Topographie,Grenze,Bundeslaender,Staedte,Postleitzahlbereiche,Bahnlinien,Fluesse,Strassen,Staedtepunkte,Postleitzahlbereichname,Staedtenamen,Bundeslaendernamen', format: 'image/png' } );
+
+ //          var jpl_wms = new OpenLayers.Layer.WMS( "Mapbender User",
+  //            "http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&", {layers: 'satellite', format: 'image/png' } );
+  //          var dm_wms = new OpenLayers.Layer.WMS( "Canada",
+   //             "http://www2.dmsolutions.ca/cgi-bin/mswms_gmap",
+    //            {layers: "bathymetry,land_fn,park,drain_fn,drainage," +
+     //                    "prov_bound,fedlimit,rail,road,popplace",
+      //           transparent: "true", format: "image/png" });
+
+//            dm_wms.setVisibility(false);
+
+
+ //           map.addLayers([ol_wms, jpl_wms, dm_wms]);
+  //          map.addControl(new OpenLayers.Control.LayerSwitcher());
+  //          map.zoomToMaxExtent();
+	
+//	var ol_map = new OpenLayers.Map('<?php echo $e_id;?>', {projection:'EPSG:4326','maxResolution': 1.40625/2,maxExtent: new OpenLayers.Bounds(5, 52, 9, 58)});
+// var wms_893 = new OpenLayers.Layer.WMS('Germany','http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/germany/germany.map&',{layers:'Germany,Topographie,Grenze,Bundeslaender,Staedte,Postleitzahlbereiche,Bahnlinien,Fluesse,Strassen,Staedtepunkte,Postleitzahlbereichname,Staedtenamen,Bundeslaendernamen', transparent: 'true',format: 'image/png'});
+//wms_893.setVisibility(true);
+//var ol_wms = new OpenLayers.Layer.WMS( "World Map","http://labs.metacarta.com/wms-c/Basic.py?", {layers: 'basic', format: 'image/png' } );
+
+//var wms_407 = new OpenLayers.Layer.WMS('Mapbender User','http://wms1.ccgis.de/cgi-bin/mapserv?map=/data/umn/mapbender_user/mapbender_user.map&',{layers:'Mapbender,Mapbender_User,Mapbender_Names', transparent: 'true',format: 'image/png'});
+//wms_407.setVisibility(false);
+//ol_map.addLayers([wms_407,wms_893]);	
+	<?php 
+	include(dirname(__FILE__)."/../php/mod_createOlObjFromDB.php");
+	?>
+	
+	ol_map.addControl(new OpenLayers.Control.LayerSwitcher());
+	ol_map.zoomToMaxExtent();
+});
\ No newline at end of file

Added: branches/nimix_dev/http/php/mod_createOlObjFromDB.php
===================================================================
--- branches/nimix_dev/http/php/mod_createOlObjFromDB.php	                        (rev 0)
+++ branches/nimix_dev/http/php/mod_createOlObjFromDB.php	2008-04-04 15:17:28 UTC (rev 2344)
@@ -0,0 +1,34 @@
+<?php
+# $Id: mod_createJSObjFromDB.php 2144 2008-02-26 23:16:14Z christoph $
+# http://www.mapbender.org/index.php/mod_createJSObjectFromDB.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__)."/../classes/class_wms.php");
+
+$sql = "SELECT fkey_wms_id FROM gui_wms WHERE fkey_gui_id = $1 ORDER BY gui_wms_position";
+$v = array($_SESSION["mb_user_gui"]);
+$t = array('s');
+$res = db_prep_query($sql,$v,$t);
+
+$cnt=0;
+while($row = db_fetch_array($res)){
+	$mywms = new wms();
+	$mywms->createObjFromDB($_SESSION["mb_user_gui"],$row["fkey_wms_id"]);
+	$mywms->createOlObjFromWMS($cnt==0);
+	$cnt++;
+}?>
\ No newline at end of file



More information about the Mapbender_commits mailing list