svn commit: r895 - trunk/mapbender/http/classes/class_wmc.php

christoph at osgeo.org christoph at osgeo.org
Tue Nov 21 03:11:07 EST 2006


Author: christoph
Date: 2006-11-21 08:11:07+0000
New Revision: 895

Modified:
   trunk/mapbender/http/classes/class_wmc.php

Log:
* added utf8_encode/decode functions
* removed verbose statements
* replaced alert by mb_exception
* added scalehints (TODO: change to "Extensions")
* now loading correct data format

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=895&p1=trunk/mapbender/http/classes/class_wmc.php&p2=trunk/mapbender/http/classes/class_wmc.php&r1=894&r2=895
==============================================================================
--- trunk/mapbender/http/classes/class_wmc.php	(original)
+++ trunk/mapbender/http/classes/class_wmc.php	2006-11-21 08:11:07+0000
@@ -1,5 +1,5 @@
 <?php
-# $Id: class_wmc.php,v 1.31 2006/03/16 14:49:30 c_baudson Exp $
+# $Id: class_wmc.php 505 2006-11-20 10:53:10Z christoph $
 # http://www.mapbender.org/index.php/class_wmc.php
 # Copyright (C) 2002 CCGIS 
 #
@@ -18,7 +18,15 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 require_once("../../conf/mapbender.conf");
 require_once("../classes/class_wms.php");
