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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Nov 20 06:44:11 EST 2009


Author: armin11
Date: 2009-11-20 06:44:10 -0500 (Fri, 20 Nov 2009)
New Revision: 5020

Modified:
   trunk/mapbender/http/classes/class_gml2.php
Log:
merge with geoportal.rlp and adoption for georss client

Modified: trunk/mapbender/http/classes/class_gml2.php
===================================================================
--- trunk/mapbender/http/classes/class_gml2.php	2009-11-20 11:09:21 UTC (rev 5019)
+++ trunk/mapbender/http/classes/class_gml2.php	2009-11-20 11:44:10 UTC (rev 5020)
@@ -127,15 +127,43 @@
 		$fGml = $unique.".gml";
 //		$pathOgr = '/appserver/postgresql/templates/postgresql824/bin/ogr2ogr';
 		$pathOgr = '/usr/bin/ogr2ogr';
+//		$pathOgr = OGR2OGR_PATH;
 		$w = $this->toFile($fGml);
+		// - get EPSC-Code from GML-File--
+		
+		$data = file_get_contents($fGml);//		
+		$gmlDoc = new SimpleXMLElement($data);
+				
+		$gmlDoc->registerXPathNamespace('xls', 'http://www.opengis.net/xls');
+		$gmlDoc->registerXPathNamespace('gml', 'http://www.opengis.net/gml');
 
- 		$exec = $pathOgr.' -f "ESRI Shapefile" "'.$fShape.'" '.$fGml;
+		$gmlBboxes = $gmlDoc->xpath("//gml:Box");	//<gml:Box srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
+		
+		if(count($gmlBboxes)>0){
+			$bbox_str = $gmlBboxes[0]['srsName'];			
+			$pos_raute = strpos($bbox_str, '#');
+			$epsg = substr($bbox_str, $pos_raute+1);
+
+		} else {
+			$e = new mb_exception("class_gml2.php:toShape() => no EPSG in GML(" . $fGml . ").");
+		}
+		// ---
+		
+		
+		$str_ogr = $pathOgr.' -a_srs EPSG:'.$epsg.' -f "ESRI Shapefile" "'.$fShape.'" '.$fGml;
+		$e = new mb_exception("ogr-Befehl:".$str_ogr);
+		
+ 		$exec = $pathOgr.' -a_srs EPSG:'.$epsg.' -f "ESRI Shapefile" "'.$fShape.'" '.$fGml;
+		
+		
+
+ 		//$exec = $pathOgr.' -f "ESRI Shapefile" "'.$fShape.'" '.$fGml;
  		exec($exec);
  		
- 		$exec = 'zip -j '.$unique.' '.$unique.'.shp '.$unique.'.dbf '.$unique.'.shx '.$unique.'.gfs '.$unique.'.gml ';
+ 		$exec = 'zip -j '.$unique.' '.$unique.'.shp '.$unique.'.dbf '.$unique.'.shx '.$unique.'.gfs '.$unique.'.gml '.$unique.'.prj ';
  		exec($exec);
 
-		$exec = 'rm -f '.$unique.' '.$unique.'.shp '.$unique.'.dbf '.$unique.'.shx '.$unique.'.gfs '.$unique.'.gml';
+		$exec = 'rm -f '.$unique.' '.$unique.'.shp '.$unique.'.dbf '.$unique.'.shx '.$unique.'.gfs '.$unique.'.gml '.$unique.'.prj ';
 		exec($exec);
 		
 		$exec = 'chmod 777 '.$unique.'.*';
@@ -368,7 +396,7 @@
 		elseif ($this->getGeometryTypeFromMember($i) == $this->geomtype_polygon || $this->getGeometryTypeFromMember($i) == $this->geomtype_multipolygon) {
 			$js .= "var current_geomtype = ".$prefix."geomType.polygon;\n";
 		}
-		else{
+		else {
 			$e = new mb_notice("unknown geometry type: '".$this->getGeometryTypeFromMember($i)."' or no geometry existing");
 			return "";
 		}	
@@ -537,6 +565,7 @@
 						case "gml:Envelope" :
 							$this->geometry = new GMLEnvelope();
 							$this->geometry->parseEnvelope($geomNode);
+							break;
 						default:
 							$this->properties[$columnName] = $value;
 							break;



More information about the Mapbender_commits mailing list