[Mapbender-commits] r8700 - in trunk/mapbender/http: classes php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Sep 4 06:15:47 PDT 2013


Author: armin11
Date: 2013-09-04 06:15:47 -0700 (Wed, 04 Sep 2013)
New Revision: 8700

Modified:
   trunk/mapbender/http/classes/class_cache.php
   trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
New function to cache INSPIRE Atom feeds via apc variable cache. This is needed to allow a fast generation of the bbox attributes of the different doanloadlinks. Testet with 9000 tiles - without caching 30 seconds, with caching 0.4 seconds ;- ) . (40.000 tiles ~1.2 seconds cached)

Modified: trunk/mapbender/http/classes/class_cache.php
===================================================================
--- trunk/mapbender/http/classes/class_cache.php	2013-09-03 13:25:18 UTC (rev 8699)
+++ trunk/mapbender/http/classes/class_cache.php	2013-09-04 13:15:47 UTC (rev 8700)
@@ -71,6 +71,28 @@
 			break;
 		}
 	}
+	
+	final public function cachedVariableCreationTime($key) {
+		switch ($this->cacheType) {
+			case "apc":
+				$cache = apc_cache_info('user');
+				if (empty($cache['cache_list'])) {
+       					return false;
+    				}
+				foreach ($cache['cache_list'] as $entry) {
+        				if ($entry['info'] != $key) {
+            					continue;
+        				}
+        				return $entry['creation_time'];
+				}
+				return false;
+			break;
+			default:
+				return false;
+			break;
+		}
+		return false;
+	}
 
 	final public function cachedVariableAdd($key, $value) {
 		switch ($this->cacheType) {
@@ -83,6 +105,17 @@
 		}
 	}
 
+	final public function cachedVariableDelete($key) {
+		switch ($this->cacheType) {
+			case "apc":
+				return apc_delete($key);
+			break;
+			default:
+				return false;
+			break;
+		}
+	}
 
+
 }
 ?>

Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2013-09-03 13:25:18 UTC (rev 8699)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2013-09-04 13:15:47 UTC (rev 8700)
@@ -28,6 +28,7 @@
 require_once dirname(__FILE__) . "/../../core/epsg.php";
 require_once(dirname(__FILE__) . "/../classes/class_Uuid.php");
 require_once(dirname(__FILE__) . "/../../conf/mimetype.conf");
+require_once(dirname(__FILE__) . "/../classes/class_cache.php");
 
 //check_epsg_wms_13($tmp_epsg)
 //http://www.weichand.de/inspire/dls/verwaltungsgrenzen.xml
@@ -540,34 +541,34 @@
 	switch ($generateFrom) {
 		case "dataurl":
 			$sql = <<<SQL
-select *, 'dataurl' as origin from (select * from (select * from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name,layer_relation.inspire_download, layer_relation.fkey_wms_id, layer_relation.layer_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace  from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as layer_metadata inner join ows_relation_data on ows_relation_data.fkey_layer_id = layer_metadata.layer_id) as layer_relation_data inner join datalink on layer
 _relation_data.fkey_datalink_id = datalink.datalink_id) as layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id)  as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326';  
+select *, 'dataurl' as origin from (select * from (select * from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name,layer_relation.inspire_download, layer_relation.fkey_wms_id, layer_relation.layer_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp   from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as layer_metadata inner join ows_relation_data on ows_relation_data.fkey_layer_id = layer_metadata.layer_id) as layer_
 relation_data inner join datalink on layer_relation_data.fkey_datalink_id = datalink.datalink_id) as layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id)  as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326';  
 SQL;
 		$generateFromDataurl = true;
 		break;
 
 		case "wmslayer":
 			$sql = <<<SQL
-select *, 'wmslayer' as origin from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name, layer_relation.fkey_wms_id, layer_relation.layer_id,layer_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace  from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id)  as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326' and layer_w
 ms.layer_id = $2;  
