diff --git a/mapwcs.c b/mapwcs.c index ea7fb0752e..1395468bbb 100644 --- a/mapwcs.c +++ b/mapwcs.c @@ -1617,6 +1617,24 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage()", par /* make sure the layer is on */ lp->status = MS_ON; + + /* If the layer has no projection set, set it to the map's projection (#4079) */ + if(lp->projection.numargs <=0) { + char *map_original_srs = msGetProjectionString(&(map->projection)); + if (msLoadProjectionString(&(lp->projection), map_original_srs) != 0) { + msSetError( MS_WCSERR, "Error when setting map projection to a layer with no projection", "msWCSGetCoverage()" ); + return msWCSException(map, NULL, NULL, params->version); + } + } + + /* If the layer has no projection set, set it to the map's projection (#4079) */ + if(lp->projection.numargs <=0) { + char *map_original_srs = msGetProjectionString(&(map->projection)); + if (msLoadProjectionString(&(lp->projection), map_original_srs) != 0) { + msSetError( MS_WCSERR, "Error when setting map projection to a layer with no projection", "msWCSGetCoverage()" ); + return msWCSException(map, NULL, NULL, params->version); + } + } /* we need the coverage metadata, since things like numbands may not be available otherwise */ status = msWCSGetCoverageMetadata(lp, &cm);