@@ -223,7 +223,7 @@ int main( int argc, char * argv[] )
223
223
theRequestHandler = new QgsGetRequestHandler ();
224
224
}
225
225
226
- std::map <QString, QString> parameterMap;
226
+ QMap <QString, QString> parameterMap;
227
227
228
228
try
229
229
{
@@ -237,17 +237,11 @@ int main( int argc, char * argv[] )
237
237
}
238
238
239
239
// set admin config file to wms server object
240
- QString configFilePath = defaultConfigFilePath;
241
- std::map<QString, QString>::const_iterator mapFileIt = parameterMap.find ( " MAP" );
242
- if ( mapFileIt != parameterMap.end () )
243
- {
244
- configFilePath = mapFileIt->second ;
245
- QgsDebugMsg ( QString ( " Configuration file path set to: %1" ).arg ( defaultConfigFilePath ) );
246
- }
247
- else
240
+ if ( !parameterMap.contains ( " MAP" ) )
248
241
{
249
242
QgsDebugMsg ( QString ( " Using default configuration file path: %1" ).arg ( defaultConfigFilePath ) );
250
243
}
244
+ QString configFilePath = parameterMap.value ( " MAP" , defaultConfigFilePath );
251
245
252
246
QgsConfigParser* adminConfigParser = QgsConfigCache::instance ()->searchConfiguration ( configFilePath );
253
247
if ( !adminConfigParser )
@@ -261,14 +255,9 @@ int main( int argc, char * argv[] )
261
255
adminConfigParser->setParameterMap ( parameterMap );
262
256
263
257
// request to WMS?
264
- QString serviceString ( " WMS" );
265
- std::map<QString, QString>::const_iterator serviceIt = parameterMap.find ( " SERVICE" );
266
- if ( serviceIt != parameterMap.end () )
267
- {
268
- serviceString = serviceIt->second ;
269
- }
258
+ QString serviceString = parameterMap.value ( " SERVICE" , " WMS" );
270
259
#if 0
271
- else
260
+ if ( !parameterMap.contains( "SERVICE" ) )
272
261
{
273
262
QgsDebugMsg( "unable to find 'SERVICE' parameter, exiting..." );
274
263
theRequestHandler->sendServiceException( QgsMapServiceException( "ServiceNotSpecified", "Service not specified. The SERVICE parameter is mandatory" ) );
@@ -292,8 +281,8 @@ int main( int argc, char * argv[] )
292
281
293
282
294
283
// request type
295
- std::map< QString, QString>::const_iterator requestIt = parameterMap.find ( " REQUEST" );
296
- if ( requestIt == parameterMap. end () )
284
+ QString request = parameterMap.value ( " REQUEST" );
285
+ if ( request. isEmpty () )
297
286
{
298
287
// do some error handling
299
288
QgsDebugMsg ( " unable to find 'REQUEST' parameter, exiting..." );
@@ -303,16 +292,18 @@ int main( int argc, char * argv[] )
303
292
continue ;
304
293
}
305
294
306
- if ( requestIt->second == " GetCapabilities" )
295
+ QString version = parameterMap.value ( " VERSION" , " 1.3.0" );
296
+
297
+ if ( request == " GetCapabilities" )
307
298
{
308
- const QDomDocument* capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument ( configFilePath );
299
+ const QDomDocument* capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument ( configFilePath, version );
309
300
if ( !capabilitiesDocument ) // capabilities xml not in cache. Create a new one
310
301
{
311
302
QgsDebugMsg ( " Capabilities document not found in cache" );
312
303
QDomDocument doc;
313
304
try
314
305
{
315
- doc = theServer->getCapabilities ();
306
+ doc = theServer->getCapabilities ( version );
316
307
}
317
308
catch ( QgsMapServiceException& ex )
318
309
{
@@ -321,8 +312,8 @@ int main( int argc, char * argv[] )
321
312
delete theServer;
322
313
continue ;
323
314
}
324
- capabilitiesCache.insertCapabilitiesDocument ( configFilePath, &doc );
325
- capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument ( configFilePath );
315
+ capabilitiesCache.insertCapabilitiesDocument ( configFilePath, version, &doc );
316
+ capabilitiesDocument = capabilitiesCache.searchCapabilitiesDocument ( configFilePath, version );
326
317
}
327
318
else
328
319
{
@@ -337,7 +328,7 @@ int main( int argc, char * argv[] )
337
328
delete theServer;
338
329
continue ;
339
330
}
340
- else if ( requestIt-> second == " GetMap" )
331
+ else if ( request == " GetMap" )
341
332
{
342
333
QImage* result = 0 ;
343
334
try
@@ -369,12 +360,12 @@ int main( int argc, char * argv[] )
369
360
delete theServer;
370
361
continue ;
371
362
}
372
- else if ( requestIt-> second == " GetFeatureInfo" )
363
+ else if ( request == " GetFeatureInfo" )
373
364
{
374
365
QDomDocument featureInfoDoc;
375
366
try
376
367
{
377
- if ( theServer->getFeatureInfo ( featureInfoDoc ) != 0 )
368
+ if ( theServer->getFeatureInfo ( featureInfoDoc, version ) != 0 )
378
369
{
379
370
delete theRequestHandler;
380
371
delete theServer;
@@ -390,19 +381,12 @@ int main( int argc, char * argv[] )
390
381
}
391
382
392
383
// info format for GetFeatureInfo
393
- QString infoFormat;
394
- std::map<QString, QString>::const_iterator p_it = parameterMap.find ( " INFO_FORMAT" );
395
- if ( p_it != parameterMap.end () )
396
- {
397
- infoFormat = p_it->second ;
398
- }
399
-
400
- theRequestHandler->sendGetFeatureInfoResponse ( featureInfoDoc, infoFormat );
384
+ theRequestHandler->sendGetFeatureInfoResponse ( featureInfoDoc, parameterMap.value ( " INFO_FORMAT" ) );
401
385
delete theRequestHandler;
402
386
delete theServer;
403
387
continue ;
404
388
}
405
- else if ( requestIt-> second == " GetStyle" )
389
+ else if ( request == " GetStyle" )
406
390
{
407
391
try
408
392
{
@@ -418,7 +402,7 @@ int main( int argc, char * argv[] )
418
402
delete theServer;
419
403
continue ;
420
404
}
421
- else if ( requestIt-> second == " GetLegendGraphics" )
405
+ else if ( request == " GetLegendGraphics" )
422
406
{
423
407
QImage* result = 0 ;
424
408
try
@@ -447,7 +431,7 @@ int main( int argc, char * argv[] )
447
431
continue ;
448
432
449
433
}
450
- else if ( requestIt-> second == " GetPrint" )
434
+ else if ( request == " GetPrint" )
451
435
{
452
436
QByteArray* printOutput = 0 ;
453
437
try
@@ -470,7 +454,7 @@ int main( int argc, char * argv[] )
470
454
}
471
455
else // unknown request
472
456
{
473
- QgsMapServiceException e ( " OperationNotSupported" , " Operation " + requestIt-> second + " not supported" );
457
+ QgsMapServiceException e ( " OperationNotSupported" , " Operation " + request + " not supported" );
474
458
theRequestHandler->sendServiceException ( e );
475
459
delete theRequestHandler;
476
460
delete theServer;
0 commit comments