[Mapbender-commits] r2071 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Feb 8 07:49:07 EST 2008


Author: verenadiewald
Date: 2008-02-08 07:49:07 -0500 (Fri, 08 Feb 2008)
New Revision: 2071

Modified:
   trunk/mapbender/http/classes/class_gml2.php
Log:
properties of Feature as JSON instead of string

Modified: trunk/mapbender/http/classes/class_gml2.php
===================================================================
--- trunk/mapbender/http/classes/class_gml2.php	2008-02-07 12:47:49 UTC (rev 2070)
+++ trunk/mapbender/http/classes/class_gml2.php	2008-02-08 12:49:07 UTC (rev 2071)
@@ -18,6 +18,7 @@
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 require_once("class_mb_exception.php");
 require_once("class_connector.php");
+require_once("../extensions/JSON.php");
 require_once("../../conf/mapbender.conf");
 class gml2 {
 	var $geomtype_point = 'Point';					
@@ -48,13 +49,13 @@
 		$x = new connector($req);
 		$data = $x->file;
 		$data = $this->removeWhiteSpace($data);
-		$this->parseXML($data);		 		
+		$this->parseXML($data);		
+		#$e = new mb_exception("data = ".$data); 		
 	}
 	
 	function parseXML($data) {
 		
 		$this->doc = $data;
-		
 		return $this->toGeoJSON();
 	}
 
@@ -84,19 +85,24 @@
 		// segments of the featzreCollection
 		$gmlFeatureMembers = $gmlDoc->xpath("//gml:featureMember");
 		
-		$cnt=0;
-		foreach ($gmlFeatureMembers as $gmlFeatureMember) {
-			$featureMember_dom = dom_import_simplexml($gmlFeatureMember);
+		if(count($gmlFeatureMembers)>0){
+			$cnt=0;
+			foreach ($gmlFeatureMembers as $gmlFeatureMember) {
+				$featureMember_dom = dom_import_simplexml($gmlFeatureMember);
+				
+				$feature = new Feature();
+				$feature->parse($featureMember_dom);
+				if (isset($feature->geometry)) {
+					$featureCollection->addFeature($feature);
+				}
+				$cnt++;
+			}
 			
-			$feature = new Feature();
-			$feature->parse($featureMember_dom);
-			if (isset($feature->geometry)) {
-				$featureCollection->addFeature($feature);
-			}
-			$cnt++;
+			return $featureCollection->toGeoJSON();
 		}
-		
-		return $featureCollection->toGeoJSON();
+		else{
+			return "{'errorMessage':'Kein Ergebnis'}";
+		}
 	}
 
 	
@@ -484,18 +490,20 @@
 			$str .= "\"\"";
 		}
 
-		$str .= ", \"properties\": {";
+		
+		$prop = array();
+		
+		$str .= ", \"properties\": ";
 		$cnt = 0;
 		foreach ($this->properties as $key => $value) {
-			if ($cnt > 0) {
-				$str .= ",";
-			}
-			$str .= "\"" . $key . "\":\"" . $value . "\"";
-			$cnt ++;
+				$prop[$key] = $value;
+				$cnt ++;
 		}
-		$str .= "}";
 
+		$json = new Services_JSON();
+		$str .= $json->encode($prop); 
 		$str .= "}";
+		
 		return $str;
 	}
 }



More information about the Mapbender_commits mailing list