svn commit: r670 - trunk/mapbender/http/classes/class_wms.php
uli at osgeo.org
uli at osgeo.org
Wed Jul 19 11:23:29 EDT 2006
Author: uli
Date: 2006-07-19 15:23:29+0000
New Revision: 670
Modified:
trunk/mapbender/http/classes/class_wms.php
Log:
layer update modified
update layer_styles included
update layer_epsg included
new function updateLayer
Modified: trunk/mapbender/http/classes/class_wms.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_wms.php?view=diff&rev=670&p1=trunk/mapbender/http/classes/class_wms.php&p2=trunk/mapbender/http/classes/class_wms.php&r1=669&r2=670
==============================================================================
--- trunk/mapbender/http/classes/class_wms.php (original)
+++ trunk/mapbender/http/classes/class_wms.php 2006-07-19 15:23:29+0000
@@ -707,8 +707,60 @@
$this->insertLayerEPSG($i);
# TABLE layer_style for each layer
- $this->insertLayerStyle($i);
+ $this->insertLayerStyle($i);
+}
+function updateLayer($i,$myWMS){
+ $sql = "SELECT layer_id FROM layer WHERE fkey_wms_id = $1 AND layer_name = $2";
+ $v = array($myWMS,$this->objLayer[$i]->layer_name);
+ $t = array('i','s');
+ $res = db_prep_query($sql,$v,$t);
+ if($row = db_fetch_array($res)){
+ $l_id = $row['layer_id'];
+ }
+ else{
+ db_rollback();
+ $e = new mb_exception("Not found: ".$this->objLayer[$i]->layer_name);
+ return;
+ }
+ $sql = "UPDATE layer SET ";
+ $sql .= "layer_pos = $1, ";
+ $sql .= "layer_parent = $2, ";
+ $sql .= "layer_title = $3, ";
+ $sql .= "layer_queryable = $4, ";
+ $sql .= "layer_minscale = $5, ";
+ $sql .= "layer_maxscale = $6, ";
+ $sql .= "layer_dataurl = $7, ";
+ $sql .= "layer_metadataurl = $8 ";
+ $sql .= "WHERE layer_id = $9";
+
+ if($this->objLayer[$i]->layer_id != null){
+ $tmpPos = $this->objLayer[$i]->layer_id;
+ }
+ else {
+ $tmpPos .= 0;
+ }
+ if($this->objLayer[$i]->layer_parent == '' && $this->objLayer[$i]->layer_parent != '0'){
+ $this->objLayer[$i]->layer_parent = '';
+ }
+ $v = array($tmpPos,$this->objLayer[$i]->layer_parent,
+ $this->objLayer[$i]->layer_title,
+ $this->objLayer[$i]->layer_queryable,$this->objLayer[$i]->layer_minscale,
+ $this->objLayer[$i]->layer_maxscale,$this->objLayer[$i]->layer_dataurl_href,
+ $this->objLayer[$i]->layer_metadataurl, $l_id
+ );
+ $t = array('i','s','s','i','i','i','s','s','i');
+ $res = db_prep_query($sql,$v,$t);
+ if(!$res){
+ db_rollback();
+ }
+
+ # save the id of each layer: set param2 true
+ $this->objLayer[$i]->db_id = $l_id;
+ $this->insertLayerEPSG($i);
+
+ # TABLE layer_style for each layer
+ $this->insertLayerStyle($i);
}
function insertGuiLayer($i,$myWMS,$gui_id){
# table gui_layer
@@ -764,6 +816,9 @@
}
}
function insertLayerEPSG($i){
+ $sql = "DELETE FROM layer_epsg WHERE fkey_layer_id = $1";
+ $v = array($this->objLayer[$i]->db_id);
+ $t = array('s');
for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
$sql = "INSERT INTO layer_epsg (fkey_layer_id, epsg, minx, miny, maxx, maxy) ";
$sql .= "VALUES($1,$2,$3,$4,$5,$6)";
@@ -779,6 +834,10 @@
}
}
function insertLayerStyle($i){
+ $sql = "DELETE FROM layer_style WHERE fkey_layer_id = $1";
+ $v = array($this->objLayer[$i]->db_id);
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
for($j=0; $j<count($this->objLayer[$i]->layer_style);$j++){
$sql = "INSERT INTO layer_style (fkey_layer_id, name, title, legendurl, legendurlformat) ";
$sql .= "VALUES($1,$2,$3,$4,$5)";
@@ -882,6 +941,7 @@
for($i=0; $i<count($this->objLayer); $i++){
if(in_array($this->objLayer[$i]->layer_name,$exLayer)){
//echo "<br>update: ".$this->objLayer[$i]->layer_name;
+ $this->updateLayer($i,$myWMS);
for($j=0; $j<count($exGui); $j++){
$this->updateGuiLayer($i,$myWMS,$exGui[$j]);
}
@@ -924,6 +984,14 @@
$res1 = db_prep_query($sql1,$v,$t);
if(!$res1){db_rollback();}
}
+ if($this->objLayer[$i]->layer_queryable == 1){
+ $sql1 = "UPDATE gui_layer set gui_layer_queryable = 1 ";
+ $sql1 .= "WHERE fkey_layer_id = $1 and fkey_gui_id = $2";
+ $v = array($l_id,$gui_id);
+ $t = array('i','s');
+ $res1 = db_prep_query($sql1,$v,$t);
+ if(!$res1){db_rollback();}
+ }
if($row["gui_layer_minscale"] < $this->objLayer[$i]->layer_minscale){
$sql1 = "UPDATE gui_layer set gui_layer_minscale = $1 ";
$sql1 .= "WHERE fkey_layer_id = $2 and fkey_gui_id = $3";
More information about the Mapbender_commits
mailing list