[Mapbender-commits] r8856 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue May 13 07:07:03 PDT 2014
Author: armin11
Date: 2014-05-13 07:07:03 -0700 (Tue, 13 May 2014)
New Revision: 8856
Modified:
trunk/mapbender/http/classes/class_metadata_new.php
Log:
Enable output of legendurls and getlegendgraphicurls for wms ressources in search interface. TODO - optimize database select - only one select for all layer_ids!
Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php 2014-05-13 13:32:35 UTC (rev 8855)
+++ trunk/mapbender/http/classes/class_metadata_new.php 2014-05-13 14:07:03 UTC (rev 8856)
@@ -746,6 +746,12 @@
$this->wmsJSON->wms->srv[$j]->layer[0]->abstract = $subLayers[$rootIndex]['layer_abstract'];
$this->wmsJSON->wms->srv[$j]->layer[0]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?languageCode=".$this->languageCode."&resource=layer&layout=tabs&id=".(integer)$subLayers[$rootIndex]['layer_id'];
$this->wmsJSON->wms->srv[$j]->layer[0]->previewURL = "http://".$this->hostName."/mapbender/geoportal/mod_showPreview.php?resource=layer&id=".(integer)$subLayers[$rootIndex]['layer_id'];
+ $legendInfo = $this->getLegendInfofromLayerId($this->wmsJSON->wms->srv[$j]->layer[0]->id);
+ $this->wmsJSON->wms->srv[$j]->layer[0]->getLegendGraphicUrl = $legendInfo['getLegendGraphicUrl'];
+ $this->wmsJSON->wms->srv[$j]->layer[0]->getLegendGraphicUrlFormat = $legendInfo['getLegendGraphicUrlFormat'];
+ $this->wmsJSON->wms->srv[$j]->layer[0]->legendUrl = $legendInfo['legendUrl'];
+
+
if ($subLayers[$rootIndex]['layer_name'] == ''){
$this->wmsJSON->wms->srv[$j]->layer[0]->loadable = 0;
}
@@ -1446,6 +1452,31 @@
}
+ private function getLegendInfofromLayerId($layerId) {
+ $sql = "SELECT layer_wms.*, layer_style.legendurl, layer_style.legendurlformat FROM (SELECT layer_id, wms_getlegendurl, wms_owsproxy FROM layer INNER JOIN wms ON layer.fkey_wms_id = wms.wms_id WHERE layer.layer_id = $1) as layer_wms, layer_style where layer_style.fkey_layer_id = layer_wms.layer_id";
+ $v = array($layerId);
+ $t = array('i');
+ $res = db_prep_query($sql, $v, $t);
+ while($row = db_fetch_array($res)){
+ $getLegendUrl = $row['wms_getlegendurl'];
+ $legendUrl = $row['legendurl'];
+ $legendUrlFormat = $row['legendurlformat'];
+ $owsProxy = $row['wms_owsproxy'];
+ }
+ //hostname does not exist! - use hostname from parameter instead
+ if ($owsProxy != null && $owsProxy != '' && $getLegendUrl != '' && $getLegendUrl != null) {
+ $sessionId = "00000000000000000000000000000000";
+ $getLegendUrlNew = "http://".$this->hostName."/owsproxy/".$sessionId."/".$owsProxy."?";
+ //also let go legendurl thru owsproxy exchange first legendurl part with owsproxy part!
+ $legendUrl = str_replace($getLegendUrl,$getLegendUrlNew,$legendUrl);
+ $getLegendUrl = $getLegendUrlNew;
+ }
+ $returnArray['legendUrl'] = $legendUrl;
+ $returnArray['getLegendGraphicUrl'] = $getLegendUrl;
+ $returnArray['getLegendGraphicUrlFormat'] = $legendUrlFormat;
+ return $returnArray;
+ }
+
private function getPermissionValueForLayer($layerId,$wmsId){
//TODO: Set Email of owner into view for ressource - so it don't have to be searched?
$return_permission="";
@@ -1603,6 +1634,10 @@
$servObject->layer[$countsublayer]->name = $child['layer_name'];
$servObject->layer[$countsublayer]->abstract = $child['layer_abstract'];
$servObject->layer[$countsublayer]->previewURL = "http://".$this->hostName."/mapbender/geoportal/mod_showPreview.php?resource=layer&id=".$child['layer_id'];
+ $legendInfo = $this->getLegendInfofromLayerId($servObject->layer[$countsublayer]->id);
+ $servObject->layer[$countsublayer]->getLegendGraphicUrl = $legendInfo['getLegendGraphicUrl'];
+ $servObject->layer[$countsublayer]->getLegendGraphicUrlFormat = $legendInfo['getLegendGraphicUrlFormat'];
+ $servObject->layer[$countsublayer]->legendUrl = $legendInfo['legendUrl'];
$servObject->layer[$countsublayer]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?languageCode=".$this->languageCode."&resource=layer&layout=tabs&id=".$child['layer_id'];
if ($child['layer_name'] == ''){
$servObject->layer[$countsublayer]->loadable = 0;
More information about the Mapbender_commits
mailing list