-
+require_once("../classes/class_mb_exception.php");
+function mb_utf8_encode ($str) {
+	if(CHARSET=="UTF-8") return utf8_encode($str);
+	return $str;
+}
+function mb_utf8_decode ($str) {
+	if(CHARSET=="UTF-8") return utf8_decode($str);
+	return $str;
+}
 class wmc {
 
 		var $wmc_id;
@@ -68,6 +76,8 @@
 		var $wmc_layer_format_current = array();
 		var $wmc_layer_dataurl = array();
 		var $wmc_layer_metadataurl = array();
+		var $wmc_layer_minscale = array();
+		var $wmc_layer_maxscale = array();
 		var $wmc_layer_format = array();
 		var $wmc_layer_style_current = array();
 		var $wmc_layer_style_name = array();
@@ -131,7 +141,8 @@
 	xml_parse_into_struct($parser,$data,$values,$tags);
 	$code = xml_get_error_code ($parser);
 	if ($code) {
-		echo "alert('Error " . $code . " (" . xml_error_string($code) .  ")');\n";
+		$line = xml_get_current_line_number($parser); 
+		$mb_exception = new mb_exception(xml_error_string($code) .  " in line " . $line);
 		return false;
 	}
 	xml_parser_free($parser);
@@ -151,243 +162,177 @@
 	$layer = false;
 	
 	foreach ($values as $element) {
-					$verbose .= ".";
 		if(strtoupper($element[tag]) == "VIEWCONTEXT" && $element[type] == "open"){
-				$this->wmc_id = $element[attributes]["id"];
-				$this->wmc_version = $element[attributes]["version"];
-				$verbose .= "Viewcontext begin<br>\n";
-				$verbose .= $this->wmc_id . "<br>\n";
-				$verbose .= $this->wmc_version . "<br>\n";
-		}
-		if(strtoupper($element[tag]) == "VIEWCONTEXT" && $element[type] == "close"){
-				$verbose .= "Viewcontext end<br>\n";
+			$this->wmc_id = $element[attributes]["id"];
+			$this->wmc_version = $element[attributes]["version"];
 		}
 		if(strtoupper($element[tag]) == "GENERAL" && $element[type] == "open"){
 		   $general = true;
-			 $verbose .= "General begin<br>\n";
 		}
 		if(strtoupper($element[tag]) == "LAYERLIST" && $element[type] == "open"){
 		   $layerlist = true;
-			 $verbose .= "LayerList begin<br>\n";
 		}
-
 		if ($general) {
-				if(strtoupper($element[tag]) == "WINDOW"){
-						$this->wmc_windowWidth = $element[attributes]["width"];
-						$this->wmc_windowHeight = $element[attributes]["height"];
-						$verbose .= $this->wmc_windowHeight . "<br>\n";
-						$verbose .= $this->wmc_windowWidth . "<br>\n";
-				}
-				if(strtoupper($element[tag]) == "BOUNDINGBOX"){
-						$this->wmc_bBox_SRS = $element[attributes]["SRS"];
-						$verbose .= $this->wmc_bBox_SRS . "<br>\n"; 
-						$this->wmc_bBox_minx = $element[attributes]["minx"];
-						$verbose .= $this->wmc_bBox_minx . "<br>\n"; 
-						$this->wmc_bBox_miny = $element[attributes]["miny"];
-						$verbose .= $this->wmc_bBox_miny . "<br>\n"; 
-						$this->wmc_bBox_maxx = $element[attributes]["maxx"];
-						$verbose .= $this->wmc_bBox_maxx . "<br>\n"; 
-						$this->wmc_bBox_maxy = $element[attributes]["maxy"];
-						$verbose .= $this->wmc_bBox_maxy . "<br>\n"; 
-				}
-				if(strtoupper($element[tag]) == "NAME"){
-						$this->wmc_name = $element[value];
-						$verbose .= $this->wmc_name . "<br>\n"; 
-				}
-				if(strtoupper($element[tag]) == "TITLE"){
-						$this->wmc_title = $element[value];
-						$verbose .= $this->wmc_title . "<br>\n"; 
-				}
-				if(strtoupper($element[tag]) == "ABSTRACT"){
-						$this->wmc_abstract = $element[value];
-						$verbose .= $this->wmc_abstract . "<br>\n"; 
-				}
-				if(strtoupper($element[tag]) == "CONTACTINFORMATION" && $element['type'] == "open"){
-						$contactinformation = true;
-						$verbose .= "Contactinformation begin<br>\n"; 
-				}
-				if ($contactinformation) {
-					if(strtoupper($element[tag]) == "CONTACTPOSITION"){
-							$this->wmc_contactposition = $element[value];
-							$verbose .= $this->wmc_contactposition . "<br>\n"; 
-					}
-					if(strtoupper($element[tag]) == "CONTACTVOICETELEPHONE"){
-							$this->wmc_contactvoicetelephone = $element[value];
-							$verbose .= $this->wmc_contactvoicetelephone . "<br>\n"; 
-					}
-					if(strtoupper($element[tag]) == "CONTACTFACSIMILETELEPHONE"){
-							$this->wmc_contactfacsimiletelephone = $element[value];
-							$verbose .= $this->wmc_contactfacsimiletelephone . "<br>\n"; 
-					}
-					if(strtoupper($element[tag]) == "CONTACTELECTRONICMAILADDRESS"){
-							$this->wmc_contactemail = $element[value];
-							$verbose .= $this->wmc_contactemail . "<br>\n"; 
-					}
-					if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "open"){
-							$contactpersonprimary = true;
-							$verbose .= "Contactpersonprimary begin<br>\n"; 
-					}
-					if ($contactpersonprimary) {
-						if(strtoupper($element[tag]) == "CONTACTPERSON"){
-								$this->wmc_contactperson = $element[value];
-								$verbose .= $this->wmc_contactperson . "<br>\n"; 
-						}
-						if(strtoupper($element[tag]) == "CONTACTORGANIZATION"){
-								$this->wmc_contactorganization = $element[value];
-								$verbose .= $this->wmc_contactorganization . "<br>\n"; 
-						}
-						if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "close"){
-								$contactpersonprimary = false;
-								$verbose .= "Contactpersonprimary end<br>\n"; 
-						}
+			if(strtoupper($element[tag]) == "WINDOW"){
+				$this->wmc_windowWidth = $element[attributes]["width"];
+				$this->wmc_windowHeight = $element[attributes]["height"];
+			}
+			if(strtoupper($element[tag]) == "BOUNDINGBOX"){
+				$this->wmc_bBox_SRS = $element[attributes]["SRS"];
+				$this->wmc_bBox_minx = $element[attributes]["minx"];
+				$this->wmc_bBox_miny = $element[attributes]["miny"];
+				$this->wmc_bBox_maxx = $element[attributes]["maxx"];
+				$this->wmc_bBox_maxy = $element[attributes]["maxy"];
+			}
+			if(strtoupper($element[tag]) == "NAME"){
+				$this->wmc_name = mb_utf8_decode($element[value]);
+			}
+			if(strtoupper($element[tag]) == "TITLE"){
+				$this->wmc_title = mb_utf8_decode($element[value]);
+			}
+			if(strtoupper($element[tag]) == "ABSTRACT"){
+				$this->wmc_abstract = mb_utf8_decode($element[value]);
+			}
+			if(strtoupper($element[tag]) == "CONTACTINFORMATION" && $element['type'] == "open"){
+				$contactinformation = true;
+			}
+			if ($contactinformation) {
+				if(strtoupper($element[tag]) == "CONTACTPOSITION"){
+					$this->wmc_contactposition = mb_utf8_decode($element[value]);
+				}
+				if(strtoupper($element[tag]) == "CONTACTVOICETELEPHONE"){
+					$this->wmc_contactvoicetelephone = $element[value];
+				}
+				if(strtoupper($element[tag]) == "CONTACTFACSIMILETELEPHONE"){
+					$this->wmc_contactfacsimiletelephone = $element[value];
+				}
+				if(strtoupper($element[tag]) == "CONTACTELECTRONICMAILADDRESS"){
+					$this->wmc_contactemail = mb_utf8_decode($element[value]);
+				}
+				if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "open"){
+					$contactpersonprimary = true;
+				}
+				if ($contactpersonprimary) {
+					if(strtoupper($element[tag]) == "CONTACTPERSON"){
+						$this->wmc_contactperson = mb_utf8_decode($element[value]);
 					}
-					if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "open"){
-							$contactaddress = true;
-							$verbose .= "Contactaddress begin<br>\n"; 
-					}
-					if ($contactaddress) {
-						if(strtoupper($element[tag]) == "ADDRESSTYPE"){
-								$this->wmc_contactaddresstype = $element[value];
-								$verbose .= $this->wmc_contactaddresstype . "<br>\n"; 
-						}
-						if(strtoupper($element[tag]) == "ADDRESS"){
-								$this->wmc_contactaddress = $element[value];
-								$verbose .= $this->wmc_contactaddress . "<br>\n"; 
-						}
-						if(strtoupper($element[tag]) == "CITY"){
-								$this->wmc_contactcity = $element[value];
-								$verbose .= $this->wmc_contactcity . "<br>\n"; 
-						}
-						if(strtoupper($element[tag]) == "STATEORPROVINCE"){
-								$this->wmc_contactstateorprovince = $element[value];
-								$verbose .= $this->wmc_contactstateorprovince . "<br>\n"; 
-						}
-						if(strtoupper($element[tag]) == "POSTCODE"){
-								$this->wmc_contactpostcode = $element[value];
-								$verbose .= $this->wmc_contactpostcode . "<br>\n"; 
-						}
-						if(strtoupper($element[tag]) == "COUNTRY"){
-								$this->wmc_contactcountry = $element[value];
-								$verbose .= $this->wmc_contactcountry . "<br>\n"; 
-						}
-						if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "close"){
-								$contactaddress = false;
-								$verbose .= "Contactaddress end<br>\n"; 
-						}
+					if(strtoupper($element[tag]) == "CONTACTORGANIZATION"){
+						$this->wmc_contactorganization = mb_utf8_decode($element[value]);
 					}
+					if(strtoupper($element[tag]) == "CONTACTPERSONPRIMARY" && $element['type'] == "close"){
+						$contactpersonprimary = false;
+					}
+				}
+				if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "open"){
+					$contactaddress = true;
+				}
+				if ($contactaddress) {
+					if(strtoupper($element[tag]) == "ADDRESSTYPE"){
+						$this->wmc_contactaddresstype = mb_utf8_decode($element[value]);
+					}
+					if(strtoupper($element[tag]) == "ADDRESS"){
+						$this->wmc_contactaddress = mb_utf8_decode($element[value]);
+					}
+					if(strtoupper($element[tag]) == "CITY"){
+						$this->wmc_contactcity = mb_utf8_decode($element[value]);
+					}
+					if(strtoupper($element[tag]) == "STATEORPROVINCE"){
+						$this->wmc_contactstateorprovince = mb_utf8_decode($element[value]);
+					}
+					if(strtoupper($element[tag]) == "POSTCODE"){
+						$this->wmc_contactpostcode = $element[value];
+					}
+					if(strtoupper($element[tag]) == "COUNTRY"){
+						$this->wmc_contactcountry = mb_utf8_decode($element[value]);
+					}
+					if(strtoupper($element[tag]) == "CONTACTADDRESS" && $element['type'] == "close"){
+						$contactaddress = false;
+					}
+				}
+			}
+			if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "open"){
+				$logourl = true;
+				$this->wmc_logourl_width = $element[attributes]["width"];
+				$this->wmc_logourl_height = $element[attributes]["height"];
+				$this->wmc_logourl_format = $element[attributes]["format"];
+			}
+			if ($logourl) {
+				if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "close"){
+					$logourl = false;
+				}
+				if(strtoupper($element[tag]) == "ONLINERESOURCE"){
+					$this->wmc_logourl_type = $element[attributes]["xlink:type"];
+					$this->wmc_logourl = $element[attributes]["xlink:href"];
 				}
