@@ -2437,21 +2437,62 @@ int msMapSetLayerProjections(mapObj* map)
2437
2437
}
2438
2438
2439
2439
for (i = 0 ; i < map -> numlayers ; i ++ ) {
2440
+ layerObj * lp = GET_LAYER (map ,i );
2440
2441
/* This layer is turned on and needs a projection? */
2441
- if (GET_LAYER ( map , i ) -> projection .numargs <= 0 &&
2442
- GET_LAYER ( map , i ) -> status != MS_OFF &&
2443
- GET_LAYER ( map , i ) -> transform == MS_TRUE ) {
2442
+ if (lp -> projection .numargs <= 0 &&
2443
+ lp -> status != MS_OFF &&
2444
+ lp -> transform == MS_TRUE ) {
2444
2445
2445
2446
/* Fetch main map projection string only now that we need it */
2446
2447
if (mapProjStr == NULL )
2447
2448
mapProjStr = msGetProjectionString (& (map -> projection ));
2448
2449
2449
2450
/* Set the projection to the map file projection */
2450
- if (msLoadProjectionString (& (GET_LAYER ( map , i ) -> projection ), mapProjStr ) != 0 ) {
2451
- msSetError (MS_CGIERR , "Unable to set projection on layer." , "msTileSetProjectionst ()" );
2451
+ if (msLoadProjectionString (& (lp -> projection ), mapProjStr ) != 0 ) {
2452
+ msSetError (MS_CGIERR , "Unable to set projection on layer." , "msMapSetLayerProjections ()" );
2452
2453
return (MS_FAILURE );
2453
2454
}
2454
- GET_LAYER (map , i )-> project = MS_TRUE ;
2455
+ lp -> project = MS_TRUE ;
2456
+ if (lp -> connection && IS_THIRDPARTY_LAYER_CONNECTIONTYPE (lp -> connectiontype )) {
2457
+ char * * reflayers ;
2458
+ int numreflayers ,j ;
2459
+ reflayers = msStringSplit (lp -> connection ,',' ,& numreflayers );
2460
+ for (j = 0 ; j < numreflayers ; j ++ ) {
2461
+ int * lidx , nlidx ;
2462
+ /* first check layers referenced by group name */
2463
+ lidx = msGetLayersIndexByGroup (map , reflayers [i ], & nlidx );
2464
+ if (lidx ) {
2465
+ int k ;
2466
+ for (k = 0 ; k < nlidx ; k ++ ) {
2467
+ layerObj * glp = GET_LAYER (map ,lidx [k ]);
2468
+ if (glp -> projection .numargs <= 0 && glp -> transform == MS_TRUE ) {
2469
+
2470
+ /* Set the projection to the map file projection */
2471
+ if (msLoadProjectionString (& (glp -> projection ), mapProjStr ) != 0 ) {
2472
+ msSetError (MS_CGIERR , "Unable to set projection on layer." , "msMapSetLayerProjections()" );
2473
+ return (MS_FAILURE );
2474
+ }
2475
+ glp -> project = MS_TRUE ;
2476
+ }
2477
+ }
2478
+ free (lidx );
2479
+ } else {
2480
+ /* group name did not match, check by layer name */
2481
+ int layer_idx = msGetLayerIndex (map ,lp -> connection );
2482
+ layerObj * glp = GET_LAYER (map ,layer_idx );
2483
+ if (glp -> projection .numargs <= 0 && glp -> transform == MS_TRUE ) {
2484
+
2485
+ /* Set the projection to the map file projection */
2486
+ if (msLoadProjectionString (& (glp -> projection ), mapProjStr ) != 0 ) {
2487
+ msSetError (MS_CGIERR , "Unable to set projection on layer." , "msMapSetLayerProjections()" );
2488
+ return (MS_FAILURE );
2489
+ }
2490
+ glp -> project = MS_TRUE ;
2491
+ }
2492
+ }
2493
+ }
2494
+ msFreeCharArray (reflayers , numreflayers );
2495
+ }
2455
2496
}
2456
2497
}
2457
2498
msFree (mapProjStr );
0 commit comments