Skip to content

Commit

Permalink
[BUGFIX] GetFeatureInfo with layer's title
Browse files Browse the repository at this point in the history
Since QGIS 2.6, When querying GetFeatureInfo with text/xml format, the
 layer's name can be the layer's title.
  • Loading branch information
rldhont committed Nov 27, 2014
1 parent ba48b8f commit 083d37e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
16 changes: 16 additions & 0 deletions lizmap/modules/lizmap/classes/lizmapProject.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ public function getOptions(){
public function getLayers(){
return $this->cfg->layers;
}

public function findLayerByName( $name ){
if ( property_exists($this->cfg->layers, $name ) )
return $this->cfg->layers->$name;
return null;
}

public function findLayerByTitle( $title ){
foreach ( $this->cfg->layers as $layer ) {
if ( !property_exists( $layer, 'title' ) )
continue;
if ( $layer->title == $title )
return $layer;
}
return null;
}

public function hasLocateByLayer(){
if ( property_exists($this->cfg,'locateByLayer') ){
Expand Down
16 changes: 11 additions & 5 deletions lizmap/modules/lizmap/controllers/service.classic.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,17 @@ function getFeatureInfoHtml($params, $xmldata){

foreach($xml->Layer as $layer){
$layername = $layer['name'];
$configLayer = $this->project->findLayerByName( $layername );
// since 2.6 layer's name can be layer's title
if ( $configLayer == null )
$configLayer = $this->project->findLayerByTitle( $layername );
if ( $configLayer == null )
continue;

// Avoid layer if no popup asked by the user for it
// or if no popup property
if(property_exists($configLayers->$layername, 'popup')){
if($configLayers->$layername->popup != 'True'){
if(property_exists($configLayer, 'popup')){
if($configLayer->popup != 'True'){
continue;
}
}
Expand All @@ -482,13 +488,13 @@ function getFeatureInfoHtml($params, $xmldata){
}

// Get layer title
$layerTitle = $configLayers->$layername->title;
$layerTitle = $configLayer->title;

// Get the template for the popup content
$templateConfigured = False;
if(property_exists($configLayers->$layername, 'popupTemplate')){
if(property_exists($configLayer, 'popupTemplate')){
// Get template content
$popupTemplate = (string)trim($configLayers->$layername->popupTemplate);
$popupTemplate = (string)trim($configLayer->popupTemplate);
// Use it if not empty
if(!empty($popupTemplate)){
$templateConfigured = True;
Expand Down

0 comments on commit 083d37e

Please sign in to comment.