-				if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "open"){
-						$logourl = true;
-						$verbose .= "Logourl begin<br>\n"; 
-						$this->wmc_logourl_width = $element[attributes]["width"];
-						$verbose .= $this->wmc_logourl_width . "<br>\n";
-						$this->wmc_logourl_height = $element[attributes]["height"];
-						$verbose .= $this->wmc_logourl_height ."<br>\n";
-						$this->wmc_logourl_format = $element[attributes]["format"];
-						$verbose .= $this->wmc_logourl_format . "<br>\n";
-				}
-				if ($logourl) {
-					if(strtoupper($element[tag]) == "LOGOURL" && $element['type'] == "close"){
-							$logourl = false;
-							$verbose .= "Logourl end<br>\n";
-					}
-					if(strtoupper($element[tag]) == "ONLINERESOURCE"){
-						$this->wmc_logourl_type = $element[attributes]["xlink:type"];
-						$verbose .= $this->wmc_logourl_type . "<br>\n"; 
-						$this->wmc_logourl = $element[attributes]["xlink:href"];
-						$verbose .= $this->wmc_logourl . "<br>\n"; 
-					}
-				}
-				if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "open"){
-						$descriptionurl = true;
-						$verbose .= "Descriptionurl begin<br>\n"; 
-						$this->wmc_descriptionurl_format = $element[attributes]["format"];
-						$verbose .= $this->wmc_descriptionurl_format . "<br>\n";
-				}
-				if ($descriptionurl) {
-					if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "close"){
-							$descriptionurl = false;
-							$verbose .= "Descriptionurl end<br>\n"; 
-					}
-					if(strtoupper($element[tag]) == "ONLINERESOURCE"){
-						$this->wmc_descriptionurl_type = $element[attributes]["xlink:type"];
-						$verbose .= $this->wmc_descriptionurl_type . "<br>\n"; 
-						$this->wmc_descriptionurl = $element[attributes]["xlink:href"];
-						$verbose .= $this->wmc_descriptionurl . "<br>\n"; 
-					}
-				}
-				if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "open"){
-						$keywordlist = true;
-						$verbose .= "Keywordlist begin<br>\n"; 
-				}
-				if ($keywordlist) {
-					if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "close"){
-							$keywordlist = false;
-							$cnt_keyword = -1;
-							$verbose .= "Keywordlist end<br>\n"; 
-					}
-					if(strtoupper($element[tag]) == "KEYWORD"){
-						$cnt_keyword++;
-						$this->wmc_keyword[$cnt_keyword] = $element[value];
-						$verbose .= $this->wmc_keyword[$cnt_keyword] . "<br>\n"; 
-					}
-				}
-						
-				if(strtoupper($element[tag]) == "GENERAL" && $element['type'] == "close"){
-		   			$general = false;
-						$verbose .= "General end<br>\n";
-			 	}
+			}
+			if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "open"){
+				$descriptionurl = true;
+				$this->wmc_descriptionurl_format = $element[attributes]["format"];
+			}
+			if ($descriptionurl) {
+				if(strtoupper($element[tag]) == "DESCRIPTIONURL" && $element['type'] == "close"){
+					$descriptionurl = false;
+				}
+				if(strtoupper($element[tag]) == "ONLINERESOURCE"){
+					$this->wmc_descriptionurl_type = $element[attributes]["xlink:type"];
+					$this->wmc_descriptionurl = $element[attributes]["xlink:href"];
+				}
+			}
+			if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "open"){
+				$keywordlist = true;
+			}
+			if ($keywordlist) {
+				if(strtoupper($element[tag]) == "KEYWORDLIST" && $element['type'] == "close"){
+					$keywordlist = false;
+					$cnt_keyword = -1;
+				}
+				if(strtoupper($element[tag]) == "KEYWORD"){
+					$cnt_keyword++;
+					$this->wmc_keyword[$cnt_keyword] = mb_utf8_decode($element[value]);
+				}
+			}
+			if(strtoupper($element[tag]) == "GENERAL" && $element['type'] == "close"){
+	   			$general = false;
+		 	}
 		}
 		if ($layerlist) {
 				if(strtoupper($element[tag]) == "LAYERLIST" && $element['type'] == "close"){
 				   $layerlist = false;
-   			   $verbose .= "LayerList end<br>\n";
 				}
 				if(strtoupper($element[tag]) == "LAYER" && $element[type] == "open"){
 					 $cnt_layer++;
 					 $this->wmc_layer_queryable[$cnt_layer] = $element[attributes]["queryable"];
 					 $this->wmc_layer_hidden[$cnt_layer] = $element[attributes]["hidden"];
 					 $layer = true;
-					 $verbose .= "Layer begin<br>\n";
-					 $verbose .= $this->wmc_layer_queryable[$cnt_layer] . "<br>\n";
-					 $verbose .= $this->wmc_layer_hidden[$cnt_layer] . "<br>\n";
       		 		 $cnt_epsg = 0;
 				}
 				if ($layer) {
 					 if(strtoupper($element[tag]) == "LAYER" && $element[type] == "close"){
-					 		$layer = false;
-					 		$verbose .= "Layer end<br>\n";
+				 		$layer = false;
 					 }
 					 if ($formatlist) {
 						 if(strtoupper($element[tag]) == "FORMAT"){
 						 	$cnt_format++;
 						 	$this->wmc_layer_format_current[$cnt_layer][$cnt_format] = $element[attributes]["current"];
-							$verbose .= $this->wmc_layer_format_current[$cnt_layer][$cnt_format] . "<br>\n";
 						 	$this->wmc_layer_format[$cnt_layer][$cnt_format] = $element[value];
-							$verbose .= $this->wmc_layer_format[$cnt_layer][$cnt_format] . "<br>\n";
 						 }
 						 if(strtoupper($element[tag]) == "FORMATLIST" && $element[type] == "close"){
-							 $verbose .= "Formatlist end<br>\n";
 							 $formatlist = false;
 						 }
 					 }
 					 elseif ($metadataurl) {
 						 if(strtoupper($element[tag]) == "ONLINERESOURCE"){
 						 	$this->wmc_layer_metadataurl[$cnt_layer] = $element[attributes]["xlink:href"];
-							$verbose .= $this->wmc_layer_metadataurl[$cnt_layer] . "<br>\n";
 						 }
 						 if(strtoupper($element[tag]) == "METADATAURL" && $element[type] == "close"){
-							 $verbose .= "Metadataurl end<br>\n";
 							 $metadataurl = false;
 						 }
 					 }
 					 elseif ($dataurl) {
 						 if(strtoupper($element[tag]) == "ONLINERESOURCE"){
 						 	$this->wmc_layer_dataurl[$cnt_layer] = $element[attributes]["xlink:href"];
-							$verbose .= $this->wmc_layer_dataurl[$cnt_layer] . "<br>\n";
 						 }
 						 if(strtoupper($element[tag]) == "DATAURL" && $element[type] == "close"){
-							 $verbose .= "Dataurl end<br>\n";
 							 $dataurl = false;
 						 }
 					 }
@@ -396,70 +341,52 @@
 						 	$cnt_style++;
 						 	$style = true;
 						 	$this->wmc_layer_style_current[$cnt_layer][$cnt_style] = $element[attributes]["current"];
-								$verbose .= "Style begin<br>\n";
-							$verbose .= $this->wmc_layer_style_current[$cnt_layer][$cnt_style] . "<br>\n";
 						 }
 						 if ($style) {
 							 if(strtoupper($element[tag]) == "STYLE" && $element[type] == "close"){
 							 	$style = false;
-								$verbose .= "Style end<br>\n";
 							 }
 							 if(strtoupper($element[tag]) == "SLD" && $element[type] == "open"){
 							 	$sld = true;
-								$verbose .= "sld begin<br>\n";
 							 }
 							 if ($sld) {
 								 if(strtoupper($element[tag]) == "SLD" && $element[type] == "close"){
-								 	$verbose .= "sld end<br>\n";
 								 	$sld = false;
 								 }
 								 if(strtoupper($element[tag]) == "ONLINERESOURCE"){
 								 	$this->wmc_layer_style_sld_type[$cnt_layer][$cnt_style] = $element[attributes]["xlink:type"];
-									$verbose .= $this->wmc_layer_style_sld_type[$cnt_layer][$cnt_style] . "<br>\n";
 								 	$this->wmc_layer_style_sld_url[$cnt_layer][$cnt_style] = $element[attributes]["xlink:href"];
-									$verbose .= $this->wmc_layer_style_sld_url[$cnt_layer][$cnt_style] . "<br>\n";
 								 }
 								 if(strtoupper($element[tag]) == "TITLE"){
-								 	$this->wmc_layer_style_sld_title[$cnt_layer][$cnt_style] = $element[value];
-									$verbose .= $this->wmc_layer_style_sld_title[$cnt_layer][$cnt_style] . "<br>\n";
+								 	$this->wmc_layer_style_sld_title[$cnt_layer][$cnt_style] = mb_utf8_decode($element[value]);
 								 }
 							 }
 							 else {
 								 if(strtoupper($element[tag]) == "NAME"){
-								 	$this->wmc_layer_style_name[$cnt_layer][$cnt_style] = $element[value];
-									$verbose .= $this->wmc_layer_style_name[$cnt_layer][$cnt_style] . "<br>\n";
+								 	$this->wmc_layer_style_name[$cnt_layer][$cnt_style] = mb_utf8_decode($element[value]);
 								 }
 								 if(strtoupper($element[tag]) == "TITLE"){
 								 	$this->wmc_layer_style_title[$cnt_layer][$cnt_style] = $element[value];
-									$verbose .= $this->wmc_layer_style_title[$cnt_layer][$cnt_style] . "<br>\n";
 								 }
 								 if(strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "open"){
-									 	$verbose .= "legendurl begin<br>\n";
 								 	$legendurl = true;
 								 	$this->wmc_layer_style_legendurl_width[$cnt_layer][$cnt_style] = $element[attributes]["width"];
-									$verbose .= $this->wmc_layer_style_legendurl_width[$cnt_layer][$cnt_style] . "<br>\n";
 								 	$this->wmc_layer_style_legendurl_height[$cnt_layer][$cnt_style] = $element[attributes]["height"];
-									$verbose .= $this->wmc_layer_style_legendurl_height[$cnt_layer][$cnt_style] . "<br>\n";
 								 	$this->wmc_layer_style_legendurl_format[$cnt_layer][$cnt_style] = $element[attributes]["format"];
-									$verbose .= $this->wmc_layer_style_legendurl_format[$cnt_layer][$cnt_style] . "<br>\n";
 								 }
 								 if ($legendurl) {
 									 if(strtoupper($element[tag]) == "LEGENDURL" && $element[type] == "close"){
-									 	$verbose .= "legendurl end<br>\n";
 									 	$legendurl = false;
 									 }
 									 if(strtoupper($element[tag]) == "ONLINERESOURCE"){
 									 	$this->wmc_layer_style_legendurl_type[$cnt_layer][$cnt_style] = $element[attributes]["xlink:type"];
-										$verbose .= $this->wmc_layer_style_legendurl_type[$cnt_layer][$cnt_style] . "<br>\n";
 									 	$this->wmc_layer_style_legendurl[$cnt_layer][$cnt_style] = $element[attributes]["xlink:href"];
-										$verbose .= $this->wmc_layer_style_legendurl[$cnt_layer][$cnt_style] . "<br>\n";
 									 }
 								 }
 							 }
 						 }
 						 if(strtoupper($element[tag]) == "STYLELIST" && $element[type] == "close"){
 							 $stylelist = false;
-							 $verbose .= "Stylelist end<br>\n";
 						 }
 					 }
 					 else {
@@ -467,68 +394,56 @@
 						 	 $server = true;
 						 	 $this->wmc_wms_service[$cnt_layer] = $element[attributes]["service"];
 						 	 $this->wmc_wms_version[$cnt_layer] = $element[attributes]["version"];
-						 	 $this->wmc_wms_title[$cnt_layer] = $element[attributes]["title"];
-						 	 $verbose .= "Server begin<br>\n";
-							 $verbose .= $this->wmc_wms_service[$cnt_layer] . "<br>\n";
-							 $verbose .= $this->wmc_wms_version[$cnt_layer] . "<br>\n";
-							 $verbose .= $this->wmc_layer_title[$cnt_layer] . "<br>\n";
+						 	 $this->wmc_wms_title[$cnt_layer] = mb_utf8_decode($element[attributes]["title"]);
 						 }
 						 if ($server) {
 							 if(strtoupper($element[tag]) == "SERVER" && $element[type] == "close"){
-							 	 $verbose .= "Server end<br>\n";
 							 	 $server = false;
 							 }
 							 if(strtoupper($element[tag]) == "ONLINERESOURCE"){
-							 		 $this->wmc_wms_serviceURL[$cnt_layer] = $element[attributes]["xlink:href"];
-									 $verbose .= $this->wmc_wms_serviceURL[$cnt_layer] . "<br>\n";
+						 		 $this->wmc_wms_serviceURL[$cnt_layer] = $element[attributes]["xlink:href"];
 							 }
 						 }
 						 if(strtoupper($element[tag]) == "NAME"){
-						 		 $this->wmc_layer_name[$cnt_layer] = $element[value];
-								 $verbose .= $this->wmc_layer_name[$cnt_layer] . "<br>\n";
+					 		 $this->wmc_layer_name[$cnt_layer] = mb_utf8_decode($element[value]);
 						 }
 						 if(strtoupper($element[tag]) == "TITLE"){
-						 		 $this->wmc_layer_title[$cnt_layer] = $element[value];
-								 $verbose .= $this->wmc_layer_title[$cnt_layer] . "<br>\n";
+					 		 $this->wmc_layer_title[$cnt_layer] = mb_utf8_decode($element[value]);
 						 }
 						 if(strtoupper($element[tag]) == "ABSTRACT"){
-						 		 $this->wmc_layer_abstract[$cnt_layer] = $element[value];
-								 $verbose .= $this->wmc_layer_abstract[$cnt_layer] . "<br>\n";
+					 		 $this->wmc_layer_abstract[$cnt_layer] = mb_utf8_decode($element[value]);
 						 }
 						 if(strtoupper($element[tag]) == "SRS"){
-								 $epsgArray = explode(" ", $element[value]);						 	
-						 		 
-						 		 for ($c = 0 ; $c < count($epsgArray) ; $c ++) {
-							 		 $this->wmc_layer_srs[$cnt_layer][$cnt_epsg] = $epsgArray[$c];
-									 $verbose .= $this->wmc_layer_srs[$cnt_layer][$cnt_epsg] . "<br>\n";
-									 $cnt_epsg++;
-						 		 }
+							 $epsgArray = explode(" ", $element[value]);						 	
+					 		 
+					 		 for ($c = 0 ; $c < count($epsgArray) ; $c ++) {
+						 		 $this->wmc_layer_srs[$cnt_layer][$cnt_epsg] = $epsgArray[$c];
+								 $cnt_epsg++;
+					 		 }
+						 }
+						 if(strtoupper($element[tag]) == "SCALEHINT"){
+					 		 $this->wmc_layer_minscale[$cnt_layer] = $element[attributes]["min"];
+					 		 $this->wmc_layer_maxscale[$cnt_layer] = $element[attributes]["max"];
 						 }
 						 if(strtoupper($element[tag]) == "METADATAURL" && $element[type] == "open"){
-								 $verbose .= "Metadataurl begin<br>\n";
 							 $metadataurl = true;
 						 }
 						 if(strtoupper($element[tag]) == "DATAURL" && $element[type] == "open"){
-								 $verbose .= "Dataurl begin<br>\n";
 							 $dataurl = true;
 						 }
 						 if(strtoupper($element[tag]) == "FORMATLIST" && $element[type] == "open"){
-								 $verbose .= "Formatlist begin<br>\n";
 							 $formatlist = true;
 							 $cnt_format = -1;
 						 }
 						 if(strtoupper($element[tag]) == "STYLELIST" && $element[type] == "open"){
-							$verbose .= "Stylelist begin<br>\n";
 							 $stylelist = true;
 							 $cnt_style = -1;
 						 }