+select *, 'wmslayer' as origin from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name, layer_relation.fkey_wms_id, layer_relation.layer_id,layer_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp   from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id)  as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and
  layer_epsg.epsg = 'EPSG:4326' and layer_wms.layer_id = $2;  
 SQL;
 		break;
 
 		case "wfs":
 			$sql = <<<SQL
-select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.featuretype_id,featuretype_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace,  featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation inner join mb_metadata on featuretype_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as feat
 uretype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id where wfs.wfs_id = $2;
+select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.featuretype_id,featuretype_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace,  featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs, mb_metadata.lastchanged as md_timestamp from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation inner join mb_metadata on featuretype_relation.fkey_metadata_id = mb_metadata.metadat
 a_id where mb_metadata.uuid = $1) as featuretype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id where wfs.wfs_id = $2;
 SQL;
 		break;
 
 		case "all":
 			$sql = array();
 			$sql[0] = <<<SQL
-select *, 'dataurl' as origin from (select * from (select * from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name, layer_relation.fkey_wms_id, layer_relation.layer_id,layer_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace  from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as layer_metadata inner join ows_relation_data on ows_relation_data.fkey_layer_id = layer_metadata.layer_id) as layer_relation_data inner join datalink on layer
 _relation_data.fkey_datalink_id = datalink.datalink_id) as layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id)  as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326'				
+select *, 'dataurl' as origin from (select * from (select * from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name, layer_relation.fkey_wms_id, layer_relation.layer_id,layer_relation.inspire_download, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp   from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as layer_metadata inner join ows_relation_data on ows_relation_data.fkey_layer_id = layer_metadata.layer_id) as layer_
 relation_data inner join datalink on layer_relation_data.fkey_datalink_id = datalink.datalink_id) as layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id)  as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326'				
 SQL;
 			$sql[1] =  <<<SQL
-select *, 'wmslayer' as origin from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name,layer_relation.inspire_download, layer_relation.fkey_wms_id, layer_relation.layer_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace  from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id)  as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and layer_epsg.epsg = 'EPSG:4326';		
+select *, 'wmslayer' as origin from (select * from (select mb_metadata.metadata_id, layer_relation.layer_name,layer_relation.inspire_download, layer_relation.fkey_wms_id, layer_relation.layer_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, layer_relation.layer_title, layer_relation.layer_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace, mb_metadata.lastchanged as md_timestamp   from (select * from layer inner join ows_relation_metadata on layer.layer_id = ows_relation_metadata.fkey_layer_id) as layer_relation inner join mb_metadata on layer_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) layer_data inner join wms on layer_data.fkey_wms_id = wms.wms_id)  as layer_wms, layer_epsg where layer_wms.layer_id = layer_epsg.fkey_layer_id and
  layer_epsg.epsg = 'EPSG:4326';		
 		
 SQL;
 			$sql[2] =  <<<SQL
-select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.inspire_download, featuretype_relation.featuretype_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace,  featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation inner join mb_metadata on featuretype_relation.fkey_metadata_id = mb_metadata.metadata_id where mb_metadata.uuid = $1) as fea
 turetype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id;		
+select *, 'wfs' as origin from (select mb_metadata.metadata_id, featuretype_relation.featuretype_name, featuretype_relation.fkey_wfs_id, featuretype_relation.inspire_download, featuretype_relation.featuretype_id, mb_metadata.uuid as metadata_uuid, mb_metadata.format,mb_metadata.title as metadata_title, mb_metadata.abstract as metadata_abstract, featuretype_relation.featuretype_title, featuretype_relation.featuretype_abstract, mb_metadata.ref_system as metadata_ref_system, mb_metadata.datasetid, mb_metadata.spatial_res_type, mb_metadata.spatial_res_value, mb_metadata.datasetid_codespace,  featuretype_relation.featuretype_latlon_bbox as latlonbbox, featuretype_relation.featuretype_srs, mb_metadata.lastchanged as md_timestamp from (select * from wfs_featuretype inner join ows_relation_metadata on wfs_featuretype.featuretype_id = ows_relation_metadata.fkey_featuretype_id) as featuretype_relation inner join mb_metadata on featuretype_relation.fkey_metadata_id = mb_metadata.metada
 ta_id where mb_metadata.uuid = $1) as featuretype_data inner join wfs on featuretype_data.fkey_wfs_id = wfs.wfs_id;		
 SQL;
 		break;
 	}
