[Mapbender-commits] r8472 - in trunk/mapbender: http/classes http/javascripts http/plugins resources/locale/de_DE/LC_MESSAGES

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 28 03:41:46 PDT 2012


Author: armin11
Date: 2012-08-28 03:41:45 -0700 (Tue, 28 Aug 2012)
New Revision: 8472

Modified:
   trunk/mapbender/http/classes/class_georss_geometry.php
   trunk/mapbender/http/classes/class_georss_item.php
   trunk/mapbender/http/javascripts/mb_downloadFeedClient.js
   trunk/mapbender/http/plugins/mb_downloadFeedServer.php
   trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po
Log:
Enhancement of the inspire download service client and bugfix of georss parsing/generating.

Modified: trunk/mapbender/http/classes/class_georss_geometry.php
===================================================================
--- trunk/mapbender/http/classes/class_georss_geometry.php	2012-08-27 13:48:29 UTC (rev 8471)
+++ trunk/mapbender/http/classes/class_georss_geometry.php	2012-08-28 10:41:45 UTC (rev 8472)
@@ -266,7 +266,7 @@
 class geoRSSPolygon extends GMLPolygon{
 	var $targetEPSG;
 	public function parsePolygon ($georssPolygon) {
-		if (gettype == 'object') {
+		if (gettype($georssPolygon) == 'object') {
 			//polygon is given as dom node
 			$coordArray = explode(' ',$georssPolygon->nodeValue);
 		} else {
@@ -284,7 +284,16 @@
 class geoRSSBox extends GMLPolygon{
 	var $targetEPSG;
 	public function parseBox ($domNode) {
-		list($x1,$y1,$x2,$y2) = explode(' ',$domNode->nodeValue);
+			////in georss lat/lon is given, in geojson lon lat will be used http://www.georss.org/simple http://www.geojson.org/geojson-spec.html#coordinate-reference-system-objects
+		if (gettype($domNode) == 'object') {
+			//polygon is given as dom node
+			list($y1,$x1,$y2,$x2) = explode(' ',$domNode->nodeValue);
+		} else {
+			//bbox is given as string
+			list($y1,$x1,$y2,$x2) = explode(' ',$domNode);
+			
+		}
+		
 		if ($this->targetEPSG != '4326') {
 			$tCoords = transform($x1, $y1,'4326', $this->targetEPSG);
 			$x1 = $tCoords["x"];
@@ -293,6 +302,7 @@
 			$x2 = $tCoords["x"];
 			$y2 = $tCoords["y"];
 		}
+		
 		$this->addPoint($x1, $y1);
 		$this->addPoint($x1, $y2);
 		$this->addPoint($x2, $y2);

Modified: trunk/mapbender/http/classes/class_georss_item.php
===================================================================
--- trunk/mapbender/http/classes/class_georss_item.php	2012-08-27 13:48:29 UTC (rev 8471)
+++ trunk/mapbender/http/classes/class_georss_item.php	2012-08-28 10:41:45 UTC (rev 8472)
@@ -25,18 +25,18 @@
 	public function getBbox () {
 		return $this->bbox;
 	}
-	
+	//to note georss defines lat/lon not lon/lat
 	protected function getItemString () {
 		$str = parent::getItemString();
 		if (is_a($this->bbox, "Mapbender_bbox")) {
 			$str .= "<georss:box>" . 
+					$this->bbox->min->y . " " . 
 					$this->bbox->min->x . " " . 
-					$this->bbox->min->y . " " . 
-					$this->bbox->max->x . " " . 
-					$this->bbox->max->y . 
+					$this->bbox->max->y . " " . 
+					$this->bbox->max->x . 
 	            "</georss:box>\n";
 		}
 		return $str;
 	}
 }
-?>
\ No newline at end of file
+?>

Modified: trunk/mapbender/http/javascripts/mb_downloadFeedClient.js
===================================================================
--- trunk/mapbender/http/javascripts/mb_downloadFeedClient.js	2012-08-27 13:48:29 UTC (rev 8471)
+++ trunk/mapbender/http/javascripts/mb_downloadFeedClient.js	2012-08-28 10:41:45 UTC (rev 8472)
@@ -191,6 +191,7 @@
 	//initialize options
 	var selectROptions = "";
 	//iterate over all possible representations, which are modeled as entries in the dataset feed (here features of the featureCollection)
+	//alert(featureCollection.features.length);
 	for(var i=0; i<featureCollection.features.length; ++i) {
 		selectROptions = selectROptions+"<option value='"+i+"' url='"+featureCollection.features[i].properties.datasetFeedLink+"'>"+featureCollection.features[i].properties.title+"</option>";
 	}
@@ -213,9 +214,11 @@
 		//initialize option string
 		var selectFOptions = "";
 		//count number of links in representation
-		var numberOfLinks = featureCollection.features[0].properties.entry[k].link.length;
+		var numberOfLinks = featureCollection.features[k].properties.link.length;
+		//alert("number of links: "+numberOfLinks+"for representation: "+k);
+		//alert(featureCollection.features[0].properties.entry[0].title);
 		//alert("number of links: "+numberOfLinks);
-		if (numberOfLinks >= 1) {
+		if (numberOfLinks >= 1 || numberOfLinks === undefined) {
 			//show list 
 			$("#representation_select").css("display","block");
 			//deactivate mapframe2 by default
@@ -225,18 +228,13 @@
 			//extent size of outer fieldset
 			$("#client").css("height","730px");
 		} else {
-			/*if (numberOfLinks == 1) {
-				//open single link for download!
-				//show download symbol
-				
-			}*/
+			alert("No links to datasets or parts of them found in feed!");
 		}
-                for (var i = 0; i < featureCollection.features[0].properties.entry[k].link.length; i++) {
-			if (featureCollection.features[0].properties.entry[k].link[i]['@attributes'].bbox == '' || featureCollection.features[0].properties.entry[k].link[i]['@attributes'].bbox === undefined) {
-				selectFOptions = selectFOptions+"<option value='"+i+"' url='"+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].href+"' title='"+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].title+"'  onclick='window.open(\""+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].href+"\");'>"+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].title+"</option>";
+                for (var i = 0; i < numberOfLinks; i++) {
+			if (featureCollection.features[k].properties.link[i]['@attributes'].bbox == '' || featureCollection.features[k].properties.link[i]['@attributes'].bbox === undefined) {
+				selectFOptions = selectFOptions+"<option value='"+i+"' url='"+featureCollection.features[k].properties.link[i]['@attributes'].href+"' title='"+featureCollection.features[k].properties.link[i]['@attributes'].title+"'  onclick='window.open(\""+featureCollection.features[k].properties.link[i]['@attributes'].href+"\");'>"+featureCollection.features[k].properties.link[i]['@attributes'].title+"</option>";
 			} else {
-				
-                		ext = featureCollection.features[0].properties.entry[k].link[i]['@attributes'].bbox;
+                		ext = featureCollection.features[k].properties.link[i]['@attributes'].bbox;
 				extArrayNew = new Array();
 				extArray = ext.split(",");
 				//sort array to lat lon
@@ -245,10 +243,10 @@
 				extArrayNew[2] = extArray[3];
 				extArrayNew[3] = extArray[2];
                 		bound = OpenLayers.Bounds.fromArray(extArrayNew);
-				attributes = {id: i, url:featureCollection.features[0].properties.entry[k].link[i]['@attributes'].href};
+				attributes = {id: i, url:featureCollection.features[k].properties.link[i]['@attributes'].href};
                 		box = new OpenLayers.Feature.Vector(bound.toGeometry(),attributes);
                 		bboxFiles.addFeatures(box);
-				selectFOptions = selectFOptions+"<option value='"+i+"' url='"+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].href+"' title='"+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].title+"' onclick='highlightFeatureIndexById("+i+",true);' onmouseover='highlightFeatureIndexById("+i+",false);'>"+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].title+"</option>";
+				selectFOptions = selectFOptions+"<option value='"+i+"' url='"+featureCollection.features[k].properties.link[i]['@attributes'].href+"' title='"+featureCollection.features[k].properties.link[i]['@attributes'].title+"' onclick='highlightFeatureIndexById("+i+",true);' onmouseover='highlightFeatureIndexById("+i+",false);'>"+featureCollection.features[k].properties.link[i]['@attributes'].title+"</option>";
 			}
 				
                	}

Modified: trunk/mapbender/http/plugins/mb_downloadFeedServer.php
===================================================================
--- trunk/mapbender/http/plugins/mb_downloadFeedServer.php	2012-08-27 13:48:29 UTC (rev 8471)
+++ trunk/mapbender/http/plugins/mb_downloadFeedServer.php	2012-08-28 10:41:45 UTC (rev 8472)
@@ -82,6 +82,7 @@
 			$feedXML->registerXPathNamespace("defaultns", "http://www.w3.org/2005/Atom");
 
 			$title = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:title');
+			//$content = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:content');
 			$rights = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:rights');
 			$summary = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:summary');
 			$date = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:date');
@@ -89,7 +90,8 @@
 			
 			$namespace = $feedXML->xpath('/defaultns:feed/defaultns:entry/inspire_dls:spatial_dataset_identifier_namespace');
 			
-			$bbox = $feedXML->xpath('/defaultns:feed/defaultns:entry/georss:polygon');
+			$polygon = $feedXML->xpath('/defaultns:feed/defaultns:entry/georss:polygon');
+			$bbox = $feedXML->xpath('/defaultns:feed/defaultns:entry/georss:box');
 			$metadataLink = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'describedby\')]/@href');
 			$datasetFeedLink = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'alternate\')]/@href');
 			//new feature collection
