Skip to content

Commit

Permalink
Zoom to filtered layers in wms server if BBOX parameter missing
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed Jun 7, 2011
1 parent 38f9296 commit aabfbf8
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions src/mapserver/qgswmsserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1556,24 +1556,49 @@ QMap<QString, QString> QgsWMSServer::applyRequestedLayerFilters( const QStringLi
QgsVectorLayer* filteredLayer = dynamic_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
if ( filteredLayer )
{
QgsVectorDataProvider* dp = filteredLayer->dataProvider();
if ( dp )
if( filteredLayer )
{
filterMap.insert( layerId, dp->subsetString() );
filterMap.insert( layerId, filteredLayer->subsetString() );
QString newSubsetString = eqSplit.at( 1 );
if ( !filteredLayer->subsetString().isEmpty() )
{
newSubsetString.prepend( " AND " );
newSubsetString.prepend( filteredLayer->subsetString() );
}
filteredLayer->setSubsetString( newSubsetString );
}

QString newSubsetString = eqSplit.at( 1 );
if ( !dp->subsetString().isEmpty() )
{
newSubsetString.prepend( " AND " );
newSubsetString.prepend( dp->subsetString() );
}
dp->setSubsetString( newSubsetString );
}
}
++listPos;
}
}

//No BBOX parameter in request. We use the union of the filtered layer
//to provide the functionality of zooming to selected records via (enhanced) WMS.
if( mMapRenderer && mMapRenderer->extent().isEmpty() )
{
QgsRectangle filterExtent;
QMap<QString, QString>::const_iterator filterIt = filterMap.constBegin();
for(; filterIt != filterMap.constEnd(); ++filterIt )
{
QgsMapLayer* mapLayer = QgsMapLayerRegistry::instance()->mapLayer( filterIt.key() );
if( !mapLayer )
{
continue;
}

QgsRectangle layerExtent = mapLayer->extent();
if( filterExtent.isEmpty() )
{
filterExtent = layerExtent;
}
else
{
filterExtent.combineExtentWith( &layerExtent );
}
}
mMapRenderer->setExtent( filterExtent );
}
}
return filterMap;
}
Expand Down

0 comments on commit aabfbf8

Please sign in to comment.