[Mapbender-commits] r9031 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Aug 6 07:08:43 PDT 2014


Author: armin11
Date: 2014-08-06 07:08:43 -0700 (Wed, 06 Aug 2014)
New Revision: 9031

Modified:
   trunk/mapbender/http/plugins/mb_downloadFeedClient.php
   trunk/mapbender/http/plugins/mb_metadata_gml_import.js
   trunk/mapbender/http/plugins/mb_metadata_server.php
   trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
Log:
Possibility to upload simple gml3 exterior rings to use them as bounding geometries of metadata sets.

Modified: trunk/mapbender/http/plugins/mb_downloadFeedClient.php
===================================================================
--- trunk/mapbender/http/plugins/mb_downloadFeedClient.php	2014-08-06 14:07:40 UTC (rev 9030)
+++ trunk/mapbender/http/plugins/mb_downloadFeedClient.php	2014-08-06 14:08:43 UTC (rev 9031)
@@ -108,7 +108,7 @@
 	<script src="http://openlayers.org/api/OpenLayers.js"></script>
 	<script src="../extensions/jquery-ui-1.8.16.custom/js/jquery-1.6.2.min.js"></script>
 	<script src="../extensions/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script>
-	<script src="../javascripts/mb_downloadFeedClient.js"></script>
+	<script src="../javascripts/mb_downloadFeedClient.php"></script>
 </head>
 <body onload="init()">
 

Modified: trunk/mapbender/http/plugins/mb_metadata_gml_import.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_gml_import.js	2014-08-06 14:07:40 UTC (rev 9030)
+++ trunk/mapbender/http/plugins/mb_metadata_gml_import.js	2014-08-06 14:08:43 UTC (rev 9031)
@@ -34,6 +34,9 @@
 				}
 				alert(message);
 				$gmlImport.dialog("close");
