[Mapbender-commits] r8537 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Dec 28 05:55:07 PST 2012
Author: armin11
Date: 2012-12-28 05:55:05 -0800 (Fri, 28 Dec 2012)
New Revision: 8537
Modified:
trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
Bugfixes and owsproxy for INSPIRE Atom feeds
Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2012-12-28 11:46:21 UTC (rev 8536)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php 2012-12-28 13:55:05 UTC (rev 8537)
@@ -66,8 +66,23 @@
}
$testMatch = NULL;
}
+//check if opensearch should be used
+if (isset($_REQUEST['OPENSEARCH']) & $_REQUEST['OPENSEARCH'] != "") {
+ //validate
+ $testMatch = $_REQUEST["OPENSEARCH"];
+ if ($testMatch != "true" && $testMatch != "false"){
+ echo 'OPENSEARCH: <b>'.$testMatch.'</b> is not valid.<br/>';
+ die();
+ }
+ $openSearch = $testMatch;
+ if ($openSearch == 'true') {
+ $openSearch = true;
+ } else {
+ $openSearch = false;
+ }
+ $testMatch = NULL;
+}
-
//validate request params
if (isset($_REQUEST['ID']) & $_REQUEST['ID'] != "") {
//validate uuid
@@ -171,7 +186,7 @@
$feedDoc->formatOutput = true;
function generateOpenSearchDescription($feedDoc, $recordId, $generateFrom) {
- global $admin, $type, $imageResolution, $maxImageSize, $maxFeatureCount, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath;
+ global $admin, $type, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper, $countRessource;
//part which generates the feed
$feed = $feedDoc->createElementNS('http://a9.com/-/spec/opensearch/1.1/', 'OpenSearchDescription');
$feed = $feedDoc->appendChild($feed);
@@ -246,12 +261,14 @@
$osImage->appendChild($osImageText);
$feed->appendChild($osImage);
//Query
+ //example
+ //$mapbenderMetadata[$m]->datasetid_codespace."#".$mapbenderMetadata[$m]->datasetid;
$osQuery = $feedDoc->createElement("Query");
- $osQuery->setAttribute("inspire_dls:spatial_dataset_identifier_namespace", "http://www.geoportal.rlp.de");
- $osQuery->setAttribute("inspire_dls:spatial_dataset_identifier_code", "some uuid");
- $osQuery->setAttribute("inspire_dls:crs", "EPSG:25832");
+ $osQuery->setAttribute("inspire_dls:spatial_dataset_identifier_namespace", $mapbenderMetadata[$m]->datasetid_codespace);
+ $osQuery->setAttribute("inspire_dls:spatial_dataset_identifier_code", $mapbenderMetadata[$m]->datasetid);
+ $osQuery->setAttribute("inspire_dls:crs", "EPSG:".$epsgId);
$osQuery->setAttribute("language", "de");
- $osQuery->setAttribute("title", "Titel des Datensatzes");
+ $osQuery->setAttribute("title", $mapbenderMetadata[$m]->metadata_title);
$osQuery->setAttribute("count", "1");
//$osQueryText = $feedDoc->createTextNode("Query");
//$osQuery->appendChild($osQueryText);
@@ -270,28 +287,8 @@
}
-
-//Some needfull functions to pull metadata out of the database.
-//List of data which is needed to build the feed:
-//header part ******
-// - feed title: Generated from dataset name - either mb_metadata.title or layer.layer_title
-// - feed subtitle: Generated from dataset name - either mb_metadata.title or layer.layer_title, organisation name - mapbender group information (metadata contact) - cause it is generated from data of a registrated wms
-// - link to ISO19139 service metadata - this will be created dynamically by given layer_id as this script itself
-// - link to opensearch description for this download service - as before the layer_id will be used as a parameter
-// - id - link to the script itself
-// - rights - the access constraints of the view service are used - they should also give information about the access constraints for the usage of the data
-// - updated : last date the feed was updated - use current timestamp of the wms as the feed will be generated from dataurl entry of the layer object - wms.wms_timestamp
-//datalink.random_id - this is newly created when layers are updated ! - new
-//author - use information from mapbender group - metadata point of contact - registrating organization
-//entry part ******
-// - entry title: Generated from dataset name - either mb_metadata.title or layer.layer_title - in combination e.g. with "Feed for ..."
-// - link to the dataset feed - invoked by layer id as this is done before
-// - summary - Generated by some infomation: mb_metadata.format, mb_metadata.ref_sytem, ...., datalink.datalink_format
-// - updated - timestamp of wms as done before
-// -
-
-function generateFeed($feedDoc, $recordId, $generateFrom) {
- global $admin, $type, $imageResolution, $maxImageSize, $maxFeatureCount, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath;
+function readInfoFromDatabase($recordId, $generateFrom){
+ global $admin, $type, $mapbenderMetadata, $indexMapbenderMetadata, $layerId, $wfsId, $mapbenderPath, $epsgId, $alterAxisOrder, $departmentMetadata, $userMetadata, $hasPermission, $m, $crs, $crsUpper, $countRessource;
switch ($generateFrom) {
case "dataurl":
@@ -460,6 +457,30 @@
$hasPermission = true;
}
+}
+
+//Some needfull functions to pull metadata out of the database.
+//List of data which is needed to build the feed:
+//header part ******
+// - feed title: Generated from dataset name - either mb_metadata.title or layer.layer_title
+// - feed subtitle: Generated from dataset name - either mb_metadata.title or layer.layer_title, organisation name - mapbender group information (metadata contact) - cause it is generated from data of a registrated wms
+// - link to ISO19139 service metadata - this will be created dynamically by given layer_id as this script itself
+// - link to opensearch description for this download service - as before the layer_id will be used as a parameter
+// - id - link to the script itself
+// - rights - the access constraints of the view service are used - they should also give information about the access constraints for the usage of the data
+// - updated : last date the feed was updated - use current timestamp of the wms as the feed will be generated from dataurl entry of the layer object - wms.wms_timestamp
+//datalink.random_id - this is newly created when layers are updated ! - new
+//author - use information from mapbender group - metadata point of contact - registrating organization
+//entry part ******
+// - entry title: Generated from dataset name - either mb_metadata.title or layer.layer_title - in combination e.g. with "Feed for ..."
+// - link to the dataset feed - invoked by layer id as this is done before
+// - summary - Generated by some infomation: mb_metadata.format, mb_metadata.ref_sytem, ...., datalink.datalink_format
+// - updated - timestamp of wms as done before
+// -
+
+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;
+
//part which generates the feed
$feed = $feedDoc->createElementNS('http://www.w3.org/2005/Atom', 'feed');
$feed = $feedDoc->appendChild($feed);
@@ -480,6 +501,8 @@
if (isset($mapbenderMetadata[$m]->metadata_title) && $mapbenderMetadata[$m]->metadata_title != '' ) {
$ressourceTitle = $mapbenderMetadata[$m]->metadata_title;
} else {
+ //TODO check wfs title....
+
if (isset($mapbenderMetadata[$m]->layer_title) && $mapbenderMetadata[$m]->layer_title != '' ) {
$ressourceTitle = $mapbenderMetadata[$m]->layer_title;
} else {
@@ -550,9 +573,9 @@
//self reference - 5.1.4 / 5.2
if ($type == 'SERVICE') {
- $selfReference = $mapbenderPath."php/mod_inspireDownloadFeed.php?ID=".$recordId."&type=SERVICE&generatefrom=".$generateFrom;
+ $selfReference = $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?ID=".$recordId."&type=SERVICE&generatefrom=".$generateFrom;
} else { //DATASET
- $selfReference = $mapbenderPath."php/mod_inspireDownloadFeed.php?ID=".$recordId."&type=DATASET&generatefrom=".$generateFrom;
+ $selfReference = $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?ID=".$recordId."&type=DATASET&generatefrom=".$generateFrom;
switch($generateFrom) {
case "wmslayer":
$selfReference .= "&layerid=".$mapbenderMetadata[$m]->layer_id;
@@ -575,7 +598,7 @@
//opensearch descriptionlink 5.1.5
if ($type == 'SERVICE') {
$feedLink = $feedDoc->createElement("link");
- $feedLink->setAttribute("href", $mapbenderPath."php/mod_inspireDownloadFeed.php?id=".$recordId."&type=".$type."&generateFrom=".$generateFrom."&wfsid=".$wfsId."&layerid=".$layerId."&getopensearch=true");
+ $feedLink->setAttribute("href", $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?id=".$recordId."&type=".$type."&generateFrom=".$generateFrom."&wfsid=".$wfsId."&layerid=".$layerId."&getopensearch=true");
$feedLink->setAttribute("rel", "search");
$feedLink->setAttribute("type", "application/opensearchdescription+xml");
//$feedLink->setAttribute("hreflang", "de");
@@ -742,6 +765,7 @@
for ($i = 0; $i < $countRessource; $i++) {
//overwrite feature count with information from database
$maxFeatureCount = (integer)$mapbenderMetadata[$i]->wfs_max_features;
+
$crs = $mapbenderMetadata[$i]->metadata_ref_system;
//use featuretype ref system?
$crs = $mapbenderMetadata[$i]->featuretype_srs;
@@ -976,7 +1000,7 @@
//<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."php/mod_inspireDownloadFeed.php?id=".$recordId."&type=DATASET&generatefrom=".$mapbenderMetadata[$i]->origin;
+ $datasetFeedLink = $mapbenderPath."..".$_SERVER['SCRIPT_NAME']."?id=".$recordId."&type=DATASET&generatefrom=".$mapbenderMetadata[$i]->origin;
switch($mapbenderMetadata[$i]->origin) {
case "wmslayer":
$datasetFeedLink .= "&layerid=".$mapbenderMetadata[$i]->layer_id;
@@ -1048,7 +1072,14 @@
$feedEntry->appendChild($feedEntryContent);
}
for ($m = 0; $m < $numberOfTiles; $m++ ) {
- $furtherLink[$m] = $mapbenderMetadata[$i]->wms_getmap."REQUEST=GetMap&VERSION=".$mapbenderMetadata[$i]->wms_version."&SERVICE=WMS&LAYERS=".$mapbenderMetadata[$i]->layer_name;
+ //check if proxy is used, if so exchange urls with proxy urls
+ if ($mapbenderMetadata[$i]->wms_owsproxy <> NULL && $mapbenderMetadata[$i]->wms_getmap != '') {
+ $getMapUrl = str_replace(":80","",HTTP_AUTH_PROXY)."/".$mapbenderMetadata[$i]->layer_id."?";
+ //TODO check why :80 is part of the http_host - maybe apache rewrite
+ } else {
+ $getMapUrl = $mapbenderMetadata[$i]->wms_getmap;
+ }
+ $furtherLink[$m] = $getMapUrl."REQUEST=GetMap&VERSION=".$mapbenderMetadata[$i]->wms_version."&SERVICE=WMS&LAYERS=".$mapbenderMetadata[$i]->layer_name;
$furtherLink[$m] .= "&STYLES=&SRS=".trim($crs)."&BBOX=".$bboxWms[$m]."&WIDTH=".$maxImageSize."&HEIGHT=".$maxImageSize."&FORMAT=image/tiff&";
$furtherLink[$m] .= "BGCOLOR=0xffffff&TRANSPARENT=TRUE&EXCEPTIONS=application/vnd.ogc.se_inimage";
$furtherLinkType[$m] = "image/tiff"; //formats from layer_format - geotiff
@@ -1092,6 +1123,11 @@
}
for ($m = 0; $m < count($getFeatureLink); $m++ ) {
$furtherLink[$m] = $getFeatureLink[$m];//was computed before
+ //discard filter if only one request is needed - problem with epsg codes? TODO solve problem
+ if (count($getFeatureLink) == 1) {
+ $splittedLink = explode('&FILTER=',$furtherLink[$m]);
+ $furtherLink[$m] = $splittedLink[0];
+ }
$furtherLinkType[$m] = "text/xml; subtype=gml/3.1.1";//TODO: set right format for wfs version!
$currentIndex = $m+1;
$furtherLinkTitle[$m] = $ressourceTitle." im CRS ".$mapbenderMetadata[$i]->metadata_ref_system." - ".$mapbenderMetadata[$i]->format." - Teil ".$currentIndex." von ".count($getFeatureLink)."";//TODO: set right format for wfs version!
@@ -1286,6 +1322,7 @@
$mapbenderMetadata[$indexMapbenderMetadata]->format = $row['format'];
$mapbenderMetadata[$indexMapbenderMetadata]->datalink_url = $row['datalink_url'];
$mapbenderMetadata[$indexMapbenderMetadata]->wms_getmap = $row['wms_getmap'];
+ $mapbenderMetadata[$indexMapbenderMetadata]->wms_owsproxy = $row['wms_owsproxy'];
$mapbenderMetadata[$indexMapbenderMetadata]->wms_version = $row['wms_version'];
$mapbenderMetadata[$indexMapbenderMetadata]->wms_max_imagesize = $row['wms_max_imagesize'];
$mapbenderMetadata[$indexMapbenderMetadata]->layer_name = $row['layer_name'];
@@ -1322,8 +1359,10 @@
if ($getOpenSearch) {
+ readInfoFromDatabase($recordId, $generateFrom);
pushOpenSearch($feedDoc, $recordId, $generateFrom);
} else {
+ readInfoFromDatabase($recordId, $generateFrom);
pushFeed($feedDoc, $recordId, $generateFrom); //throw it out to world!
}
More information about the Mapbender_commits
mailing list