[QGIS Commit] r15111 - trunk/qgis/src/mapserver
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Mon Jan 31 05:47:19 EST 2011
Author: mhugent
Date: 2011-01-31 02:47:19 -0800 (Mon, 31 Jan 2011)
New Revision: 15111
Modified:
trunk/qgis/src/mapserver/qgsconfigparser.cpp
Log:
Change getPrint syntax to use several parameters for composer maps, e.g. map0:extent=xmin,ymin,xmax,ymax or map0:rotation=45
Modified: trunk/qgis/src/mapserver/qgsconfigparser.cpp
===================================================================
--- trunk/qgis/src/mapserver/qgsconfigparser.cpp 2011-01-31 10:46:46 UTC (rev 15110)
+++ trunk/qgis/src/mapserver/qgsconfigparser.cpp 2011-01-31 10:47:19 UTC (rev 15111)
@@ -302,69 +302,83 @@
continue;
}
- //search composer map title in parameter map-> string
- QMap< QString, QString >::const_iterator titleIt = parameterMap.find( "MAP" + QString::number( currentMap->id() ) );
- if ( titleIt == parameterMap.constEnd() )
+ QString mapId = "MAP" + QString::number( currentMap->id() );
+ QMap< QString, QString >::const_iterator extentIt = parameterMap.find( mapId + ":EXTENT" );
+ if ( extentIt == parameterMap.constEnd() ) //map extent is mandatory
{
//remove map from composition if not referenced by the request
- c->removeItem( *mapIt );
- delete( *mapIt );
- continue;
+ c->removeItem( *mapIt ); delete( *mapIt ); continue;
}
- QString replaceString = titleIt.value();
- QStringList replacementList = replaceString.split( "/" );
- //get map extent from string
- if ( replacementList.size() > 0 )
+ QStringList coordList = extentIt.value().split( "," );
+ if ( coordList.size() < 4 )
{
- QStringList coordList = replacementList.at( 0 ).split( "," );
- if ( coordList.size() > 3 )
+ c->removeItem( *mapIt ); delete( *mapIt ); continue; //need at least four coordinates
+ }
+
+ bool xMinOk, yMinOk, xMaxOk, yMaxOk;
+ double xmin = coordList.at( 0 ).toDouble( &xMinOk );
+ double ymin = coordList.at( 1 ).toDouble( &yMinOk );
+ double xmax = coordList.at( 2 ).toDouble( &xMaxOk );
+ double ymax = coordList.at( 3 ).toDouble( &yMaxOk );
+ if ( !xMinOk || !yMinOk || !xMaxOk || !yMaxOk )
+ {
+ c->removeItem( *mapIt ); delete( *mapIt ); continue;
+ }
+
+ //Change x- and y- of extent for WMS 1.3.0 and geographic coordinate systems
+ QMap<QString, QString>::const_iterator versionIt = parameterMap.find( "VERSION" );
+ if ( versionIt != parameterMap.end() )
+ {
+ if ( mapRenderer && versionIt.value() == "1.3.0" && mapRenderer->destinationSrs().geographicFlag() )
{
- bool xMinOk, yMinOk, xMaxOk, yMaxOk;
- double xmin = coordList.at( 0 ).toDouble( &xMinOk );
- double ymin = coordList.at( 1 ).toDouble( &yMinOk );
- double xmax = coordList.at( 2 ).toDouble( &xMaxOk );
- double ymax = coordList.at( 3 ).toDouble( &yMaxOk );
- if ( xMinOk && yMinOk && xMaxOk && yMaxOk )
- {
- currentMap->setNewExtent( QgsRectangle( xmin, ymin, xmax, ymax ) );
- }
+ //switch coordinates of extent
+ double tmp;
+ tmp = xmin;
+ xmin = ymin; ymin = tmp;
+ tmp = xmax;
+ xmax = ymax; ymax = tmp;
}
}
+ currentMap->setNewExtent( QgsRectangle( xmin, ymin, xmax, ymax ) );
- //get rotation from string
- if ( replacementList.size() > 1 )
+ //scale
+ QMap< QString, QString >::const_iterator scaleIt = parameterMap.find( mapId + ":SCALE" );
+ if ( scaleIt != parameterMap.constEnd() )
{
- bool rotationOk;
- double rotation = replacementList.at( 1 ).toDouble( &rotationOk );
- if ( rotationOk )
+ bool scaleOk;
+ double scale = scaleIt->toDouble( &scaleOk );
+ if ( scaleOk )
{
- currentMap->setMapRotation( rotation );
+ currentMap->setNewScale( scale );
}
}
- //get forced scale from string
- if ( replacementList.size() > 2 )
+ //rotation
+ QMap< QString, QString >::const_iterator rotationIt = parameterMap.find( mapId + ":ROTATION" );
+ if ( rotationIt != parameterMap.constEnd() )
{
- bool conversionOk;
- double scale = replacementList.at( 2 ).toDouble( &conversionOk );
- if ( conversionOk )
+ bool rotationOk;
+ double rotation = rotationIt->toDouble( &rotationOk );
+ if ( rotationOk )
{
- currentMap->setNewScale( scale );
+ currentMap->setMapRotation( rotation );
}
}
- //get layer list from string
- if ( replacementList.size() > 3 )
+ //layers / styles
+ QMap< QString, QString >::const_iterator layersIt = parameterMap.find( mapId + ":LAYERS" );
+ QMap< QString, QString >::const_iterator stylesIt = parameterMap.find( mapId + ":STYLES" );
+ if ( layersIt != parameterMap.constEnd() )
{
QStringList layerSet;
- QStringList wmsLayerList = replacementList.at( 3 ).split( "," );
+ QStringList wmsLayerList = layersIt->split( "," );
QStringList wmsStyleList;
- if ( replacementList.size() > 4 )
+
+ if ( stylesIt != parameterMap.constEnd() )
{
- wmsStyleList = replacementList.at( 4 ).split( "," );
+ wmsStyleList = stylesIt->split( "," );
}
-
for ( int i = 0; i < wmsLayerList.size(); ++i )
{
QString styleName;
More information about the QGIS-commit
mailing list