| 297 | | |
|---|
| 298 | | /* Alloc and init pasOWSReqInfo... for now we alloc numlayers+1 entries |
|---|
| 299 | | * but this could definitely be optimized |
|---|
| 300 | | */ |
|---|
| 301 | | pasOWSReqInfo = (httpRequestObj *)malloc((map->numlayers+1)*sizeof(httpRequestObj)); |
|---|
| 302 | | if (pasOWSReqInfo == NULL) { |
|---|
| 303 | | msSetError(MS_MEMERR, "Allocation of httpRequestObj failed.", "msDrawMap()"); |
|---|
| 304 | | return NULL; |
|---|
| 305 | | } |
|---|
| 306 | | |
|---|
| 307 | | msHTTPInitRequestObj(pasOWSReqInfo, map->numlayers+1); |
|---|
| 308 | | msInitWmsParamsObj(&sLastWMSParams); |
|---|
| 325 | | msFreeWmsParamsObj(&sLastWMSParams); |
|---|
| 326 | | msFree(pasOWSReqInfo); |
|---|
| 327 | | #endif |
|---|
| 328 | | return(NULL); |
|---|
| 329 | | } |
|---|
| 330 | | |
|---|
| 331 | | #if defined(USE_WMS_LYR) || defined(USE_WFS_LYR) |
|---|
| 332 | | /* Pre-download all WMS/WFS layers in parallel before starting to draw map */ |
|---|
| 333 | | lastconnectiontype = MS_SHAPEFILE; |
|---|
| | 316 | /* How many OWS (WMS/WFS) layers do we have to draw? |
|---|
| | 317 | * Note: numOWSLayers is the number of actual layers and numOWSRequests is |
|---|
| | 318 | * the number of HTTP requests which could be lower if multiple layers |
|---|
| | 319 | * are merged into the same request. |
|---|
| | 320 | */ |
|---|
| | 321 | numOWSLayers=0; |
|---|
| 335 | | /* if(map->layerorder[i] == -1 || !msLayerIsVisible(map, &(map->layers[map->layerorder[i]]))) */ |
|---|
| 336 | | if(map->layerorder[i] == -1 || !msLayerIsVisible(map, GET_LAYER(map,map->layerorder[i]))) |
|---|
| 337 | | continue; |
|---|
| 338 | | |
|---|
| 339 | | lp = GET_LAYER(map,map->layerorder[i]); |
|---|
| | 323 | if(map->layerorder[i] != -1 && |
|---|
| | 324 | msLayerIsVisible(map, GET_LAYER(map,map->layerorder[i]))) |
|---|
| | 325 | numOWSLayers++; |
|---|
| | 326 | } |
|---|
| | 327 | |
|---|
| | 328 | if (numOWSLayers > 0) { |
|---|
| | 329 | /* Alloc and init pasOWSReqInfo... |
|---|
| | 330 | */ |
|---|
| | 331 | pasOWSReqInfo = (httpRequestObj *)malloc((numOWSLayers+1)*sizeof(httpRequestObj)); |
|---|
| | 332 | if (pasOWSReqInfo == NULL) { |
|---|
| | 333 | msSetError(MS_MEMERR, "Allocation of httpRequestObj failed.", "msDrawMap()"); |
|---|
| | 334 | return NULL; |
|---|
| | 335 | } |
|---|
| | 336 | msHTTPInitRequestObj(pasOWSReqInfo, numOWSLayers+1); |
|---|
| | 337 | msInitWmsParamsObj(&sLastWMSParams); |
|---|
| | 338 | |
|---|
| | 339 | /* Pre-download all WMS/WFS layers in parallel before starting to draw map */ |
|---|
| | 340 | lastconnectiontype = MS_SHAPEFILE; |
|---|
| | 341 | for(i=0; numOWSLayers && i<map->numlayers; i++) { |
|---|
| | 342 | if(map->layerorder[i] == -1 || !msLayerIsVisible(map, GET_LAYER(map,map->layerorder[i]))) |
|---|
| | 343 | continue; |
|---|
| | 344 | |
|---|
| | 345 | lp = GET_LAYER(map,map->layerorder[i]); |
|---|
| 342 | | if(lp->connectiontype == MS_WMS) { |
|---|
| 343 | | if(msPrepareWMSLayerRequest(map->layerorder[i], map, lp, lastconnectiontype, &sLastWMSParams, pasOWSReqInfo, &numOWSRequests) == MS_FAILURE) { |
|---|
| 344 | | msFreeWmsParamsObj(&sLastWMSParams); |
|---|
| 345 | | msFreeImage(image); |
|---|
| 346 | | msFree(pasOWSReqInfo); |
|---|
| 347 | | return NULL; |
|---|
| 348 | | } |
|---|
| 349 | | } |
|---|
| | 348 | if(lp->connectiontype == MS_WMS) { |
|---|
| | 349 | if(msPrepareWMSLayerRequest(map->layerorder[i], map, lp, lastconnectiontype, &sLastWMSParams, pasOWSReqInfo, &numOWSRequests) == MS_FAILURE) { |
|---|
| | 350 | msFreeWmsParamsObj(&sLastWMSParams); |
|---|
| | 351 | msFreeImage(image); |
|---|
| | 352 | msFree(pasOWSReqInfo); |
|---|
| | 353 | return NULL; |
|---|
| | 354 | } |
|---|
| | 355 | } |
|---|
| 353 | | if(lp->connectiontype == MS_WFS) { |
|---|
| 354 | | if(msPrepareWFSLayerRequest(map->layerorder[i], map, lp, pasOWSReqInfo, &numOWSRequests) == MS_FAILURE) { |
|---|
| 355 | | msFreeWmsParamsObj(&sLastWMSParams); |
|---|
| 356 | | msFreeImage(image); |
|---|
| 357 | | msFree(pasOWSReqInfo); |
|---|
| 358 | | return NULL; |
|---|
| 359 | | } |
|---|
| 360 | | } |
|---|
| 361 | | #endif |
|---|
| 362 | | |
|---|
| 363 | | lastconnectiontype = lp->connectiontype; |
|---|
| 364 | | } |
|---|
| | 359 | if(lp->connectiontype == MS_WFS) { |
|---|
| | 360 | if(msPrepareWFSLayerRequest(map->layerorder[i], map, lp, pasOWSReqInfo, &numOWSRequests) == MS_FAILURE) { |
|---|
| | 361 | msFreeWmsParamsObj(&sLastWMSParams); |
|---|
| | 362 | msFreeImage(image); |
|---|
| | 363 | msFree(pasOWSReqInfo); |
|---|
| | 364 | return NULL; |
|---|
| | 365 | } |
|---|
| | 366 | } |
|---|
| | 367 | #endif |
|---|
| | 368 | |
|---|
| | 369 | lastconnectiontype = lp->connectiontype; |
|---|
| | 370 | } |
|---|