-	
 					 }
 				}
 			}
 		}
 		return true;
-	  //return $verbose;
 	}
 
 	function createJsObjFromWMC($target, $mapObj, $action){
@@ -581,7 +496,12 @@
 						echo "alert('Error: no valid capabilities-document !!');\n";
 						die; exit;
 					}
-		
+
+					for($j=0;$j<count($this->wmc_layer_format[$i]);$j++){
+						if ($this->wmc_layer_format_current[$i][$j] == 1) {
+							$wms_data_format = $this->wmc_layer_format[$i][$j];
+						}
+					}
 					// add wms
 					$wmc_string .= "\t" . $target . "add_wms('','".
 						$this->wmc_wms_version[$i] ."','".
@@ -590,7 +510,7 @@
 						$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','". 
+						$wms_data_format ."','text/html','application/vnd.ogc.se_xml','". 
 						$this->wmc_bBox_SRS ."','1');\n";
 		
 					$added_wms[count($added_wms)] = $current_wms;
@@ -665,17 +585,19 @@
 							// add layer
 							$wmc_string .= "\t" . $target . "wms_add_layer('0','". 
 								$this->wmc_layer_name[$ii] . "','". 
-								$this->wmc_layer_title[$ii]  ."','". 
-								$this->wmc_layer_dataurl[$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]
-								."','". 
+								$this->wmc_layer_queryable[$ii] ."','".
+								$this->wmc_layer_minscale[$ii]  ."','". 
+								$this->wmc_layer_maxscale[$ii]  ."','". 
+								$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";
+								$this->wmc_layer_queryable[$ii] ."','".
+								$this->wmc_layer_minscale[$ii]  ."','". 
+								$this->wmc_layer_maxscale[$ii]  ."');\n";
 	
 							if ($action == "merge") {
 								$wmc_string .= "\t}\n";




More information about the Mapbender_commits mailing list