Skip to content

Commit

Permalink
Allow map->projection inheritance for layers referenced by connection (
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Feb 21, 2014
1 parent bab4738 commit 05ff84f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 30 deletions.
1 change: 1 addition & 0 deletions mapserver.h
Expand Up @@ -492,6 +492,7 @@ extern "C" {
#define MS_GIANT 16 #define MS_GIANT 16
enum MS_QUERYMAP_STYLES {MS_NORMAL, MS_HILITE, MS_SELECTED}; 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 }; 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_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}; enum MS_JOIN_TYPE {MS_JOIN_ONE_TO_ONE, MS_JOIN_ONE_TO_MANY};


Expand Down
53 changes: 47 additions & 6 deletions maputil.c
Expand Up @@ -2437,21 +2437,62 @@ int msMapSetLayerProjections(mapObj* map)
} }


for(i=0; i<map->numlayers; i++) { for(i=0; i<map->numlayers; i++) {
layerObj *lp = GET_LAYER(map,i);
/* This layer is turned on and needs a projection? */ /* This layer is turned on and needs a projection? */
if (GET_LAYER(map, i)->projection.numargs <= 0 && if (lp->projection.numargs <= 0 &&
GET_LAYER(map, i)->status != MS_OFF && lp->status != MS_OFF &&
GET_LAYER(map, i)->transform == MS_TRUE) { lp->transform == MS_TRUE) {


/* Fetch main map projection string only now that we need it */ /* Fetch main map projection string only now that we need it */
if (mapProjStr == NULL) if (mapProjStr == NULL)
mapProjStr = msGetProjectionString(&(map->projection)); mapProjStr = msGetProjectionString(&(map->projection));


/* Set the projection to the map file projection */ /* Set the projection to the map file projection */
if (msLoadProjectionString(&(GET_LAYER(map, i)->projection), mapProjStr) != 0) { if (msLoadProjectionString(&(lp->projection), mapProjStr) != 0) {
msSetError(MS_CGIERR, "Unable to set projection on layer.", "msTileSetProjectionst()"); msSetError(MS_CGIERR, "Unable to set projection on layer.", "msMapSetLayerProjections()");
return(MS_FAILURE); 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); msFree(mapProjStr);
Expand Down
24 changes: 1 addition & 23 deletions mapwms.c
Expand Up @@ -1410,30 +1410,8 @@ this request. Check wms/ows_enable_request settings.",


if (nonsquare_enabled || if (nonsquare_enabled ||
msProjectionsDiffer(&(map->projection), &newProj)) { msProjectionsDiffer(&(map->projection), &newProj)) {
char *original_srs = NULL; msMapSetLayerProjections(map);

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);
} }

msFreeProjection(&newProj); msFreeProjection(&newProj);
} }


Expand Down
2 changes: 1 addition & 1 deletion msautotest
Submodule msautotest updated from 3e4822 to ebe1ed

0 comments on commit 05ff84f

Please sign in to comment.