Skip to content

Commit

Permalink
Merge branch 'memcheck' into branch-6-2
Browse files Browse the repository at this point in the history
Conflicts:
	mapwcs.c
	mapwcs11.c
	mapwcs20.c
  • Loading branch information
tbonfort committed Sep 17, 2012
2 parents 243a2ea + 218b73f commit 8d4657d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
7 changes: 7 additions & 0 deletions maputil.c
Expand Up @@ -1883,9 +1883,16 @@ void msCleanup(int signal)
msGEOSCleanup();
#endif

/* make valgrind happy on debug code */
#ifndef NDEBUG
#ifdef USE_CAIRO
msCairoCleanup();
#endif
#if defined(USE_LIBXML2)
xmlCleanupParser();
#endif
#endif

msTimeCleanup();

msIO_Cleanup();
Expand Down
15 changes: 14 additions & 1 deletion mapwcs.c
Expand Up @@ -1286,6 +1286,7 @@ static int msWCSDescribeCoverage_CoverageOffering(layerObj *layer, wcsParamsObj
msIO_printf(" <formats>%s</formats>\n", tokens[i]);
msFreeCharArray(tokens, numtokens);
}
msFree((char*)value);
}
msIO_printf(" </supportedFormats>\n");

Expand Down Expand Up @@ -1337,8 +1338,13 @@ static int msWCSDescribeCoverage(mapObj *map, wcsParamsObj *params, owsRequestOb
coverageName = msOWSGetEncodeMetadata(&(GET_LAYER(map, i)->metadata), "CO", "name", GET_LAYER(map, i)->name);
if( EQUAL(coverageName, coverages[k]) &&
(msIntegerInArray(GET_LAYER(map, i)->index, ows_request->enabled_layers, ows_request->numlayers)) ) {
<<<<<<< HEAD
msFree(coverageName);
break;
=======
msFree(coverageName);
break;
>>>>>>> memcheck
}
msFree(coverageName);
}
Expand Down Expand Up @@ -1437,14 +1443,18 @@ static int msWCSGetCoverageBands10( mapObj *map, cgiRequestObj *request,

/* ok, a parameter has been passed which matches a token in wcs_rangeset_axes */
if(msWCSValidateRangeSetParam(lp, tokens[i], value) != MS_SUCCESS) {
int ret;
msSetError( MS_WCSERR, "Error specifying \"%s\" parameter value(s).", "msWCSGetCoverage()", tokens[i]);
return msWCSException(map, "InvalidParameterValue", tokens[i], params->version );
ret = msWCSException(map, "InvalidParameterValue", tokens[i], params->version );
msFreeCharArray(tokens, numtokens);
return ret;
}

/* xxxxx_rangeitem tells us how to subset */
snprintf(tag, sizeof(tag), "%s_rangeitem", tokens[i]);
if((rangeitem = msOWSLookupMetadata(&(lp->metadata), "CO", tag)) == NULL) {
msSetError( MS_WCSERR, "Missing required metadata element \"%s\", unable to process %s=%s.", "msWCSGetCoverage()", tag, tokens[i], value);
msFreeCharArray(tokens, numtokens);
return msWCSException(map, NULL, NULL, params->version);
}

Expand All @@ -1453,12 +1463,15 @@ static int msWCSGetCoverageBands10( mapObj *map, cgiRequestObj *request,

if(!*p_bandlist) {
msSetError( MS_WCSERR, "Error specifying \"%s\" parameter value(s).", "msWCSGetCoverage()", tokens[i]);
msFreeCharArray(tokens, numtokens);
return msWCSException(map, NULL, NULL, params->version );
}
} else if(strcasecmp(rangeitem, "_pixels") == 0) { /* special case, subset pixels */
msFreeCharArray(tokens, numtokens);
msSetError( MS_WCSERR, "Arbitrary range sets based on pixel values are not yet supported.", "msWCSGetCoverage()" );
return msWCSException(map, NULL, NULL, params->version);
} else {
msFreeCharArray(tokens, numtokens);
msSetError( MS_WCSERR, "Arbitrary range sets based on tile (i.e. image) attributes are not yet supported.", "msWCSGetCoverage()" );
return msWCSException(map, NULL, NULL, params->version );
}
Expand Down
3 changes: 2 additions & 1 deletion mapwcs11.c
Expand Up @@ -791,7 +791,6 @@ msWCSDescribeCoverage_CoverageDescription11(
xmlNewChild( psField, psOwsNs, BAD_CAST "Title", BAD_CAST value );
msFree(value);


/* ows:Abstract? TODO */

value = msOWSGetEncodeMetadata( &(layer->metadata), "CO",
Expand Down Expand Up @@ -1206,6 +1205,7 @@ int msWCSReturnCoverage11( wcsParamsObj *params, mapObj *map,
msReleaseLock( TLOCK_GDAL );
status = msSaveImage(map, image, filename);
if( status != MS_SUCCESS ) {
msFree(filename);
msSetError(MS_MISCERR, "msSaveImage() failed",
"msWCSReturnCoverage11()");
return msWCSException11(map, "mapserv", "NoApplicableCode",
Expand Down Expand Up @@ -1370,6 +1370,7 @@ int msWCSReturnCoverage11( wcsParamsObj *params, mapObj *map,
}

msFree(base_dir);
msFree(filename);
CSLDestroy( all_files );
msReleaseLock( TLOCK_GDAL );

Expand Down
19 changes: 18 additions & 1 deletion mapwcs20.c
Expand Up @@ -1202,7 +1202,7 @@ static char *msWCSGetFormatsList20( mapObj *map, layerObj *layer )
char *format_list = msStrdup("");
char **tokens = NULL, **formats = NULL;
int i, numtokens = 0, numformats;
const char *value;
char *value;

/* -------------------------------------------------------------------- */
/* Parse from layer metadata. */
Expand All @@ -1211,6 +1211,7 @@ static char *msWCSGetFormatsList20( mapObj *map, layerObj *layer )
&& (value = msOWSGetEncodeMetadata( &(layer->metadata),"CO","formats",
NULL )) != NULL ) {
tokens = msStringSplit(value, ' ', &numtokens);
msFree(value);
}

/* -------------------------------------------------------------------- */
Expand All @@ -1219,6 +1220,7 @@ static char *msWCSGetFormatsList20( mapObj *map, layerObj *layer )
else if((value = msOWSGetEncodeMetadata( &(map->web.metadata), "CO", "formats",
NULL)) != NULL ) {
tokens = msStringSplit(value, ' ', &numtokens);
msFree(value);
}

/* -------------------------------------------------------------------- */
Expand Down Expand Up @@ -2594,12 +2596,14 @@ int msWCSGetCapabilities20(mapObj *map, cgiRequestObj *req,
if (i == 0) { /* current */
msSetError(MS_WCSERR, "UPDATESEQUENCE parameter (%s) is equal to server (%s)",
"msWCSGetCapabilities20()", params->updatesequence, updatesequence);
xmlFreeDoc(psDoc);
return msWCSException(map, "updatesequence",
"CurrentUpdateSequence", params->version);
}
if (i > 0) { /* invalid */
msSetError(MS_WCSERR, "UPDATESEQUENCE parameter (%s) is higher than server (%s)",
"msWCSGetCapabilities20()", params->updatesequence, updatesequence);
xmlFreeDoc(psDoc);
return msWCSException(map, "updatesequence",
"InvalidUpdateSequence", params->version);
}
Expand Down Expand Up @@ -2629,6 +2633,7 @@ int msWCSGetCapabilities20(mapObj *map, cgiRequestObj *req,
if ( MS_WCS_20_CAPABILITIES_INCLUDE_SECTION(params, "OperationsMetadata") ) {
if ((script_url = msOWSGetOnlineResource(map, "CO", "onlineresource", req)) == NULL
|| (script_url_encoded = msEncodeHTMLEntities(script_url)) == NULL) {
xmlFreeDoc(psDoc);
msSetError(MS_WCSERR, "Server URL not found", "msWCSGetCapabilities20()");
return msWCSException(map, "mapserv", "NoApplicableCode", params->version);
}
Expand Down Expand Up @@ -3187,6 +3192,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p

msInitProjection(&imageProj);
if (msLoadProjectionString(&imageProj, cm.srs) == -1) {
msWCSClearCoverageMetadata20(&cm);
msSetError(MS_WCSERR,
"Error loading CRS %s.",
"msWCSGetCoverage20()", params->subsetcrs);
Expand Down Expand Up @@ -3238,6 +3244,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
/* if the subsets have a crs given, project the image extent to it */
msInitProjection(&subsetProj);
if(msLoadProjectionString(&subsetProj, params->subsetcrs) != MS_SUCCESS) {
msWCSClearCoverageMetadata20(&cm);
msSetError(MS_WCSERR,
"Error loading CRS %s.",
"msWCSGetCoverage20()", params->subsetcrs);
Expand All @@ -3262,6 +3269,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
/* create boundings of params subsets and image extent */
if(msRectOverlap(&subsets, &(layer->extent)) == MS_FALSE) {
/* extent and bbox do not overlap -> exit */
msWCSClearCoverageMetadata20(&cm);
msSetError(MS_WCSERR, "Image extent does not intersect with desired region.",
"msWCSGetCoverage20()");
msWCSClearCoverageMetadata20(&cm);
Expand All @@ -3277,6 +3285,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
/* check if we are overspecified */
if((params->width != 0 && params->resolutionX != MS_WCS20_UNBOUNDED)
|| (params->height != 0 && params->resolutionY != MS_WCS20_UNBOUNDED)) {
msWCSClearCoverageMetadata20(&cm);
msSetError(MS_WCSERR, "GetCoverage operation supports only one of SIZE or RESOLUTION per axis.",
"msWCSGetCoverage20()");
msWCSClearCoverageMetadata20(&cm);
Expand Down Expand Up @@ -3363,6 +3372,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p

/* Are we exceeding the MAXSIZE limit on result size? */
if(map->width > map->maxsize || map->height > map->maxsize ) {
msWCSClearCoverageMetadata20(&cm);
msSetError(MS_WCSERR, "Raster size out of range, width and height of "
"resulting coverage must be no more than MAXSIZE=%d.",
"msWCSGetCoverage20()", map->maxsize);
Expand Down Expand Up @@ -3398,6 +3408,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
}

if (!params->format) {
msWCSClearCoverageMetadata20(&cm);
msSetError(MS_WCSERR, "Output format could not be automatically determined. "
"Use the FORMAT parameter to specify a format.",
"msWCSGetCoverage20()");
Expand All @@ -3418,6 +3429,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
msApplyDefaultOutputFormats(map);

if (msGetOutputFormatIndex(map, params->format) == -1) {
msWCSClearCoverageMetadata20(&cm);
msSetError(MS_WCSERR, "Unrecognized value '%s' for the FORMAT parameter.",
"msWCSGetCoverage20()", params->format);
msWCSClearCoverageMetadata20(&cm);
Expand All @@ -3431,6 +3443,7 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
MS_NOOVERRIDE, MS_NOOVERRIDE);

if(msWCSGetCoverage20_GetBands(map, layer, params, &cm, &bandlist) != MS_SUCCESS) {
msFree(bandlist);
msWCSClearCoverageMetadata20(&cm);
return msWCSException(map, "InvalidParameterValue", "rangesubset",
params->version);
Expand All @@ -3449,6 +3462,8 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p
} else if(EQUAL(params->interpolation,"AVERAGE")) {
msLayerSetProcessingKey(layer, "RESAMPLE", "AVERAGE");
} else {
msWCSClearCoverageMetadata20(&cm);
msFree(bandlist);
msSetError( MS_WCSERR, "'%s' specifies an unsupported interpolation method.",
"msWCSGetCoverage20()", params->interpolation );
msWCSClearCoverageMetadata20(&cm);
Expand All @@ -3468,6 +3483,8 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage20()", p

/* create the image object */
if (!map->outputformat) {
msWCSClearCoverageMetadata20(&cm);
msFree(bandlist);
msSetError(MS_WCSERR, "The map outputformat is missing!",
"msWCSGetCoverage20()");
msWCSClearCoverageMetadata20(&cm);
Expand Down
2 changes: 1 addition & 1 deletion mapwfs.c
Expand Up @@ -368,8 +368,8 @@ static int msWFSGetFeatureApplySRS(mapObj *map, const char *srs, const char *ver
nTmp = msLoadProjectionStringEPSG(&(sProjTmp), pszOutputSRS);
if (nTmp == 0) {
msProjectRect(&(map->projection), &(sProjTmp), &map->extent);
msFreeProjection(&(sProjTmp));
}
msFreeProjection(&(sProjTmp));
/*check if the srs passed is valid. Assuming that it is an EPSG:xxx format,
Or urn:ogc:def:crs:EPSG:xxx format. */
if (strncasecmp(pszOutputSRS, "EPSG:", 5) == 0 ||
Expand Down
2 changes: 2 additions & 0 deletions mapwfs11.c
Expand Up @@ -336,6 +336,8 @@ int msWFSGetCapabilities11(mapObj *map, wfsParamsObj *params,
xmlNewNs(psRootNode, BAD_CAST namespaceList->namespaces[i].uri, BAD_CAST namespaceList->namespaces[i].prefix);
}
}
msGMLFreeNamespaces(namespaceList);


xmlNewProp(psRootNode, BAD_CAST "version", BAD_CAST params->pszVersion );

Expand Down

0 comments on commit 8d4657d

Please sign in to comment.