[Mapbender-commits] r8763 - in trunk/mapbender: . cors_proxy cors_proxy/http http/classes http/php resources/db/pgsql/UTF-8/update
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Jan 30 07:10:23 PST 2014
Author: armin11
Date: 2014-01-30 07:10:23 -0800 (Thu, 30 Jan 2014)
New Revision: 8763
Added:
trunk/mapbender/cors_proxy/
trunk/mapbender/cors_proxy/http/
trunk/mapbender/cors_proxy/http/index.php
Modified:
trunk/mapbender/http/classes/class_metadata_new.php
trunk/mapbender/http/php/mod_callMetadata.php
trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php
trunk/mapbender/http/php/mod_metadataWrite.php
trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
Log:
New cors_proxy for opendata classified wms and search possibility to restrict searchInterface to opendata resources (wms/wfs)
Added: trunk/mapbender/cors_proxy/http/index.php
===================================================================
--- trunk/mapbender/cors_proxy/http/index.php (rev 0)
+++ trunk/mapbender/cors_proxy/http/index.php 2014-01-30 15:10:23 UTC (rev 8763)
@@ -0,0 +1,316 @@
+<?php
+# $Id: index.php 8761 2014-01-27 22:24:41Z armin11 $
+# http://www.mapbender.org/index.php/cors_proxy
+# Module maintainer armin11
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//http://localhost/cors_proxy/1046?VERSION=1.1.1&REQUEST=GetMap&SERVICE=WMS&LAYERS=BPlan.07141058.1.0,BPlan.07141058.1.1,BPlan.07141058.2.0,BPlan.07141058.2.1,BPlan.07141058.3.0,BPlan.07141058.3.1,BPlan.07141058.3.2,BPlan.07141058.4.0,BPlan.07141058.5.0,BPLAN.07141058.0&STYLES=,,,,,,,,,&SRS=EPSG:25832&BBOX=412771.875,5576280,413428.125,5576700&WIDTH=625&HEIGHT=400&FORMAT=image/png&BGCOLOR=0xffffff&TRANSPARENT=TRUE&EXCEPTIONS=application/vnd.ogc.se_xml&vendorspecific_oek=1
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
+require_once(dirname(__FILE__) . "/../../http/classes/class_administration.php");
+require_once(dirname(__FILE__) . "/../../http/classes/class_connector.php");
+require_once(dirname(__FILE__) . "/../../owsproxy/http/classes/class_QueryHandler.php");
+$startTime = microtime(true);
+$imageformats = array("image/png","image/gif","image/jpeg", "image/jpg");
+$width = 400;
+$height = 400;
+$tmpSession = false;
+//parse url
+$query = new QueryHandler();
+$reqParams = $query->getRequestParams();
+//echo $query->getRequest();
+//check request for id
+if (isset($_REQUEST["wmsid"]) & $_REQUEST["wmsid"] != "") {
+ $testMatch = $_REQUEST["wmsid"];
+ $pattern = '/^[0-9]*$/';
+ if (!preg_match($pattern,$testMatch)){
+ throwExceptionXml('','Parameter for wmsid is not valid (integer)');
+ }
+ $wmsId = $testMatch;
+ $testMatch = NULL;
+}
+//check if session has user_id
+$e = new mb_exception("Initial session_id: ".session_id());
+$e = new mb_exception("userFromSession: ".getUserFromSession());
+if (getUserFromSession()) {
+ $userId = getUserFromSession();
+} else {
+ $e = new mb_exception("cors_proxy/http/index.php: No userId found in session - delete session after proxied request!");
+ $userId = PUBLIC_USER;
+ $tmpSession = session_id();
+}
+//check header - see invoking server
+$headers = apache_request_headers();//from php 5.4 also for php fcgi
+/*foreach ($headers as $header => $value) {
+ echo "$header: $value <br />\n";
+}*/
+foreach ($headers as $header => $value) {
+ if ($header === "Origin") {
+ $originFromHeader = $value;
+ } else {
+ $originFromHeader = false;
+ //throwExceptionXml('','CORS Proxy don\'t find Origin header from client!');
+ $originFromHeader = "http://localhost";
+ }
+}
+//check server against whitelist for cors header
+if (defined("CORS_WHITELIST") && CORS_WHITELIST != "") {
+ //check if server is in cors whitelist
+ $CORS_WHITELIST_array = explode(" ",CORS_WHITELIST);
+ if (!in_array($originFromHeader,$CORS_WHITELIST_array)) {
+ throwExceptionXml('','Server not found in whitelist of cors_proxy, please check your configuration!');
+ }
+} else {
+ throwExceptionXml('','Mapbenders cors_proxy has no whitelist defined, check your configuration!');
+}
+$n = new administration();
+//get authentication infos if they are available in wms table! if not $auth = false
+$auth = $n->getAuthInfoOfWMS($wmsId);
+if ($auth['auth_type']==''){
+ unset($auth);
+}
+$e = new mb_exception("userId: ".$userId);
+//check header - see invoking server
+switch (strtolower($reqParams['request'])) {
+ case 'getmap':
+ $arrayOnlineresources = checkWmsPermission($wmsId, $userId);
+ $query->setOnlineResource($arrayOnlineresources['wms_getmap']);
+ $layers = checkLayerPermission($arrayOnlineresources['wms_id'],$reqParams['layers'],$userId);
+ if($layers===""){
+ throwE("Permission denied");
+ die();
+ }
+ $query->setParam("layers",urldecode($layers));//the decoding of layernames dont make problems - but not really good names will be requested also ;-)
+ $request = $query->getRequest();
+ $startRequestTime = microtime(true);
+ if(isset($auth)){
+ getImage($request,$auth);
+ }
+ else {
+ getImage($request);
+ }
+ $endRequestTime = microtime(true);
+ break;
+ case 'map':
+ $arrayOnlineresources = checkWmsPermission($wmsId, $userId);
+ $query->setOnlineResource($arrayOnlineresources['wms_getmap']);
+ $layers = checkLayerPermission($arrayOnlineresources['wms_id'],$reqParams['layers'], $userId);
+ if($layers===""){
+ throwE("Permission denied");
+ die();
+ }
+ $query->setParam("layers",urldecode($layers));
+ $request = $query->getRequest();
+ if(isset($auth)){
+ getImage($url,$auth);
+ }
+ else {
+ getImage($url);
+ }
+ break;
+ default:
+}
+
+//delete tmpSession
+if ($tmpSession) {
+ $e = new mb_notice("cors_proxy/http/index.php: temporal generated session will be deleted!");
+ Mapbender::session()->storageDestroy($tmpSession);
+}
+$endTime = microtime(true);
+$e = new mb_exception("cors_proxy/http/index.php: Time of execution: ".(string)($endTime - $startTime). "s - time for getting image: ".($endRequestTime - $startRequestTime)."s - time for script and control: ".(string)(($endTime - $endRequestTime) + ($startRequestTime - $startTime)));
+//following functions came from owsproxy - maybe they will be better defined in a proxy class itself
+//checkWmsPermission
+//checkLayerPermission
+//throwE
+//getImage
+function checkLayerPermission($wms_id,$l,$userId){
+ global $n;
+ $myl = explode(",",$l);
+ $r = array();
+ foreach($myl as $mysl){
+ if($n->getLayerPermission($wms_id, $mysl, $userId) === true){
+ array_push($r, $mysl);
+ }
+ }
+ $ret = implode(",",$r);
+ return $ret;
+}
+/**
+ * validated access permission on requested wms
+ *
+ * @param integer wms_id
+ * @return array array with detailed information about requested wms
+ */
+function checkWmsPermission($wmsid,$userId){
+ global $n;
+ $myguis = $n->getGuisByPermission($userId,true);
+ $mywms = $n->getWmsByOwnGuis($myguis);
+ $sql = "SELECT * FROM wms WHERE wms_id = $1";
+ $v = array($wmsid);
+ $t = array("i");
+ $res = db_prep_query($sql, $v, $t);
+ $service = array();
+ if($row = db_fetch_array($res)){
+ $service["wms_id"] = $row["wms_id"];
+ $service["wms_getcapabilities"] = $row["wms_getcapabilities"];
+ $service["wms_getmap"] = $row["wms_getmap"];
+ $service["wms_getfeatureinfo"] = $row["wms_getfeatureinfo"];
+ $service["wms_getcapabilities_doc"] = $row["wms_getcapabilities_doc"];
+ }
+ if(!$row || count($mywms) == 0){
+ throwE(array("No wms data for this user available."));
+ die();
+ }
+ if(!in_array($service["wms_id"], $mywms)){
+ throwE(array("Permission denied."," -> ".$service["wms_id"], implode(",", $mywms)));
+ die();
+ }
+ return $service;
+}
+/**
+ * fetch and returns an image to client
+ *
+ * @param string the original url of the image to send
+ */
+function getImage($or){
+ global $reqParams;
+ header("Content-Type: ".$reqParams['format']);
+ //set cors header
+ header('Access-Control-Allow-Origin: '.CORS_WHITELIST);
+ //log the image_requests to database
+ //log the following to table mb_proxy_log
+ //timestamp,user_id,getmaprequest,amount pixel,price - but do this only for wms to log - therefor first get log tag out of wms!
+ //
+ //
+ if (func_num_args() == 2) { //new for HTTP Authentication
+ $auth = func_get_arg(1);
+ echo getDocumentContent($or,$auth);
+ }
+ else
+ {
+ echo getDocumentContent($or);
+ }
+
+}
+/*********************************************************/
+function throwE($e){
+ global $reqParams, $imageformats;
+ if(in_array($reqParams['format'],$imageformats)){
+ throwImage($e);
+ }
+ else{
+ throwText($e);
+ }
+}
+
+function throwImage($e){
+ global $width,$height;
+ $image = imagecreate($width,$height);
+ $transparent = ImageColorAllocate($image,155,155,155);
+ ImageFilledRectangle($image,0,0,$width,$height,$transparent);
+ imagecolortransparent($image, $transparent);
+ $text_color = ImageColorAllocate ($image, 233, 14, 91);
+ if (count($e) > 1){
+ for($i=0; $i<count($e); $i++){
+ $imageString = $e[$i];
+ ImageString ($image, 3, 5, $i*20, $imageString, $text_color);
+ }
+ } else {
+ if (is_array($e)) {
+ $imageString = $e[0];
+ } else {
+ $imageString = $e;
+ }
+ if ($imageString == "") {
+ $imageString = "An unknown error occured!";
+ }
+ ImageString ($image, 3, 5, $i*20, $imageString, $text_color);
+ }
+ responseImage($image);
+}
+
+function throwText($e){
+ echo join(" ", $e);
+}
+
+function responseImage($im){
+ global $reqParams;
+ $format = $reqParams['format'];
+ $format="image/gif";
+ header('Access-Control-Allow-Origin: '.CORS_WHITELIST);
+ if($format == 'image/png'){header("Content-Type: image/png");}
+ if($format == 'image/jpeg' || $format == 'image/jpg'){header("Content-Type: image/jpeg");}
+ if($format == 'image/gif'){header("Content-Type: image/gif");}
+
+ if($format == 'image/png'){imagepng($im);}
+ if($format == 'image/jpeg' || $format == 'image/jpg'){imagejpeg($im);}
+ if($format == 'image/gif'){imagegif($im);}
+}
+
+function getDocumentContent($url){
+ //$e = new mb_exception("cors_proxy/http/index.php: Begin to request external image: ".microtime(true));
+ if (func_num_args() == 2) { //new for HTTP Authentication
+ $auth = func_get_arg(1);
+ $d = new connector($url, $auth);
+ }
+ else {
+ $d = new connector($url);
+ }
+ //$e = new mb_exception("cors_proxy/http/index.php: Got image!: ".microtime(true));
+ return $d->file;
+}
+
+/**
+ * Creates an XML Exception according to WMS 1.1.1
+ *
+ * @return an XML String
+ * @param $errorCode String
+ * @param $errorMessage String
+ */
+function throwExceptionXml ($errorCode, $errorMessage) {
+ // see http://de2.php.net/manual/de/domimplementation.createdocumenttype.php
+ $imp = new DOMImplementation;
+ $dtd = $imp->createDocumentType("ServiceExceptionReport", "", "http://schemas.opengis.net/wms/1.1.1/exception_1_1_1.dtd");
+
+ $doc = $imp->createDocument("", "", $dtd);
+ $doc->encoding = 'UTF-8';
+ $doc->standalone = false;
+
+ $el = $doc->createElement("ServiceExceptionReport");
+ $exc = $doc->createElement("ServiceException", $errorMessage);
+ if ($errorCode) {
+ $exc->setAttribute("code", $errorCode);
+ }
+ $el->appendChild($exc);
+ $doc->appendChild($el);
+ header("Content-type: application/xhtml+xml; charset=UTF-8");
+ header('Access-Control-Allow-Origin: '.CORS_WHITELIST);
+ echo $doc->saveXML();
+ die;
+}
+
+function getUserFromSession() {
+ if (Mapbender::session()->get('mb_user_id')) {
+ if ((integer)Mapbender::session()->get('mb_user_id') >= 0) {
+ $foundUserId = (integer)Mapbender::session()->get('mb_user_id');
+ } else {
+ $foundUserId = false;
+ }
+ } else {
+ $foundUserId = false;
+ }
+ return $foundUserId;
+}
+?>
Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php 2014-01-28 07:09:12 UTC (rev 8762)
+++ trunk/mapbender/http/classes/class_metadata_new.php 2014-01-30 15:10:23 UTC (rev 8763)
@@ -58,8 +58,9 @@
var $orderBy;
var $hostName;
var $resourceIds;
+ var $restrictToOpenData;
- function __construct($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources, $searchPages, $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds){
+ function __construct($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources, $searchPages, $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData){
$this->userId = (integer)$userId;
$this->searchId = $searchId;
$this->searchText = $searchText;
@@ -86,6 +87,7 @@
$this->hostName = $hostName;
$this->orderBy = $orderBy;
$this->resourceIds = $resourceIds;
+ $this->restrictToOpenData = $restrictToOpenData;
//definitions for generating tagClouds
$this->maxObjects = 15;
$this->maxFontSize = 30;
@@ -698,6 +700,7 @@
//check if a disclaimer has to be shown and give the relevant symbol
list($hasConstraints, $symbolLink) = $this->hasConstraints("wms", $subLayers[$rootIndex]['wms_id']);
$this->wmsJSON->wms->srv[$j]->hasConstraints = $hasConstraints;
+ $this->wmsJSON->wms->srv[$j]->isopen = $subLayers[$rootIndex]['isopen'];
$this->wmsJSON->wms->srv[$j]->symbolLink = $symbolLink;
//TODO check the field accessconstraints - which should be presented?
$this->wmsJSON->wms->srv[$j]->status = $subLayers[$rootIndex]['status']; //$wmsMatrix[$i][''];
@@ -821,6 +824,9 @@
$this->allJSON->filter = $filterJSON;
}
$this->allJSON->wms = $this->json->decode($this->wmsJSON);
+ if (defined("CORS_WHITELIST") && CORS_WHITELIST != "") {
+ header('Access-Control-Allow-Origin: '.CORS_WHITELIST);
+ }
echo $this->json->encode($this->allJSON);
//echo "test";
}
@@ -1033,10 +1039,14 @@
}
}
}
+ //search filter for isopen - open data classification of the managed termsofuse
+ //
+ if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wfs") & $this->restrictToOpenData) {
+ array_push($whereCondArray, '(isopen = 1)');
+ }
//search filter for md_topic_categories
//
if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc" or strtolower($this->searchResources) === "dataset") & $this->isoCategories != NULL) {
-
$isoArray = explode(',',$this->isoCategories);
$topicCond = "(";
for($i=0; $i < count($isoArray); $i++){
@@ -1635,17 +1645,10 @@
}
$v = array();
$t = array();
-
-
array_push($t, "i");
array_push($v, $id);
-
$res = db_prep_query($sql,$v,$t);
-
$row = db_fetch_array($res);
-
-
-
if ((isset($row[$type.'_proxylog']) & $row[$type.'_proxylog'] != 0) or strtoupper($row['accessconstraints']) != "NONE" or strtoupper($row['fees']) != "NONE" or isset($row['termsofuse_id']) ) {
//service has some constraints defined!
//give symbol and true
Modified: trunk/mapbender/http/php/mod_callMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callMetadata.php 2014-01-28 07:09:12 UTC (rev 8762)
+++ trunk/mapbender/http/php/mod_callMetadata.php 2014-01-30 15:10:23 UTC (rev 8763)
@@ -36,6 +36,7 @@
$searchBbox = NULL;
$searchTypeBbox = "intersects"; //outside / inside
$accessRestrictions = "false";
+$restrictToOpenData = false;
$languageCode = "de";
$outputFormat = 'json';
#$searchResources = "wms,wfs,wmc,georss,dataset";
@@ -265,6 +266,23 @@
$outputFormat = $testMatch;
$testMatch = NULL;
}
+//$restrictToOpenData = false;
+if (isset($_REQUEST["restrictToOpenData"]) & $_REQUEST["restrictToOpenData"] != "") {
+ $testMatch = $_REQUEST["restrictToOpenData"];
+ if (!($testMatch == 'true' or $testMatch == 'false')){
+ echo 'Parameter <b>restrictToOpenData</b> is not valid (true,false).<br/>';
+ die();
+ }
+ switch ($testMatch) {
+ case "true":
+ $restrictToOpenData = true;
+ break;
+ case "false":
+ $restrictToOpenData = false;
+ break;
+ }
+ $testMatch = NULL;
+}
if (isset($_REQUEST["hostName"]) & $_REQUEST["hostName"] != "") {
//validate to some hosts
$testMatch = $_REQUEST["hostName"];
@@ -525,19 +543,8 @@
return $customCategoryArray;
}
-
-
-
-
-
-
-//define where to become the information from - this is relavant for the information which must be pulled out of the database
+//define where to become the information from - this is relevant for the information which must be pulled out of the database
$classificationElements = array();
-
-
-
-
-
$classificationElements[0]['name'] = 'searchText';
$classificationElements[1]['name'] = 'registratingDepartments';
$classificationElements[2]['name'] = 'isoCategories';
@@ -546,6 +553,7 @@
$classificationElements[5]['name'] = 'searchBbox';
$classificationElements[6]['name'] = 'regTimeBegin';
$classificationElements[7]['name'] = 'regTimeEnd';
+$classificationElements[8]['name'] = 'restrictedToOpenData';
$classificationElements[0]['source'] = '';
$classificationElements[1]['source'] = 'database';
@@ -555,6 +563,7 @@
$classificationElements[5]['source'] = '';
$classificationElements[6]['source'] = '';
$classificationElements[7]['source'] = '';
+$classificationElements[8]['source'] = '';
$classificationElements[0]['list'] = true;
$classificationElements[1]['list'] = true;
@@ -564,6 +573,7 @@
$classificationElements[5]['list'] = false;
$classificationElements[6]['list'] = false;
$classificationElements[7]['list'] = false;
+$classificationElements[8]['list'] = true;
//Defining of the different result categories
$resourceCategories = array();
@@ -583,6 +593,7 @@
$classificationElements[5]['name2show'] = 'Räumliche Einschränkung:';
$classificationElements[6]['name2show'] = 'Registrierung/Aktualisierung von:';
$classificationElements[7]['name2show'] = 'Registrierung/Aktualisierung bis:';
+ $classificationElements[8]['name2show'] = 'Nur OpenData Ressourcen:';
$resourceCategories['wms'] = 'Darstellungsdienste';
$resourceCategories['wfs'] = 'Such- und Download- und Erfassungsmodule';
@@ -608,7 +619,8 @@
$classificationElements[4]['name2show'] = 'RP Categories:';
$classificationElements[5]['name2show'] = 'Spatial Filter:';
$classificationElements[6]['name2show'] = 'Registration/Update from:';
- $classificationElements[7]['name2show'] = 'Registration/Update till:';
+ $classificationElements[7]['name2show'] = 'Registration/Update till:';
+ $classificationElements[8]['name2show'] = 'Only OpenData resources:';
$resourceCategories['wms'] = 'Viewingservices';
$resourceCategories['wfs'] = 'Search- and Downloadservices';
@@ -634,6 +646,7 @@
$classificationElements[5]['name2show'] = 'Requête spatiale:';
$classificationElements[6]['name2show'] = 'Enregistrement/Mise à jour du :';
$classificationElements[7]['name2show'] = 'Enregistrement/Mise à jour au:';
+ $classificationElements[8]['name2show'] = 'Pas plus de OpenData:';
$resourceCategories['wms'] = 'Services de visualisation';
$resourceCategories['wfs'] = 'Services de recherche et de téléchargement';
@@ -659,6 +672,7 @@
$classificationElements[5]['name2show'] = 'Räumliche Einschränkung:';
$classificationElements[6]['name2show'] = 'Registrierung/Aktualisierung von:';
$classificationElements[7]['name2show'] = 'Registrierung/Aktualisierung bis:';
+ $classificationElements[8]['name2show'] = 'Nur OpenData Ressourcen:';
$resourceCategories['wms'] = 'Darstellungsdienste';
$resourceCategories['wfs'] = 'Such- und Downloaddienste';
@@ -783,11 +797,6 @@
}
}
-
-
-
-
-
//generate filter for different order possibilities
//$queryJSON->searchFilter = (object) array();
@@ -956,8 +965,6 @@
}
//call class_metadata - in case of file for all requested resources, in case of web only for one resource - cause there are different result files
-
-
if ($resultTarget == 'file') {
for($i=0; $i<count($searchResources);$i++){
$str = "nohup php5 /data/mapbender/http/php/mod_metadataWrite.php ";
@@ -985,7 +992,8 @@
$str .= "'".$customCategories."' ";
$str .= "'".$hostName."' ";
$str .= "'".$orderBy."' ";
- $str .= "'".$resourceIds."' ";
+ $str .= "'".$resourceIds."' ";
+ $str .= "'".$restrictToOpenData."' ";
$str .= " & ";
$e = new mb_notice($str);
exec($str);
@@ -993,7 +1001,7 @@
}
if ($resultTarget == 'web' or $resultTarget == 'debug' or $resultTarget == 'webclient') {
if (count($searchResources) == 1) {
- $metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources[0], $searchPages[0], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds);
+ $metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources[0], $searchPages[0], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData);
#if ($outputFormat == 'xml') {
# header("Content-type: application/xhtml+xml; charset=UTF-8");
#}
Modified: trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php 2014-01-28 07:09:12 UTC (rev 8762)
+++ trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php 2014-01-30 15:10:23 UTC (rev 8763)
@@ -84,7 +84,7 @@
if (isset($_REQUEST['GENERATEFROM']) & $_REQUEST['GENERATEFROM'] != "") {
//validate type
$testMatch = $_REQUEST["GENERATEFROM"];
- if ($testMatch != 'wmslayer' && $testMatch != 'dataurl' && $testMatch != 'wfs'){
+ if ($testMatch != 'wmslayer' && $testMatch != 'dataurl' && $testMatch != 'wfs' && $testMatch != 'metadata'){
//echo 'GENERATEFROM: <b>'.$testMatch.'</b> is not valid.<br/>';
echo 'Parameter <b>GENERATEFROM</b> is not valid (dataurl,wfs,wmslayer).<br/>';
die();
@@ -192,7 +192,76 @@
$mapbenderMetadata['maxx'] = $mbMetadata['maxx'];
$mapbenderMetadata['maxy'] = $mbMetadata['maxy'];
break;
+ case "metadata":
+ /*given information:
+ elements from metadata set
+ needed information:
+ mb_metadata.title,
+ mb_metadata.abstract,
+ wms.wms_department,
+ (mb_group.mb_group_title),
+ mb_metadata.ref_system,
+ wms.owner,
+ wms.fkey_group_id,
+ wms.uuid,
+ dataset identifier*/
+ foreach ($downloadOptions->{$recordId}->option as $option) {
+ if ($option->type == "downloadlink") {
+ $mapbenderMetadata['mdFileIdentifier'] = $recordId;
+ //$mapbenderMetadata['serviceId'] = $option->serviceId;
+ //$mapbenderMetadata['resourceId'] = $option->resourceId;
+ $mapbenderMetadata['downloadLink'] = $option->link;
+ } else {
+ echo "<error>No option for downloading service from metadata found in database</error>";
+ die();
+ }
+ }
+ //check if entries are filled
+ //read information from metadata table
+ //TODO!!!!
+ $sql = <<<SQL
+ SELECT * , box2d(the_geom) as bbox2d from mb_metadata WHERE mb_metadata.uuid = $1;
+SQL;
+ $v = array($recordId);
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+ $mbMetadata = db_fetch_array($res);
+ $mapbenderMetadata['mdTitle'] = $mbMetadata['title'];
+ $mapbenderMetadata['mdAbstract'] = $mbMetadata['abstract'];
+ $mapbenderMetadata['mdRefSystem'] = $mbMetadata['ref_sytem'];
+ $mapbenderMetadata['datasetId'] = $mbMetadata['datasetid'];
+ $mapbenderMetadata['mdOrigin'] = $mbMetadata['origin'];
+ $mapbenderMetadata['serviceUuid'] = $mbMetadata['uuid'];
+ $mapbenderMetadata['serviceTimestamp'] = strtotime($mbMetadata['wms_timestamp']);
+ $mapbenderMetadata['serviceTimestampCreate'] = strtotime($mbMetadata['wms_timestamp_create']);
+ //$mapbenderMetadata['serviceTimestamp'] = date("Y-m-d",strtotime($mb_metadata['lastchanged']));
+ //$mapbenderMetadata['serviceTimestampCreate'] = date("Y-m-d",strtotime($mb_metadata['lastchanged']));
+ $mapbenderMetadata['serviceDepartment'] = $mbMetadata['responsible_party'];
+ $mapbenderMetadata['serviceDepartmentMail'] = "kontakt at geoportal.rlp.de";
+ //$mapbenderMetadata['serviceGroupId'] = $mbMetadata['fkey_mb_group_id'];
+ $mapbenderMetadata['serviceOwnerId'] = $mbMetadata['fkey_mb_user_id'];
+ //TODO!
+ $mapbenderMetadata['serviceAccessConstraints'] = "Please ask the contact point!";
+ $mapbenderMetadata['serviceFees'] = "Please ask the contact point!";
+ //$mapbenderMetadata['minScale'] = $mbMetadata['layer_minscale'];
+ //$mapbenderMetadata['maxScale'] = $mbMetadata['layer_maxscale'];
+ //extract the coordinates from the_geom column
+ if (isset($mbMetadata['bbox2d']) && $mbMetadata['bbox2d'] != '') {
+ $bbox = str_replace(' ',',',str_replace(')','',str_replace('BOX(','',$mbMetadata['bbox2d'])));
+ //$e = new mb_exception("class_iso19139.php: got bbox for metadata: ".$bbox);
+ $wgs84Bbox = explode(',',$bbox);
+ } else {
+ $wgs84Bbox[0] = "6";
+ $wgs84Bbox[1] = "48";
+ $wgs84Bbox[2] = "8";
+ $wgs84Bbox[3] = "51";
+ }
+ $mapbenderMetadata['minx'] = $wgs84Bbox[0];
+ $mapbenderMetadata['miny'] = $wgs84Bbox[1];
+ $mapbenderMetadata['maxx'] = $wgs84Bbox[2];
+ $mapbenderMetadata['maxy'] = $wgs84Bbox[3];
+ break;
case "wmslayer":
/*given information:
wms_id, layer_id
@@ -408,7 +477,7 @@
//generate identifier part
$identifier = $iso19139->createElement("gmd:fileIdentifier");
$identifierString = $iso19139->createElement("gco:CharacterString");
- //How to generate UUIDs for INSPIRE Download Service Metadata records (not really needed for INSPIRE!!! See DB Metadaten)
+ //How to generate UUIDs for INSPIRE Download Service Metadata records (not really needed for INSPIRE!!! See DB Metadata)
//12-4-4-4-8
//dataurl
//WMS uuid (12-4), Type (4) - 0001, MD uuid (4-8)
@@ -417,7 +486,7 @@
//wmsgetmap
//WMS uuid (12-4), Type (4) - 0002, MD uuid (4-8)
//metadata
- //metadata uuid (12-4),hash(downloadurl) (4-8);
+ //metadata uuid (12-4),hash(downloadLink) (4-8);
if (isset($mapbenderMetadata['serviceUuid']) && $mapbenderMetadata['serviceUuid'] != '' ) {
$servicePart = explode('-',$mapbenderMetadata['serviceUuid']);
@@ -432,6 +501,13 @@
case "wfs":
$dlsFileIdentifier = $servicePart[0]."-".$servicePart[1]."-".$mdPart[2]."-".$mdPart[3]."-".$mdPart[4];
break;
+ //TODO!!!!!
+ case "metadata":
+ //$dlsFileIdentifier = $servicePart[0]."-".$servicePart[1]."-".$mdPart[2]."-".$mdPart[3]."-".$mdPart[4];
+ //generate hash from downloadLink
+ $linkPart = md5($mapbenderMetadata['downloadLink']);
+ $dlsFileIdentifier = $mdPart[0]."-".$mdPart[1]."-".$mdPart[2]."-".substr($linkPart, -12, 4)."-".substr($linkPart, -8, 8);
+ break;
}
$identifierText = $iso19139->createTextNode($dlsFileIdentifier);
} else {
@@ -670,6 +746,9 @@
case "wfs":
$generatorText = "GetFeature Anfragen an einen WFS 1.1.0";
break;
+ case "metadata":
+ $generatorText = "Download Link aus einem Metadatensatz";
+ break;
}
$abstractText = $iso19139->createTextNode("Beschreibung des INSPIRE Download Service (predefined Atom): ".$mapbenderMetadata['mdAbstract']." - Der/die Link(s) für das Herunterladen der Datensätze wird/werden dynamisch aus ".$generatorText." generiert");
}
@@ -1018,6 +1097,9 @@
case "wfs":
$gmd_URLText=$iso19139->createTextNode($mapbenderPath."/php/mod_inspireDownloadFeed.php?id=".$recordId."&type=SERVICE&generateFrom=wfs&wfsid=".$mapbenderMetadata['serviceId']);
break;
+ case "metadata":
+ $gmd_URLText=$iso19139->createTextNode($mapbenderPath."/php/mod_inspireDownloadFeed.php?id=".$recordId."&type=SERVICE&generateFrom=metadata");
+ break;
}
//Check if anonymous user has rights to access this layer - if not ? which resource should be advertised? TODO
Modified: trunk/mapbender/http/php/mod_metadataWrite.php
===================================================================
--- trunk/mapbender/http/php/mod_metadataWrite.php 2014-01-28 07:09:12 UTC (rev 8762)
+++ trunk/mapbender/http/php/mod_metadataWrite.php 2014-01-30 15:10:23 UTC (rev 8763)
@@ -25,6 +25,7 @@
$hostName = $_SERVER["argv"][23];
$orderBy = $_SERVER["argv"][24];
$resourceIds = $_SERVER["argv"][25];
+$restrictToOpenData = $_SERVER["argv"][26];
-$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources, $searchPages, $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds);
+$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources, $searchPages, $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData);
?>
Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql 2014-01-28 07:09:12 UTC (rev 8762)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7.4_to_2.8_pgsql_UTF-8.sql 2014-01-30 15:10:23 UTC (rev 8763)
@@ -197,3 +197,62 @@
ALTER TABLE wms_list_view
OWNER TO postgres;
+-- Function: f_tou_isopen(integer)
+
+-- DROP FUNCTION f_tou_isopen(integer);
+
+CREATE OR REPLACE FUNCTION f_tou_isopen(integer)
+ RETURNS integer AS
+$BODY$
+DECLARE
+ tou_isopen int4;
+BEGIN
+tou_isopen := isopen from termsofuse where termsofuse.termsofuse_id = $1;
+RETURN tou_isopen;
+END;
+$BODY$
+ LANGUAGE plpgsql VOLATILE
+ COST 100;
+ALTER FUNCTION f_tou_isopen(integer)
+ OWNER TO postgres;
+
+--enhance search view with isopen classification for resources
+-- View: search_wms_view
+
+DROP VIEW search_wms_view;
+
+CREATE OR REPLACE VIEW search_wms_view AS
+ SELECT DISTINCT ON (wms_unref.layer_id) wms_unref.wms_id, wms_unref.availability, wms_unref.status, wms_unref.wms_title, wms_unref.wms_abstract, wms_unref.stateorprovince, wms_unref.country, wms_unref.accessconstraints, wms_unref.termsofuse, wms_unref.isopen, wms_unref.wms_owner, wms_unref.layer_id, wms_unref.epsg, wms_unref.layer_title, wms_unref.layer_abstract, wms_unref.layer_name, wms_unref.layer_parent, wms_unref.layer_pos, wms_unref.layer_queryable, wms_unref.load_count, wms_unref.searchtext, wms_unref.wms_timestamp, wms_unref.department, wms_unref.mb_group_name, f_collect_custom_cat_layer(wms_unref.layer_id) AS md_custom_cats, f_collect_inspire_cat_layer(wms_unref.layer_id) AS md_inspire_cats, f_collect_topic_cat_layer(wms_unref.layer_id) AS md_topic_cats, geometryfromtext(((((((((((((((((((('POLYGON(('::text || layer_epsg.minx::text) || ' '::text) || layer_epsg.miny::text) || ','::text) || layer_epsg.minx::text) || ' '::text) || layer_epsg.maxy::text) || ','::text)
|| layer_epsg.maxx::text) || ' '::text) || layer_epsg.maxy::text) || ','::text) || layer_epsg.maxx::text) || ' '::text) || layer_epsg.miny::text) || ','::text) || layer_epsg.minx::text) || ' '::text) || layer_epsg.miny::text) || '))'::text, 4326) AS the_geom, (((((layer_epsg.minx::text || ','::text) || layer_epsg.miny::text) || ','::text) || layer_epsg.maxx::text) || ','::text) || layer_epsg.maxy::text AS bbox, wms_unref.wms_proxylog, wms_unref.wms_network_access, wms_unref.wms_pricevolume, wms_unref.mb_group_logo_path
+ FROM ( SELECT wms_uncat.wms_id, wms_uncat.availability, wms_uncat.status, wms_uncat.wms_title, wms_uncat.wms_abstract, wms_uncat.stateorprovince, wms_uncat.country, wms_uncat.accessconstraints, wms_uncat.termsofuse, wms_uncat.isopen, wms_uncat.wms_owner, wms_uncat.layer_id, wms_uncat.epsg, wms_uncat.layer_title, wms_uncat.layer_abstract, wms_uncat.layer_name, wms_uncat.layer_parent, wms_uncat.layer_pos, wms_uncat.layer_queryable, wms_uncat.load_count, wms_uncat.searchtext, wms_uncat.wms_timestamp, wms_uncat.department, wms_uncat.mb_group_name, wms_uncat.wms_proxylog, wms_uncat.wms_network_access, wms_uncat.wms_pricevolume, wms_uncat.mb_group_logo_path
+ FROM ( SELECT wms_dep.wms_id, wms_dep.availability, wms_dep.status, wms_dep.wms_title, wms_dep.wms_abstract, wms_dep.stateorprovince, wms_dep.country, wms_dep.accessconstraints, wms_dep.termsofuse, wms_dep.isopen, wms_dep.wms_owner, layer.layer_id, f_collect_epsg(layer.layer_id) AS epsg, layer.layer_title, layer.layer_abstract, layer.layer_name, layer.layer_parent, layer.layer_pos, layer.layer_queryable, f_layer_load_count(layer.layer_id) AS load_count, f_collect_searchtext(wms_dep.wms_id, layer.layer_id) AS searchtext, wms_dep.wms_timestamp, wms_dep.department, wms_dep.mb_group_name, wms_dep.wms_proxylog, wms_dep.wms_network_access, wms_dep.wms_pricevolume, wms_dep.mb_group_logo_path
+ FROM ( SELECT wms.wms_id, wms.wms_title, wms.wms_abstract, wms.stateorprovince, wms.country, mb_wms_availability.availability, mb_wms_availability.last_status AS status, wms.accessconstraints, f_getwms_tou(wms.wms_id) AS termsofuse, f_tou_isopen(f_getwms_tou(wms.wms_id)) as isopen, wms.wms_timestamp, wms.wms_owner, wms.wms_proxylog, wms.wms_network_access, wms.wms_pricevolume, user_dep.fkey_mb_group_id AS department, user_dep.fkey_mb_group_id, user_dep.fkey_mb_group_id AS wms_department, user_dep.mb_group_name, user_dep.mb_group_logo_path
+ FROM ( SELECT registrating_groups.fkey_mb_user_id, mb_group.mb_group_id AS fkey_mb_group_id, mb_group.mb_group_name, mb_group.mb_group_title, mb_group.mb_group_country, mb_group.mb_group_stateorprovince, mb_group.mb_group_logo_path
+ FROM registrating_groups, mb_group
+ WHERE registrating_groups.fkey_mb_group_id = mb_group.mb_group_id) user_dep, wms, mb_wms_availability
+ WHERE wms.wms_owner = user_dep.fkey_mb_user_id AND wms.wms_id = mb_wms_availability.fkey_wms_id) wms_dep, layer
+ WHERE layer.fkey_wms_id = wms_dep.wms_id AND layer.layer_searchable = 1) wms_uncat) wms_unref, layer_epsg
+ WHERE layer_epsg.epsg::text = 'EPSG:4326'::text AND wms_unref.layer_id = layer_epsg.fkey_layer_id
+ ORDER BY wms_unref.layer_id;
+
+ALTER TABLE search_wms_view
+ OWNER TO postgres;
+
+-- View: search_wfs_view
+
+DROP VIEW search_wfs_view;
+
+CREATE OR REPLACE VIEW search_wfs_view AS
+ SELECT wfs_dep.wfs_id, wfs_dep.wfs_title, wfs_dep.wfs_abstract, wfs_dep.administrativearea, wfs_dep.country, wfs_dep.accessconstraints, wfs_dep.termsofuse, wfs_dep.isopen, wfs_dep.wfs_owner, wfs_featuretype.featuretype_id, wfs_featuretype.featuretype_srs, wfs_featuretype.featuretype_title, wfs_featuretype.featuretype_abstract, f_collect_searchtext_wfs(wfs_dep.wfs_id, wfs_featuretype.featuretype_id) AS searchtext, wfs_element.element_type, wfs_conf.wfs_conf_id, wfs_conf.wfs_conf_abstract, wfs_conf.wfs_conf_description, f_getwfsmodultype(wfs_conf.wfs_conf_id) AS modultype, wfs_dep.wfs_timestamp, wfs_dep.department, wfs_dep.mb_group_name, wfs_dep.mb_group_logo_path
+ FROM ( SELECT wfs.wfs_id, wfs.wfs_title, wfs.wfs_abstract, wfs.administrativearea, wfs.country, wfs.accessconstraints, f_getwfs_tou(wfs.wfs_id) AS termsofuse, f_tou_isopen(f_getwfs_tou(wfs.wfs_id)) as isopen, wfs.wfs_timestamp, wfs.wfs_owner, user_dep.mb_group_id AS department, user_dep.mb_group_name, user_dep.mb_group_logo_path
+ FROM ( SELECT registrating_groups.fkey_mb_user_id AS mb_user_id, mb_group.mb_group_id, mb_group.mb_group_name, mb_group.mb_group_logo_path
+ FROM registrating_groups, mb_group
+ WHERE registrating_groups.fkey_mb_group_id = mb_group.mb_group_id) user_dep, wfs
+ WHERE user_dep.mb_user_id = wfs.wfs_owner) wfs_dep, wfs_featuretype, wfs_element, wfs_conf
+ WHERE wfs_featuretype.fkey_wfs_id = wfs_dep.wfs_id AND wfs_featuretype.featuretype_searchable = 1 AND wfs_element.element_type::text ~~ '%Type'::text AND wfs_featuretype.featuretype_id = wfs_element.fkey_featuretype_id AND wfs_featuretype.featuretype_id = wfs_conf.fkey_featuretype_id
+ ORDER BY wfs_featuretype.featuretype_id;
+
+ALTER TABLE search_wfs_view
+ OWNER TO postgres;
+
+
+
More information about the Mapbender_commits
mailing list