Skip to content

Commit

Permalink
Fix usage of static string for epsg lookups (#4731)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbonfort committed Feb 24, 2016
1 parent af3bd6e commit 4dd30cd
Show file tree
Hide file tree
Showing 13 changed files with 295 additions and 208 deletions.
19 changes: 11 additions & 8 deletions mapcontext.c
Expand Up @@ -1302,7 +1302,8 @@ int msSaveMapContext(mapObj *map, char *filename)
int msWriteMapContext(mapObj *map, FILE *stream) int msWriteMapContext(mapObj *map, FILE *stream)
{ {
#if defined(USE_WMS_LYR) && defined(USE_OGR) #if defined(USE_WMS_LYR) && defined(USE_OGR)
const char * version, *value; const char * version;
char *pszEPSG;
char * tabspace=NULL, *pszValue, *pszChar,*pszSLD=NULL,*pszURL,*pszSLD2=NULL; char * tabspace=NULL, *pszValue, *pszChar,*pszSLD=NULL,*pszURL,*pszSLD2=NULL;
char *pszStyle, *pszCurrent, *pszStyleItem, *pszSLDBody; char *pszStyle, *pszCurrent, *pszStyleItem, *pszSLDBody;
char *pszEncodedVal; char *pszEncodedVal;
Expand Down Expand Up @@ -1407,18 +1408,19 @@ int msWriteMapContext(mapObj *map, FILE *stream)
if(tabspace) if(tabspace)
free(tabspace); free(tabspace);
tabspace = msStrdup(" "); tabspace = msStrdup(" ");
value = msOWSGetEPSGProj(&(map->projection), &(map->web.metadata), "MO", MS_TRUE); msOWSGetEPSGProj(&(map->projection), &(map->web.metadata), "MO", MS_TRUE, &pszEPSG);
msIO_fprintf( stream, msIO_fprintf( stream,
"%s<!-- Bounding box corners and spatial reference system -->\n", "%s<!-- Bounding box corners and spatial reference system -->\n",
tabspace ); tabspace );
if(!value || (strcasecmp(value, "(null)") == 0)) if(!pszEPSG || (strcasecmp(pszEPSG, "(null)") == 0))
msIO_fprintf(stream, "<!-- WARNING: Mandatory data 'projection' was missing in this context. -->\n"); msIO_fprintf(stream, "<!-- WARNING: Mandatory data 'projection' was missing in this context. -->\n");


pszEncodedVal = msEncodeHTMLEntities(value); pszEncodedVal = msEncodeHTMLEntities(pszEPSG);
msIO_fprintf( stream, "%s<BoundingBox SRS=\"%s\" minx=\"%f\" miny=\"%f\" maxx=\"%f\" maxy=\"%f\"/>\n", msIO_fprintf( stream, "%s<BoundingBox SRS=\"%s\" minx=\"%f\" miny=\"%f\" maxx=\"%f\" maxy=\"%f\"/>\n",
tabspace, pszEncodedVal, map->extent.minx, map->extent.miny, tabspace, pszEncodedVal, map->extent.minx, map->extent.miny,
map->extent.maxx, map->extent.maxy ); map->extent.maxx, map->extent.maxy );
msFree(pszEncodedVal); msFree(pszEncodedVal);
msFree(pszEPSG);


/* Title, name */ /* Title, name */
if( nVersion >= OWS_0_1_7 && nVersion < OWS_1_0_0 ) { if( nVersion >= OWS_0_1_7 && nVersion < OWS_1_0_0 ) {
Expand Down Expand Up @@ -1625,14 +1627,15 @@ int msWriteMapContext(mapObj *map, FILE *stream)
GET_LAYER(map, i)->maxscaledenom); GET_LAYER(map, i)->maxscaledenom);


/* Layer SRS */ /* Layer SRS */
pszValue = (char*)msOWSGetEPSGProj(&(GET_LAYER(map, i)->projection), msOWSGetEPSGProj(&(GET_LAYER(map, i)->projection),
&(GET_LAYER(map, i)->metadata), &(GET_LAYER(map, i)->metadata),
"MO", MS_FALSE); "MO", MS_FALSE, &pszEPSG);
if(pszValue && (strcasecmp(pszValue, "(null)") != 0)) { if(pszEPSG && (strcasecmp(pszEPSG, "(null)") != 0)) {
pszEncodedVal = msEncodeHTMLEntities(pszValue); pszEncodedVal = msEncodeHTMLEntities(pszEPSG);
msIO_fprintf(stream, " <SRS>%s</SRS>\n", pszEncodedVal); msIO_fprintf(stream, " <SRS>%s</SRS>\n", pszEncodedVal);
msFree(pszEncodedVal); msFree(pszEncodedVal);
} }
msFree(pszEPSG);


/* Format */ /* Format */
if(msLookupHashTable(&(GET_LAYER(map, i)->metadata),"wms_formatlist")==NULL && if(msLookupHashTable(&(GET_LAYER(map, i)->metadata),"wms_formatlist")==NULL &&
Expand Down
34 changes: 16 additions & 18 deletions mapgml.c
Expand Up @@ -1390,7 +1390,7 @@ int msGMLWriteQuery(mapObj *map, char *filename, const char *namespaces)
FILE *stream=stdout; /* defaults to stdout */ FILE *stream=stdout; /* defaults to stdout */
char szPath[MS_MAXPATHLEN]; char szPath[MS_MAXPATHLEN];
char *value; char *value;
const char *pszMapSRS = NULL; char *pszMapSRS = NULL;


gmlGroupListObj *groupList=NULL; gmlGroupListObj *groupList=NULL;
gmlItemListObj *itemList=NULL; gmlItemListObj *itemList=NULL;
Expand Down Expand Up @@ -1423,11 +1423,11 @@ int msGMLWriteQuery(mapObj *map, char *filename, const char *namespaces)
msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "description", OWS_NOERR, "\t<gml:description>%s</gml:description>\n", NULL); msOWSPrintEncodeMetadata(stream, &(map->web.metadata), namespaces, "description", OWS_NOERR, "\t<gml:description>%s</gml:description>\n", NULL);


/* Look up map SRS. We need an EPSG code for GML, if not then we get null and we'll fall back on the layer's SRS */ /* Look up map SRS. We need an EPSG code for GML, if not then we get null and we'll fall back on the layer's SRS */
pszMapSRS = msOWSGetEPSGProj(&(map->projection), NULL, namespaces, MS_TRUE); msOWSGetEPSGProj(&(map->projection), NULL, namespaces, MS_TRUE, &pszMapSRS);


/* step through the layers looking for query results */ /* step through the layers looking for query results */
for(i=0; i<map->numlayers; i++) { for(i=0; i<map->numlayers; i++) {
const char *pszOutputSRS = NULL; char *pszOutputSRS = NULL;
int nSRSDimension = 2; int nSRSDimension = 2;
const char* geomtype; const char* geomtype;


Expand All @@ -1438,7 +1438,7 @@ int msGMLWriteQuery(mapObj *map, char *filename, const char *namespaces)
#ifdef USE_PROJ #ifdef USE_PROJ
/* Determine output SRS, if map has none, then try using layer's native SRS */ /* Determine output SRS, if map has none, then try using layer's native SRS */
if ((pszOutputSRS = pszMapSRS) == NULL) { if ((pszOutputSRS = pszMapSRS) == NULL) {
pszOutputSRS = msOWSGetEPSGProj(&(lp->projection), NULL, namespaces, MS_TRUE); msOWSGetEPSGProj(&(lp->projection), NULL, namespaces, MS_TRUE, &pszOutputSRS);
if (pszOutputSRS == NULL) { if (pszOutputSRS == NULL) {
msSetError(MS_WMSERR, "No valid EPSG code in map or layer projection for GML output", "msGMLWriteQuery()"); msSetError(MS_WMSERR, "No valid EPSG code in map or layer projection for GML output", "msGMLWriteQuery()");
continue; /* No EPSG code, cannot output this layer */ continue; /* No EPSG code, cannot output this layer */
Expand Down Expand Up @@ -1557,12 +1557,16 @@ int msGMLWriteQuery(mapObj *map, char *filename, const char *namespaces)


/* msLayerClose(lp); */ /* msLayerClose(lp); */
} }
if(pszOutputSRS!=pszMapSRS) {
msFree(pszOutputSRS);
}
} /* next layer */ } /* next layer */


/* end this document */ /* end this document */
msOWSPrintValidateMetadata(stream, &(map->web.metadata), namespaces, "rootname", OWS_NOERR, "</%s>\n", "msGMLOutput"); msOWSPrintValidateMetadata(stream, &(map->web.metadata), namespaces, "rootname", OWS_NOERR, "</%s>\n", "msGMLOutput");


if(filename && strlen(filename) > 0) fclose(stream); if(filename && strlen(filename) > 0) fclose(stream);
msFree(pszMapSRS);


return(MS_SUCCESS); return(MS_SUCCESS);


Expand Down Expand Up @@ -1604,12 +1608,9 @@ void msGMLWriteWFSBounds(mapObj *map, FILE *stream, const char *tab,
} }
else else
{ {
const char* constsrs; msOWSGetEPSGProj(&(map->projection), NULL, "FGO", MS_TRUE, &srs);
constsrs = msOWSGetEPSGProj(&(map->projection), NULL, "FGO", MS_TRUE); if (!srs)
if (!constsrs) msOWSGetEPSGProj(&(map->projection), &(map->web.metadata), "FGO", MS_TRUE, &srs);
constsrs = msOWSGetEPSGProj(&(map->projection), &(map->web.metadata), "FGO", MS_TRUE);
if (constsrs)
srs = msStrdup(constsrs);
} }


gmlWriteBounds(stream, outputformat, &resultBounds, srs, tab, gmlWriteBounds(stream, outputformat, &resultBounds, srs, tab,
Expand Down Expand Up @@ -1733,14 +1734,11 @@ int msGMLWriteWFSQuery(mapObj *map, FILE *stream, const char *default_namespace_
} }
else else
{ {
const char* constsrs; msOWSGetEPSGProj(&(map->projection), NULL, "FGO", MS_TRUE, &srs);
constsrs = msOWSGetEPSGProj(&(map->projection), NULL, "FGO", MS_TRUE); if (!srs)
if (!constsrs) msOWSGetEPSGProj(&(map->projection), &(map->web.metadata), "FGO", MS_TRUE, &srs);
constsrs = msOWSGetEPSGProj(&(map->projection), &(map->web.metadata), "FGO", MS_TRUE); if (!srs)
if (!constsrs) msOWSGetEPSGProj(&(lp->projection), &(lp->metadata), "FGO", MS_TRUE, &srs);
constsrs = msOWSGetEPSGProj(&(lp->projection), &(lp->metadata), "FGO", MS_TRUE);
if (constsrs)
srs = msStrdup(constsrs);
} }
#endif #endif


Expand Down
34 changes: 22 additions & 12 deletions mapogcsos.c
Expand Up @@ -350,17 +350,21 @@ void msSOSAddPropertyNode(xmlNsPtr psNsSwe, xmlNsPtr psNsXLink, xmlNodePtr psPar
/* possible. */ /* possible. */
/************************************************************************/ /************************************************************************/
void msSOSAddGeometryNode(xmlNsPtr psNsGml, xmlNsPtr psNsMs, xmlNodePtr psParent, mapObj *map, layerObj *lp, shapeObj *psShape, void msSOSAddGeometryNode(xmlNsPtr psNsGml, xmlNsPtr psNsMs, xmlNodePtr psParent, mapObj *map, layerObj *lp, shapeObj *psShape,
const char *pszEpsg) const char *pszEpsg_in)
{ {
char *pszTmp = NULL; char *pszTmp = NULL;
int i,j = 0; int i,j = 0;
xmlNodePtr psPointNode, psNode, psLineNode, psPolygonNode; xmlNodePtr psPointNode, psNode, psLineNode, psPolygonNode;
int *panOuterList = NULL, *panInnerList = NULL; int *panOuterList = NULL, *panInnerList = NULL;
const char *pszEpsg = pszEpsg_in;
char *pszEpsg_buf = NULL;



if (psParent && psShape) { if (psParent && psShape) {
if (msProjectionsDiffer(&map->projection, &lp->projection) == MS_TRUE) { if (msProjectionsDiffer(&map->projection, &lp->projection) == MS_TRUE) {
msProjectShape(&lp->projection, &map->projection, psShape); msProjectShape(&lp->projection, &map->projection, psShape);
pszEpsg = msOWSGetEPSGProj(&(map->projection), &(lp->metadata), "SO", MS_TRUE); msOWSGetEPSGProj(&(map->projection), &(lp->metadata), "SO", MS_TRUE, &pszEpsg_buf);
pszEpsg = pszEpsg_buf;
} }
switch(psShape->type) { switch(psShape->type) {
case(MS_SHAPE_POINT): case(MS_SHAPE_POINT):
Expand Down Expand Up @@ -508,6 +512,7 @@ void msSOSAddGeometryNode(xmlNsPtr psNsGml, xmlNsPtr psNsMs, xmlNodePtr psParen
} }


} }
msFree(pszEpsg_buf);


} }


Expand Down Expand Up @@ -626,7 +631,8 @@ void msSOSAddMemberNode(xmlNsPtr psNsGml, xmlNsPtr psNsOm, xmlNsPtr psNsSwe, xml
int iFeatureId, const char *script_url, const char *opLayerName) int iFeatureId, const char *script_url, const char *opLayerName)
{ {
xmlNodePtr psObsNode, psNode, psLayerNode = NULL; xmlNodePtr psObsNode, psNode, psLayerNode = NULL;
const char *pszEpsg = NULL, *pszValue = NULL; const char *pszValue = NULL;
char *pszEpsg = NULL;
int status,i,j; int status,i,j;
shapeObj sShape; shapeObj sShape;
char szTmp[256]; char szTmp[256];
Expand Down Expand Up @@ -785,9 +791,9 @@ void msSOSAddMemberNode(xmlNsPtr psNsGml, xmlNsPtr psNsOm, xmlNsPtr psNsSwe, xml


/*bbox*/ /*bbox*/
#ifdef USE_PROJ #ifdef USE_PROJ
pszEpsg = msOWSGetEPSGProj(&(map->projection), &(lp->metadata), "SO", MS_TRUE); msOWSGetEPSGProj(&(map->projection), &(lp->metadata), "SO", MS_TRUE, &pszEpsg);
if (!pszEpsg) if (!pszEpsg)
pszEpsg = msOWSGetEPSGProj(&(lp->projection), &(lp->metadata), "SO", MS_TRUE); msOWSGetEPSGProj(&(lp->projection), &(lp->metadata), "SO", MS_TRUE, &pszEpsg);


if (msProjectionsDiffer(&map->projection, &lp->projection) == MS_TRUE) if (msProjectionsDiffer(&map->projection, &lp->projection) == MS_TRUE)
msProjectRect(&lp->projection, &map->projection, &sShape.bounds); msProjectRect(&lp->projection, &map->projection, &sShape.bounds);
Expand All @@ -796,6 +802,7 @@ void msSOSAddMemberNode(xmlNsPtr psNsGml, xmlNsPtr psNsOm, xmlNsPtr psNsSwe, xml


/*geometry*/ /*geometry*/
msSOSAddGeometryNode(psNsGml, psNsMs, psLayerNode, map, lp, &sShape, pszEpsg); msSOSAddGeometryNode(psNsGml, psNsMs, psLayerNode, map, lp, &sShape, pszEpsg);
msFree(pszEpsg);


/*attributes */ /*attributes */
/* TODO only output attributes where there is a sos_%s_alias (to be discussed)*/ /* TODO only output attributes where there is a sos_%s_alias (to be discussed)*/
Expand Down Expand Up @@ -1369,18 +1376,19 @@ int msSOSGetCapabilities(mapObj *map, sosParamsObj *sosparams, cgiRequestObj *re
Check also what happen if epsg not present */ Check also what happen if epsg not present */
value = msOWSLookupMetadata(&(lp->metadata), "S", "offering_extent"); value = msOWSLookupMetadata(&(lp->metadata), "S", "offering_extent");
if (value) { if (value) {
char **tokens; char **tokens,*pszLayerEPSG;
int n; int n;
tokens = msStringSplit(value, ',', &n); tokens = msStringSplit(value, ',', &n);
if (tokens==NULL || n != 4) { if (tokens==NULL || n != 4) {
msSetError(MS_SOSERR, "Wrong number of arguments for sos_offering_extent.", msSetError(MS_SOSERR, "Wrong number of arguments for sos_offering_extent.",
"msSOSGetCapabilities()"); "msSOSGetCapabilities()");
return msSOSException(map, "sos_offering_extent", "InvalidParameterValue"); return msSOSException(map, "sos_offering_extent", "InvalidParameterValue");
} }
value = msOWSGetEPSGProj(&(lp->projection), msOWSGetEPSGProj(&(lp->projection),&(lp->metadata), "SO", MS_TRUE,&pszLayerEPSG);
&(lp->metadata), "SO", MS_TRUE); if (pszLayerEPSG) {
if (value) psNode = xmlAddChild(psOfferingNode, msGML3BoundedBy(psNsGml, atof(tokens[0]), atof(tokens[1]), atof(tokens[2]), atof(tokens[3]), pszLayerEPSG));
psNode = xmlAddChild(psOfferingNode, msGML3BoundedBy(psNsGml, atof(tokens[0]), atof(tokens[1]), atof(tokens[2]), atof(tokens[3]), value)); msFree(pszLayerEPSG);
}
msFreeCharArray(tokens, n); msFreeCharArray(tokens, n);


} }
Expand Down Expand Up @@ -2284,10 +2292,11 @@ this request. Check sos/ows_enable_request settings.", "msSOSGetObservation()",


if (pszTmp) { if (pszTmp) {
char **tokens; char **tokens;
char *pszMapEpsg;
int n; int n;
rectObj envelope; rectObj envelope;


pszTmp2 = msOWSGetEPSGProj(&(map->projection), &(lp->metadata), "SO", MS_TRUE); msOWSGetEPSGProj(&(map->projection), &(lp->metadata), "SO", MS_TRUE, &pszMapEpsg);


tokens = msStringSplit(pszTmp, ',', &n); tokens = msStringSplit(pszTmp, ',', &n);
if (tokens==NULL || n != 4) { if (tokens==NULL || n != 4) {
Expand All @@ -2308,8 +2317,9 @@ this request. Check sos/ows_enable_request settings.", "msSOSGetObservation()",
} }
} }


psNode = xmlAddChild(psRootNode, msGML3BoundedBy(psNsGml, envelope.minx, envelope.miny, envelope.maxx, envelope.maxy, pszTmp2)); psNode = xmlAddChild(psRootNode, msGML3BoundedBy(psNsGml, envelope.minx, envelope.miny, envelope.maxx, envelope.maxy, pszMapEpsg));
msFreeCharArray(tokens, n); msFreeCharArray(tokens, n);
msFree(pszMapEpsg);
} }


/* time /* time
Expand Down
72 changes: 40 additions & 32 deletions mapows.c
Expand Up @@ -2129,8 +2129,8 @@ void msOWSPrintBoundingBox(FILE *stream, const char *tabspace,
const char *namespaces, const char *namespaces,
int wms_version) int wms_version)
{ {
const char *value, *resx, *resy, *wms_bbox_extended, *epsg_str; const char *value, *resx, *resy, *wms_bbox_extended;
char *encoded, *encoded_resx, *encoded_resy; char *encoded, *encoded_resx, *encoded_resy, *epsg_str;
char **epsgs; char **epsgs;
int i, num_epsgs; int i, num_epsgs;
projectionObj proj; projectionObj proj;
Expand All @@ -2141,18 +2141,19 @@ void msOWSPrintBoundingBox(FILE *stream, const char *tabspace,
/* get a list of all projections from the metadata /* get a list of all projections from the metadata
try the layer metadata first, otherwise use the map's */ try the layer metadata first, otherwise use the map's */
if( msOWSLookupMetadata(layer_meta, namespaces, "srs") ) { if( msOWSLookupMetadata(layer_meta, namespaces, "srs") ) {
epsg_str = msOWSGetEPSGProj(srcproj, layer_meta, namespaces, MS_FALSE); msOWSGetEPSGProj(srcproj, layer_meta, namespaces, MS_FALSE, &epsg_str);
} else { } else {
epsg_str = msOWSGetEPSGProj(srcproj, map_meta, namespaces, MS_FALSE); msOWSGetEPSGProj(srcproj, map_meta, namespaces, MS_FALSE, &epsg_str);
} }
epsgs = msStringSplit(epsg_str, ' ', &num_epsgs); epsgs = msStringSplit(epsg_str, ' ', &num_epsgs);
msFree(epsg_str);
} else { } else {
/* Look for EPSG code in PROJECTION block only. "wms_srs" metadata cannot be /* Look for EPSG code in PROJECTION block only. "wms_srs" metadata cannot be
* used to establish the native projection of a layer for BoundingBox purposes. * used to establish the native projection of a layer for BoundingBox purposes.
*/ */
epsgs = (char **) msSmallMalloc(sizeof(char *)); epsgs = (char **) msSmallMalloc(sizeof(char *));
num_epsgs = 1; num_epsgs = 1;
epsgs[0] = msStrdup( msOWSGetEPSGProj(srcproj, layer_meta, namespaces, MS_TRUE) ); msOWSGetEPSGProj(srcproj, layer_meta, namespaces, MS_TRUE, &(epsgs[0]));
} }


for( i = 0; i < num_epsgs; i++) { for( i = 0; i < num_epsgs; i++) {
Expand Down Expand Up @@ -2495,34 +2496,37 @@ char *msOWSBuildURLFilename(const char *pszPath, const char *pszURL,
** then only the first one (which is assumed to be the layer's default ** then only the first one (which is assumed to be the layer's default
** projection) is returned. ** projection) is returned.
*/ */
const char *msOWSGetEPSGProj(projectionObj *proj, hashTableObj *metadata, const char *namespaces, int bReturnOnlyFirstOne) void msOWSGetEPSGProj(projectionObj *proj, hashTableObj *metadata, const char *namespaces, int bReturnOnlyFirstOne, char **epsgCode)
{ {
static char epsgCode[20] =""; const char *value;
char *value; *epsgCode = NULL;


/* metadata value should already be in format "EPSG:n" or "AUTO:..." */ /* metadata value should already be in format "EPSG:n" or "AUTO:..." */
if (metadata && ((value = (char *) msOWSLookupMetadata(metadata, namespaces, "srs")) != NULL)) { if (metadata && ((value = msOWSLookupMetadata(metadata, namespaces, "srs")) != NULL)) {

const char *space_ptr;
if (!bReturnOnlyFirstOne) return value; if (!bReturnOnlyFirstOne || (space_ptr = strchr(value,' ')) == NULL) {

*epsgCode = msStrdup(value);
/* caller requested only first projection code */ return;
strlcpy(epsgCode, value, 20); }


if ((value=strchr(epsgCode, ' ')) != NULL) *value = '\0';


return epsgCode; *epsgCode = msSmallMalloc((space_ptr - value + 1)*sizeof(char));
} else if (proj && proj->numargs > 0 && (value = strstr(proj->args[0], "init=epsg:")) != NULL && strlen(value) < 20) { /* caller requested only first projection code, copy up to the first space character*/
snprintf(epsgCode, sizeof(epsgCode), "EPSG:%s", value+10); strlcpy(*epsgCode, value, space_ptr - value + 1) ;
return epsgCode; return;
} else if (proj && proj->numargs > 0 && (value = strstr(proj->args[0], "init=crs:")) != NULL && strlen(value) < 20) { } else if (proj && proj->numargs > 0 && (value = strstr(proj->args[0], "init=epsg:")) != NULL) {
snprintf(epsgCode, sizeof(epsgCode), "CRS:%s", value+9); *epsgCode = msSmallMalloc((strlen("EPSG:")+strlen(value+10)+1)*sizeof(char));
return epsgCode; sprintf(*epsgCode, "EPSG:%s", value+10);
return;
} else if (proj && proj->numargs > 0 && (value = strstr(proj->args[0], "init=crs:")) != NULL) {
*epsgCode = msSmallMalloc((strlen("CRS:")+strlen(value+9)+1)*sizeof(char));
sprintf(*epsgCode, "CRS:%s", value+9);
return;
} else if (proj && proj->numargs > 0 && (strncasecmp(proj->args[0], "AUTO:", 5) == 0 || } else if (proj && proj->numargs > 0 && (strncasecmp(proj->args[0], "AUTO:", 5) == 0 ||
strncasecmp(proj->args[0], "AUTO2:", 6) == 0)) { strncasecmp(proj->args[0], "AUTO2:", 6) == 0)) {
return proj->args[0]; *epsgCode = msStrdup(proj->args[0]);
return;
} }

return NULL;
} }
/* /*
** msOWSGetProjURN() ** msOWSGetProjURN()
Expand All @@ -2538,16 +2542,18 @@ char *msOWSGetProjURN(projectionObj *proj, hashTableObj *metadata, const char *n
char **tokens; char **tokens;
int numtokens, i; int numtokens, i;
size_t bufferSize = 0; size_t bufferSize = 0;

char *oldStyle;
const char *oldStyle = msOWSGetEPSGProj( proj, metadata, namespaces,
bReturnOnlyFirstOne ); msOWSGetEPSGProj( proj, metadata, namespaces,
bReturnOnlyFirstOne, &oldStyle );


if( oldStyle == NULL || strncmp(oldStyle,"EPSG:",5) != 0 ) if( oldStyle == NULL || strncmp(oldStyle,"EPSG:",5) != 0 )
return NULL; return NULL;


result = msStrdup(""); result = msStrdup("");


tokens = msStringSplit(oldStyle, ' ', &numtokens); tokens = msStringSplit(oldStyle, ' ', &numtokens);
msFree(oldStyle);
for(i=0; tokens != NULL && i<numtokens; i++) { for(i=0; tokens != NULL && i<numtokens; i++) {
char urn[100]; char urn[100];


Expand Down Expand Up @@ -2596,16 +2602,18 @@ char *msOWSGetProjURI(projectionObj *proj, hashTableObj *metadata, const char *n
char *result; char *result;
char **tokens; char **tokens;
int numtokens, i; int numtokens, i;

char *oldStyle;
const char *oldStyle = msOWSGetEPSGProj( proj, metadata, namespaces,
bReturnOnlyFirstOne ); msOWSGetEPSGProj( proj, metadata, namespaces,
bReturnOnlyFirstOne, &oldStyle);


if( oldStyle == NULL || !EQUALN(oldStyle,"EPSG:",5) ) if( oldStyle == NULL || !EQUALN(oldStyle,"EPSG:",5) )
return NULL; return NULL;


result = msStrdup(""); result = msStrdup("");


tokens = msStringSplit(oldStyle, ' ', &numtokens); tokens = msStringSplit(oldStyle, ' ', &numtokens);
msFree(oldStyle);
for(i=0; tokens != NULL && i<numtokens; i++) { for(i=0; tokens != NULL && i<numtokens; i++) {
char urn[100]; char urn[100];


Expand Down
2 changes: 1 addition & 1 deletion mapows.h
Expand Up @@ -293,7 +293,7 @@ void msOWSProcessException(layerObj *lp, const char *pszFname,
int nErrorCode, const char *pszFuncName); int nErrorCode, const char *pszFuncName);
char *msOWSBuildURLFilename(const char *pszPath, const char *pszURL, char *msOWSBuildURLFilename(const char *pszPath, const char *pszURL,
const char *pszExt); const char *pszExt);
const char *msOWSGetEPSGProj(projectionObj *proj, hashTableObj *metadata, const char *namespaces, int bReturnOnlyFirstOne); void msOWSGetEPSGProj(projectionObj *proj, hashTableObj *metadata, const char *namespaces, int bReturnOnlyFirstOne, char **epsgProj);
char *msOWSGetProjURN(projectionObj *proj, hashTableObj *metadata, const char *namespaces, int bReturnOnlyFirstOne); char *msOWSGetProjURN(projectionObj *proj, hashTableObj *metadata, const char *namespaces, int bReturnOnlyFirstOne);
char *msOWSGetProjURI(projectionObj *proj, hashTableObj *metadata, const char *namespaces, int bReturnOnlyFirstOne); char *msOWSGetProjURI(projectionObj *proj, hashTableObj *metadata, const char *namespaces, int bReturnOnlyFirstOne);


Expand Down

0 comments on commit 4dd30cd

Please sign in to comment.