svn commit: r636 - trunk/mapbender/http: classes javascripts php
christoph at osgeo.org
christoph at osgeo.org
Wed Jun 28 10:23:01 EDT 2006
Author: christoph
Date: 2006-06-28 14:23:01+0000
New Revision: 636
Modified:
trunk/mapbender/http/classes/class_wmc.php
trunk/mapbender/http/javascripts/mod_initWmc.php
trunk/mapbender/http/javascripts/mod_loadwmc.php
trunk/mapbender/http/php/mb_listWMCs.php
Log:
improvement:
-merged two functions in class_wmc: createJsObjectFromWMC and MergeJsObject, saved 100+ lines
-moved code from list_wmcs to class_wmc
-repaired ie bug
to do:
-sync problem in IE: after a load/append/merge the map request doesn't work
-after the wmc window has been closed, load/merge/append doesn't work any longer in IE (somewhere the closed window is being referenced)
Modified: trunk/mapbender/http/classes/class_wmc.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_wmc.php?view=diff&rev=636&p1=trunk/mapbender/http/classes/class_wmc.php&p2=trunk/mapbender/http/classes/class_wmc.php&r1=635&r2=636
==============================================================================
--- trunk/mapbender/http/classes/class_wmc.php (original)
+++ trunk/mapbender/http/classes/class_wmc.php 2006-06-28 14:23:01+0000
@@ -536,256 +536,66 @@
//return $verbose;
}
-
- function createJsObjFromWMC($target, $mapObj){
-
- $wmc_string = "";
-
- $new_wms = "";
- $cnt_wms = -1;
-
- //added_wms contains all the wms that have been added already.
- $added_wms = array();
-
- // for all layers do
- for ($i = 0; $i < count($this->wmc_layer_title); $i++) {
-
- //get wms of this layer
- $current_wms = $this->wmc_wms_serviceURL[$i];
-
- //BEGIN : check if wms has not been added before
- if (!in_array($current_wms , $added_wms)) {
-
- //gathers all the layers of the current wms (seperated by ,)
- $layerlist = "";
- //gathers all the querylayers of the current wms (seperated by ,)
- $querylayerlist = "";
-
- $srs_array = array();
-
- // BEGIN: add this wms as it has not been added before
- $mywms = new wms();
-
- if(!$this->wmc_layer_title[$i] || $this->wmc_layer_title[$i] == ""){
- echo "alert('Error: no valid capabilities-document !!');";
- die; exit;
- }
-
- // create temporary WMS id
- $time = explode(" ", microtime(1));
- $id = substr(md5(substr($time[0], 2)), 0, 5);
-
- $this->wmc_wms_count ++;
-
- $wmc_string .= $target . "add_wms('" .
- $id ."','".
- $this->wmc_wms_version[$i] ."','".
- $this->wmc_wms_title[$i] ."','".
- $this->wmc_layer_abstract[$i] ."','".
- $this->wmc_wms_serviceURL[$i] ."','" .
- $this->wmc_wms_serviceURL[$i] ."','" .
- $this->wmc_layer_style_legendurl[$i][0] ."','','".
- $this->wmc_layer_format[$i][0] ."','text/html','application/vnd.ogc.se_xml','".
- $this->wmc_layer_srs[$i][0] ."','1');\n";
-
- // END: add this wms as it has not been added before
-
- // add wms to added wms
- $added_wms[count($added_wms)] = $current_wms;
-
-
- $cnt_wms++;
- $cnt_layers = 0;
- $cnt_query_layers = 0;
- // list of all added formats in this wms
-
- //BEGIN : gather all layers of this wms
- for ($ii = 0; $ii < count($this->wmc_layer_title); $ii++) {
-
- //the wms of the current layer
- $layer_wms = $this->wmc_wms_serviceURL[$ii];
-
- // BEGIN: check if the layer belongs to the current wms
- if ($current_wms == $layer_wms) {
-
-
- // BEGIN: Add format to WMS
- $z = count($this->wmc_layer_format[$ii]);
-
- for($j=0;$j<$z;$j++){
- $wmc_string .= $target . "wms_add_data_type_format('map','". $this->wmc_layer_format[$ii][$j] ."');\n";
- }
- // END: Add format to WMS
-
- // BEGIN: BUILD AND ADD PARENT LAYER
- if ($cnt_layers == 0) {
- $wmc_string .= $target . "wms_add_layer('','','". $this->wmc_wms_title[$i] ."','','0','0','0','0','','".$id."','1','1','1','0','0','0','0');\n";
-
- }
- // END: BUILD AND ADD PARENT LAYER
-
-
- // BEGIN: counting layers and queryable layers belonging to a certain wms
-
- $cnt_layers++;
-
- if ($this->wmc_layer_queryable[$ii]) {
- $cnt_query_layers++;
- //add layer to querylayerlist
- if (!in_array($this->wmc_layer_name[$ii], explode(",", $querylayerlist))) {
- if ($querylayerlist == "") {$querylayerlist = $this->wmc_layer_name[$ii];} else {$querylayerlist .= "," . $this->wmc_layer_name[$ii];}
- }
-
- }
- // END: counting layers and queryable layers belonging to a certain wms
-
- // BEGIN: Add layer to WMS (using $new_wms_id as index)
- $wmc_string .= $target . "wms_add_layer('0','".
- $this->wmc_layer_name[$ii] . "','".
- $this->wmc_layer_title[$ii] ."','".
- $this->wmc_layer_dataurl[$ii]
- . "','".
- intval($cnt_layers) ."','".
- $this->wmc_layer_queryable[$ii] ."','0','0','".
- $this->wmc_layer_metadataurl[$ii]
- ."','".
- $id ."','1','1','".
- intval(!$this->wmc_layer_hidden[$ii]) ."','".
- $this->wmc_layer_queryable[$ii] ."','".
- $this->wmc_layer_queryable[$ii] ."','0','0');\n";
- // END: Add layer to WMS (using $new_wms_id as index)
-
- //add layer to layerlist if layer is visible
- if (intval(!$this->wmc_layer_hidden[$ii]) && !in_array($this->wmc_layer_name[$ii], explode(",", $layerlist))) {
- if ($layerlist == "") {$layerlist = $this->wmc_layer_name[$ii];} else {$layerlist .= "," . $this->wmc_layer_name[$ii];}
- }
-
- // BEGIN: Add epsg to layer
- for($j=0; $j<count($this->wmc_layer_srs[$ii]);$j++){
- if (!in_array($this->wmc_layer_srs[$ii][$j], $srs_array)) {
- $srs_array[count($srs_array)] = $this->wmc_layer_srs[$ii][$j];
- $wmc_string .= $target . "wms_addSRS('".
- $this->wmc_layer_srs[$ii][$j] ."','".
- $this->wmc_bBox_minx ."','".
- $this->wmc_bBox_miny ."','".
- $this->wmc_bBox_maxx ."','".
- $this->wmc_bBox_maxy ."','".
- "');\n";
- }
- }
- // END: Add epsg to layer
-
- // BEGIN: Add style to layer
- for($j=0; $j<count($this->wmc_layer_style_name[$ii]);$j++){
- $wmc_string .= $target . "wms_addLayerStyle('".$this->wmc_layer_style_name[$ii][$j] ."','".$this->wmc_layer_style_title[$ii][$j] ."','".$j."','".$cnt_layers."', '" . $this->wmc_layer_style_legendurl[$ii][$j] . "', '" . $this->wmc_layer_style_legendurl_format[$ii][$j] . "');\n";
- }
- // END: Add style to layer
- }
- // END: check if the layer belongs to the current wms
- }
- //END : gather all layers of this wms
-
- // add wms to mapObj with all layers and querylayers
-// $wmc_string .= $target;
-// $wmc_string .= "mb_mapObjaddWMSwithLayers('" . $mapObj . "', '" . $layerlist . "', '" . $querylayerlist . "');\n";
-
- }
- //END : check if wms has not been added before
- }
-// $wmc_string .= "var ind = " . $target . "getMapObjIndexByName('" . $mapObj . "');\n";
-// $wmc_string .= $target . "mb_mapObj[ind].width = " . $this->wmc_windowWidth . ";\n";
-// $wmc_string .= $target . "mb_mapObj[ind].height = " . $this->wmc_windowHeight . ";\n";
-// $wmc_string .= $target . "mb_mapObj[ind].epsg = '" . $this->wmc_bBox_SRS . "';\n";
-// $wmc_string .= $target . "mb_calculateExtent('" . $mapObj . "', " . $this->wmc_bBox_minx . ", " . $this->wmc_bBox_miny . ", " . $this->wmc_bBox_maxx . ", " . $this->wmc_bBox_maxy . ");\n";
-
-
- $wmc_string .= "var old_mapObj = ".$target."cloneObject(".$target."mb_mapObj);\n";
- $wmc_string .= $target . "mb_mapObj = new Array();\n";
- $wmc_string .= "for (var i=0; i<old_mapObj.length; i++) {\n";
- $wmc_string .= "\tif (old_mapObj[i].frameName != 'overview') {\n";
- $wmc_string .= "\t\t" . $target . "mb_registerMapObj(old_mapObj[i].frameName, old_mapObj[i].elementName, null, " . $this->wmc_windowWidth . ", " . $this->wmc_windowHeight . ");\n";
- $wmc_string .= $target . "document.getElementById(old_mapObj[i].frameName).style.width = " . $this->wmc_windowWidth . ";\n";
- $wmc_string .= $target . "document.getElementById(old_mapObj[i].frameName).style.height = " . $this->wmc_windowHeight . ";\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "\telse {\n";
- $wmc_string .= "\t\t" . $target . "mb_registerMapObj(old_mapObj[i].frameName, old_mapObj[i].elementName, 0, old_mapObj[i].width, old_mapObj[i].width);\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "}\n";
-
- return $wmc_string;
- }
-
-/*
- *
- * checks if layers of the wmc are existing in the client. If yes, they are only updated, and not loaded twice.
- *
- *
- */
-
- function mergeExistingJsObjWithWMC($target, $mapObj){
+ function createJsObjFromWMC($target, $mapObj, $action){
$wmc_string = "";
- $wmc_string .= "var ind = " . $target . "getMapObjIndexByName('" . $mapObj . "');\n";
- $wmc_string .= "var wms_exists = false;\n";
- $wmc_string .= "var layer_exists = false;\n";
- $wmc_string .= "var current_wms_index = null;\n";
- $wmc_string .= "var current_layer_index = null;\n";
- $wmc_string .= "var changedWmsIds = new Array();\n";
- $wmc_string .= "var wmsAlreadyInArray = false;\n";
-
- $new_wms = "";
- $cnt_wms = -1;
-
- //added_wms contains all the wms that have been added already.
- $added_wms = array();
-
- // for all layers do
- for ($i = 0; $i < count($this->wmc_layer_title); $i++) {
-
- //get wms of this layer
- $current_wms = $this->wmc_wms_serviceURL[$i];
-
- //BEGIN : check if wms has not been added before
- if (!in_array($current_wms , $added_wms)) {
-
- //gathers all the layers of the current wms (seperated by ,)
- $layerlist = "";
- //gathers all the querylayers of the current wms (seperated by ,)
- $querylayerlist = "";
-
- // BEGIN: check if this wms is already included in the client
- // if not, add wms and and add layers
- // if yes, check layers
-
-
- $wmc_string .= "wms_exists = false;\n";
- $wmc_string .= "current_wms_index = null;\n";
- $wmc_string .= "for (var m=0; m < " . $target . "mb_mapObj[ind].wms.length; m++) {\n";
- $wmc_string .= "\tif ('" . $this->wmc_wms_serviceURL[$i] . "' == " . $target . "mb_mapObj[ind].wms[m].wms_getmap) {\n";
- $wmc_string .= "\t\twms_exists = true;\n";
- $wmc_string .= "\t\tcurrent_wms_index = m;\n";
-// $wmc_string .= "\t\talert('match: ' + " . $target . "mb_mapObj[ind].wms[m].wms_getmap);\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "}\n";
-
- $wmc_string .= "if (!wms_exists) {\n";
-
- // END: check if this wms is already included in the client
-
- // BEGIN: add this wms as it has not been added before
+ $validActions = array("load", "merge", "append");
+ if (!in_array($action, $validActions)) {
+ $wmc_string .= "alert('invalid action: ".$action."');";
+ }
+ else {
+ $wmc_string .= "var index = " . $target . "getMapObjIndexByName('" . $mapObj . "');\n";
+ if ($action == "load") {
+ $wmc_string .= "while(" . $target . "mb_mapObj[index].wms.length > 0){" . $target . "mb_mapObjremoveWMS(index,0);}";
+ $wmc_string .= $target . "deleteWmsObject();\n";
+ }
+ if ($action == "merge") {
+ $wmc_string .= "var ind = " . $target . "getMapObjIndexByName('" . $mapObj . "');\n";
+ $wmc_string .= "var wms_exists = false;\n";
+ $wmc_string .= "var layer_exists = false;\n";
+ $wmc_string .= "var current_wms_index = null;\n";
+ $wmc_string .= "var current_layer_index = null;\n";
+ $wmc_string .= "var changedWmsIds = new Array();\n";
+ $wmc_string .= "var wmsAlreadyInArray = false;\n";
+ }
+ $new_wms = "";
+ $cnt_wms = -1;
+ $added_wms = array();
+
+ for ($i = 0; $i < count($this->wmc_layer_title); $i++) {
+ $current_wms = $this->wmc_wms_serviceURL[$i];
+ if (!in_array($current_wms , $added_wms)) {
+ $layerlist = "";
+ $querylayerlist = "";
+ $srs_array = array();
+
+ if ($action == "merge") {
+ $wmc_string .= "wms_exists = false;\n";
+ $wmc_string .= "current_wms_index = null;\n";
+ $wmc_string .= "for (var m=0; m < " . $target . "mb_mapObj[ind].wms.length; m++) {\n";
+ $wmc_string .= "\tif ('" . $this->wmc_wms_serviceURL[$i] . "' == " . $target . "mb_mapObj[ind].wms[m].wms_getmap) {\n";
+ $wmc_string .= "\t\twms_exists = true;\n";
+ $wmc_string .= "\t\tcurrent_wms_index = m;\n";
+ $wmc_string .= "\t}\n";
+ $wmc_string .= "}\n";
+ $wmc_string .= "if (!wms_exists) {\n";
+ }
+
$mywms = new wms();
-
+
if(!$this->wmc_layer_title[$i] || $this->wmc_layer_title[$i] == ""){
echo "alert('Error: no valid capabilities-document !!');\n";
die; exit;
}
-
+
// create temporary WMS id
$time = explode(" ", microtime(1));
$id = substr(md5(substr($time[0], 2)), 0, 5);
-
$this->wmc_wms_count ++;
- $wmc_string .= "\tchangedWmsIds[changedWmsIds.length] = '" . $id . "';\n";
+
+ if ($action == "merge") {
+ $wmc_string .= "\tchangedWmsIds[changedWmsIds.length] = '" . $id . "';\n";
+ }
$wmc_string .= "\t" . $target . "add_wms('" .
$id ."','".
$this->wmc_wms_version[$i] ."','".
@@ -796,175 +606,159 @@
$this->wmc_layer_style_legendurl[$i][0] ."','','".
$this->wmc_layer_format[$i][0] ."','text/html','application/vnd.ogc.se_xml','".
$this->wmc_layer_srs[$i][0] ."','1');\n";
-
- // END: add this wms as it has not been added before
-
- // add wms to added wms
+
$added_wms[count($added_wms)] = $current_wms;
-
-
$cnt_wms++;
$cnt_layers = 0;
$cnt_query_layers = 0;
+ if ($action == "merge") {
+ $wmc_string .= "}\n";
+ }
-
- $wmc_string .= "}\n";
-
- //BEGIN : gather all layers of this wms
- for ($ii = 0; $ii < count($this->wmc_layer_title); $ii++) {
-
- //the wms of the current layer
- $layer_wms = $this->wmc_wms_serviceURL[$ii];
-
- // BEGIN: check if the layer belongs to the current wms
- if ($current_wms == $layer_wms) {
-
-
- // BEGIN: Add format to WMS
- $z = count($this->wmc_layer_format[$ii]);
-
- for($j=0;$j<$z;$j++){
- $wmc_string .= $target . "wms_add_data_type_format('map','". $this->wmc_layer_format[$ii][$j] ."');\n";
- }
- // END: Add format to WMS
-
-
- // BEGIN: BUILD AND ADD PARENT LAYER
- if ($cnt_layers == 0) {
- $wmc_string .= "if (!wms_exists) {\n";
- $wmc_string .= "\t" . $target . "wms_add_layer('','','". $this->wmc_wms_title[$i] ."','','0','0','0','0','','".$id."','1','1','1','0','0','0','0');\n";
- $wmc_string .= "}\n";
- }
- // END: BUILD AND ADD PARENT LAYER
-
-
- // BEGIN: counting layers and queryable layers belonging to a certain wms
-
- $cnt_layers++;
-
- if ($this->wmc_layer_queryable[$ii]) {
- $cnt_query_layers++;
- //add layer to querylayerlist
- if (!in_array($this->wmc_layer_name[$ii], explode(",",$querylayerlist))) {
- if ($querylayerlist == "") {$querylayerlist = $this->wmc_layer_name[$ii];} else {$querylayerlist .= "," . $this->wmc_layer_name[$ii];}
+ for ($ii = 0; $ii < count($this->wmc_layer_title); $ii++) {
+ $layer_wms = $this->wmc_wms_serviceURL[$ii];
+ if ($current_wms == $layer_wms) {
+ $z = count($this->wmc_layer_format[$ii]);
+ for($j=0;$j<$z;$j++){
+ $wmc_string .= $target . "wms_add_data_type_format('map','". $this->wmc_layer_format[$ii][$j] ."');\n";
}
+ if ($cnt_layers == 0) {
+ if ($action == "merge") {
+ $wmc_string .= "if (!wms_exists) {\n\t";
+ }
+ $wmc_string .= $target . "wms_add_layer('','','". $this->wmc_wms_title[$i] ."','','0','0','0','0','','".$id."','1','1','1','0','0','0','0');\n";
+ if ($action == "merge") {
+ $wmc_string .= "}\n";
+ }
+ }
+
+ $cnt_layers++;
+ if ($this->wmc_layer_queryable[$ii]) {
+ $cnt_query_layers++;
+ if (!in_array($this->wmc_layer_name[$ii], explode(",",$querylayerlist))) {
+ if ($querylayerlist == "") {$querylayerlist = $this->wmc_layer_name[$ii];} else {$querylayerlist .= "," . $this->wmc_layer_name[$ii];}
+ }
+ }
- }
- // END: counting layers and queryable layers belonging to a certain wms
-
- $wmc_string .= "if (!wms_exists) {\n";
- // BEGIN: Add layer to WMS (using $new_wms_id as index)
- $wmc_string .= "\t" . $target . "wms_add_layer('0','".
- $this->wmc_layer_name[$ii] . "','".
- $this->wmc_layer_title[$ii] ."','".
- $this->wmc_layer_dataurl[$ii]
- . "','".
- intval($cnt_layers) ."','".
- $this->wmc_layer_queryable[$ii] ."','0','0','".
- $this->wmc_layer_metadataurl[$ii]
- ."','".
- $id ."','1','1','".
- intval(!$this->wmc_layer_hidden[$ii]) ."','".
- $this->wmc_layer_queryable[$ii] ."','".
- $this->wmc_layer_queryable[$ii] ."','0','0');\n";
- // END: Add layer to WMS (using $new_wms_id as index)
- $wmc_string .= "}\n";
-
- // in this case, check if the current (PHP) wmc layer exists within the (JS) wms at current_wms_index
- $wmc_string .= "else {\n";
-
- // check if this layer already exists in this wms
- $wmc_string .= "\tlayer_exists = false;\n";
- $wmc_string .= "\tcurrent_layer_index = null;\n";
- $wmc_string .= "\tfor (var m=0; m < " . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer.length; m++) {\n";
- $wmc_string .= "\t\tif ('" . $this->wmc_layer_name[$ii] . "' == " . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[m].layer_name) {\n";
- $wmc_string .= "\t\t\tlayer_exists = true;\n";
- $wmc_string .= "\t\t\tcurrent_layer_index = m;\n";
-// $wmc_string .= "\t\t\talert('match: ' + " . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[m].layer_name);\n";
- $wmc_string .= "\t\t}\n";
- $wmc_string .= "\t}\n";
-
- $wmc_string .= "\tif (!layer_exists) {\n";
-
- // do nothing (later: add this layer to current wms)
-
- $wmc_string .= "\t}\n";
-
- $wmc_string .= "\telse {\n";
-
- // check if the visibility or the queryability are different to the existing layer
- // FIXME: this 'if' may not work
- $wmc_string .= "\t\tif (" . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_visible != '" . intval(!$this->wmc_layer_hidden[$ii]) . "'";
- $wmc_string .= " || " . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer != '" . $this->wmc_layer_queryable[$ii] . "') {\n";
-
- // if yes, update the visibility and queryability..
- $wmc_string .= "\t\t\t" . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_visible = " . intval(!$this->wmc_layer_hidden[$ii]) . ";\n";
- $wmc_string .= "\t\t\t" . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer = " . $this->wmc_layer_queryable[$ii] . ";\n";
-
- // ... and check if current wms is in array of wmses that need restating...
- $wmc_string .= "\t\t\twmsAlreadyInArray = false;\n";
- $wmc_string .= "\t\t\tfor (var z=0; z<changedWmsIds.length; z++) {\n";
- // FIXME: this 'if' may not work
- $wmc_string .= "\t\t\t\tif (changedWmsIds[z] == " . $target . "mb_mapObj[ind].wms[current_wms_index].wms_id) {\n";
- $wmc_string .= "\t\t\t\t\twmsAlreadyInArray = true;\n";
- $wmc_string .= "\t\t\t\t}\n";
- $wmc_string .= "\t\t\t}\n";
-
- //...if the layers of the current wms need restating, add them to the array
- $wmc_string .= "\t\t\tif (wmsAlreadyInArray == false) {\n";
- $wmc_string .= "\t\t\t\tchangedWmsIds[changedWmsIds.length] = " . $target . "mb_mapObj[ind].wms[current_wms_index].wms_id;\n";
-
- $wmc_string .= "\t\t\t}\n";
- $wmc_string .= "\t\t}\n";
- $wmc_string .= "\t}\n";
- $wmc_string .= "}\n";
-
- //add layer to layerlist if layer is visible
- if (intval(!$this->wmc_layer_hidden[$ii]) && !in_array($this->wmc_layer_name[$ii], explode(",",$layerlist))) {
- if ($layerlist == "") {$layerlist = $this->wmc_layer_name[$ii];} else {$layerlist .= "," . $this->wmc_layer_name[$ii];}
- }
- // BEGIN: Add epsg to layer
- for($j=0; $j<count($this->wmc_layer_srs[$ii]);$j++){
- $wmc_string .= $target . "wms_addSRS('".
- $this->wmc_layer_srs[$ii][$j] ."','".
- $this->wmc_bBox_minx ."','".
- $this->wmc_bBox_miny ."','".
- $this->wmc_bBox_maxx ."','".
- $this->wmc_bBox_maxy ."','".
- "');\n";
- }
- // END: Add epsg to layer
-
- // BEGIN: Add style to layer
- for($j=0; $j<count($this->wmc_layer_style_name[$ii]);$j++){
- $wmc_string .= $target . "wms_addLayerStyle('".$this->wmc_layer_style_name[$ii][$j] ."','".$this->wmc_layer_style_title[$ii][$j] ."','".$j."','".$cnt_layers."', '" . $this->wmc_layer_style_legendurl[$ii][$j] . "', '" . $this->wmc_layer_style_legendurl_format[$ii][$j] . "');\n";
+ if ($action == "merge") {
+ $wmc_string .= "if (!wms_exists) {\n";
+ }
+ $wmc_string .= "\t" . $target . "wms_add_layer('0','".
+ $this->wmc_layer_name[$ii] . "','".
+ $this->wmc_layer_title[$ii] ."','".
+ $this->wmc_layer_dataurl[$ii]
+ . "','".
+ intval($cnt_layers) ."','".
+ $this->wmc_layer_queryable[$ii] ."','0','0','".
+ $this->wmc_layer_metadataurl[$ii]
+ ."','".
+ $id ."','1','1','".
+ intval(!$this->wmc_layer_hidden[$ii]) ."','".
+ $this->wmc_layer_queryable[$ii] ."','".
+ $this->wmc_layer_queryable[$ii] ."','0','0');\n";
+
+ if ($action == "merge") {
+ $wmc_string .= "}\n";
+ $wmc_string .= "else {\n";
+
+ // check if this layer already exists in this wms
+ $wmc_string .= "\tlayer_exists = false;\n";
+ $wmc_string .= "\tcurrent_layer_index = null;\n";
+ $wmc_string .= "\tfor (var m=0; m < " . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer.length; m++) {\n";
+ $wmc_string .= "\t\tif ('" . $this->wmc_layer_name[$ii] . "' == " . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[m].layer_name) {\n";
+ $wmc_string .= "\t\t\tlayer_exists = true;\n";
+ $wmc_string .= "\t\t\tcurrent_layer_index = m;\n";
+ $wmc_string .= "\t\t}\n";
+ $wmc_string .= "\t}\n";
+
+ $wmc_string .= "\tif (!layer_exists) {\n";
+ // do nothing (later: add this layer to current wms)
+ $wmc_string .= "\t}\n";
+ $wmc_string .= "\telse {\n";
+
+ // check if the visibility or the queryability are different to the existing layer
+ // FIXME: this 'if' may not work
+ $wmc_string .= "\t\tif (" . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_visible != '" . intval(!$this->wmc_layer_hidden[$ii]) . "'";
+ $wmc_string .= " || " . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer != '" . $this->wmc_layer_queryable[$ii] . "') {\n";
+
+ // if yes, update the visibility and queryability..
+ $wmc_string .= "\t\t\t" . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_visible = " . intval(!$this->wmc_layer_hidden[$ii]) . ";\n";
+ $wmc_string .= "\t\t\t" . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer = " . $this->wmc_layer_queryable[$ii] . ";\n";
+
+ // ... and check if current wms is in array of wmses that need restating...
+ $wmc_string .= "\t\t\twmsAlreadyInArray = false;\n";
+ $wmc_string .= "\t\t\tfor (var z=0; z<changedWmsIds.length; z++) {\n";
+ // FIXME: this 'if' may not work
+ $wmc_string .= "\t\t\t\tif (changedWmsIds[z] == " . $target . "mb_mapObj[ind].wms[current_wms_index].wms_id) {\n";
+ $wmc_string .= "\t\t\t\t\twmsAlreadyInArray = true;\n";
+ $wmc_string .= "\t\t\t\t}\n";
+ $wmc_string .= "\t\t\t}\n";
+
+ //...if the layers of the current wms need restating, add them to the array
+ $wmc_string .= "\t\t\tif (wmsAlreadyInArray == false) {\n";
+ $wmc_string .= "\t\t\t\tchangedWmsIds[changedWmsIds.length] = " . $target . "mb_mapObj[ind].wms[current_wms_index].wms_id;\n";
+ $wmc_string .= "\t\t\t}\n";
+ $wmc_string .= "\t\t}\n";
+ $wmc_string .= "\t}\n";
+ $wmc_string .= "}\n";
+ }
+
+
+ if (intval(!$this->wmc_layer_hidden[$ii]) && !in_array($this->wmc_layer_name[$ii], explode(",",$layerlist))) {
+ if ($layerlist == "") {$layerlist = $this->wmc_layer_name[$ii];} else {$layerlist .= "," . $this->wmc_layer_name[$ii];}
+ }
+
+ for($j=0; $j<count($this->wmc_layer_srs[$ii]);$j++){
+ if (!in_array($this->wmc_layer_srs[$ii][$j], $srs_array)) {
+ $srs_array[count($srs_array)] = $this->wmc_layer_srs[$ii][$j];
+ $wmc_string .= $target . "wms_addSRS('".
+ $this->wmc_layer_srs[$ii][$j] ."','".
+ $this->wmc_bBox_minx ."','".
+ $this->wmc_bBox_miny ."','".
+ $this->wmc_bBox_maxx ."','".
+ $this->wmc_bBox_maxy ."','".
+ "');\n";
+ }
+ }
+
+ for($j=0; $j<count($this->wmc_layer_style_name[$ii]);$j++){
+ $wmc_string .= $target . "wms_addLayerStyle('".$this->wmc_layer_style_name[$ii][$j] ."','".$this->wmc_layer_style_title[$ii][$j] ."','".$j."','".$cnt_layers."', '" . $this->wmc_layer_style_legendurl[$ii][$j] . "', '" . $this->wmc_layer_style_legendurl_format[$ii][$j] . "');\n";
+ }
}
- // END: Add style to layer
}
- // END: check if the layer belongs to the current wms
+
+ // add wms to mapObj with all layers and querylayers
+ if ($action == "merge") {
+ $wmc_string .= "if (!wms_exists) {\n";
+ }
+ $wmc_string .= $target. "mb_mapObjaddWMSwithLayers('" . $mapObj . "', '" . $layerlist . "', '" . $querylayerlist . "');\n";
+ if ($action == "merge") {
+ $wmc_string .= "}\n";
+ $wmc_string .= "else {\n";
+ $wmc_string .= $target. "mb_mapObj[ind].layers[current_wms_index] = \"" . $layerlist . "\";\n";
+ $wmc_string .= $target. "mb_mapObj[ind].querylayers[current_wms_index] = \"" . $querylayerlist . "\";\n";
+ $wmc_string .= "}\n";
+ }
}
- //END : gather all layers of this wms
-
- // add wms to mapObj with all layers and querylayers
- $wmc_string .= "if (!wms_exists) {\n";
- $wmc_string .= $target. "mb_mapObjaddWMSwithLayers('" . $mapObj . "', '" . $layerlist . "', '" . $querylayerlist . "');\n";
- $wmc_string .= "}\n";
-
- // if the wms already exists, the layerlist and the querylayerlist of the mapObj have to be updated
- $wmc_string .= "else {\n";
- $wmc_string .= $target. "mb_mapObj[ind].layers[current_wms_index] = \"" . $layerlist . "\";\n";
- $wmc_string .= $target. "mb_mapObj[ind].querylayers[current_wms_index] = \"" . $querylayerlist . "\";\n";
- $wmc_string .= "}\n";
}
- //END : check if wms has not been added before
+ $wmc_string .= "var old_mapObj = ".$target."cloneObject(".$target."mb_mapObj);\n";
+ $wmc_string .= $target . "mb_mapObj = new Array();\n";
+ $wmc_string .= "for (var i=0; i<old_mapObj.length; i++) {\n";
+ $wmc_string .= "\tif (old_mapObj[i].frameName != 'overview') {\n";
+ $wmc_string .= "\t\t" . $target . "mb_registerMapObj(old_mapObj[i].frameName, old_mapObj[i].elementName, null, " . $this->wmc_windowWidth . ", " . $this->wmc_windowHeight . ");\n";
+ $wmc_string .= "\t\t" . $target . "document.getElementById(old_mapObj[i].frameName).style.width = " . $this->wmc_windowWidth . ";\n";
+ $wmc_string .= "\t\t" . $target . "document.getElementById(old_mapObj[i].frameName).style.height = " . $this->wmc_windowHeight . ";\n";
+ $wmc_string .= "\t}\n";
+ $wmc_string .= "\telse {\n";
+ $wmc_string .= "\t\t" . $target . "mb_registerMapObj(old_mapObj[i].frameName, old_mapObj[i].elementName, 0, old_mapObj[i].width, old_mapObj[i].width);\n";
+ $wmc_string .= "\t}\n";
+ $wmc_string .= "}\n";
+ $wmc_string .= $target . "mb_execloadWmsSubFunctions();\n";
+ $wmc_string .= $target . "setMapRequest('" . $mapObj . "');\n";
}
- $wmc_string .= $target . "mb_mapObj[ind].width = " . $this->wmc_windowWidth . ";\n";
- $wmc_string .= $target . "mb_mapObj[ind].height = " . $this->wmc_windowHeight . ";\n";
- $wmc_string .= $target . "mb_mapObj[ind].epsg = '" . $this->wmc_bBox_SRS . "';\n";
- $wmc_string .= $target . "mb_calculateExtent('" . $mapObj . "', " . $this->wmc_bBox_minx . ", " . $this->wmc_bBox_miny . ", " . $this->wmc_bBox_maxx . ", " . $this->wmc_bBox_maxy . ");\n";
-
return $wmc_string;
}
+
function char_encode($s){
if(CHARSET == 'UTF-8'){
$s = utf8_encode($s);
@@ -973,47 +767,4 @@
}
}
// end class
-
-#$my_wmc = new wmc();
-
-//missing: createWmcStringFromJsObj
-
-//gets wmc from db and creates a PHP object
-//$my_wmc->createObjFromWMC("16_1112782628445");
-//creates a JS object from a PHP object
-//$my_wmc->createJsObjFromWMC("");
-
-
-
-//print("mb_restateLayers('" . $frameName . "');\n");
-//print("mb_repaint('" . $frameName . "'," . $my_wmc->wmc_bBox_minx . ",". $my_wmc->wmc_bBox_maxx . ",". $my_wmc->wmc_bBox_miny . ",". $my_wmc->wmc_bBox_maxy . ");\n");
-
-/*
-
-require_once("../../conf/mapbender.conf");
-$mywms = new wms();
-mywms->createObjFromXML("http://wms1.ccgis.de/cgi-bin/mapserv44?map=/data/umn/germany_demo/germany_demo_wfs.map&&VERSION=1.1.1&REQUEST=GetCapabilities&SERVICE=WMS");
-$mywms->optimizeWMS();
-$mywms->writeObjInDB("legend");
-*/
-#$mywms->displayWMS();
-
-#$mywms->createObjFromXML("http://zoidberg/web/xml/brd_administrativ.xml");
-#$mywms->createObjFromXML("http://zoidberg/web/xml/dienste_1_1_1.xml");
-#$mywms->createObjFromXML("http://localhost/cgi-bin/mapserv?map=/data/umn/germany_demo/germany_demo.map&&VERSION=1.1.0&REQUEST=GetCapabilities&SERVICE=WMS");
-/*
-$mywms = new wms();
-$mywms->createObjFromXML("http://localhost/mapbender2/classes/germany.xml");
-
-$mywms->displayWMS();
-*/
-/*
-require_once("../../conf/mapbender.conf");
-$mywms = new wms();
-#$mywms->createObjFromDB("gui1",2);
-$mywms->createObjFromXML("http://localhost/mapbender2/caps/rastertest.xml");
-$mywms->optimizeWMS();
-$mywms->createJsObjFromWMS();
-#$mywms->displayWMS();
-*/
?>
Modified: trunk/mapbender/http/javascripts/mod_initWmc.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_initWmc.php?view=diff&rev=636&p1=trunk/mapbender/http/javascripts/mod_initWmc.php&p2=trunk/mapbender/http/javascripts/mod_initWmc.php&r1=635&r2=636
==============================================================================
--- trunk/mapbender/http/javascripts/mod_initWmc.php (original)
+++ trunk/mapbender/http/javascripts/mod_initWmc.php 2006-06-28 14:23:01+0000
@@ -30,12 +30,7 @@
echo "wmc_id = '".$_SESSION['mb_myWmc']."';";
$wmc = new wmc();
$wmc->createObjFromWMC($_SESSION['mb_myWmc']);
- $js .= "deleteWmsObject();\n";
- $js .= $wmc->createJsObjFromWMC("", $e_target[0]);
- $js .= "var index = getMapObjIndexByName('" . $e_target[0] . "');\n";
- $js .= "document.getElementById('".$e_target[0]."').style.width = mb_mapObj[index].width;\n";
- $js .= "document.getElementById('".$e_target[0]."').style.height = mb_mapObj[index].height;\n";
- $js .= "mb_execloadWmsSubFunctions();\n";
+ $js .= $wmc->createJsObjFromWMC("", $e_target[0], "load");
}
else {
$js .= "alert('".$adm->getUserNameByUserId($_SESSION["mb_user_id"])." is not allowed to access WMC ".$_SESSION['mb_myWmc'].". Default GUI will be loaded instead.');";
Modified: trunk/mapbender/http/javascripts/mod_loadwmc.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_loadwmc.php?view=diff&rev=636&p1=trunk/mapbender/http/javascripts/mod_loadwmc.php&p2=trunk/mapbender/http/javascripts/mod_loadwmc.php&r1=635&r2=636
==============================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.php (original)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.php 2006-06-28 14:23:01+0000
@@ -48,7 +48,7 @@
}
function mod_loadwmc(obj){
windowWmc = window.open("../php/mb_listWMCs.php?<?php echo SID;?>","displayWmc","width=500, dependent=yes");
- windowWmc.focus();
+ //windowWmc.focus();
}
function mod_loadwmc_init(obj){
//document.getElementById("loadwmc").src = mod_zoom1_img_over.src;
Modified: trunk/mapbender/http/php/mb_listWMCs.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mb_listWMCs.php?view=diff&rev=636&p1=trunk/mapbender/http/php/mb_listWMCs.php&p2=trunk/mapbender/http/php/mb_listWMCs.php&r1=635&r2=636
==============================================================================
--- trunk/mapbender/http/php/mb_listWMCs.php (original)
+++ trunk/mapbender/http/php/mb_listWMCs.php 2006-06-28 14:23:01+0000
@@ -131,38 +131,19 @@
$target = explode(",", $e_target);
$wmc = new wmc();
$wmc->createObjFromWMC($_GET["wmc_id"]);
- if ($_GET["action"] == "append") {
- $js = $wmc->createJsObjFromWMC("window.opener.", trim($target[1]));
- }
- elseif ($_GET["action"] == "merge") {
- $js = $wmc->mergeExistingJsObjWithWMC("window.opener.", trim($target[1]));
- }
- elseif ($_GET["action"] == "load") {
- $js = "var index = window.opener.getMapObjIndexByName('" . trim($target[1]) . "');\n";
- $js .= "while(window.opener.mb_mapObj[index].wms.length > 0){window.opener.mb_mapObjremoveWMS(index,0);}";
- $js .= "window.opener.deleteWmsObject();\n";
- $js .= $wmc->createJsObjFromWMC("window.opener.", trim($target[1]));
+ if ($_GET["action"] == "append" || $_GET["action"] == "merge" || $_GET["action"] == "load") {
+ $js = $wmc->createJsObjFromWMC("window.opener.", trim($target[1]), $_GET["action"]);
}
// display all JavaScript statements as debugging text
//echo $js;
echo "<script language='javascript'>";
if($cnt > 1){ echo "alert('addWMS: ID not unique!');\n";}
- echo "var mod_addWMS_data = '".$e_require."';\n";
- echo "var mod_addWMS_target1 = '".trim($target[0])."';\n";
- echo "var mod_addWMS_target2 = '".trim($target[1])."';\n";
echo $js;
- // adjust the size of the navFrame
- echo "window.opener.document.getElementById(mod_addWMS_target2).style.width = window.opener.mb_mapObj[ind].width;\n";
- echo "window.opener.document.getElementById(mod_addWMS_target2).style.height = window.opener.mb_mapObj[ind].height;\n";
- // execute functions that need to be run after a wms update
- echo "window.opener.mb_execloadWmsSubFunctions();\n";
- // alert: wmc has been loaded
+
$title = $wmc->getTitle();
if ($title) {$title = "'" . $title . "' ";}
echo "alert(\"WMC " . $title . ": " . $_GET["action"] . " successful.\");\n";
- // reload the map
- echo "window.opener.setMapRequest(mod_addWMS_target2);\n";
- // close the 'load wmc' window
+
echo "window.close();";
echo "</script>";
}
More information about the Mapbender_commits
mailing list