[Mapbender-commits] r7032 - in trunk/mapbender: http/classes test/data test/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Oct 7 13:24:14 EDT 2010


Author: christoph
Date: 2010-10-07 17:24:14 +0000 (Thu, 07 Oct 2010)
New Revision: 7032

Added:
   trunk/mapbender/test/data/multiline.gml2.xml
   trunk/mapbender/test/data/multiline.gml3.xml
Modified:
   trunk/mapbender/http/classes/class_gml_multiline.php
   trunk/mapbender/http/classes/class_gml_multipoint.php
   trunk/mapbender/http/classes/class_gml_polygon.php
   trunk/mapbender/test/data/multipoint.gml2.xml
   trunk/mapbender/test/data/multipoint.gml3.xml
   trunk/mapbender/test/http/classes/Gml2FactoryTest.php
   trunk/mapbender/test/http/classes/Gml3FactoryTest.php
Log:
finished unit tests (+ bug fixes) for geojson to GML converter

Modified: trunk/mapbender/http/classes/class_gml_multiline.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_multiline.php	2010-10-06 18:26:54 UTC (rev 7031)
+++ trunk/mapbender/http/classes/class_gml_multiline.php	2010-10-07 17:24:14 UTC (rev 7032)
@@ -31,11 +31,14 @@
 	}
 	
 	public function addPoint ($x, $y, $i) {
-		array_push($this->lineArray[$i], array("x" => $x, "y" => $y));
+            if (!is_array($this->lineArray[$i])) {
+                $this->lineArray[$i] = array();
+            }
+            array_push($this->lineArray[$i], array("x" => $x, "y" => $y));
 	}
 	
 	public function toGml2 () {
-		$str = "<gml:MultiLineString srsName='$srsName'>";
+		$str = "<gml:MultiLineString srsName='$this->srs'>";
 		foreach ($this->lineArray as $line) {
 			$str .=	"<gml:lineStringMember><gml:LineString><gml:coordinates>";
 			$ptArray = array();
@@ -43,14 +46,14 @@
 				$ptArray[] = $point["x"] . "," . $point["y"];
 			}
 			$str .= implode(" ", $ptArray);
-			$str .= "</gml:coordinates></gml:LineString>";
+			$str .= "</gml:coordinates></gml:LineString></gml:lineStringMember>";
 		}
-		$str .=	"<gml:lineStringMember><gml:MultiLineString>";
+		$str .=	"</gml:MultiLineString>";
 		return $str;		
 	}
 	
 	public function toGml3 () {
-		$str = "<gml:MultiCurve srsName='$srsName'>";
+		$str = "<gml:MultiCurve srsName='$this->srs'>";
 		foreach ($this->lineArray as $line) {
 			$str .=	"<gml:curveMember><gml:LineString>";
 			$ptArray = array();
@@ -58,9 +61,9 @@
 				$ptArray[] = "<gml:pos>" . $point["x"] . " " . $point["y"] . "</gml:pos>";
 			}
 			$str .= implode("", $ptArray);
-			$str .= "</gml:LineString><gml:curveMember>";
+			$str .= "</gml:LineString></gml:curveMember>";
 		}
-		$str .=	"<gml:MultiCurve>";
+		$str .=	"</gml:MultiCurve>";
 		return $str;		
 		
 	}

Modified: trunk/mapbender/http/classes/class_gml_multipoint.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_multipoint.php	2010-10-06 18:26:54 UTC (rev 7031)
+++ trunk/mapbender/http/classes/class_gml_multipoint.php	2010-10-07 17:24:14 UTC (rev 7032)
@@ -35,25 +35,25 @@
 	}
 	
 	public function toGml2 () {
-		$str = "<gml:MultiPoint srsName='$srsName'>";
+		$str = "<gml:MultiPoint srsName='$this->srs'>";
 		foreach ($this->pointArray as $point) {
 			$str .=	"<gml:pointMember><gml:Point><gml:coordinates>";
 			$str .= $point["x"] . "," . $point["y"];
 			$str .= "</gml:coordinates></gml:Point>";
 		}
-		$str .=	"<gml:pointMember><gml:MultiPoint>";
+		$str .=	"</gml:pointMember></gml:MultiPoint>";
 		return $str;		
 	}
 	
 	public function toGml3 () {
 		
-		$str = "<gml:MultiPoint srsName='$srsName'>";
+		$str = "<gml:MultiPoint srsName='$this->srs'>";
 		foreach ($this->pointArray as $point) {
 			$str .=	"<gml:pointMember><gml:Point>";
 			$str .= "<gml:pos>" . $point["x"] . " " . $point["y"] . "</gml:pos>";
-			$str .= "</gml:Point><gml:pointMember>";
+			$str .= "</gml:Point></gml:pointMember>";
 		}
-		$str .=	"<gml:MultiPoint>";
+		$str .=	"</gml:MultiPoint>";
 		return $str;		
 		
 	}

Modified: trunk/mapbender/http/classes/class_gml_polygon.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_polygon.php	2010-10-06 18:26:54 UTC (rev 7031)
+++ trunk/mapbender/http/classes/class_gml_polygon.php	2010-10-07 17:24:14 UTC (rev 7032)
@@ -79,7 +79,7 @@
 		foreach ($this->pointArray as $point) {
 			$ptArray[] = "<gml:pos>" . $point["x"] . " " . $point["y"] . "</gml:pos>";
 		}
-		$str .= implode(" ", $ptArray);
+		$str .= implode("", $ptArray);
 
 		$str .= '</gml:LinearRing></gml:exterior>';
 				

