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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Sep 30 06:03:16 EDT 2010


Author: christoph
Date: 2010-09-30 10:03:16 +0000 (Thu, 30 Sep 2010)
New Revision: 6981

Added:
   trunk/mapbender/test/data/polygonDonut.gml2.xml
   trunk/mapbender/test/data/polygonDonut.json
   trunk/mapbender/test/data/polygonDonutNoWhiteSpace.gml2.xml
   trunk/mapbender/test/http/classes/Gml2FactoryTest.php
Modified:
   trunk/mapbender/http/classes/class_gml_polygon.php
Log:
bug with multipolygons

Modified: trunk/mapbender/http/classes/class_gml_polygon.php
===================================================================
--- trunk/mapbender/http/classes/class_gml_polygon.php	2010-09-29 20:08:03 UTC (rev 6980)
+++ trunk/mapbender/http/classes/class_gml_polygon.php	2010-09-30 10:03:16 UTC (rev 6981)
@@ -37,12 +37,10 @@
 	}
 	
 	public function addPointToRing ($i, $x, $y) {
-		if (count($this->innerRingArray) <= $i) {
+		if (count($this->innerRingArray) < $i) {
 			array_push($this->innerRingArray, array());
 		}
-		$index = count($this->innerRingArray);
-		$currentIndex = ($i < $index ? $i : $index);
-		array_push($this->innerRingArray[$currentIndex], array("x" => $x, "y" => $y));
+		array_push($this->innerRingArray[$i-1], array("x" => $x, "y" => $y));
 	}
 	
 	public function toGml2 () {

Added: trunk/mapbender/test/data/polygonDonut.gml2.xml
===================================================================
--- trunk/mapbender/test/data/polygonDonut.gml2.xml	                        (rev 0)
+++ trunk/mapbender/test/data/polygonDonut.gml2.xml	2010-09-30 10:03:16 UTC (rev 6981)
@@ -0,0 +1,16 @@
+<gml:MultiPolygon srsName="EPSG:4326">
+	<gml:polygonMember>
+		<gml:Polygon>
+			<gml:outerBoundaryIs>
+				<gml:LinearRing>
+					<gml:coordinates>-19,-70 -7,-62 13,-67 3,-72 -19,-70</gml:coordinates>
+				</gml:LinearRing>
+			</gml:outerBoundaryIs>
+			<gml:innerBoundaryIs>
+				<gml:LinearRing>
+					<gml:coordinates>-7.4,-67.6 -4.8,-66.9 -6.6,-65.5 -7.4,-67.6</gml:coordinates>
+				</gml:LinearRing>
+			</gml:innerBoundaryIs>
+		</gml:Polygon>
+	</gml:polygonMember>
+</gml:MultiPolygon>
\ No newline at end of file

Added: trunk/mapbender/test/data/polygonDonut.json
===================================================================
--- trunk/mapbender/test/data/polygonDonut.json	                        (rev 0)
+++ trunk/mapbender/test/data/polygonDonut.json	2010-09-30 10:03:16 UTC (rev 6981)
@@ -0,0 +1,63 @@
+{
+    "type": "FeatureCollection",
+    "features": [
+        {
+            "type": "Feature",
+            "crs": {
+                "type": "name",
+                "properties": {
+                    "name": "EPSG:4326"
+                }
+            },
+            "geometry": {
+                "type": "Polygon",
+                "coordinates": [
+                    [
+                        [
+                            -19,
+                            -70
+                        ],
+                        [
+                            -7,
+                            -62
+                        ],
+                        [
+                            13,
+                            -67
+                        ],
+                        [
+                            3,
+                            -72
+                        ],
+                        [
+                            -19,
+                            -70
+                        ]
+                    ],
+                    [
+                        [
+                            -7.4,
+                            -67.6
+                        ],
+                        [
+                            -4.8,
+                            -66.9
+                        ],
+                        [
+                            -6.6,
+                            -65.5
+                        ],
+                        [
+                            -7.4,
+                            -67.6
+                        ]
+                    ]
+                ]
+            },
+            "properties": {
+                "name": "test",
+                "style": "1"
+            }
+        }
+    ]
+}
\ No newline at end of file

Added: trunk/mapbender/test/data/polygonDonutNoWhiteSpace.gml2.xml
===================================================================
--- trunk/mapbender/test/data/polygonDonutNoWhiteSpace.gml2.xml	                        (rev 0)
+++ trunk/mapbender/test/data/polygonDonutNoWhiteSpace.gml2.xml	2010-09-30 10:03:16 UTC (rev 6981)
@@ -0,0 +1 @@
+<gml:MultiPolygon srsName="EPSG:4326"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>-19,-70 -7,-62 13,-67 3,-72 -19,-70</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>-7.4,-67.6 -4.8,-66.9 -6.6,-65.5 -7.4,-67.6</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon>
\ No newline at end of file

Added: trunk/mapbender/test/http/classes/Gml2FactoryTest.php
===================================================================
--- trunk/mapbender/test/http/classes/Gml2FactoryTest.php	                        (rev 0)
+++ trunk/mapbender/test/http/classes/Gml2FactoryTest.php	2010-09-30 10:03:16 UTC (rev 6981)
@@ -0,0 +1,41 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+require_once dirname(__FILE__) . "/../../../http/classes/class_gml_2_factory.php";
+
+class Gml2FactoryTest extends PHPUnit_Framework_TestCase
+{
+
+	protected $gml2Factory;
+	protected $geoJsonPolygonDonut;
+
+	public function setUp () {
+    	$this->geoJsonPolygonDonut = dirname(__FILE__) . "/../../data/polygonDonut.json";
+    	$this->gml2PolygonDonutNoWhiteSpace = dirname(__FILE__) . "/../../data/polygonDonutNoWhiteSpace.gml2.xml";
+    	$this->gml2PolygonDonut = dirname(__FILE__) . "/../../data/polygonDonut.gml2.xml";
+
+		$this->gml2Factory = new Gml_2_Factory();
+    }
+
+	public function testRemoveWhiteSpace () {
+		$gml2 = file_get_contents($this->gml2PolygonDonut);
+		$expectedGml2 = file_get_contents($this->gml2PolygonDonutNoWhiteSpace);
+		$this->assertEquals(
+        	$expectedGml2,
+        	$this->gml2Factory->removeWhiteSpace($gml2)
+        );
+
+	}
+
+	public function testGeoJsonToGml2PolygonDonut() {
+		$geoJson = file_get_contents($this->geoJsonPolygonDonut);
+		$expectedGml2 = file_get_contents($this->gml2PolygonDonut);
+
+		$gmlObj = $this->gml2Factory->createFromGeoJson($geoJson);
+
+		$this->assertEquals(
+        	$this->gml2Factory->removeWhiteSpace($expectedGml2),
+        	$gmlObj->toGml()
+        );
+    }
+}
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list