From d83b2d0989c9823e8850bffd89b06c8ccd26406b Mon Sep 17 00:00:00 2001 From: uprel Date: Wed, 20 Dec 2017 21:48:30 +0100 Subject: [PATCH] New client setting in settings.template to overwrite Identify name for raster files (Band 1 -> anything you set) Identify Window - layer name also for raster --- client/site/js/FeatureInfoDisplay.js | 22 +++++++++------------- client_common/load.php | 11 +++++++++++ client_common/settings.template | 6 ++++++ client_mobile/src/feature_info.js | 8 +++----- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/client/site/js/FeatureInfoDisplay.js b/client/site/js/FeatureInfoDisplay.js index 57d2b0c4..c44961b3 100755 --- a/client/site/js/FeatureInfoDisplay.js +++ b/client/site/js/FeatureInfoDisplay.js @@ -422,22 +422,22 @@ function parseFIResult(node) { var hasAttributes = false; var rasterData = false; var htmlText = ""; - //if (showFILayerTitle) { - // htmlText += "

" + wmsLoader.layerProperties[node.getAttribute("name")].title + "

"; - //} + var layerChildNode = node.firstChild; var layerTitle = wmsLoader.layerProperties[node.getAttribute("name")].title; + if (showFILayerTitle) { + htmlText += "

" + layerTitle + "

"; + } + var fid = layerTitle+"."+node.firstElementChild.id; while (layerChildNode) { + + if (layerChildNode.hasChildNodes() && layerChildNode.nodeName === "Feature") { var attributeNode = layerChildNode.firstChild; - if (showFILayerTitle) { - htmlText += "

" + layerTitle + "

"; - } - - htmlText += '\n

\n \n '; + htmlText += '
'; //case vector data //add geometry actions if layer is WFS published or geometry is added to response @@ -503,7 +503,7 @@ function parseFIResult(node) { if (rasterData == false) { htmlText += "\n

\n
\n "; } - htmlText += '\n'; + htmlText += '\n'; hasAttributes = true; rasterData = true; } @@ -698,8 +698,4 @@ function identifyAction(type,id) { } - - - - } \ No newline at end of file diff --git a/client_common/load.php b/client_common/load.php index 90071bbc..0e7d05b5 100644 --- a/client_common/load.php +++ b/client_common/load.php @@ -112,5 +112,16 @@ } }; +function getRasterFieldName(layer, name) { + if (!(Eqwc.settings.overWriteRasterFieldName && Eqwc.settings.overWriteRasterFieldName[layer])) { + return name; + } + if (Eqwc.settings.overWriteRasterFieldName[layer][0] == name) { + return Eqwc.settings.overWriteRasterFieldName[layer][1]; + } else { + return name; + } +} + //TODO use in css! var userLogoImg = projectData.gis_projects.path + 'admin/resources/images/user_gray.png'; \ No newline at end of file diff --git a/client_common/settings.template b/client_common/settings.template index bc3ec4df..e2af9cbc 100644 --- a/client_common/settings.template +++ b/client_common/settings.template @@ -42,6 +42,12 @@ Eqwc.settings.visibleFirstBaseLayer = true; //Relevant for 2.14, since 2.18 already returns blank string Eqwc.settings.noDataValue = ''; +//overwrite identify return of raster files +//instead of Band 1 write desired value +Eqwc.settings.overWriteRasterFieldName = {}; +//Eqwc.settings.overWriteRasterFieldName["layername"] = ["Band 1", "Your value"]; + + //use separate gisportal code to browse projects, register users and login //code available here - https://github.com/uprel/gisportal Eqwc.settings.useGisPortal = false; diff --git a/client_mobile/src/feature_info.js b/client_mobile/src/feature_info.js index 709f2500..4b98afe1 100755 --- a/client_mobile/src/feature_info.js +++ b/client_mobile/src/feature_info.js @@ -79,6 +79,7 @@ FeatureInfo.prototype.parseResults = function(featureInfos) { var xml = $.parseXML(featureInfos[i]); $(xml).find('Layer').each(function() { var features = []; + var lay = $(this).attr('name'); if ($(this).find('Feature').length > 0) { // vector features $(this).find('Feature').each(function() { @@ -88,7 +89,7 @@ FeatureInfo.prototype.parseResults = function(featureInfos) { if ($(this).attr('name') != 'geometry') { attributes.push({ name: $(this).attr('name'), - value: $(this).attr('value') + value: $(this).attr('value').replace("NULL", Eqwc.settings.noDataValue) }); } }); @@ -103,7 +104,7 @@ FeatureInfo.prototype.parseResults = function(featureInfos) { var attributes = []; $(this).find('Attribute').each(function() { attributes.push({ - name: $(this).attr('name'), + name: getRasterFieldName(Config.getLayerName(lay), $(this).attr('name')), value: $(this).attr('value').replace("NULL", Eqwc.settings.noDataValue) }); }); @@ -114,9 +115,6 @@ FeatureInfo.prototype.parseResults = function(featureInfos) { } if (features.length > 0) { - - var lay = $(this).attr('name'); - results.push({ layer: Config.getLayerName(lay), features: features
' + layerChildNode.getAttribute("name") + '' + layerChildNode.getAttribute("value") + '
' + getRasterFieldName(layerTitle, layerChildNode.getAttribute("name")) + '' + layerChildNode.getAttribute("value") + '