Added: trunk/mapbender/test/data/multiline.gml2.xml
===================================================================
--- trunk/mapbender/test/data/multiline.gml2.xml	                        (rev 0)
+++ trunk/mapbender/test/data/multiline.gml2.xml	2010-10-07 17:24:14 UTC (rev 7032)
@@ -0,0 +1,13 @@
+
+<gml:MultiLineString srsName='EPSG:4326'>
+    <gml:lineStringMember>
+        <gml:LineString>
+            <gml:coordinates>100,0 101,1</gml:coordinates>
+        </gml:LineString>
+    </gml:lineStringMember>
+    <gml:lineStringMember>
+        <gml:LineString>
+            <gml:coordinates>102,2 103,3</gml:coordinates>
+        </gml:LineString>
+    </gml:lineStringMember>
+</gml:MultiLineString>
\ No newline at end of file

Added: trunk/mapbender/test/data/multiline.gml3.xml
===================================================================
--- trunk/mapbender/test/data/multiline.gml3.xml	                        (rev 0)
+++ trunk/mapbender/test/data/multiline.gml3.xml	2010-10-07 17:24:14 UTC (rev 7032)
@@ -0,0 +1,14 @@
+<gml:MultiCurve srsName='EPSG:4326'>
+    <gml:curveMember>
+        <gml:LineString>
+            <gml:pos>100 0</gml:pos>
+            <gml:pos>101 1</gml:pos>
+        </gml:LineString>
+    </gml:curveMember>
+    <gml:curveMember>
+        <gml:LineString>
+            <gml:pos>102 2</gml:pos>
+            <gml:pos>103 3</gml:pos>
+        </gml:LineString>
+    </gml:curveMember>
+</gml:MultiCurve>
\ No newline at end of file

Modified: trunk/mapbender/test/data/multipoint.gml2.xml
===================================================================
--- trunk/mapbender/test/data/multipoint.gml2.xml	2010-10-06 18:26:54 UTC (rev 7031)
+++ trunk/mapbender/test/data/multipoint.gml2.xml	2010-10-07 17:24:14 UTC (rev 7032)
@@ -1 +1,8 @@
-<gml:MultiPoint srsName='EPSG:4326'><gml:pointMember><gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point><gml:pointMember><gml:MultiPoint>
\ No newline at end of file
+
+<gml:MultiPoint srsName='EPSG:4326'>
+    <gml:pointMember>
+        <gml:Point>
+            <gml:coordinates>1,2</gml:coordinates>
+        </gml:Point>
+    </gml:pointMember>
+</gml:MultiPoint>
\ No newline at end of file

Modified: trunk/mapbender/test/data/multipoint.gml3.xml
===================================================================
--- trunk/mapbender/test/data/multipoint.gml3.xml	2010-10-06 18:26:54 UTC (rev 7031)
+++ trunk/mapbender/test/data/multipoint.gml3.xml	2010-10-07 17:24:14 UTC (rev 7032)
@@ -1 +1,7 @@
-<gml:MultiPoint srsName='EPSG:4326'><gml:pointMember><gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point><gml:pointMember><gml:MultiPoint>
\ No newline at end of file
+<gml:MultiPoint srsName='EPSG:4326'>
+    <gml:pointMember>
+        <gml:Point>
+            <gml:pos>1 2</gml:pos>
+        </gml:Point>
+    </gml:pointMember>
+</gml:MultiPoint>
\ No newline at end of file

Modified: trunk/mapbender/test/http/classes/Gml2FactoryTest.php
===================================================================
--- trunk/mapbender/test/http/classes/Gml2FactoryTest.php	2010-10-06 18:26:54 UTC (rev 7031)
+++ trunk/mapbender/test/http/classes/Gml2FactoryTest.php	2010-10-07 17:24:14 UTC (rev 7032)
@@ -101,7 +101,7 @@
 
         public function testGeoJsonToGml2MultiPoint() {
 		$geoJson = file_get_contents($this->geoJsonMultiPoint);
-		$expectedGml2 = "";
+		$expectedGml2 = file_get_contents($this->gml2MultiPoint);
 
 		$gmlObj = $this->gml2Factory->createFromGeoJson($geoJson);
 
@@ -113,7 +113,7 @@
 
         public function testGeoJsonToGml2MultiLine() {
 		$geoJson = file_get_contents($this->geoJsonMultiLine);
-		$expectedGml2 = "";
+		$expectedGml2 = file_get_contents($this->gml2MultiLine);
 
 		$gmlObj = $this->gml2Factory->createFromGeoJson($geoJson);
 

Modified: trunk/mapbender/test/http/classes/Gml3FactoryTest.php
===================================================================
--- trunk/mapbender/test/http/classes/Gml3FactoryTest.php	2010-10-06 18:26:54 UTC (rev 7031)
+++ trunk/mapbender/test/http/classes/Gml3FactoryTest.php	2010-10-07 17:24:14 UTC (rev 7032)
@@ -101,7 +101,7 @@
 
         public function testGeoJsonToGml3MultiPoint() {
 		$geoJson = file_get_contents($this->geoJsonMultiPoint);
-		$expectedGml3 = "";
+		$expectedGml3 = file_get_contents($this->gml3MultiPoint);
 
 		$gmlObj = $this->gml3Factory->createFromGeoJson($geoJson);
 
@@ -113,7 +113,7 @@
 
         public function testGeoJsonToGml3MultiLine() {
 		$geoJson = file_get_contents($this->geoJsonMultiLine);
-		$expectedGml3 = "";
+		$expectedGml3 = file_get_contents($this->gml3MultiLine);
 
 		$gmlObj = $this->gml3Factory->createFromGeoJson($geoJson);
 



More information about the Mapbender_commits mailing list