Permalink
Browse files

Allow map->projection inheritance for layers referenced by connection (

  • Loading branch information...
tbonfort committed Feb 21, 2014
1 parent bab4738 commit 05ff84f136afd3a578fff59f4f99f31a7a4e6212
Showing with 50 additions and 30 deletions.
  1. +1 −0 mapserver.h
  2. +47 −6 maputil.c
  3. +1 −23 mapwms.c
  4. +1 −1 msautotest
View
@@ -492,6 +492,7 @@ extern "C" {
#define MS_GIANT 16
enum MS_QUERYMAP_STYLES {MS_NORMAL, MS_HILITE, MS_SELECTED};
enum MS_CONNECTION_TYPE {MS_INLINE, MS_SHAPEFILE, MS_TILED_SHAPEFILE, MS_SDE, MS_OGR, MS_UNUSED_1, MS_POSTGIS, MS_WMS, MS_ORACLESPATIAL, MS_WFS, MS_GRATICULE, MS_MYSQL, MS_RASTER, MS_PLUGIN, MS_UNION, MS_UVRASTER, MS_CONTOUR, MS_KERNELDENSITY };
+#define IS_THIRDPARTY_LAYER_CONNECTIONTYPE(type) ((type) == MS_UNION || (type) == MS_KERNELDENSITY)
enum MS_JOIN_CONNECTION_TYPE {MS_DB_XBASE, MS_DB_CSV, MS_DB_MYSQL, MS_DB_ORACLE, MS_DB_POSTGRES};
enum MS_JOIN_TYPE {MS_JOIN_ONE_TO_ONE, MS_JOIN_ONE_TO_MANY};
View
@@ -2437,21 +2437,62 @@ int msMapSetLayerProjections(mapObj* map)
}
for(i=0; i<map->numlayers; i++) {
+ layerObj *lp = GET_LAYER(map,i);
/* This layer is turned on and needs a projection? */
- if (GET_LAYER(map, i)->projection.numargs <= 0 &&
- GET_LAYER(map, i)->status != MS_OFF &&
- GET_LAYER(map, i)->transform == MS_TRUE) {
+ if (lp->projection.numargs <= 0 &&
+ lp->status != MS_OFF &&
+ lp->transform == MS_TRUE) {
/* Fetch main map projection string only now that we need it */
if (mapProjStr == NULL)
mapProjStr = msGetProjectionString(&(map->projection));
/* Set the projection to the map file projection */
- if (msLoadProjectionString(&(GET_LAYER(map, i)->projection), mapProjStr) != 0) {
- msSetError(MS_CGIERR, "Unable to set projection on layer.", "msTileSetProjectionst()");
+ if (msLoadProjectionString(&(lp->projection), mapProjStr) != 0) {
+ msSetError(MS_CGIERR, "Unable to set projection on layer.", "msMapSetLayerProjections()");
return(MS_FAILURE);
}
- GET_LAYER(map, i)->project = MS_TRUE;
+ lp->project = MS_TRUE;
+ if(lp->connection && IS_THIRDPARTY_LAYER_CONNECTIONTYPE(lp->connectiontype)) {
+ char **reflayers;
+ int numreflayers,j;
+ reflayers = msStringSplit(lp->connection,',',&numreflayers);
+ for(j=0; j<numreflayers; j++) {
+ int *lidx, nlidx;
+ /* first check layers referenced by group name */
+ lidx = msGetLayersIndexByGroup(map, reflayers[i], &nlidx);
+ if(lidx) {
+ int k;
+ for(k=0; k<nlidx; k++) {
+ layerObj *glp = GET_LAYER(map,lidx[k]);
+ if (glp->projection.numargs <= 0 && glp->transform == MS_TRUE) {
+
+ /* Set the projection to the map file projection */
+ if (msLoadProjectionString(&(glp->projection), mapProjStr) != 0) {
+ msSetError(MS_CGIERR, "Unable to set projection on layer.", "msMapSetLayerProjections()");
+ return(MS_FAILURE);
+ }
+ glp->project = MS_TRUE;
+ }
+ }
+ free(lidx);
+ } else {
+ /* group name did not match, check by layer name */
+ int layer_idx = msGetLayerIndex(map,lp->connection);
+ layerObj *glp = GET_LAYER(map,layer_idx);
+ if (glp->projection.numargs <= 0 && glp->transform == MS_TRUE) {
+
+ /* Set the projection to the map file projection */
+ if (msLoadProjectionString(&(glp->projection), mapProjStr) != 0) {
+ msSetError(MS_CGIERR, "Unable to set projection on layer.", "msMapSetLayerProjections()");
+ return(MS_FAILURE);
+ }
+ glp->project = MS_TRUE;
+ }
+ }
+ }
+ msFreeCharArray(reflayers, numreflayers);
+ }
}
}
msFree(mapProjStr);
View
@@ -1410,30 +1410,8 @@ this request. Check wms/ows_enable_request settings.",
if (nonsquare_enabled ||
msProjectionsDiffer(&(map->projection), &newProj)) {
- char *original_srs = NULL;
-
- for(i=0; i<map->numlayers; i++) {
- if (GET_LAYER(map, i)->projection.numargs <= 0 &&
- GET_LAYER(map, i)->status != MS_OFF &&
- GET_LAYER(map, i)->transform == MS_TRUE) {
- /* This layer is turned on and needs a projection */
-
- /* Fetch main map projection string only now that we need it */
- if (original_srs == NULL)
- original_srs = msGetProjectionString(&(map->projection));
-
- if (msLoadProjectionString(&(GET_LAYER(map, i)->projection),
- original_srs) != 0) {
- msFreeProjection(&newProj);
- return msWMSException(map, nVersion, NULL, wms_exception_format);
- }
- GET_LAYER(map, i)->project = MS_TRUE;
- }
- }
-
- msFree(original_srs);
+ msMapSetLayerProjections(map);
}
-
msFreeProjection(&newProj);
}
Submodule msautotest updated from 3e4822 to ebe1ed

0 comments on commit 05ff84f

Please sign in to comment.