Permalink
Browse files

WCS 2.0: special processing for wcs_rangeset_axes=bands

WCS 2.0 has a special compatibility mode where it can use WCS 1.1 metadata
items. Unfortunately, it does a wrong assumption on how wcs_rangeset_axes works
in WCS 1.0/1.1. The implementation of it is probably not completely right in
WCS 1.0/1.1, but at least a special case that works is when 'bands' is assigned
to wcs_rangeset_axes. So make WCS 2.0 code handle wcs_rangeset_axes=bands
as the special case handled by msWCSSetDefaultBandsRangeSetInfo()
in https://github.com/mapserver/mapserver/blob/branch-7-0/mapwcs.c#L281

Modify wcs_multi.map to use wcs_rangeset_axes=bands. This will also make the
wcs_10_getcov_bands_name_new request to properly return 3 bands. So band
subsetting works in both in WCS 1.0 and 2.0 with the same mapfile.

The "New band related metadata entries" paragraph of
http://mapserver.org/ogc/wcs_server.html
should probably be revised to remove reference to the WCS 1.1 compatibility
mode.
  • Loading branch information...
rouault committed Nov 21, 2017
1 parent 116c7d2 commit 2493287b0e35f54c671d6dae33ebabfc7869bb60
@@ -2681,7 +2681,21 @@ static int msWCSGetCoverageMetadata20(layerObj *layer, wcs20coverageMetadataObj
} else if( (value = msOWSLookupMetadata(&(layer->metadata), "CO", wcs11_band_names_key)) != NULL ) {
keys = wcs11_keys;
interval_key = wcs11_interval_key;
band_names = msStringSplit(value, ' ', &num_band_names);
if( EQUAL(value, "bands") )
{
num_band_names = cm->numbands;
band_names = (char**) msSmallMalloc( sizeof(char*) * num_band_names );
for( i = 0; i < num_band_names; i++ )
{
char szName[30];
snprintf(szName, sizeof(szName), "Band%d", i+1);
band_names[i] = msStrdup(szName);
}
}
else
{
band_names = msStringSplit(value, ' ', &num_band_names);
}
}

/* return with error when number of bands does not match */
@@ -3756,9 +3770,21 @@ static int msWCSGetCoverage20_GetBands(mapObj *map, layerObj *layer,
"CO", "rangeset_axes", NULL))) {
tmp = msOWSGetEncodeMetadata(&layer->metadata,
"CO", "band_names", NULL);
} else {
if( EQUAL(tmp, "bands") )
{
int num_band_names = cm->numbands;
band_ids = (char**) msSmallCalloc( sizeof(char*), (num_band_names + 1) );
for( i = 0; i < num_band_names; i++ )
{
char szName[30];
snprintf(szName, sizeof(szName), "Band%d", i+1);
band_ids[i] = msStrdup(szName);
}
}
}

if(NULL != tmp) {
if(NULL != tmp && band_ids == NULL) {
band_ids = CSLTokenizeString2(tmp, " ", 0);
msFree(tmp);
}
Binary file not shown.
@@ -30,7 +30,7 @@ Content-Type: text/xml; charset=UTF-8
</gml:domainSet>
<gmlcov:rangeType>
<swe:DataRecord>
<swe:field name="bands">
<swe:field name="Band1">
<swe:Quantity>
<swe:description>Test description</swe:description>
<swe:nilValues>
@@ -28,7 +28,7 @@
</gml:domainSet>
<gmlcov:rangeType>
<swe:DataRecord>
<swe:field name="bands">
<swe:field name="Band1">
<swe:Quantity>
<swe:description>Test description</swe:description>
<swe:nilValues>
Binary file not shown.
@@ -40,7 +40,7 @@ Content-Type: application/gml+xml; charset=UTF-8
</gml:rangeSet>
<gmlcov:rangeType>
<swe:DataRecord>
<swe:field name="bands">
<swe:field name="Band1">
<swe:Quantity>
<swe:description>Test description</swe:description>
<swe:nilValues>
Binary file not shown.
@@ -28,7 +28,7 @@
</gml:domainSet>
<gmlcov:rangeType>
<swe:DataRecord>
<swe:field name="bands">
<swe:field name="Band1">
<swe:Quantity>
<swe:description>Test description</swe:description>
<swe:nilValues>
Binary file not shown.
Binary file not shown.
@@ -40,7 +40,7 @@ Content-Type: application/gml+xml; charset=UTF-8
</gml:rangeSet>
<gmlcov:rangeType>
<swe:DataRecord>
<swe:field name="bands">
<swe:field name="Band1">
<swe:Quantity>
<swe:description>Test description</swe:description>
<swe:nilValues>
Binary file not shown.
@@ -120,7 +120,7 @@ LAYER
"wcs_imagemode" "BYTE"

"wcs_bandcount" "9"
"wcs_rangeset_axes" "Band1 Band2 Band3 Band4 Band5 Band6 Band7 Band8 Band9"
"wcs_rangeset_axes" "bands"
"wcs_rangeset_name" "Landsat 5 TM Bands"
"wcs_rangeset_label" "Bands"
"wcs_rangeset_description" "Bands for Landsat 5 TM"
@@ -153,6 +153,7 @@ LAYER
"wcs_imagemode" "BYTE"

"wcs_bandcount" "9"
"wcs_rangeset_axes" "bands"
"wcs_band_names" "Band1 Band2 Band3 Band4 Band5 Band6 Band7 Band8 Band9"

#default values

0 comments on commit 2493287

Please sign in to comment.