@@ -302,69 +302,83 @@ QgsComposition* QgsConfigParser::createPrintComposition( const QString& composer
302
302
continue ;
303
303
}
304
304
305
- // search composer map title in parameter map-> string
306
- QMap< QString, QString >::const_iterator titleIt = parameterMap.find ( " MAP " + QString::number ( currentMap-> id () ) );
307
- if ( titleIt == parameterMap.constEnd () )
305
+ QString mapId = " MAP " + QString::number ( currentMap-> id () );
306
+ QMap< QString, QString >::const_iterator extentIt = parameterMap.find ( mapId + " :EXTENT " );
307
+ if ( extentIt == parameterMap.constEnd () ) // map extent is mandatory
308
308
{
309
309
// remove map from composition if not referenced by the request
310
- c->removeItem ( *mapIt );
311
- delete ( *mapIt );
312
- continue ;
310
+ c->removeItem ( *mapIt ); delete ( *mapIt ); continue ;
311
+ }
312
+
313
+ QStringList coordList = extentIt.value ().split ( " ," );
314
+ if ( coordList.size () < 4 )
315
+ {
316
+ c->removeItem ( *mapIt ); delete ( *mapIt ); continue ; // need at least four coordinates
313
317
}
314
- QString replaceString = titleIt.value ();
315
- QStringList replacementList = replaceString.split ( " /" );
316
318
317
- // get map extent from string
318
- if ( replacementList.size () > 0 )
319
+ bool xMinOk, yMinOk, xMaxOk, yMaxOk;
320
+ double xmin = coordList.at ( 0 ).toDouble ( &xMinOk );
321
+ double ymin = coordList.at ( 1 ).toDouble ( &yMinOk );
322
+ double xmax = coordList.at ( 2 ).toDouble ( &xMaxOk );
323
+ double ymax = coordList.at ( 3 ).toDouble ( &yMaxOk );
324
+ if ( !xMinOk || !yMinOk || !xMaxOk || !yMaxOk )
319
325
{
320
- QStringList coordList = replacementList.at ( 0 ).split ( " ," );
321
- if ( coordList.size () > 3 )
326
+ c->removeItem ( *mapIt ); delete ( *mapIt ); continue ;
327
+ }
328
+
329
+ // Change x- and y- of extent for WMS 1.3.0 and geographic coordinate systems
330
+ QMap<QString, QString>::const_iterator versionIt = parameterMap.find ( " VERSION" );
331
+ if ( versionIt != parameterMap.end () )
332
+ {
333
+ if ( mapRenderer && versionIt.value () == " 1.3.0" && mapRenderer->destinationSrs ().geographicFlag () )
322
334
{
323
- bool xMinOk, yMinOk, xMaxOk, yMaxOk;
324
- double xmin = coordList.at ( 0 ).toDouble ( &xMinOk );
325
- double ymin = coordList.at ( 1 ).toDouble ( &yMinOk );
326
- double xmax = coordList.at ( 2 ).toDouble ( &xMaxOk );
327
- double ymax = coordList.at ( 3 ).toDouble ( &yMaxOk );
328
- if ( xMinOk && yMinOk && xMaxOk && yMaxOk )
329
- {
330
- currentMap->setNewExtent ( QgsRectangle ( xmin, ymin, xmax, ymax ) );
331
- }
335
+ // switch coordinates of extent
336
+ double tmp;
337
+ tmp = xmin;
338
+ xmin = ymin; ymin = tmp;
339
+ tmp = xmax;
340
+ xmax = ymax; ymax = tmp;
332
341
}
333
342
}
343
+ currentMap->setNewExtent ( QgsRectangle ( xmin, ymin, xmax, ymax ) );
334
344
335
- // get rotation from string
336
- if ( replacementList.size () > 1 )
345
+ // scale
346
+ QMap< QString, QString >::const_iterator scaleIt = parameterMap.find ( mapId + " :SCALE" );
347
+ if ( scaleIt != parameterMap.constEnd () )
337
348
{
338
- bool rotationOk ;
339
- double rotation = replacementList. at ( 1 ). toDouble ( &rotationOk );
340
- if ( rotationOk )
349
+ bool scaleOk ;
350
+ double scale = scaleIt-> toDouble ( &scaleOk );
351
+ if ( scaleOk )
341
352
{
342
- currentMap->setMapRotation ( rotation );
353
+ currentMap->setNewScale ( scale );
343
354
}
344
355
}
345
356
346
- // get forced scale from string
347
- if ( replacementList.size () > 2 )
357
+ // rotation
358
+ QMap< QString, QString >::const_iterator rotationIt = parameterMap.find ( mapId + " :ROTATION" );
359
+ if ( rotationIt != parameterMap.constEnd () )
348
360
{
349
- bool conversionOk ;
350
- double scale = replacementList. at ( 2 ). toDouble ( &conversionOk );
351
- if ( conversionOk )
361
+ bool rotationOk ;
362
+ double rotation = rotationIt-> toDouble ( &rotationOk );
363
+ if ( rotationOk )
352
364
{
353
- currentMap->setNewScale ( scale );
365
+ currentMap->setMapRotation ( rotation );
354
366
}
355
367
}
356
368
357
- // get layer list from string
358
- if ( replacementList.size () > 3 )
369
+ // layers / styles
370
+ QMap< QString, QString >::const_iterator layersIt = parameterMap.find ( mapId + " :LAYERS" );
371
+ QMap< QString, QString >::const_iterator stylesIt = parameterMap.find ( mapId + " :STYLES" );
372
+ if ( layersIt != parameterMap.constEnd () )
359
373
{
360
374
QStringList layerSet;
361
- QStringList wmsLayerList = replacementList. at ( 3 ). split ( " ," );
375
+ QStringList wmsLayerList = layersIt-> split ( " ," );
362
376
QStringList wmsStyleList;
363
- if ( replacementList.size () > 4 )
377
+
378
+ if ( stylesIt != parameterMap.constEnd () )
364
379
{
365
- wmsStyleList = replacementList. at ( 4 ). split ( " ," );
380
+ wmsStyleList = stylesIt-> split ( " ," );
366
381
}
367
-
368
382
for ( int i = 0 ; i < wmsLayerList.size (); ++i )
369
383
{
370
384
QString styleName;
0 commit comments