@@ -99,17 +101,20 @@
 				$uuid = new Uuid;
 				$feature->fid = $uuid;	
 				$titleArray = (array)$title[$i];
+				$contentArray = (array)$content[$i];
 				$rightsArray = (array)$rights[$i];
 				$summaryArray = (array)$summary[$i];
 				$dateArray = (array)$date[$i];
 				$codeArray = (array)$code[$i];
 				$namespaceArray = (array)$namespace[$i];
 				$bboxArray = (array)$bbox[$i];
+				$polygonArray = (array)$polygon[$i];
 				$mdLinkArray = (array)$metadataLink[$i];
 				$mdLinkArray = $mdLinkArray["@attributes"];
 				$dsLinkArray = (array)$datasetFeedLink[$i];
 				$dsLinkArray = $dsLinkArray["@attributes"];
 				$feature->properties["title"] = $titleArray[0];
+				//$feature->properties["content"] = $contentArray[0];
 				$feature->properties["summary"] = $summaryArray[0];
 				$feature->properties["rights"] = $rightsArray[0];
 				$feature->properties["date"] = $dateArray[0];
@@ -117,8 +122,22 @@
 				$feature->properties["namespace"] = $namespaceArray[0];
 				$feature->properties["metadataLink"] = $mdLinkArray["href"];
 				$feature->properties["datasetFeedLink"] = $dsLinkArray["href"];
