Skip to content

Commit 5f6ebab

Browse files
committed
PROJ6: do more projection context sharing
1 parent 1ca010b commit 5f6ebab

12 files changed

+44
-13
lines changed

mapogcfilter.c

+13-6
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ int FLTApplySimpleSQLFilter(FilterEncodingNode *psNode, mapObj *map, int iLayerI
425425
szEPSG = FLTGetBBOX(psNode, &sQueryRect);
426426
if(szEPSG && map->projection.numargs > 0) {
427427
msInitProjection(&sProjTmp);
428+
msProjectionInheritContextFrom(&sProjTmp, &map->projection);
428429
/* Use the non EPSG variant since axis swapping is done in FLTDoAxisSwappingIfNecessary */
429430
if (msLoadProjectionString(&sProjTmp, szEPSG) == 0) {
430431
msProjectRect(&sProjTmp, &map->projection, &sQueryRect);
@@ -768,6 +769,7 @@ int FLTLayerApplyPlainFilterToLayer(FilterEncodingNode *psNode, mapObj *map,
768769
if(pszEPSG && map->projection.numargs > 0) {
769770
projectionObj sProjTmp;
770771
msInitProjection(&sProjTmp);
772+
msProjectionInheritContextFrom(&sProjTmp, &map->projection);
771773
/* Use the non EPSG variant since axis swapping is done in FLTDoAxisSwappingIfNecessary */
772774
if (msLoadProjectionString(&sProjTmp, pszEPSG) == 0) {
773775
rectObj oldRect = rect;
@@ -2923,11 +2925,15 @@ int FLTParseGMLEnvelope(CPLXMLNode *psRoot, rectObj *psBbox, char **ppszSRS)
29232925
/* FLTNeedSRSSwapping */
29242926
/************************************************************************/
29252927

2926-
static int FLTNeedSRSSwapping( const char* pszSRS )
2928+
static int FLTNeedSRSSwapping( mapObj *map, const char* pszSRS )
29272929
{
29282930
int bNeedSwapping = MS_FALSE;
29292931
projectionObj sProjTmp;
29302932
msInitProjection(&sProjTmp);
2933+
if( map )
2934+
{
2935+
msProjectionInheritContextFrom(&sProjTmp, &map->projection);
2936+
}
29312937
if (msLoadProjectionStringEPSG(&sProjTmp, pszSRS) == 0) {
29322938
bNeedSwapping = msIsAxisInvertedProj(&sProjTmp);
29332939
}
@@ -2944,7 +2950,8 @@ static int FLTNeedSRSSwapping( const char* pszSRS )
29442950
/* caller will have to determine its value from a more general */
29452951
/* context. */
29462952
/************************************************************************/
2947-
void FLTDoAxisSwappingIfNecessary(FilterEncodingNode *psFilterNode,
2953+
void FLTDoAxisSwappingIfNecessary(mapObj *map,
2954+
FilterEncodingNode *psFilterNode,
29482955
int bDefaultSRSNeedsAxisSwapping)
29492956
{
29502957
if( psFilterNode == NULL )
@@ -2955,7 +2962,7 @@ void FLTDoAxisSwappingIfNecessary(FilterEncodingNode *psFilterNode,
29552962
{
29562963
rectObj* rect = (rectObj *)psFilterNode->psRightNode->pOther;
29572964
const char* pszSRS = psFilterNode->pszSRS;
2958-
if( (pszSRS != NULL && FLTNeedSRSSwapping(pszSRS)) ||
2965+
if( (pszSRS != NULL && FLTNeedSRSSwapping(map, pszSRS)) ||
29592966
(pszSRS == NULL && bDefaultSRSNeedsAxisSwapping) )
29602967
{
29612968
double tmp;
@@ -2974,16 +2981,16 @@ void FLTDoAxisSwappingIfNecessary(FilterEncodingNode *psFilterNode,
29742981
{
29752982
shapeObj* shape = (shapeObj *)(psFilterNode->psRightNode->pOther);
29762983
const char* pszSRS = psFilterNode->pszSRS;
2977-
if( (pszSRS != NULL && FLTNeedSRSSwapping(pszSRS)) ||
2984+
if( (pszSRS != NULL && FLTNeedSRSSwapping(map, pszSRS)) ||
29782985
(pszSRS == NULL && bDefaultSRSNeedsAxisSwapping) )
29792986
{
29802987
msAxisSwapShape(shape);
29812988
}
29822989
}
29832990
else
29842991
{
2985-
FLTDoAxisSwappingIfNecessary(psFilterNode->psLeftNode, bDefaultSRSNeedsAxisSwapping);
2986-
FLTDoAxisSwappingIfNecessary(psFilterNode->psRightNode, bDefaultSRSNeedsAxisSwapping);
2992+
FLTDoAxisSwappingIfNecessary(map, psFilterNode->psLeftNode, bDefaultSRSNeedsAxisSwapping);
2993+
FLTDoAxisSwappingIfNecessary(map, psFilterNode->psRightNode, bDefaultSRSNeedsAxisSwapping);
29872994
}
29882995
}
29892996

mapogcfilter.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ MS_DLL_EXPORT int FLTApplyFilterToLayerCommonExpression(mapObj *map, int iLayerI
130130
MS_DLL_EXPORT xmlNodePtr FLTGetCapabilities(xmlNsPtr psNsParent, xmlNsPtr psNsOgc, int bTemporal);
131131
#endif
132132

133-
void FLTDoAxisSwappingIfNecessary(FilterEncodingNode *psFilterNode, int bDefaultSRSNeedsAxisSwapping);
133+
void FLTDoAxisSwappingIfNecessary(mapObj *map, FilterEncodingNode *psFilterNode, int bDefaultSRSNeedsAxisSwapping);
134134

135135
void FLTPreParseFilterForAliasAndGroup(FilterEncodingNode *psFilterNode,
136136
mapObj *map, int i, const char *namespaces);

mapogcfiltercommon.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,10 @@ char *FLTGetSpatialComparisonCommonExpression(FilterEncodingNode *psNode, layerO
517517
fabs(sQueryRect.maxy - 90.0) < 1e-5)
518518
{
519519
if (lp->projection.numargs > 0) {
520-
if (psNode->pszSRS)
520+
if (psNode->pszSRS) {
521521
msInitProjection(&sProjTmp);
522+
msProjectionInheritContextFrom(&sProjTmp, &lp->projection);
523+
}
522524
if (psNode->pszSRS) {
523525
/* Use the non EPSG variant since axis swapping is done in FLTDoAxisSwappingIfNecessary */
524526
if (msLoadProjectionString(&sProjTmp, psNode->pszSRS) == 0) {
@@ -567,8 +569,10 @@ char *FLTGetSpatialComparisonCommonExpression(FilterEncodingNode *psNode, layerO
567569
** target is layer projection
568570
*/
569571
if (!bAlreadyReprojected && lp->projection.numargs > 0) {
570-
if (psNode->pszSRS)
572+
if (psNode->pszSRS) {
571573
msInitProjection(&sProjTmp);
574+
msProjectionInheritContextFrom(&sProjTmp, &lp->projection);
575+
}
572576
if (psNode->pszSRS) {
573577
/* Use the non EPSG variant since axis swapping is done in FLTDoAxisSwappingIfNecessary */
574578
if (msLoadProjectionString(&sProjTmp, psNode->pszSRS) == 0) {

mapogcsos.c

+1
Original file line numberDiff line numberDiff line change
@@ -2122,6 +2122,7 @@ this request. Check sos/ows_enable_request settings.", "msSOSGetObservation()",
21222122

21232123
/* project MAP.EXTENT to this SRS */
21242124
msInitProjection(&po);
2125+
msProjectionInheritContextFrom(&po, &map->projection);
21252126

21262127
snprintf(srsbuffer, sizeof(srsbuffer), "+init=epsg:%.20s", sosparams->pszSrsName+strlen("EPSG:"));
21272128

mapproject.c

+2
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ void msFreeProjection(projectionObj *p)
495495
#endif
496496
#endif
497497

498+
p->gt.need_geotransform = MS_FALSE;
499+
p->wellknownprojection = wkp_none;
498500
msFreeCharArray(p->args, p->numargs);
499501
p->args = NULL;
500502
p->numargs = 0;

mapshape.c

+1
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,7 @@ int msTiledSHPOpenFile(layerObj *layer)
19741974
tSHP = (msTiledSHPLayerInfo *) calloc(1, sizeof(msTiledSHPLayerInfo));
19751975
MS_CHECK_ALLOC(tSHP, sizeof(msTiledSHPLayerInfo), MS_FAILURE);
19761976
msInitProjection(&(tSHP->sTileProj));
1977+
msProjectionInheritContextFrom(&(tSHP->sTileProj), &layer->projection);
19771978

19781979
tSHP->shpfile = (shapefileObj *) malloc(sizeof(shapefileObj));
19791980
if (tSHP->shpfile == NULL) {

maptemplate.c

+3
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,7 @@ static int processExtentTag(mapservObj *mapserv, char **line, char *name, rectOb
14581458
} else if(rectProj && projectionString) {
14591459
projectionObj projection;
14601460
msInitProjection(&projection);
1461+
msProjectionInheritContextFrom(&projection, &mapserv->map->projection);
14611462

14621463
if(MS_SUCCESS != msLoadProjectionString(&projection, projectionString)) return MS_FAILURE;
14631464

@@ -1756,6 +1757,7 @@ static int processShplabelTag(layerObj *layer, char **line, shapeObj *origshape)
17561757
} else if(projectionString) {
17571758
projectionObj projection;
17581759
msInitProjection(&projection);
1760+
msProjectionInheritContextFrom(&projection, &layer->map->projection);
17591761

17601762
status = msLoadProjectionString(&projection, projectionString);
17611763
if(status != MS_SUCCESS) return MS_FAILURE;
@@ -2161,6 +2163,7 @@ static int processShpxyTag(layerObj *layer, char **line, shapeObj *shape)
21612163
} else if(projectionString) {
21622164
projectionObj projection;
21632165
msInitProjection(&projection);
2166+
msProjectionInheritContextFrom(&projection, &(layer->projection));
21642167

21652168
status = msLoadProjectionString(&projection, projectionString);
21662169
if(status != MS_SUCCESS) return MS_FAILURE;

mapwcs.c

+3
Original file line numberDiff line numberDiff line change
@@ -1770,6 +1770,7 @@ static int msWCSGetCoverage(mapObj *map, cgiRequestObj *request,
17701770
projectionObj proj;
17711771

17721772
msInitProjection( &proj );
1773+
msProjectionInheritContextFrom(&proj, &(map->projection));
17731774
if( msLoadProjectionString( &proj, (char *) params->crs ) == 0 ) {
17741775
msAxisNormalizePoints( &proj, 1,
17751776
&(params->bbox.minx),
@@ -1958,6 +1959,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage()", par
19581959
projectionObj tmp_proj;
19591960

19601961
msInitProjection(&tmp_proj);
1962+
msProjectionInheritContextFrom(&tmp_proj, &(map->projection));
19611963
if (msLoadProjectionString(&tmp_proj, (char *) params->crs) != 0) {
19621964
msWCSFreeCoverageMetadata(&cm);
19631965
return msWCSException( map, NULL, NULL, params->version);
@@ -2803,6 +2805,7 @@ int msWCSGetCoverageMetadata( layerObj *layer, coverageMetadataObj *cm )
28032805
char projstring[32];
28042806

28052807
msInitProjection(&proj); /* or bad things happen */
2808+
msProjectionInheritContextFrom(&proj, &(layer->map->projection));
28062809

28072810
snprintf(projstring, sizeof(projstring), "init=epsg:%.20s", cm->srs_epsg+5);
28082811
if (msLoadProjectionString(&proj, projstring) != 0) return MS_FAILURE;

mapwcs11.c

+1
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ msWCSDescribeCoverage_CoverageDescription11(
728728
double resy = cm.geotransform[5];
729729

730730
msInitProjection( &proj );
731+
msProjectionInheritContextFrom(&proj, &(layer->projection));
731732
if( msLoadProjectionString( &proj, cm.srs_urn ) == 0 ) {
732733
msAxisNormalizePoints( &proj, 1, &x0, &y0 );
733734
msAxisNormalizePoints( &proj, 1, &resx, &resy );

mapwcs20.c

+3
Original file line numberDiff line numberDiff line change
@@ -4383,6 +4383,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
43834383
/************************************************************************/
43844384

43854385
msInitProjection(&imageProj);
4386+
msProjectionInheritContextFrom(&imageProj, &(layer->projection));
43864387
if (msLoadProjectionString(&imageProj, cm.srs_epsg) == -1) {
43874388
msFreeProjection(&imageProj);
43884389
msWCSClearCoverageMetadata20(&cm);
@@ -4474,6 +4475,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
44744475

44754476
/* if the subsets have a crs given, project the image extent to it */
44764477
msInitProjection(&subsetProj);
4478+
msProjectionInheritContextFrom(&subsetProj, &(layer->projection));
44774479
if(msLoadProjectionString(&subsetProj, params->subsetcrs) != MS_SUCCESS) {
44784480
msFreeProjection(&subsetProj);
44794481
msFreeProjection(&imageProj);
@@ -4625,6 +4627,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
46254627
projectionObj outputProj;
46264628

46274629
msInitProjection(&outputProj);
4630+
msProjectionInheritContextFrom(&outputProj, &(layer->projection));
46284631
if(msLoadProjectionString(&outputProj, params->outputcrs) == -1) {
46294632
msFreeProjection(&outputProj);
46304633
msWCSClearCoverageMetadata20(&cm);

mapwfs.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ static int msWFSGetFeatureApplySRS(mapObj *map, const char *srs, int nWFSVersion
379379
if(pszMapSRS && nWFSVersion > OWS_1_0_0){
380380
projectionObj proj;
381381
msInitProjection(&proj);
382+
msProjectionInheritContextFrom(&proj, &(map->projection));
382383
if (map->projection.numargs > 0 && msLoadProjectionStringEPSG(&proj, pszMapSRS) == 0) {
383384
msProjectRect(&(map->projection), &proj, &map->extent);
384385
}
@@ -471,6 +472,7 @@ static int msWFSGetFeatureApplySRS(mapObj *map, const char *srs, int nWFSVersion
471472
int nTmp=0;
472473

473474
msInitProjection(&sProjTmp);
475+
msProjectionInheritContextFrom(&sProjTmp, &(map->projection));
474476
if( nWFSVersion >= OWS_1_1_0 ) {
475477
nTmp = msLoadProjectionStringEPSG(&(sProjTmp), pszOutputSRS);
476478
} else {
@@ -604,6 +606,7 @@ int msWFSDumpLayer(mapObj *map, layerObj *lp, const char *script_url_encoded)
604606
/* If layer has no proj set then use map->proj for bounding box. */
605607
if (msOWSGetLayerExtent(map, lp, "FO", &ext) == MS_SUCCESS) {
606608
msInitProjection(&poWfs);
609+
msProjectionInheritContextFrom(&poWfs, &(map->projection));
607610
if (pszWfsSrs != NULL)
608611
msLoadProjectionString(&(poWfs), pszWfsSrs);
609612

@@ -2081,7 +2084,7 @@ static int msWFSRunFilter(mapObj* map,
20812084
bDefaultSRSNeedsAxisSwapping = msIsAxisInverted(atoi(srs+5));
20822085
}
20832086
msFree(srs);
2084-
FLTDoAxisSwappingIfNecessary(psNode, bDefaultSRSNeedsAxisSwapping);
2087+
FLTDoAxisSwappingIfNecessary(map, psNode, bDefaultSRSNeedsAxisSwapping);
20852088
}
20862089

20872090
layerWasOpened = msLayerIsOpen(lp);
@@ -2548,6 +2551,7 @@ this request. Check wfs/ows_enable_request settings.", "msWFSGetFeature()",
25482551
projectionObj sProjTmp;
25492552

25502553
msInitProjection(&sProjTmp);
2554+
msProjectionInheritContextFrom(&sProjTmp, &(map->projection));
25512555
msOWSGetEPSGProj(&sProjTmp,&(map->web.metadata),"FO",MS_TRUE, &sBBoxSrs);
25522556
msFreeProjection(&sProjTmp);
25532557
}
@@ -2557,6 +2561,7 @@ this request. Check wfs/ows_enable_request settings.", "msWFSGetFeature()",
25572561
projectionObj sProjTmp;
25582562

25592563
msInitProjection(&sProjTmp);
2564+
msProjectionInheritContextFrom(&sProjTmp, &(map->projection));
25602565
/*do the axis order for now. It is unclear if the bbox are expected
25612566
ro respect the axis oder defined in the projectsion #3296*/
25622567

mapwms.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ int msWMSApplyFilter(mapObj *map, int version, const char *filter,
405405
* elements inside the filter(s)
406406
*/
407407
if (version >= OWS_1_3_0)
408-
FLTDoAxisSwappingIfNecessary(psNode, def_srs_needs_axis_swap);
408+
FLTDoAxisSwappingIfNecessary(map, psNode, def_srs_needs_axis_swap);
409409

410410
#ifdef do_we_need_this
411411
FLTProcessPropertyIsNull(psNode, map, lp->index);
@@ -1335,6 +1335,7 @@ int msWMSLoadGetMapParams(mapObj *map, int nVersion,
13351335
/*try to adjust the axes if necessary*/
13361336
if (strlen(srsbuffer) > 1) {
13371337
msInitProjection(&proj);
1338+
msProjectionInheritContextFrom(&proj, &(map->projection));
13381339
if (msLoadProjectionStringEPSG(&proj, (char *)srsbuffer) == 0 &&
13391340
(need_axis_swap = msIsAxisInvertedProj(&proj) ) ) {
13401341
msAxisNormalizePoints( &proj, 1, &rect.minx, &rect.miny );
@@ -1610,6 +1611,7 @@ this request. Check wms/ows_enable_request settings.",
16101611
}
16111612

16121613
msInitProjection(&newProj);
1614+
msProjectionInheritContextFrom(&newProj, &map->projection);
16131615
if (strlen(srsbuffer) > 1) {
16141616
int nTmp;
16151617

@@ -1634,8 +1636,7 @@ this request. Check wms/ows_enable_request settings.",
16341636
/* that the srs given as parameter is valid for all layers */
16351637
if (strlen(srsbuffer) > 1) {
16361638
int nTmp;
1637-
msFreeProjection(&map->projection);
1638-
msInitProjection(&map->projection);
1639+
msFreeProjectionExceptContext(&map->projection);
16391640
if (nVersion >= OWS_1_3_0)
16401641
nTmp = msLoadProjectionStringEPSG(&(map->projection), srsbuffer);
16411642
else

0 commit comments

Comments
 (0)