@@ -674,7 +675,7 @@
 	if (!isset($mapbenderMetadata[$m]->fkey_mb_group_id) or is_null($mapbenderMetadata[$m]->fkey_mb_group_id) or $mapbenderMetadata[$m]->fkey_mb_group_id == 0){
 		$e = new mb_exception("mod_inspireDownloadFeed.php: fkey_mb_group_id not found!");
 		//Get information about owning user of the relation mb_user_mb_group - alternatively the defined fkey_mb_group_id from the service must be used!
-		$sqlDep = "SELECT mb_group_name, mb_group_title, mb_group_id, mb_group_logo_path, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  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 LIMIT 1";
+		$sqlDep = "SELECT mb_group_name, mb_group_title, mb_group_id, mb_group_logo_path, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, a.timestamp FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  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 LIMIT 1";
 		if ($generateFrom != "wfs") {
 			$vDep = array($mapbenderMetadata[$m]->wms_owner);
 		} else {
@@ -686,7 +687,7 @@
 		$departmentMetadata = db_fetch_array($resDep);
 	} else {
 		$e = new mb_exception("mod_inspireDownloadFeed.php: fkey_mb_group_id found!");
-		$sqlDep = "SELECT mb_group_name , mb_group_title, mb_group_id, mb_group_logo_path , mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
+		$sqlDep = "SELECT mb_group_name , mb_group_title, mb_group_id, mb_group_logo_path , mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone, timestamp FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
 		$vDep = array($mapbenderMetadata[$m]->fkey_mb_group_id);
 		$tDep = array('i');
 		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
@@ -694,7 +695,7 @@
 	}
 
 	//infos about the owner of the service - he is the man who administrate the metadata - register the service
-	$sql = "SELECT mb_user_email ";
+	$sql = "SELECT mb_user_email, timestamp ";
 	$sql .= "FROM mb_user WHERE mb_user_id = $1";
 	if ($generateFrom != "wfs") {
 			$v = array($mapbenderMetadata[$m]->wms_owner);
@@ -735,7 +736,45 @@
 
 function generateFeed($feedDoc, $recordId, $generateFrom) {
 	global $admin, $type, $imageResolution, $maxImageSize, $maxFeatureCount, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper,$countRessource, $numberOfTiles, $furtherLink;
-	
+	//caching feeds in apc cache
+	//check age of information to allow caching of atom feeds
+	/*$e = new mb_exception("mod_inspireDownloadFeed.php: wms_timestamp: ".date("Y-m-d H:i:s",$mapbenderMetadata[$m]->wms_timestamp));
+	$e = new mb_exception("mod_inspireDownloadFeed.php: wfs_timestamp: ".date("Y-m-d H:i:s",$mapbenderMetadata[$m]->wfs_timestamp));
+	$e = new mb_exception("mod_inspireDownloadFeed.php: md_timestamp: ".date("Y-m-d H:i:s",strtotime($mapbenderMetadata[$m]->md_timestamp)));
+	$e = new mb_exception("mod_inspireDownloadFeed.php: group timestamp: ".date("Y-m-d H:i:s",strtotime($departmentMetadata['timestamp'])));
+	$e = new mb_exception("mod_inspireDownloadFeed.php: user timestamp: ".date("Y-m-d H:i:s",strtotime($userMetadata['timestamp'])));*/
+	$timestamps = array(
+		date("Y-m-d H:i:s",$mapbenderMetadata[$m]->wms_timestamp),
+		date("Y-m-d H:i:s",$mapbenderMetadata[$m]->wfs_timestamp),
+		date("Y-m-d H:i:s",strtotime($mapbenderMetadata[$m]->md_timestamp)),
+		date("Y-m-d H:i:s",strtotime($departmentMetadata['timestamp'])),
+		date("Y-m-d H:i:s",strtotime($userMetadata['timestamp']))
+	);
+	$maxDate = max($timestamps);
+	//$e = new mb_exception("mod_inspireDownloadFeed.php: maxDate: ".$maxDate);
+	//instantiate cache if available
+	$cache = new Cache();
+	//define key name cache
+	$atomFeedKey = 'atomFeed_'.$type."_".$recordId."_".$generateFrom.'_';
+	switch ($generateFrom) {
+		case "wmslayer":
+			$atomFeedKey .= $layerId;
+		break;
+		case "dataurl":
+			$atomFeedKey .= $layerId;
+		break;
+		case "wfs":
+			$atomFeedKey .= $wfsId;
+		break;
+	}
+	$e = new mb_exception("mod_inspireDownloadFeed.php: cachedVariableTimestamp: ".date("Y-m-d H:i:s",$cache->cachedVariableCreationTime($atomFeedKey)));
+	if ($cache->isActive && $cache->cachedVariableExists($atomFeedKey) && (date("Y-m-d H:i:s",$cache->cachedVariableCreationTime($atomFeedKey)) > $maxDate)) {
+		$e = new mb_exception("class_map.php: read ".$atomFeedKey." from ".$cache->cacheType." cache!");
+		return $cache->cachedVariableFetch($atomFeedKey);
+	} else {
+//*****************************************************************
+	//compare highestDate with timestamp of cache
+
 	//part which generates the feed 
 	$feed =  $feedDoc->createElementNS('http://www.w3.org/2005/Atom', 'feed');
 	$feed = $feedDoc->appendChild($feed);
@@ -1250,9 +1289,7 @@
 		<link rel="alternate" href="http://xyz.org/data/waternetwork_feed.xml" type="application/atom+xml" hreflang="en" title="Feed containing the pre-defined waternetwork dataset (in one or more downloadable formats)"/>
 		<!-- identifier for "Dataset Feed" for pre-defined dataset -->
 		<id>http://xyz.org/data/waternetwork_feed.xml</id>*/
-
 		//or link to dataset 5.2.3
-
 		//<link rel="alternate" href="http://xyz.org/data/abc/waternetwork_WGS84.shp" type="application/x-shp" hreflang="en" title="Water Network encoded as a ShapeFile in WGS84geographic coordinates (http://www.opengis.net/def/crs/OGC/1.3/CRS84)"/>
 			
 		$datasetFeedLink = $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?id=".$recordId."&type=DATASET&generatefrom=".$mapbenderMetadata[$i]->origin;
@@ -1265,27 +1302,22 @@
 			break;
 		}
 		$datasetLink = $mapbenderMetadata[$i]->datalink_url;
-		
 		if ($type == 'SERVICE') {
 			//insert resource identifier for service / dataset coupling!!
 			$feedEntryIdCode = $feedDoc->createElement("inspire_dls:spatial_dataset_identifier_code");
 			$feedEntryIdCodeText = $feedDoc->createTextNode($mapbenderMetadata[$i]->datasetid);
 			$feedEntryIdCode->appendChild($feedEntryIdCodeText);
 			$feedEntry->appendChild($feedEntryIdCode);
-
 			$feedEntryIdNamespace = $feedDoc->createElement("inspire_dls:spatial_dataset_identifier_namespace");
 			$feedEntryIdNamespaceText = $feedDoc->createTextNode($mapbenderMetadata[$i]->datasetid_codespace);
 			$feedEntryIdNamespace->appendChild($feedEntryIdNamespaceText);
 			$feedEntry->appendChild($feedEntryIdNamespace);
-
-
 			$metadataLink = $mapbenderPath."php/mod_dataISOMetadata.php?outputFormat=iso19139&id=".$mapbenderMetadata[$m]->metadata_uuid;
 			$feedEntryMetadataLink = $feedDoc->createElement("link");
 			$feedEntryMetadataLink->setAttribute("href",$metadataLink);
 			$feedEntryMetadataLink->setAttribute("rel", "describedby");
 			$feedEntryMetadataLink->setAttribute("type", "application/vnd.iso.19139+xml");
 			$feedEntry->appendChild($feedEntryMetadataLink);
-
 			$furtherLink = $datasetFeedLink;
 			$furtherLinkType = "application/atom+xml";
 			$furtherLinkTitle = "Feed für den pre-defined Datensatz ".$ressourceTitle;
@@ -1450,15 +1482,12 @@
 		$georssPolygon .= $mapbenderMetadata[$i]->miny." ".$mapbenderMetadata[$i]->minx;	
 		$feedEntryBbox->appendChild($feedDoc->createTextNode($georssPolygon));
 		$feedEntry->appendChild($feedEntryBbox);
-	
 		//category entry for crs (from mb_metadata) 5.1.17
 		/*<!-- CRSs in which the pre-defined Dataset is available --> <category term="EPSG:25832" scheme="http://www.opengis.net/def/crs/" label="EPSG/0/25832"/> <category term="EPSG:4258" scheme="http://www.opengis.net/def/crs/" label="EPSG/0/4258"/>*/
-		
 		$feedEntryCategory = $feedDoc->createElement("category");
 		$feedEntryCategory->setAttribute("term", "http://www.opengis.net/def/crs/EPSG/".$epsgId);
 		$feedEntryCategory->setAttribute("label", "EPSG/0/".$epsgId);
 		$feedEntry->appendChild($feedEntryCategory);
-
 		//<!-- INSPIRE Spatial Object Types contained in the pre-defined dataset -->
 		//<category term="Watercourse" scheme="http://inspire-registry.jrc.ec.europa.eu/registers/FCD/" label="Watercourse" xml:lang="en"/>
 		//only applicable for inspire conformant datasets!
@@ -1491,11 +1520,22 @@
 		$feedEntryCategory->setAttribute("xml:lang", "en");
 		$feedEntry->appendChild($feedEntryCategory);*/
 	//</entry>
-
 		$feed->appendChild($feedEntry);
 	}
 	//}
+	//store feed to variable:
+	//atom_feed_{mdid}_{type}_{generateFrom}_{resource_id}
+	if ($cache->isActive) {
+		//delete old variable first - cause the timestamp will remain the old!
+		if ($cache->cachedVariableExists($atomFeedKey)) {
+			$cache->cachedVariableDelete($atomFeedKey);
+			//$e = new mb_exception("mod_inspireDownloadFeed.php: Delete old atom feed in cache!");
+		}
+		$cache->cachedVariableAdd($atomFeedKey,$feedDoc->saveXML());
+		//$e = new mb_exception("mod_inspireDownloadFeed.php: Save atom feed to apc cache!");
+	}
 	return $feedDoc->saveXML();
+	} //loop if no cached variable is available	
 }
 
 
@@ -1594,6 +1634,10 @@
 		$mapbenderMetadata[$indexMapbenderMetadata]->wfs_getfeature = $row['wfs_getfeature'];
 		$mapbenderMetadata[$indexMapbenderMetadata]->wfs_version = $row['wfs_version'];
 		$mapbenderMetadata[$indexMapbenderMetadata]->wfs_max_features = $row['wfs_max_features'];
+
+		$mapbenderMetadata[$indexMapbenderMetadata]->md_timestamp = $row['md_timestamp'];
+		$mapbenderMetadata[$indexMapbenderMetadata]->wms_timestamp = $row['wms_timestamp'];
+		$mapbenderMetadata[$indexMapbenderMetadata]->wfs_timestamp = $row['wfs_timestamp'];
 		//$mapbenderMetadata[$indexMapbenderMetadata]->format = $row['format'];
 		//check if codespace was given in metadata or it must be generated from uuid and default codespace
 		if (($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid_codespace)) or ($mapbenderMetadata[$indexMapbenderMetadata]->datasetid == '' or !isset($mapbenderMetadata[$indexMapbenderMetadata]->datasetid))) {



More information about the Mapbender_commits mailing list