-				$feature->geometry = new geoRSSPolygon();
-				$feature->geometry->parsePolygon($bboxArray[0]);
+				//check if polygon is given			
+				if (isset($polygonArray[0]) && $polygonArray[0] != '') {
+					$feature->geometry = new geoRSSPolygon();
+					$feature->geometry->parsePolygon($polygonArray[0]);
+				} else { //maybe bbox is given 
+					if (isset($bboxArray[0]) && $bboxArray[0] != '') {
+						$feature->geometry = new geoRSSBox();
+						$feature->geometry->targetEPSG = '4326';
+						$feature->geometry->parseBox($bboxArray[0]);
+					} else {
+						//set dummy extent - maybe the one of the first feed
+						$feature->geometry = null;
+						
+					}
+					
+				}
 				//$feature->geometry->targetEPSG = "EPSG:4326";
 				if (isset($feature->geometry) && $feature->geometry!==false) {
 					$featureCollection->addFeature($feature);
@@ -160,9 +179,9 @@
 			$feedXML->registerXPathNamespace("defaultns", "http://www.w3.org/2005/Atom");
 
 			$title = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:title');
-
-
-			$bbox = $feedXML->xpath('/defaultns:feed/defaultns:entry/georss:polygon');
+			$content = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:content');
+			$polygon = $feedXML->xpath('/defaultns:feed/defaultns:entry/georss:polygon');
+			$bbox = $feedXML->xpath('/defaultns:feed/defaultns:entry/georss:box');
 			//$link = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'section\')]/@bbox');
 			//$datasetFeedLink = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'alternate\')]/@href');
 			//new feature collection
@@ -172,29 +191,42 @@
 				$uuid = new Uuid;
 				$feature->fid = $uuid;
 				
-				$entry = $feedXML->xpath('/defaultns:feed/defaultns:entry');
+				$links = $feedXML->xpath('/defaultns:feed/defaultns:entry['.(string)($i + 1).']/defaultns:link');
 
 				$titleArray = (array)$title[$i];
+				$contentArray = (array)$content[$i];
 				$bboxArray = (array)$bbox[$i];
+				$polygonArray = (array)$polygon[$i];
 				$mdLinkArray = (array)$metadataLink[$i];
 				$mdLinkArray = $mdLinkArray["@attributes"];
 				$dsLinkArray = (array)$datasetFeedLink[$i];
 				$dsLinkArray = $dsLinkArray["@attributes"];
 				$feature->properties["title"] = $titleArray[0];
+				$feature->properties["content"] = $contentArray[0];
 				$feature->properties["metadataLink"] = $mdLinkArray["href"];
 				$feature->properties["datasetFeedLink"] = $dsLinkArray["href"];
-				$feature->properties["entry"] = array();
-				for ($j=0; $j<=(count($entry)-1); $j++) {
-					$feature->properties["entry"][$j] = $entry[$j];
+				//$feature->properties["entry"] = array();			
+				if (isset($polygonArray[0]) && $polygonArray[0] != '') {
+					$feature->geometry = new geoRSSPolygon();
+					$feature->geometry->parsePolygon($polygonArray[0]);
+				} else { //maybe bbox is given 
+					if (isset($bboxArray[0]) && $bboxArray[0] != '') {
+						$feature->geometry = new geoRSSBox();
+						$feature->geometry->targetEPSG = '4326';
+						$feature->geometry->parseBox($bboxArray[0]);
+					} else {
+						//set dummy extent - maybe the one of the first feed
+						$feature->geometry = null;
+						
+					}
+					
 				}
-				$link = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'section\')]/@bbox');
-				$feature->geometry = new geoRSSPolygon();
-				$e = new mb_notice("mod_downloadFeedServer.php: bboxArray[0]: ".$bboxArray[0]);
-				if (!isset($bboxArray[0]) || $bboxArray[0] == "") {
-					$feature->geometry = null;
-				} else {
-					$feature->geometry->parsePolygon($bboxArray[0]);
+				//extract all links
+				for ($j=0; $j<=(count($links)-1); $j++) {
+					$feature->properties["link"][$j] = $links[$j];
 				}
+				//$link = $feedXML->xpath('/defaultns:feed/defaultns:entry/defaultns:link[contains(@rel,\'section\')]/@bbox');
+				//check if polygon is given
 				
 				//$feature->geometry->targetEPSG = "EPSG:4326";
 				//set geometry to null if geometry is not given!

Modified: trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po
===================================================================
--- trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po	2012-08-27 13:48:29 UTC (rev 8471)
+++ trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po	2012-08-28 10:41:45 UTC (rev 8472)
@@ -3561,7 +3561,7 @@
 msgid "Search for addresses"
 msgstr "Suche nach Adressen"
 
-#plugins/mod_downloadFeedClient.php
+#: ../plugins/mod_downloadFeedClient.php
 msgid "INSPIRE ATOM Feed Client"
 msgstr "INSPIRE ATOM Feed Client"
 
@@ -3583,5 +3583,3 @@
 msgid "Select to download dataset"
 msgstr "Auswahl zum Download"
 
-
-



More information about the Mapbender_commits mailing list