+				//alter the url to the overview image to force reload!
+				alert($("#extent_preview").attr('src'));
+				$("#extent_preview").attr('src',$("#extent_preview").attr('src')+"&imagetime="+ new Date().getTime());
 				//invoke external script from mb_metadata_showMetadataAddon.js
 				//that.fillLayerForm(layerId);
 				//Mapbender.modules.mb_md_showMetadataAddon.fillLayerForm(layerId);

Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php	2014-08-06 14:07:40 UTC (rev 9030)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php	2014-08-06 14:08:43 UTC (rev 9031)
@@ -52,6 +52,7 @@
 function gml2wkt($gml) {
 	//function to create wkt from given gml multipolygon
 	//DOM
+	$polygonalExtentExterior = array();
 	$gmlObject = new DOMDocument();
 	libxml_use_internal_errors(true);
 	try {
@@ -72,22 +73,54 @@
 
 	//if parsing was successful
 	if ($gmlObject !== false) {
-		//ST_GeomFromText('MULTIPOLYGON(((235670.354215375 894016.780856,235668.324215375 894025.050856,235681.154215375 894028.210856,235683.184215375 894019.940856,235670.354215375 894016.780856)))', 2805) )
 		//read crs from gml
 		$xpath = new DOMXPath($gmlObject);
 		$xpath->registerNamespace('gml','http://www.opengis.net/gml');
 		$crs = $xpath->query('/gml:Polygon/@srsName');
 		$crsArray = DOMNodeListObjectValuesToArray($crs);
 		$crsId = end(explode(":",$crsArray[0]));
+		//look for GML3 polygon as exterior ring in two alternative encodings (see: http://www.galdosinc.com/archives/191 - all coords are interpreted as given in EPSG:4326 for the moment!!!):
+		if ($xpath->query('/gml:Polygon/gml:exterior/gml:LinearRing/gml:posList')) {
+			//read posList
+			$exteriorRingPoints = $xpath->query('/gml:Polygon/gml:exterior/gml:LinearRing/gml:posList');
+			$exteriorRingPoints = DOMNodeListObjectValuesToArray($exteriorRingPoints);
+			if (count($exteriorRingPoints) > 0) {
+				//poslist is only space separated
+				$exteriorRingPointsArray = explode(' ',$exteriorRingPoints[0]);
+				for ($i = 0; $i <= count($exteriorRingPointsArray)/2-1; $i++) {
+					$polygonalExtentExterior[$i]['x'] = $exteriorRingPointsArray[2*$i];
+					$polygonalExtentExterior[$i]['y'] = $exteriorRingPointsArray[(2*$i)+1];
+				}
+			}
+		} else {
+			//try to read coordinates
+			$exteriorRingPoints = $xpath->query('/gml:Polygon/gml:exterior/gml:LinearRing/gml:coordinates');
+			$exteriorRingPoints = DOMNodeListObjectValuesToArray($exteriorRingPoints);
+			if (count($exteriorRingPoints) > 0) {
+				//two coordinates of one point are comma separated
+				//problematic= ", " or " ," have to be deleted before
+				$exteriorRingPoints[0] = str_replace(', ',',',str_replace(' ,',',',$exteriorRingPoints[0]));
+				$exteriorRingPointsArray = explode(' ',$exteriorRingPoints[0]);
+				for ($i = 0; $i <= count($exteriorRingPointsArray)-1;$i++) {
+					$coords = explode(",",$exteriorRingPointsArray[$i]);
+					$polygonalExtentExterior[$i]['x'] = $coords[0];
+					$polygonalExtentExterior[$i]['y'] = $coords[1];
+				}
+			}
+		}
+		//build wkt
 		if (!isset($crsId) || $crsId =="" || $crsId == NULL) {
 			//set default to lonlat wgs84
 			$crsId = "4326";
 		}
-		$wkt = "SRID=".$crsId.";POLYGON(";
-		$outerPolygons = $xpath->query('/gml:Polygon/gml:outerBoundaryIs/gml:LinearRing/gml:coordinates');
-		$outerPolygonsArray = DOMNodeListObjectValuesToArray($outerPolygons);
-		//$e = new mb_exception("mb_metadata_server.php: ".$outerPolygonsArray[0]);
-		$wkt .= "(".str_replace(";",",",str_replace(","," ",str_replace(" ",";",$outerPolygonsArray[0])))."))";
+		$wkt = "SRID=".$crsId.";POLYGON((";
+		//Example: "SRID=4326;POLYGON((-140 -80,-140 80,170 80,170 -80,-140 -80))"
+		foreach ($polygonalExtentExterior as $point) {
+			$wkt .= trim($point['x'])." ".trim($point['y']).",";
+		}
+		$wkt = rtrim($wkt,',');
+		$wkt .= "))";
+		$e = new mb_exception("plugins/mb_metadata_server.php: polygon: ".$wkt);
 		return $wkt;
 	}
 }
@@ -763,6 +796,7 @@
 			$resultObj["downloadlink"] = $mbMetadata->downloadLinks[0]; //only the first link!
 			$resultObj["inspire_whole_area"] = $mbMetadata->inspireWholeArea;
 			$resultObj["inspire_actual_coverage"] = $mbMetadata->inspireActualCoverage;
+			$resultObj["overview_url"] = $mbMetadata->getExtentGraphic($mbMetadata->wgs84Bbox);
 			$export2csw = $mbMetadata->export2Csw; //boolean
 			$resultObj["update_frequency"] = $mbMetadata->updateFrequency; //text
 			switch ($export2csw) {

Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js	2014-08-06 14:07:40 UTC (rev 9030)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js	2014-08-06 14:08:43 UTC (rev 9031)
@@ -130,6 +130,7 @@
 				$(".charset_selectbox").val(obj.inspire_charset);
 				$(".ref_system_selectbox").val(obj.ref_system);
 				$(".cyclic_selectbox").val(obj.update_frequency);
+				$("#extent_preview").attr('src',obj.overview_url+"&time="+ new Date().getTime());
 				$(".radioRes").filter('[value='+obj.spatial_res_type+']').attr('checked', true);
 
 			}



More information about the Mapbender_commits mailing list