[Mapbender-commits] r8589 - in trunk/mapbender/http: geoportal php plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Mar 26 08:03:39 PDT 2013
Author: armin11
Date: 2013-03-26 08:03:39 -0700 (Tue, 26 Mar 2013)
New Revision: 8589
Modified:
trunk/mapbender/http/geoportal/mod_pullInspireMonitoring.php
trunk/mapbender/http/php/mod_getDownloadOptions.php
trunk/mapbender/http/php/mod_showMetadata.php
trunk/mapbender/http/plugins/mod_jsonAutocompleteGazetteer.php
Log:
Bugfixes and a possibility to pull INSPIRE Monitoring information out of the mapbender database.
Modified: trunk/mapbender/http/geoportal/mod_pullInspireMonitoring.php
===================================================================
--- trunk/mapbender/http/geoportal/mod_pullInspireMonitoring.php 2013-03-20 07:13:04 UTC (rev 8588)
+++ trunk/mapbender/http/geoportal/mod_pullInspireMonitoring.php 2013-03-26 15:03:39 UTC (rev 8589)
@@ -16,20 +16,32 @@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once dirname(__FILE__)."/../classes/class_connector.php";
+require_once dirname(__FILE__) . "/../classes/class_Uuid.php";
$inspireCatId = 11;
$outputFormat = 'json';
$lang = 'de';
$registratingDepartments = null;
+$exportObjects = null;
//check http get parameters
if (isset($_REQUEST["outputFormat"]) & $_REQUEST["outputFormat"] != "") {
$testMatch = $_REQUEST["outputFormat"];
- if (!($testMatch == 'json' or $testMatch == 'table')){
+ if (!($testMatch == 'json' or $testMatch == 'monitoring' or $testMatch == 'table')){
echo 'outputFormat: is not valid.<br/>';
die();
}
$outputFormat = $testMatch;
$testMatch = NULL;
}
+if (isset($_REQUEST["exportObjects"]) & $_REQUEST["exportObjects"] != "") {
+ $testMatch = $_REQUEST["exportObjects"];
+ if (!($testMatch == 'datasets' or $testMatch == 'services' or $testMatch == 'organizations')){
+ echo 'outputFormat: is not valid.<br/>';
+ die();
+ }
+ $exportObjects = $testMatch;
+ $testMatch = NULL;
+}
if (isset($_REQUEST["registratingDepartments"]) & $_REQUEST["registratingDepartments"] != "") {
//validate to csv integer list
$testMatch = $_REQUEST["registratingDepartments"];
@@ -65,11 +77,11 @@
//The classifications of the layers are used to decide if the resource is in the outgoing table.
$sql = <<<SQL
-select metadata_layer.title, metadata_layer.uuid, resource_id, resource_type, service_id, inspire_download, wms_owner as service_owner, fkey_mb_group_id as service_group, wms_title as service_title, f_collect_inspire_cat_layer(resource_id) as inspire_cat from (select title,uuid, layer_id as resource_id, 'layer' as resource_type, fkey_wms_id as service_id, inspire_download from (select layer.layer_id, layer.fkey_wms_id, layer.inspire_download, layer_custom_category.fkey_custom_category_id from layer inner join layer_custom_category on layer.layer_id = layer_custom_category.fkey_layer_id where layer_custom_category.fkey_custom_category_id = $inspireCatId AND layer_searchable = 1 ORDER BY layer_id) as layer_inspire inner join (select metadata_id, uuid, title, fkey_layer_id from mb_metadata inner join ows_relation_metadata on ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id) as metadata_relation on metadata_relation.fkey_layer_id = layer_inspire.layer_id) as meta
data_layer INNER JOIN wms ON metadata_layer.service_id = wms_id
+select metadata_layer.title, wms.uuid as service_uuid, wms_title || ':' || layer_title as inspire_service_title, metadata_layer.uuid, metadata_layer.datasetid, metadata_layer.datasetid_codespace, resource_id, resource_uuid, resource_type, service_id, inspire_download, wms_owner as service_owner, fkey_mb_group_id as service_group, wms_title as service_title, f_collect_inspire_cat_layer(resource_id) as inspire_cat from (select title, uuid, datasetid, datasetid_codespace, layer_id as resource_id, 'layer' as resource_type, fkey_wms_id as service_id, inspire_download, layer_title, resource_uuid from (select layer.layer_id, layer.layer_title, layer.fkey_wms_id, layer.uuid as resource_uuid, layer.inspire_download, layer_custom_category.fkey_custom_category_id from layer inner join layer_custom_category on layer.layer_id = layer_custom_category.fkey_layer_id where layer_custom_category.fkey_custom_category_id = $inspireCatId AND layer_searchable = 1 ORDER BY layer_id) as layer_inspi
re inner join (select metadata_id, datasetid, datasetid_codespace, uuid, title, fkey_layer_id from mb_metadata inner join ows_relation_metadata on ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id) as metadata_relation on metadata_relation.fkey_layer_id = layer_inspire.layer_id) as metadata_layer INNER JOIN wms ON metadata_layer.service_id = wms_id
union
-select metadata_featuretype.title, metadata_featuretype.uuid, resource_id, resource_type, service_id, inspire_download, wfs_owner as service_owner, fkey_mb_group_id as service_group, wfs_title as service_title, f_collect_inspire_cat_wfs_featuretype(resource_id) as inspire_cat from (select title, uuid, featuretype_id as resource_id, 'wfs_featuretype' as resource_type, fkey_wfs_id as service_id, inspire_download from (select wfs_featuretype.featuretype_id ,wfs_featuretype.fkey_wfs_id, wfs_featuretype.inspire_download from wfs_featuretype) as featuretype_inspire inner join (select metadata_id, uuid, title, fkey_featuretype_id from mb_metadata inner join ows_relation_metadata on ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id) as metadata_relation on metadata_relation.fkey_featuretype_id = featuretype_inspire.featuretype_id) as metadata_featuretype INNER JOIN wfs ON metadata_featuretype.service_id = wfs_id
+select metadata_featuretype.title, wfs.uuid as service_uuid, wfs_title || ':' || featuretype_title as inspire_service_title, metadata_featuretype.uuid, metadata_featuretype.datasetid, metadata_featuretype.datasetid_codespace, resource_id, resource_uuid, resource_type, service_id, inspire_download, wfs_owner as service_owner, fkey_mb_group_id as service_group, wfs_title as service_title, f_collect_inspire_cat_wfs_featuretype(resource_id) as inspire_cat from (select title, uuid, datasetid, datasetid_codespace, featuretype_id as resource_id, 'wfs_featuretype' as resource_type, resource_uuid, fkey_wfs_id as service_id, inspire_download, featuretype_title from (select wfs_featuretype.featuretype_id , wfs_featuretype.featuretype_title, wfs_featuretype.fkey_wfs_id, wfs_featuretype.inspire_download, wfs_featuretype.uuid as resource_uuid from wfs_featuretype) as featuretype_inspire inner join (select metadata_id, datasetid, datasetid_codespace, uuid, title, fkey_featuretype_id from
mb_metadata inner join ows_relation_metadata on ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id) as metadata_relation on metadata_relation.fkey_featuretype_id = featuretype_inspire.featuretype_id) as metadata_featuretype INNER JOIN wfs ON metadata_featuretype.service_id = wfs_id
order by uuid
SQL;
@@ -83,12 +95,27 @@
$sqlTable['uuid'][] = $row['uuid'];
$sqlTable['title'][] = $row['title'];
$sqlTable['service_id'][] = $row['service_id'];
+ $sqlTable['service_uuid'][] = $row['service_uuid'];
+ $sqlTable['service_title'][] = $row['inspire_service_title'];
$sqlTable['resource_type'][] = $row['resource_type'];
$sqlTable['resource_id'][] = $row['resource_id'];
+ $sqlTable['resource_uuid'][] = $row['resource_uuid'];
$sqlTable['service_group'][] = $row['service_group'];
$sqlTable['service_owner'][] = $row['service_owner'];
$sqlTable['inspire_cat'][] = replaceCategories($row['inspire_cat'], $inspireCategories);
- $sqlTable['inspire_download'][] = $row['inspire_download'];
+ $sqlTable['inspire_cat_monitoring'][] = replaceCategoriesList($row['inspire_cat']);
+ $sqlTable['inspire_download'][] = $row['inspire_download'];
+ //extract datasetid
+ if (isset($row['datasetid']) && $row['datasetid'] != '') {
+ if (isset($row['datasetid_codespace']) && $row['datasetid_codespace'] != '') {
+ $sqlTable['datasetid'][] = $row['datasetid_codespace']."#".$row['datasetid'];
+ } else {
+ $sqlTable['datasetid'][] = $row['datasetid'];
+ }
+ //$sqlTable['datasetid'][] = "test";
+ } else {
+ $sqlTable['datasetid'][] = METADATA_DEFAULT_CODESPACE.'#'.$row['uuid'];
+ }
}
$groupOwnerArray = array();
$groupOwnerArray[0] = $sqlTable['service_group'];
@@ -103,77 +130,458 @@
$sqlTable['organization'] = $groupOwnerArray[3];
//$sqlTable['userId'] = $groupOwnerArray[2];
$sqlTable['orgaId'] = $groupOwnerArray[4];
+$sqlTable['orgaEmail'] = $groupOwnerArray[5];
+$sqlTable['adminCode'] = $groupOwnerArray[6];
//TODO: check sorting
//$wfsMatrix = $this->flipDiagonally($wfsMatrix); //- see class_metadata_new.php
//array_multisort($sqlTable['uuid'], SORT_STRING);
//array_multisort($sqlTable['uuid'], SORT_STRING, $sqlTable['resource_type'], SORT_STRING);
//debug output option:
-if ($outputFormat == 'table') {
+
+switch ($outputFormat) {
+ case 'table':
for ($i=0; $i < count($sqlTable['uuid']); $i++){
- echo $sqlTable['uuid'][$i]." - ".$sqlTable['title'][$i]." - ".$sqlTable['resource_type'][$i]." - ".$sqlTable['resource_id'][$i]." - ".$groupOwnerArray[3][$i]." - ".$sqlTable['inspire_cat'][$i]." - ".$sqlTable['organization'][$i]." - ".$sqlTable['orgaId'][$i]."<br>";
+ $rowString = "";
+ $rowString .= $sqlTable['datasetid'][$i]."|".$sqlTable['title'][$i]."|".$sqlTable['organization'][$i]."|".$sqlTable['orgaEmail'][$i]."|"."|"."|";
+ //metadata exists
+ $rowString .= "[X]|";
+ //uuid metadata set
+ $rowString .= "".$sqlTable['uuid'][$i]."|";
+ //conformancy of metadata with regulation
+ $rowString .= "[X]|";
+ //availability of metadata via csw
+ $rowString .= "[X]|";
+ //existence of view service always
+ $rowString .= "[X]|";
+ //id of viewservice
+ //use layerid and some other things - problem there are more than one result for each metadata entry!
+ $rowString .= "".$sqlTable['resource_id'][$i]."|";
+ //existence of download service
+ $rowString .= "[X]|";
+ //id of downloadservice
+ //use downloadservice id - use webservice
+ $rowString .= "".$sqlTable['resource_id'][$i]."|";
+ //check if data is harmonized - no
+ $rowString .= "|";
+ //add list with inspire themes
+
+ //comment
+ $rowString .= "|";
+ $rowString .= "<br>";
+ echo $rowString;
+
}
-} else {
- //normal output as json
- $metadataIndex = -1;
- $currentUuid = "";
- $output = array(
- "aaData" => array()
- );
- for ($i=0; $i < count($sqlTable['uuid']); $i++){
- //filter for orga_id
- //generate entry only if orga_id is the same as expected
- if (!$registratingDepartments || ($registratingDepartments != null && in_array($groupOwnerArray[4][$i],explode(',',$registratingDepartments)))) {
- if ($sqlTable['uuid'][$i] != $currentUuid) {
- //new metadataset identified - initialize it
- $currentUuid = $sqlTable['uuid'][$i];
- $metadataIndex++;
- $output['aaData'][$metadataIndex]->detailImage = "<img id=\"expander\" src=\"../img/gnome/stock_zoom-in.png\">";
- $output['aaData'][$metadataIndex]->title = $sqlTable['title'][$i];
- $output['aaData'][$metadataIndex]->uuid = $sqlTable['uuid'][$i];
- $output['aaData'][$metadataIndex]->organization = $sqlTable['organization'][$i];
- $insCat = '';
- $output['aaData'][$metadataIndex]->inspireCategories = '';
- $output['aaData'][$metadataIndex]->numberViewServices = 0;
- $output['aaData'][$metadataIndex]->numberDownloadServices = 0;
+ die();
+ break;
+ case 'monitoring':
+ $metadataIndex = -1;
+ $serviceIndex = 0;
+ $orgaIndex = 0;
+ $alreadyBuildDls = array();
+ $alreadyReadOrgas = array();
+ $currentUuid = "";
+ $inspireMonitoring = array(
+ "datasets" => array(),
+ "services" => array(),
+ "organizations" => array()
+ );
+
+ for ($i=0; $i < count($sqlTable['uuid']); $i++){
+ //filter for orga_id
+ //generate entry only if orga_id is the same as expected
+ if (!$registratingDepartments || ($registratingDepartments != null && in_array($groupOwnerArray[4][$i],explode(',',$registratingDepartments)))) {
+ if ($sqlTable['uuid'][$i] != $currentUuid) {
+ //new metadataset identified - initialize it
+ $currentUuid = $sqlTable['uuid'][$i];
+ $metadataIndex++;
+ $e = new mb_exception("index: ".$metadataIndex);
+ $inspireMonitoring['datasets'][$metadataIndex]->datasetid = $sqlTable['datasetid'][$i];
+ $inspireMonitoring['datasets'][$metadataIndex]->title = $sqlTable['title'][$i];
+
+ $inspireMonitoring['datasets'][$metadataIndex]->organization = $sqlTable['organization'][$i];
+ $inspireMonitoring['datasets'][$metadataIndex]->orgaEmail = $sqlTable['orgaEmail'][$i];
+ $inspireMonitoring['datasets'][$metadataIndex]->relevantArea = "";
+ $inspireMonitoring['datasets'][$metadataIndex]->actualArea = "";
+ $inspireMonitoring['datasets'][$metadataIndex]->metadataExists = "[X]";
+ $inspireMonitoring['datasets'][$metadataIndex]->uuid = $sqlTable['uuid'][$i];
+ //metadata conform
+ $inspireMonitoring['datasets'][$metadataIndex]->metadataConform = "[X]";
+ //metadata available
+ $inspireMonitoring['datasets'][$metadataIndex]->metadataAvailable = "[X]";
+ $inspireMonitoring['datasets'][$metadataIndex]->viewServiceAvailable = "";
+ $inspireMonitoring['datasets'][$metadataIndex]->viewServiceId = "";
+ $inspireMonitoring['datasets'][$metadataIndex]->downloadServiceAvailable = "";
+ $inspireMonitoring['datasets'][$metadataIndex]->downloadServiceId = "";
+ $inspireMonitoring['datasets'][$metadataIndex]->datasetConform = "";
+ $insCat = '';
+ $inspireMonitoring['datasets'][$metadataIndex]->inspireCategories = '';
+ $inspireMonitoring['datasets'][$metadataIndex]->numberViewServices = 0;
+ $inspireMonitoring['datasets'][$metadataIndex]->numberDownloadServices = 0;
+ $inspireMonitoring['datasets'][$metadataIndex]->report = "";
+ $inspireMonitoring['datasets'][$metadataIndex]->comment = "";
+ }
+ if ($metadataIndex > -1) { //prohibit indexes which are not real - otherwise the json array will become an object
+ //build view service
+ $e = new mb_exception("resource type: ".$sqlTable['resource_type'][$i]." - uuid: ".$sqlTable['uuid'][$i]);
+ if ($sqlTable['resource_type'][$i] == "layer") {
+ //addview view service
+ $inspireMonitoring['services'][$serviceIndex]->id = $sqlTable['resource_uuid'][$i];
+ //name
+ $inspireMonitoring['services'][$serviceIndex]->name = $sqlTable['service_title'][$i];
+ //typ
+ $inspireMonitoring['services'][$serviceIndex]->type = "Darstellungsdienst";
+ //url
+ $inspireMonitoring['services'][$serviceIndex]->url = MAPBENDER_PATH."/php/wms.php?layer_id=".$sqlTable['resource_id'][$i]."&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS&INSPIRE=1";
+ //orga
+ $inspireMonitoring['services'][$serviceIndex]->organization = $sqlTable['organization'][$i];
+ //orga email
+ $inspireMonitoring['services'][$serviceIndex]->orgaEmail = $sqlTable['orgaEmail'][$i];
+ //metadata exists
+ $inspireMonitoring['services'][$serviceIndex]->metadataExists = "[X]";
+ //service uuid - view/download difference
+ $inspireMonitoring['services'][$serviceIndex]->serviceUuid = $sqlTable['resource_uuid'][$i];
+ //metadata conform
+ $inspireMonitoring['services'][$serviceIndex]->metadataConform = "[X]";
+ //metadata available
+ $inspireMonitoring['services'][$serviceIndex]->metadataAvailable = "[X]";
+ //service conform
+ $inspireMonitoring['services'][$serviceIndex]->serviceConform = "[X]";
+ //requests per day
+ $inspireMonitoring['services'][$serviceIndex]->requestsPerDay = 0;
+ //comment
+ $inspireMonitoring['services'][$serviceIndex]->report = "";
+ //report
+ $inspireMonitoring['services'][$serviceIndex]->comment = "";
+ //get inspire categories
+ $catString = $sqlTable['inspire_cat_monitoring'][$i];
+ $insCat .= $sqlTable['inspire_cat_monitoring'][$i];
+ if ($insCat != '') {
+ $insCat .= ",";
+ }
+ //increment amount of view services
+
+ /*if ($sqlTable['inspire_download'][$i] == 1) {
+ //add further inspire_download service element for this layer
+ //increment amount of view services
+ $output['aaData'][$metadataIndex]->numberDownloadServices++;
+ }*/
+ $inspireMonitoring['datasets'][$metadataIndex]->numberViewServices++;
+ $serviceIndex++;
+ //Add view service to dataset list
+ $inspireMonitoring['datasets'][$metadataIndex]->viewServiceId = $sqlTable['resource_uuid'][$i];
+
+
+ }
+ $e = new mb_exception("generate downloadservice");
+ if (!in_array($sqlTable['uuid'][$i],$alreadyBuildDls)) {
+ //initialize array of uuids which are already tested for downloadservices!
+ //the options are all the same for one single metadata uuid - therefor this has only to be done once for a uuid!
+ //the service information is pulled from the first organization - TODO - maybe change this?
+
+ //build download services
+ //get download options
+ //Pull download options for specific dataset from mapbender database and show them
+ $downloadOptionsConnector = new connector("http://localhost".$_SERVER['SCRIPT_NAME']."/../../php/mod_getDownloadOptions.php?id=".$sqlTable['uuid'][$i]);
+ $e = new mb_exception("download options: ".$downloadOptionsConnector->file);
+ $downloadOptions = json_decode($downloadOptionsConnector->file);
+ if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != '') {
+ $mapbenderUrl = MAPBENDER_PATH;
+ } else {
+ $mapbenderUrl = "http://www.geoportal.rlp.de/mapbender";
+ }
+ if ($downloadOptions != null) {
+ $mdUuid = $sqlTable['uuid'][$i];
+ $alreadyBuildDls[] = $mdUuid;
+ foreach ($downloadOptions->{$mdUuid}->option as $option) {
+ //create download service entries
+ //create ids for download services on the fly
+ //How to generate UUIDs for INSPIRE Download Service Metadata records (not really needed for INSPIRE!!! See DB Metadaten)
+ //12-4-4-4-8
+ //dataurl
+ //WMS uuid (12-4), Type (4) - 0001, MD uuid (4-8)
+ //wfs
+ //WFS uuid (12-4), MD uuid (4-4-8)
+ //wmsgetmap
+ //WMS uuid (12-4), Type (4) - 0002, MD uuid (4-8)
+ //
+ if (isset($sqlTable['service_uuid'][$i]) && $sqlTable['service_uuid'][$i] != '' ) { //TODO - don't use service uuids from table but from options!
+ //TODO - what to do if metadata id is no uuid?????
+ $uuid = new Uuid();
+ $uuidTest = $uuid->isuuid($mdUuid);
+
+ if ($uuidTest) {
+ $mdPart = explode('-',$mdUuid);
+ $e = new mb_exception("is uuid");
+ } else {
+ $e = new mb_exception("is not uuid");
+ $mdPart = array();
+ $mdPart[2] = substr($mdUuid,-12,-8);
+ $mdPart[3] = substr($mdUuid,-4);
+ }
+ $servicePart = explode('-',$option->serviceUuid);
+ //$mdPart = explode('-',$mdUuid);
+ switch ($option->type) {
+ case "wmslayergetmap":
+ $dlsFileIdentifier = $servicePart[0]."-".$servicePart[1]."-"."0002"."-".$mdPart[3]."-".$mdPart[4];
+ $capUrl = $mapbenderUrl."/php/mod_inspireDownloadFeed.php?id=".$sqlTable['uuid'][$i]."&type=SERVICE&generateFrom=wmslayer&layerid=".$option->resourceId;
+ break;
+ case "wmslayerdataurl":
+ $dlsFileIdentifier = $servicePart[0]."-".$servicePart[1]."-"."0001"."-".$mdPart[3]."-".$mdPart[4];
+ $capUrl = $mapbenderUrl."/php/mod_inspireDownloadFeed.php?id=".$sqlTable['uuid'][$i]."&type=SERVICE&generateFrom=dataurl&layerid=".$option->resourceId;
+ break;
+ case "wfsrequest":
+ $dlsFileIdentifier = $servicePart[0]."-".$servicePart[1]."-".$mdPart[2]."-".$mdPart[3]."-".$mdPart[4];
+ $capUrl = $mapbenderUrl."/php/mod_inspireDownloadFeed.php?id=".$sqlTable['uuid'][$i]."&type=SERVICE&generateFrom=wfs&wfsid=".$option->serviceId;
+ break;
+ }
+
+ } else {
+ $dlsFileIdentifier = "no id found - please check if services have uuids or generate new ones!";
+ }
+ //generate the rest of the service element
+ //addview view service
+ $inspireMonitoring['services'][$serviceIndex]->id = $dlsFileIdentifier;
+ //name
+ $inspireMonitoring['services'][$serviceIndex]->name = $sqlTable['service_title'][$i];
+ //typ
+ $inspireMonitoring['services'][$serviceIndex]->type = "Download-Dienst";
+ //url
+ $inspireMonitoring['services'][$serviceIndex]->url = $capUrl;
+ //orga
+ $inspireMonitoring['services'][$serviceIndex]->organization = $sqlTable['organization'][$i];
+ //orga email
+ $inspireMonitoring['services'][$serviceIndex]->orgaEmail = $sqlTable['orgaEmail'][$i];
+ //metadata exists
+ $inspireMonitoring['services'][$serviceIndex]->metadataExists = "[X]";
+ //service uuid - view/download difference
+ $inspireMonitoring['services'][$serviceIndex]->serviceUuid = $dlsFileIdentifier;
+ //metadata conform
+ $inspireMonitoring['services'][$serviceIndex]->metadataConform = "[X]";
+ //metadata available
+ $inspireMonitoring['services'][$serviceIndex]->metadataAvailable = "[X]";
+ //service conform
+ $inspireMonitoring['services'][$serviceIndex]->serviceConform = "[X]";
+ //requests per day
+ $inspireMonitoring['services'][$serviceIndex]->requestsPerDay = 0;
+ //comment
+ $inspireMonitoring['services'][$serviceIndex]->report = "";
+ //report
+ $inspireMonitoring['services'][$serviceIndex]->comment = "";
+ $inspireMonitoring['datasets'][$metadataIndex]->numberDownloadServices++;
+ $serviceIndex++;
+ //add download service to dataset list
+ $inspireMonitoring['datasets'][$metadataIndex]->downloadServiceId = $dlsFileIdentifier;
+
+ }
+ }
+ }
+ $e = new mb_exception("generate organization entry");
+ if (!in_array($sqlTable['organization'][$i],$alreadyReadOrgas)) {
+ $alreadyReadOrgas[] = $sqlTable['organization'][$i];
+ $inspireMonitoring['organizations'][$orgaIndex]->id = $sqlTable['orgaId'][$i];
+ $inspireMonitoring['organizations'][$orgaIndex]->name = $sqlTable['organization'][$i];
+ switch ($sqlTable['adminCode'][$i]) {
+ case "NUTS 1":
+ $inspireMonitoring['organizations'][$orgaIndex]->adminLevel = "Land";
+ break;
+ case "NUTS 2":
+ $inspireMonitoring['organizations'][$orgaIndex]->adminLevel = "Regierungsbezirk";
+ break;
+ case "NUTS 3":
+ $inspireMonitoring['organizations'][$orgaIndex]->adminLevel = "Landkreis";
+ break;
+ case "LAU 1":
+ $inspireMonitoring['organizations'][$orgaIndex]->adminLevel = "Verbandsgemeinde/Stadt";
+ break;
+ case "LAU 2":
+ $inspireMonitoring['organizations'][$orgaIndex]->adminLevel = "Gemeinde";
+ break;
+ default:
+ $inspireMonitoring['organizations'][$orgaIndex]->adminLevel = "Andere";
+ break;
+ }
+
+ $orgaIndex++;
+ }
+ if ($sqlTable['resource_type'][$i] == "wfs_featuretype" && $sqlTable['inspire_download'][$i] == "1") {
+ //add download service element
+ //$output['aaData'][$metadataIndex]->numberDownloadServices++;
+ $insCat .= $sqlTable['inspire_cat_monitoring'][$i];
+ if ($insCat != '') {
+ $insCat .= ",";
+ }
+ //$output['aaData'][$metadataIndex]->downloadServices[]->id = $sqlTable['resource_id'][$i];
+ }
+ //reduce categories if there are double entries
+ $arrayInspireCategories = array_unique(explode(',',(rtrim($insCat,','))));
+ for ($j=0; $j < 34; $j++) {
+ $catId = $j+1;
+ if (in_array($catId,$arrayInspireCategories)) {
+ $arrayInspireCat[$j] = "[X]";
+ } else {
+ $arrayInspireCat[$j] = "";
+ }
+ }
+ $inspireMonitoring['datasets'][$metadataIndex]->inspireCategories = $arrayInspireCat;
+ //set view and downloadservice information
+ if ($inspireMonitoring['datasets'][$metadataIndex]->numberViewServices > 0) {
+ $inspireMonitoring['datasets'][$metadataIndex]->viewServiceAvailable = "[X]";
+ }
+ if ($inspireMonitoring['datasets'][$metadataIndex]->numberDownloadServices > 0) {
+ $inspireMonitoring['datasets'][$metadataIndex]->downloadServiceAvailable = "[X]";
+ }
+
+
+ }
}
- if ($metadataIndex > -1) { //prohibit indexes which are not real - otherwise the json array will become an object
- if ($sqlTable['resource_type'][$i] == "layer") {
- //addview service element
- $output['aaData'][$metadataIndex]->viewServices[]->id = $sqlTable['resource_id'][$i];
- $catString = $sqlTable['inspire_cat'][$i];
- $insCat .= $sqlTable['inspire_cat'][$i];
- if ($insCat != '') {
- $insCat .= ",";
+ }
+ if (isset($exportObjects) && $exportObjects != null) {
+ //echo "export ".$exportObjects;
+ switch ($exportObjects) {
+ case "datasets":
+ $html = "";
+ foreach ($inspireMonitoring["datasets"] as $entry) {
+ $row = "";
+ $row .= $entry->datasetid."|";
+ $row .= $entry->title."|";
+ $row .= $entry->organization."|";
+ $row .= $entry->orgaEmail."|";
+ $row .= $entry->relevantArea."|";
+ $row .= $entry->actualArea."|";
+ $row .= $entry->metadataExists."|";
+ $row .= $entry->uuid."|";
+ $row .= $entry->metadataConform."|";
+ $row .= $entry->metadataAvailable."|";
+ $row .= $entry->viewServiceAvailable."|";
+ $row .= $entry->viewServiceId."|";
+ $row .= $entry->downloadServiceAvailable."|";
+ $row .= $entry->downloadServiceId."|";
+ $row .= $entry->datasetConform."|";
+ foreach ($entry->inspireCategories as $category) {
+ $row .= $category."|";
+ }
+ $row .= $entry->report."|";
+ $row .= $entry->comment;
+ $row .= "\r\n";
+ $html .= $row;
}
- //increment amount of view services
- $output['aaData'][$metadataIndex]->numberViewServices++;
- if ($sqlTable['inspire_download'][$i] == 1) {
- //add further inspire_download service element for this layer
+ header('Content-type: application/octetstream');
+ //header('Content-Length: ' . filesize($html));
+ header('Content-Disposition: attachment; filename="datasets.csv"');
+ echo $html;
+ break;
+ case "services":
+ $html = "";
+ foreach ($inspireMonitoring["services"] as $entry) {
+ $row = "";
+ $row .= $entry->id."|";
+ $row .= $entry->name."|";
+ $row .= $entry->type."|";
+ $row .= $entry->url."|";
+ $row .= $entry->organization."|";
+ $row .= $entry->orgaEmail."|";
+ $row .= $entry->metadataExists."|";
+ $row .= $entry->serviceUuid."|";
+ $row .= $entry->metadataConform."|";
+ $row .= $entry->metadataAvailable."|";
+ $row .= $entry->serviceConform."|";
+ $row .= $entry->requestsPerDay."|";
+ $row .= $entry->report."|";
+ $row .= $entry->comment;
+ $row .= "\r\n";
+ $html .= $row;
+ }
+ header('Content-type: application/octetstream');
+ //header('Content-Length: ' . filesize($html));
+ header('Content-Disposition: attachment; filename="services.csv"');
+ echo $html;
+ break;
+ case "organizations":
+ $html = "";
+ foreach ($inspireMonitoring["organizations"] as $entry) {
+ $row = "";
+ $row .= $entry->id."|";
+ $row .= $entry->name."|";
+ $row .= $entry->adminLevel;
+ $row .= "\r\n";
+ $html .= $row;
+ }
+ header('Content-type: application/octetstream');
+ //header('Content-Length: ' . filesize($html));
+ header('Content-Disposition: attachment; filename="organizations.csv"');
+ echo $html;
+ break;
+ }
+ } else {
+ //give away all information as json
+ header('Content-Type: application/json; charset='.CHARSET);
+ echo json_encode($inspireMonitoring, JSON_NUMERIC_CHECK);
+ }
+ break;
+ default:
+ //normal output as json
+ $metadataIndex = -1;
+ $currentUuid = "";
+ $output = array(
+ "aaData" => array()
+ );
+ for ($i=0; $i < count($sqlTable['uuid']); $i++){
+ //filter for orga_id
+ //generate entry only if orga_id is the same as expected
+ if (!$registratingDepartments || ($registratingDepartments != null && in_array($groupOwnerArray[4][$i],explode(',',$registratingDepartments)))) {
+ if ($sqlTable['uuid'][$i] != $currentUuid) {
+ //new metadataset identified - initialize it
+ $currentUuid = $sqlTable['uuid'][$i];
+ $metadataIndex++;
+ $output['aaData'][$metadataIndex]->detailImage = "<img id=\"expander\" src=\"../img/gnome/stock_zoom-in.png\">";
+ $output['aaData'][$metadataIndex]->title = $sqlTable['title'][$i];
+ $output['aaData'][$metadataIndex]->uuid = $sqlTable['uuid'][$i];
+ $output['aaData'][$metadataIndex]->organization = $sqlTable['organization'][$i];
+ $insCat = '';
+ $output['aaData'][$metadataIndex]->inspireCategories = '';
+ $output['aaData'][$metadataIndex]->numberViewServices = 0;
+ $output['aaData'][$metadataIndex]->numberDownloadServices = 0;
+ }
+ if ($metadataIndex > -1) { //prohibit indexes which are not real - otherwise the json array will become an object
+ if ($sqlTable['resource_type'][$i] == "layer") {
+ //addview service element
+ $output['aaData'][$metadataIndex]->viewServices[]->id = $sqlTable['resource_id'][$i];
+ $catString = $sqlTable['inspire_cat'][$i];
+ $insCat .= $sqlTable['inspire_cat'][$i];
+ if ($insCat != '') {
+ $insCat .= ",";
+ }
//increment amount of view services
+ $output['aaData'][$metadataIndex]->numberViewServices++;
+ if ($sqlTable['inspire_download'][$i] == 1) {
+ //add further inspire_download service element for this layer
+ //increment amount of view services
+ $output['aaData'][$metadataIndex]->numberDownloadServices++;
+ }
+ }
+ if ($sqlTable['resource_type'][$i] == "wfs_featuretype" && $sqlTable['inspire_download'][$i] == "1") {
+ //add download service element
$output['aaData'][$metadataIndex]->numberDownloadServices++;
+ $insCat .= $sqlTable['inspire_cat'][$i];
+ if ($insCat != '') {
+ $insCat .= ",";
+ }
+ //$output['aaData'][$metadataIndex]->downloadServices[]->id = $sqlTable['resource_id'][$i];
}
+ //reduce categories if there are double entries
+ $output['aaData'][$metadataIndex]->inspireCategories = implode(',',array_unique(explode(',',(rtrim($insCat,',')))));
}
- if ($sqlTable['resource_type'][$i] == "wfs_featuretype" && $sqlTable['inspire_download'][$i] == "1") {
- //add download service element
- $output['aaData'][$metadataIndex]->numberDownloadServices++;
- $insCat .= $sqlTable['inspire_cat'][$i];
- if ($insCat != '') {
- $insCat .= ",";
- }
- //$output['aaData'][$metadataIndex]->downloadServices[]->id = $sqlTable['resource_id'][$i];
- }
- //reduce categories if there are double entries
- $output['aaData'][$metadataIndex]->inspireCategories = implode(',',array_unique(explode(',',(rtrim($insCat,',')))));
}
}
- }
- header('Content-Type: application/json; charset='.CHARSET);
- echo json_encode($output, JSON_NUMERIC_CHECK);
- //$endTime = microtime();
- //$diffTime = $endTime - $startTime;
- //echo "<br>".$diffTime."<br>";
- //echo "Ready!";
+ header('Content-Type: application/json; charset='.CHARSET);
+ echo json_encode($output, JSON_NUMERIC_CHECK);
+ //$endTime = microtime();
+ //$diffTime = $endTime - $startTime;
+ //echo "<br>".$diffTime."<br>";
+ //echo "Ready!";
+ break;
}
+
function getOrganizationInfoForServices($groupOwnerArray) {
//split array into two lists which are requested in two separate sqls
$listGroupIds = array();
@@ -196,14 +604,16 @@
$listGroupIdsString = implode(",",$listGroupIds);
//do the database requests
if ($listOwnerIdsString != "") {
- $sql = "SELECT mb_group_name as metadatapointofcontactorgname, mb_group_title as metadatapointofcontactorgtitle, mb_group_id, mb_group_logo_path as metadatapointofcontactorglogo, mb_group_address as metadatapointofcontactorgaddress, mb_group_email as metadatapointofcontactorgemail, mb_group_postcode as metadatapointofcontactorgpostcode, mb_group_city as metadatapointofcontactorgcity, mb_group_voicetelephone as metadatapointofcontactorgtelephone, mb_group_facsimiletelephone as metadatapointofcontactorgfax , b.mb_user_id as mb_user_id FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id IN (".$listOwnerIdsString.") AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2";
+ $sql = "SELECT mb_group_name as metadatapointofcontactorgname, mb_group_title as metadatapointofcontactorgtitle, mb_group_id, mb_group_logo_path as metadatapointofcontactorglogo, mb_group_address as metadatapointofcontactorgaddress, mb_group_email as metadatapointofcontactorgemail, mb_group_postcode as metadatapointofcontactorgpostcode, mb_group_city as metadatapointofcontactorgcity, mb_group_voicetelephone as metadatapointofcontactorgtelephone, mb_group_facsimiletelephone as metadatapointofcontactorgfax, mb_group_admin_code , b.mb_user_id as mb_user_id FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id IN (".$listOwnerIdsString.") AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2";
$resultOrgaOwner = db_query($sql);
$index = 0;
while ($row = db_fetch_array($resultOrgaOwner)) {
//push information into metadataContactArray
$metadataContactOwnerArray[$index]['metadatapointofcontactorgname'] = $row['metadatapointofcontactorgname'];
+ $metadataContactOwnerArray[$index]['metadatapointofcontactorgemail'] = $row['metadatapointofcontactorgemail'];
$metadataContactOwnerArray[$index]['mb_user_id'] = $row['mb_user_id'];
$metadataContactOwnerArray[$index]['orga_id'] = $row['mb_group_id'];
+ $metadataContactOwnerArray[$index]['admin_code'] = $row['mb_group_admin_code'];
$index++;
}
$index = 0;
@@ -214,18 +624,22 @@
$groupOwnerArray[2][$listOwnerIdsKeys[$i]] = $metadataContactOwnerArray[$index]['user_id']; //user_id - 2
$groupOwnerArray[3][$listOwnerIdsKeys[$i]] = $metadataContactOwnerArray[$index]['metadatapointofcontactorgname']; //orga_name - 3
$groupOwnerArray[4][$listOwnerIdsKeys[$i]] = $metadataContactOwnerArray[$index]['orga_id'];
+ $groupOwnerArray[5][$listOwnerIdsKeys[$i]] = $metadataContactOwnerArray[$index]['metadatapointofcontactorgemail']; //orga_email 5
+ $groupOwnerArray[6][$listOwnerIdsKeys[$i]] = $metadataContactOwnerArray[$index]['admin_code']; // 6
}
}
//for groupList
if ($listGroupIdsString != "") {
- $sql = "SELECT mb_group_name as metadatapointofcontactorgname, mb_group_title as metadatapointofcontactorgtitle, mb_group_id, mb_group_logo_path as metadatapointofcontactorglogo, mb_group_address as metadatapointofcontactorgaddress, mb_group_email as metadatapointofcontactorgemail, mb_group_postcode as metadatapointofcontactorgpostcode, mb_group_city as metadatapointofcontactorgcity, mb_group_voicetelephone as metadatapointofcontactorgtelephone, mb_group_facsimiletelephone as metadatapointofcontactorgfax, mb_group_id FROM mb_group WHERE mb_group_id IN (".$listGroupIdsString.")";
+ $sql = "SELECT mb_group_name as metadatapointofcontactorgname, mb_group_title as metadatapointofcontactorgtitle, mb_group_id, mb_group_logo_path as metadatapointofcontactorglogo, mb_group_address as metadatapointofcontactorgaddress, mb_group_email as metadatapointofcontactorgemail, mb_group_postcode as metadatapointofcontactorgpostcode, mb_group_city as metadatapointofcontactorgcity, mb_group_voicetelephone as metadatapointofcontactorgtelephone, mb_group_facsimiletelephone as metadatapointofcontactorgfax, mb_group_id, mb_group_admin_code FROM mb_group WHERE mb_group_id IN (".$listGroupIdsString.")";
$resultOrgaGroup = db_query($sql);
$index = 0;
while ($row = db_fetch_array($resultOrgaGroup)) {
//push information into metadataContactArray
$metadataContactGroupArray[$index]['metadatapointofcontactorgname'] = $row['metadatapointofcontactorgname'];
+ $metadataContactGroupArray[$index]['metadatapointofcontactorgemail'] = $row['metadatapointofcontactorgemail'];
$metadataContactGroupArray[$index]['mb_group_id'] = $row['mb_group_id'];
$metadataContactGroupArray[$index]['orga_id'] = $row['mb_group_id'];
+ $metadataContactGroupArray[$index]['admin_code'] = $row['mb_group_admin_code'];
$index++;
}
$index = 0;
@@ -236,6 +650,8 @@
$groupOwnerArray[2][$listGroupIdsKeys[$i]] = $metadataContactGroupArray[$index]['mb_group_id']; //user_id - 2
$groupOwnerArray[3][$listGroupIdsKeys[$i]] = $metadataContactGroupArray[$index]['metadatapointofcontactorgname']; //orga_name - 3
$groupOwnerArray[4][$listGroupIdsKeys[$i]] = $metadataContactGroupArray[$index]['orga_id'];
+ $groupOwnerArray[5][$listGroupIdsKeys[$i]] = $metadataContactGroupArray[$index]['metadatapointofcontactorgemail'];
+ $groupOwnerArray[6][$listGroupIdsKeys[$i]] = $metadataContactGroupArray[$index]['admin_code'];
}
}
return $groupOwnerArray;
@@ -255,6 +671,12 @@
return $catStringNew;
}
+function replaceCategoriesList($idString){
+ $idString = str_replace('}{',',',$idString);
+ $idString = str_replace('{','',str_replace('}','',$idString));
+ return $idString;
+}
+
function findIndexInMultiDimArray($multiDimArray, $needle, $columnName) {
foreach($multiDimArray as $index => $object) {
if($object[$columnName] == $needle) return $index;
Modified: trunk/mapbender/http/php/mod_getDownloadOptions.php
===================================================================
--- trunk/mapbender/http/php/mod_getDownloadOptions.php 2013-03-20 07:13:04 UTC (rev 8588)
+++ trunk/mapbender/http/php/mod_getDownloadOptions.php 2013-03-26 15:03:39 UTC (rev 8589)
@@ -51,13 +51,28 @@
//define query to pull all download options - actually only the inspire download services based on atom feeds
+$sql = "select service_id, service_uuid, resource_id, resource_type, datalink from (
+select service_id, resource_id, service_uuid, resource_type, fkey_datalink_id as datalink from (select fkey_wms_id as service_id, layer_id as resource_id, 'layer' as resource_type, layer.uuid as service_uuid from layer inner join (select metadata_id, uuid, fkey_layer_id from mb_metadata inner join ows_relation_metadata on ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id) ";
+
+$sql .= "as metadata_relation on metadata_relation.fkey_layer_id = layer.layer_id where layer.inspire_download = 1 and metadata_relation.uuid = $1) as layer_metadata LEFT OUTER JOIN ows_relation_data ON layer_metadata.resource_id = ows_relation_data.fkey_layer_id
+) as inspire_layer inner join wms on inspire_layer.service_id = wms.wms_id ";
+
+
+$sql .= "union select fkey_wfs_id as service_id, service_uuid, featuretype_id as resource_id, 'wfs' as resource_type, NULL ";
+
+$sql .= "as datalink from (select wfs_featuretype.featuretype_id ,wfs_featuretype.fkey_wfs_id, wfs.uuid as service_uuid, wfs_featuretype.inspire_download from wfs_featuretype inner join wfs on wfs_featuretype.fkey_wfs_id = wfs.wfs_id WHERE inspire_download = 1 ORDER BY featuretype_id) as featuretype_inspire inner join (select metadata_id, uuid, fkey_featuretype_id from mb_metadata inner join ows_relation_metadata on ";
+
+$sql .= "ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id) as metadata_relation on metadata_relation.fkey_featuretype_id = featuretype_inspire.featuretype_id and metadata_relation.uuid = $1;";
+
+
+/*
$sql = "select service_id, resource_id, resource_type, fkey_datalink_id as datalink from (select fkey_wms_id as service_id, layer_id as resource_id, 'layer' as resource_type from layer inner join (select metadata_id, uuid, fkey_layer_id from mb_metadata inner join ows_relation_metadata on ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id) ";
$sql .= "as metadata_relation on metadata_relation.fkey_layer_id = layer.layer_id where layer.inspire_download = 1 and metadata_relation.uuid = $1) as layer_metadata LEFT OUTER JOIN ows_relation_data ON layer_metadata.resource_id = ows_relation_data.fkey_layer_id union select fkey_wfs_id as service_id, featuretype_id as resource_id, 'wfs' as resource_type, NULL ";
$sql .= "as datalink from (select wfs_featuretype.featuretype_id ,wfs_featuretype.fkey_wfs_id, wfs_featuretype.inspire_download from wfs_featuretype WHERE inspire_download = 1 ORDER BY featuretype_id) as featuretype_inspire inner join (select metadata_id, uuid, fkey_featuretype_id from mb_metadata inner join ows_relation_metadata on ";
-$sql .= "ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id) as metadata_relation on metadata_relation.fkey_featuretype_id = featuretype_inspire.featuretype_id and metadata_relation.uuid = $1;";
+$sql .= "ows_relation_metadata.fkey_metadata_id = mb_metadata.metadata_id) as metadata_relation on metadata_relation.fkey_featuretype_id = featuretype_inspire.featuretype_id and metadata_relation.uuid = $1;";*/
//initialize array for result
@@ -92,6 +107,7 @@
} else {
$downloadOptions->{$idList[$i]}->option[$j]->type = "wfsrequest";
$downloadOptions->{$idList[$i]}->option[$j]->serviceId = $row['service_id'];
+ $downloadOptions->{$idList[$i]}->option[$j]->serviceUuid = $row['service_uuid'];
$downloadOptions->{$idList[$i]}->option[$j]->featureType[0] = $row['resource_id'];
}
break;
@@ -102,6 +118,7 @@
$downloadOptions->{$idList[$i]}->option[$j]->type = "wmslayerdataurl";
}
$downloadOptions->{$idList[$i]}->option[$j]->serviceId = $row['service_id'];
+ $downloadOptions->{$idList[$i]}->option[$j]->serviceUuid = $row['service_uuid'];//This is a layer uuid - not a service uuid!!!!
$downloadOptions->{$idList[$i]}->option[$j]->resourceId = $row['resource_id'];
$downloadOptions->{$idList[$i]}->option[$j]->dataLink = $row['datalink'];
break;
Modified: trunk/mapbender/http/php/mod_showMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_showMetadata.php 2013-03-20 07:13:04 UTC (rev 8588)
+++ trunk/mapbender/http/php/mod_showMetadata.php 2013-03-26 15:03:39 UTC (rev 8589)
@@ -1282,10 +1282,11 @@
$filename = "qr_wmc_".$uuid.".png";
//generate qr on the fly in tmp folder
//link to invoke wmc per get api if wrapper path isset
- if (WRAPPER_PATH != "") {
- $invokeLink = $mapbenderBaseUrl."".WRAPPER_PATH."?WMC=".$resourceMetadata['contentid'];
+ if (defined("MAPBENDER_PATH") && MAPBENDER_PATH != "") {
+ $invokeLink = MAPBENDER_PATH."/extensions/mobilemap/map.php?wmcid=".$resourceMetadata['contentid'];
+ //$invokeLink = "http://www.geoportal.rlp.de/mapbender/extensions/mobilemap/map.php";
QRcode::png($invokeLink,TMPDIR."/".$filename);
- $html .= $t_a.$translation['loadWmc'].$t_b."<img src='".TMPDIR."/".$filename."'>".$t_c;
+ $html .= $t_a.$translation['loadWmc'].$t_b."<a href = '".$invokeLink."'><img src='".TMPDIR."/".$filename."'></a>".$t_c;
}
}
Modified: trunk/mapbender/http/plugins/mod_jsonAutocompleteGazetteer.php
===================================================================
--- trunk/mapbender/http/plugins/mod_jsonAutocompleteGazetteer.php 2013-03-20 07:13:04 UTC (rev 8588)
+++ trunk/mapbender/http/plugins/mod_jsonAutocompleteGazetteer.php 2013-03-26 15:03:39 UTC (rev 8589)
@@ -227,6 +227,9 @@
this.inputAddress.attr({'id':'geographicName'});
//default value
this.inputAddress.val('<?php echo _mb('Search for addresses'); ?>');
+ this.inputAddress.click(function() {
+ that.inputAddress.val('');
+ });
this.inputAddress.css('width',options.inputWidth);
$('.ui-menu').css('width','100px');
$('.ui-menu-item').css('width','100px');
More information about the Mapbender_commits
mailing list