svn commit: r352 - trunk/mapbender/http/php/mod_wfs_result.php

christoph at osgeo.org christoph at osgeo.org
Mon May 29 06:26:29 EDT 2006


Author: christoph
Date: 2006-05-29 10:26:29+0000
New Revision: 352

Modified:
   trunk/mapbender/http/php/mod_wfs_result.php

Log:
now uses mod_geometryArray.js

Modified: trunk/mapbender/http/php/mod_wfs_result.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/php/mod_wfs_result.php?view=diff&rev=352&p1=trunk/mapbender/http/php/mod_wfs_result.php&p2=trunk/mapbender/http/php/mod_wfs_result.php&r1=351&r2=352
==============================================================================
--- trunk/mapbender/http/php/mod_wfs_result.php	(original)
+++ trunk/mapbender/http/php/mod_wfs_result.php	2006-05-29 10:26:29+0000
@@ -44,8 +44,6 @@
 	xml_parse_into_struct($parser,$data,$values,$tags);
 	xml_parser_free($parser);
 	$member = -1;
-	
-	
 	$section = false;
 	$geom = false;
 	$str = array();
@@ -54,36 +52,49 @@
 	echo "<html><head>\n";
 	echo "<meta http-equiv='Content-Type' content='text/html; charset=".CHARSET."'>\n";
 	echo "<script language='JavaScript' type='text/javascript'>\n<!--\n";
-	echo "var member = new Array();\n";
+
+	require_once("../javascripts/mod_geometryArray.js");
+
+	$element_str = "";
+	$geom_str = "";
+	$geom_str .= "var geom = new GeometryArray();\n";
+
 	foreach ($values as $element) {
 		if(strtoupper($element[tag]) == strtoupper("gml:featureMember") && $element[type] == "open"){
 			$member++;
-			echo "member[".$member."] = new Array();\n";
-			echo "member[".$member."]['geometry'] = new Array();\n";
-			echo "member[".$member."]['element'] = new Array();\n";
 			$section = true;
 			$cnt_geom = 0;
 		}
 		else if(in_array(sepNameSpace($element[tag]),$geometries) && $element[type] == "open" && $section == true){
 			$geom = true;
-			// edited by CB: only Line, Polygon and Point are allowed as geomtype
-			if (sepNameSpace($element[tag]) == "LineString" || sepNameSpace($element[tag]) == "MultiLineString" ) {
-				echo "member[".$member."]['geomtype'] = 'Line';\n";
+			if (sepNameSpace($element[tag]) == "MultiLineString") {
+				$geom_str .= "geom.addMember(geomTypeLine);\n";
+			}
+			else if (sepNameSpace($element[tag]) == "MultiPolygon" ) {
+				$geom_str .= "geom.addMember(geomTypePolygon);\n";
+			}
+			elseif (sepNameSpace($element[tag]) == "Point") {
+				$geom_str .= "geom.addMember(geomTypePoint);\n";
+				$geom_str .= "geom.get(-1).addGeometry();\n";
 			}
-			else if (sepNameSpace($element[tag]) == "Point" || sepNameSpace($element[tag]) == "MultiPoint" ) {
-				echo "member[".$member."]['geomtype'] = 'Point';\n";
+			elseif (sepNameSpace($element[tag]) == "LineString") {
+				$geom_str .= "geom.get(-1).addGeometry();\n";
 			}
-			else if (sepNameSpace($element[tag]) == "MultiPolygon") {
-				echo "member[".$member."]['geomtype'] = 'Polygon';\n";
+			else if (sepNameSpace($element[tag]) == "Polygon" ) {
+				$geom_str .= "geom.get(-1).addGeometry();\n";
 			}
 			else {
-				echo "member[".$member."]['geomtype'] = '".sepNameSpace($element[tag])."';\n";
+				$geom_str .= "alert('unknown geomtype ".sepNameSpace($element[tag])."');";
 			}
 		}
 		else if(strtoupper($element[tag]) == strtoupper("gml:coordinates") && $geom == true){
 			$tmp =  str_replace(",,","",str_replace(" ",",",trim($element[value])));
-			echo "var tmp = '".$tmp."';";
-			echo "member[".$member."]['geometry'][".$cnt_geom."] = tmp.split(',');\n";
+			$geom_str .= "var tmp1 = '".$tmp."';\n";
+			$geom_str .= "var tmp = tmp1.split(',');\n";
+			$geom_str .= "for (var i = 0 ; i < tmp.length ; i+=2) {\n";
+			$geom_str .= "\tgeom.getGeometry(-1,-1).addPointByCoordinates(parseFloat(tmp[i]), parseFloat(tmp[i+1]));\n";
+			$geom_str .= "}\n";
+			$geom_str .= "geom.close();\n";
             $cnt_geom++;
             
 		}
@@ -92,21 +103,21 @@
 		}
 		else if($section == true && $geom == false && $element[value]){
 			$el++;
-			echo "member[".$member."]['element'][".$el."] = new Array();\n";
-			echo "member[".$member."]['element'][".$el."]['name'] = '".sepNameSpace($element[tag])."';\n";
 			$str = $element[value];
-			echo "member[".$member."]['element'][".$el."]['val'] = '".$str."';\n";
+			$element_str .= "geom.get(" . $member . ").e.setElement('".sepNameSpace($element[tag])."', '".$str."');\n";
 		}
 		else if(strtoupper($element[tag]) == strtoupper("gml:featureMember") && $element[type] == "close"){
 			$section = false;	
 			$el = -1;			
 		}
    	}
+   	echo $geom_str;
+   	echo $element_str;
 }   	
 ?> 
 function mb_wfs_reg(){
-	if(member.length > 0){
-		parent.mb_wfs_register('<?php echo $_REQUEST['id'] ?>',member);
+	if(geom.count() > 0){
+		parent.mb_wfs_register('<?php echo $_REQUEST['id'] ?>',geom);
 	}
 	else{ 
 		parent.mb_wfs_register('<?php echo $_REQUEST['id'] ?>',false);




More information about the Mapbender_commits mailing list