[Mapbender-commits] r10389 - in trunk/mapbender: http/classes http/javascripts http/php lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Jan 21 08:42:59 PST 2020
Author: armin11
Date: 2020-01-21 08:42:58 -0800 (Tue, 21 Jan 2020)
New Revision: 10389
Modified:
trunk/mapbender/http/classes/class_map.php
trunk/mapbender/http/classes/class_wms.php
trunk/mapbender/http/javascripts/initWmcObj.php
trunk/mapbender/http/php/mod_getCoupledResourcesForDataset.php
trunk/mapbender/lib/class_GetApi.php
Log:
Add possibility to give a new GET parameter DATASETID when giving a wms url to load as GET parameter WMS. If a layer in the parsed wms has an identifier which is identical to DATASETID, the layer will be activated. This is the INSPIRE way of getting the right layer of a invoked service. Some services from CSW will have hundreds of different layers and otherwise it would be not possible to find the right one!
Modified: trunk/mapbender/http/classes/class_map.php
===================================================================
--- trunk/mapbender/http/classes/class_map.php 2020-01-21 11:32:09 UTC (rev 10388)
+++ trunk/mapbender/http/classes/class_map.php 2020-01-21 16:42:58 UTC (rev 10389)
@@ -435,9 +435,14 @@
for ($j = 0; $j < $numLayers; $j++) {
$wmsArray[$i]->objLayer[$j]->gui_layer_visible = 0;
+ //layer which has defined a identifier (this came from the search) should be visible
+ if (isset($wmsArray[$i]->objLayer[$j]->layer_identifier)) {
+ $wmsArray[$i]->objLayer[$j]->gui_layer_visible = 1;
+ }
}
}
}
+
}
// querylayer
Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php 2020-01-21 11:32:09 UTC (rev 10388)
+++ trunk/mapbender/http/classes/class_wms.php 2020-01-21 16:42:58 UTC (rev 10389)
@@ -620,10 +620,9 @@
return strval($this->wms_title);
}
- function createObjFromXML($url){
- if (func_num_args() == 2) { //new for HTTP Authentication
- $auth = func_get_arg(1);
- $x = new connector($url,$auth);
+ function createObjFromXML($url, $auth=false, $datasetId=false){
+ if ($auth != false) { //new for HTTP Authentication
+ $x = new connector($url, $auth);
}
else {
$x = new connector($url);
@@ -1014,6 +1013,16 @@
if(mb_strtoupper($element['tag']) == "NAME"){
$this->objLayer[$cnt_layer]->layer_name = $element['value'];
}
+ if(mb_strtoupper($element['tag']) == "IDENTIFIER"){
+ if ($datasetId != false) {
+ if ($datasetId == $element['value']) {
+ $e = new mb_exception("classes/class_wms.php: found a layer with searched identifier in wms - its name is: ".$this->objLayer[$cnt_layer]->layer_name);
+ //only set the identifier if a requested datasetId was found
+ $this->objLayer[$cnt_layer]->layer_identifier = $element['value'];
+ }
+ }
+ //$this->objLayer[$cnt_layer]->layer_identifier = $element['value'];
+ }
if(mb_strtoupper($element['tag']) == "TITLE"){
$this->objLayer[$cnt_layer]->layer_title = $this->stripEndlineAndCarriageReturn($element['value']);
}
Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php 2020-01-21 11:32:09 UTC (rev 10388)
+++ trunk/mapbender/http/javascripts/initWmcObj.php 2020-01-21 16:42:58 UTC (rev 10389)
@@ -172,6 +172,7 @@
$getParams = array(
"WMC" => getConfiguration("WMC"),
"WMS" => getConfiguration("WMS"),
+ "DATASETID" => getConfiguration("DATASETID"),
"LAYER" => getConfiguration("LAYER"),
"FEATURETYPE" => getConfiguration("FEATURETYPE"),
"GEORSS"=>getConfiguration("GEORSS"),
@@ -212,6 +213,9 @@
WMS
*/
$e = new mb_notice("javascripts/initWmcObj.php: check WMS API");
+
+//private $datasetid; //new parameter to find a layer with a corresponding identifier element - solves the INSPIRE data service coupling after retrieving the ows from a dataset search via CSW interface! Only relevant, if a WMS is gioven
+
if ($getParams['WMS']) {
// WMS param given as array
if (is_array($getParams['WMS'])) {
@@ -263,6 +267,7 @@
);
}
} else {
+ //one single WMS capabilities url is given - check it
$currentWms = new wms();
if(is_numeric($key)) {
// get WMS by ID
@@ -271,7 +276,9 @@
}
// get WMS by URL
else if (is_string($val)) {
- $resultOfWmsParsing = $currentWms->createObjFromXML($val);
+ //$e = new mb_exception("javascripts/initWmcObj.php: look for identifier element: ".$getParams['DATASETID']);
+ $resultOfWmsParsing = $currentWms->createObjFromXML($val, false, $getParams['DATASETID']);
+ //$e = new mb_exception("javascripts/initWmcObj.php: wms object to add: ".json_encode($currentWms));
}
if ($resultOfWmsParsing['success'] == true) {
array_push($wmsArray, $currentWms);
Modified: trunk/mapbender/http/php/mod_getCoupledResourcesForDataset.php
===================================================================
--- trunk/mapbender/http/php/mod_getCoupledResourcesForDataset.php 2020-01-21 11:32:09 UTC (rev 10388)
+++ trunk/mapbender/http/php/mod_getCoupledResourcesForDataset.php 2020-01-21 16:42:58 UTC (rev 10389)
@@ -279,6 +279,7 @@
$numberOfMetadataRecords++;
}*/
//$e = new mb_exception("found service with fileIdentifier: ".$fileIdentifier." - date - ".$mdDateStamp);
+ $serviceMetadata->service[$k]->datasetId = $datasetId;
$serviceMetadata->service[$k]->serviceType = $mdServiceType;
$serviceMetadata->service[$k]->serviceTitle = $mdTitle;
$serviceMetadata->service[$k]->serviceDate = $mdDateStamp;
Modified: trunk/mapbender/lib/class_GetApi.php
===================================================================
--- trunk/mapbender/lib/class_GetApi.php 2020-01-21 11:32:09 UTC (rev 10388)
+++ trunk/mapbender/lib/class_GetApi.php 2020-01-21 16:42:58 UTC (rev 10389)
@@ -19,7 +19,8 @@
private $wmc = array();
private $zoom = array();
private $geojsonzoom;
- private $geojsonzoomscale;
+ private $geojsonzoomscale;
+ private $datasetid; //new parameter to find a layer with a corresponding identifier element - solves the INSPIRE data service coupling after retrieving the ows from a dataset search via CSW interface! Only relevant, if a WMS is given
/**
* @param array $input
@@ -57,6 +58,9 @@
case "ZOOM":
$this->zoom = $this->normalizeZoomInput($value);
break;
+ case "DATASETID":
+ $this->datasetid = $this->normalizeDatasetIdInput($value);
+ break;
}
}
}
@@ -117,6 +121,13 @@
return $this->geojsonzoomoffset;
}
+ /*
+ *
+ *
+ */
+ public function getDatasetId(){
+ return $this->datasetid;
+ }
/**
* Returns an array of zoom parameters
@@ -355,6 +366,17 @@
return $offset;
}
+ private function normalizeDatasetIdInput($input){
+ $datasetId = false;
+ $testMatch = $input;
+ $pattern = '/^(?!\s*$).+/';
+ if (preg_match($pattern,$testMatch)){
+ $e = new mb_exception("lib/classGetApi.php: Get parameter DATASETID has whitespaces - will be set to false!");
+ } else {
+ $datasetId = $testMatch;
+ }
+ return $datasetId;
+ }
}
?>
More information about the Mapbender_commits
mailing list