[Mapbender-commits] r9744 - trunk/mapbender/http/geoportal

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed May 24 03:06:29 PDT 2017


Author: armin11
Date: 2017-05-24 03:06:29 -0700 (Wed, 24 May 2017)
New Revision: 9744

Modified:
   trunk/mapbender/http/geoportal/mod_showCatalogueStatistics.php
   trunk/mapbender/http/geoportal/mod_showCatalogueStatistics_server.php
Log:
New possibility to show amount of opendata classified datasets

Modified: trunk/mapbender/http/geoportal/mod_showCatalogueStatistics.php
===================================================================
--- trunk/mapbender/http/geoportal/mod_showCatalogueStatistics.php	2017-05-19 09:18:31 UTC (rev 9743)
+++ trunk/mapbender/http/geoportal/mod_showCatalogueStatistics.php	2017-05-24 10:06:29 UTC (rev 9744)
@@ -197,6 +197,9 @@
 								case "inspire":
 									searchLinkNew = searchLink+"inspireThemes="+data.data.id;
 								break;
+								case "opendata":							
+									searchLinkNew = searchLink+"restrictToOpenData=true";
+								break;
 								default:
 									searchLinkNew = searchLink;
 							}
@@ -207,7 +210,7 @@
 				});
 			} else {
 				//alert("Keine weitere Kategorisierung vorhanden!");
-				$("#dialog").append( "<p id=\"error\">Keine Kategorisierung von Datensätzen vorhanden!<br><a onclick='window.top.location.href = searchAll;'>Alle Datensätze anzeigen</a></p>" );
+				$("#dialog").append( "<p id=\"error\">Keine Kategorisierung von Datensätzen vorhanden!<br><a onclick=\"window.top.location.href = searchAll;\">Alle Datensätze anzeigen</a></p>" );
 				if (pie2 !== undefined) {
 					pie2.destroy();
 				}

Modified: trunk/mapbender/http/geoportal/mod_showCatalogueStatistics_server.php
===================================================================
--- trunk/mapbender/http/geoportal/mod_showCatalogueStatistics_server.php	2017-05-19 09:18:31 UTC (rev 9743)
+++ trunk/mapbender/http/geoportal/mod_showCatalogueStatistics_server.php	2017-05-24 10:06:29 UTC (rev 9744)
@@ -102,12 +102,6 @@
 		$e = new mb_exception("Error while request to database!");
 	}
 } else {
-	//call searchInterface for categories
-	$connector = new connector(MAPBENDER_PATH."/php/mod_callMetadata.php?searchText=e&outputFormat=json&resultTarget=categories&searchResources=wms&searchId=test&registratingDepartments=".$registratingDepartments);
-	$jsonString = $connector->file;
-	$jsonObject = json_decode($jsonString);
-	$i = 0;
-	$dataCount = 0;
 	switch ($categoryType) {
 		case "inspire":
 			$catId = 1;
@@ -119,13 +113,51 @@
 			$catId = 0;
 		break;
 	}
-	foreach ($jsonObject->searchMD->category[$catId]->subcat as $cat) {
-		$resultObj[$i]["label"] = $cat->title . " (".$cat->count.")";
-		$resultObj[$i]["value"] = $cat->count;				
-		$resultObj[$i]["caption"] = $cat->title;
-		$resultObj[$i]["id"] = $cat->id;
-		$dataCount = $dataCount + $resultObj[$i]["value"];
-		$i++;
+	if ($categoryType !== "opendata") {
+		//call searchInterface for categories
+		$connector = new connector(MAPBENDER_PATH."/php/mod_callMetadata.php?searchText=e&outputFormat=json&resultTarget=categories&searchResources=wms&searchId=test&registratingDepartments=".$registratingDepartments);
+		$jsonString = $connector->file;
+		$jsonObject = json_decode($jsonString);
+		$i = 0;
+		$dataCount = 0;
+		foreach ($jsonObject->searchMD->category[$catId]->subcat as $cat) {
+			$resultObj[$i]["label"] = $cat->title . " (".$cat->count.")";
+			$resultObj[$i]["value"] = $cat->count;				
+			$resultObj[$i]["caption"] = $cat->title;
+			$resultObj[$i]["id"] = $cat->id;
+			$dataCount = $dataCount + $resultObj[$i]["value"];
+			$i++;
+		}
+	} else {
+		//count twice - first for number of all results, second for number of opendata classified results
+		//call searchInterface
+		$connector = new connector(MAPBENDER_PATH."/php/mod_callMetadata.php?searchText=e&outputFormat=json&searchResources=wms&searchId=test&registratingDepartments=".$registratingDepartments."&maxResults=1");
+		$jsonString = $connector->file;
+		$jsonObject = json_decode($jsonString);
+		$numberOfResults = $jsonObject->wms->md->nresults;
+		$connector = new connector(MAPBENDER_PATH."/php/mod_callMetadata.php?searchText=e&outputFormat=json&searchResources=wms&searchId=test&registratingDepartments=".$registratingDepartments."&maxResults=1&restrictToOpenData=true");
+		$jsonString = $connector->file;
+		$jsonObject = json_decode($jsonString);
+		$numberOfOpenResults = $jsonObject->wms->md->nresults;
+		//define values to return
+		$dataCount = $numberOfResults;
+		if ($numberOfOpenResults == $numberOfResults) {
+			$resultObj[0]["label"] = "OpenData (100%)";
+			$resultObj[0]["value"] = $numberOfResults;				
+			$resultObj[0]["caption"] = "OpenData";
+			$resultObj[0]["id"] = 0;
+			$i = 1;
+		} else {
+			$resultObj[0]["label"] = "OpenData";
+			$resultObj[0]["value"] = $numberOfOpenResults;				
+			$resultObj[0]["caption"] = "OpenData";
+			$resultObj[0]["id"] = 0;
+			$resultObj[1]["label"] = "Keine freie Lizenz!";
+			$resultObj[1]["value"] = $numberOfResults;				
+			$resultObj[1]["caption"] = "Keine freie Lizenz!";
+			$resultObj[1]["id"] = 1;
+			$i = 2;
+		}
 	}
 	if ($i == 0) {
 		$resultObj = false;



More information about the Mapbender_commits mailing list