Permalink
Browse files

Merge pull request #5523 from rouault/wcs20_special_case_for_wcs_rang…

…eset_axes_equal_bands

WCS 2.0: special processing for wcs_rangeset_axes=bands
  • Loading branch information...
rouault committed Nov 30, 2017
2 parents 8a949f7 + 6a09273 commit fc06d45fd7c5ecd06562bd4f3edf42436468576a
View
@@ -2681,7 +2681,26 @@ 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);
/* "bands" has a special processing in WCS 1.0. See */
/* msWCSSetDefaultBandsRangeSetInfo */
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
{
/* WARNING: in WCS 1.x,, "rangeset_axes" has never been intended */
/* to contain the list of band names... This code should probably */
/* be removed */
band_names = msStringSplit(value, ' ', &num_band_names);
}
}
/* return with error when number of bands does not match */
@@ -3752,13 +3771,29 @@ static int msWCSGetCoverage20_GetBands(mapObj *map, layerObj *layer,
maxlen = cm->numbands * 4 * sizeof(char);
*bandlist = msSmallCalloc(sizeof(char), maxlen);
if (NULL == (tmp = msOWSGetEncodeMetadata(&layer->metadata,
"CO", "rangeset_axes", NULL))) {
tmp = msOWSGetEncodeMetadata(&layer->metadata,
/* Use WCS 2.0 metadata items in priority */
tmp = msOWSGetEncodeMetadata(&layer->metadata,
"CO", "band_names", NULL);
if( NULL == tmp ) {
/* Otherwise default to WCS 1.x*/
tmp = msOWSGetEncodeMetadata(&layer->metadata,
"CO", "rangeset_axes", NULL);
/* "bands" has a special processing in WCS 1.0. See */
/* msWCSSetDefaultBandsRangeSetInfo */
if( tmp != NULL && 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>
@@ -352,7 +352,7 @@
</swe:constraint>
</swe:Quantity>
</swe:field>
<swe:field name="Band9">
<swe:field name="myBand9">
<swe:Quantity definition="DefaultDefinition">
<swe:description>Default description</swe:description>
<swe:nilValues>
Binary file not shown.
Binary file not shown.
View
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>
View
Binary file not shown.
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.
View
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.
@@ -11,12 +11,12 @@
# RUN_PARMS: wcs_20_getcov_bands_name.dat [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi&FORMAT=image/tiff&mediatype=multipart/related&RANGESUBSET=Band9,Band5,Band1" > [RESULT_DEMIME]
#
# RUN_PARMS: wcs_20_getcov_bands_index_new.tif [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&RANGESUBSET=1,5,9" > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_getcov_bands_name_new.tif [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&RANGESUBSET=Band9,Band5,Band1" > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_getcov_bands_name_new.dat [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&mediatype=multipart/related&RANGESUBSET=Band9,Band5,Band1" > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_getcov_bands_name_new.tif [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&RANGESUBSET=myBand9,Band5,Band1" > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_getcov_bands_name_new.dat [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&mediatype=multipart/related&RANGESUBSET=myBand9,Band5,Band1" > [RESULT_DEMIME]
#
# RUN_PARMS: wcs_10_getcov_bands_name_new.dat [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&COVERAGE=multi_new&FORMAT=GEOTIFF_8&BBOX=15,48,16,49&bands=9,5,1&CRS=EPSG:4326&WIDTH=5&HEIGHT=5" > [RESULT_DEMIME]
#
# RUN_PARMS: wcs_20_getcov_bands_name_new_reproject.dat [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&mediatype=multipart/related&RANGESUBSET=Band9,Band5,Band1&OUTPUTCRS=EPSG:3857" > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_getcov_bands_name_new_reproject.dat [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&mediatype=multipart/related&RANGESUBSET=myBand9,Band5,Band1&OUTPUTCRS=EPSG:3857" > [RESULT_DEMIME]
#
# RUN_PARMS: wcs_20_getcov_native_format.tif [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new" > [RESULT_DEMIME]
#
@@ -26,8 +26,8 @@
# RUN_PARMS: wcs_20_post_bands_name.dat [MAPSERV] [POST]<?xml version="1.0" encoding="UTF-8"?><wcs:GetCoverage xmlns:wcs="http://www.opengis.net/wcs/2.0" service="WCS" version="2.0.1"><wcs:format>image/tiff</wcs:format><wcs:CoverageId>multi</wcs:CoverageId><wcs:mediaType>multipart/related</wcs:mediaType><wcs:rangeSubset><wcs:band>Band9</wcs:band><wcs:band>Band5</wcs:band><wcs:band>Band1</wcs:band></wcs:rangeSubset></wcs:GetCoverage>[/POST] > [RESULT_DEMIME]
#
# RUN_PARMS: wcs_20_post_bands_index_new.tif [MAPSERV] [POST]<?xml version="1.0" encoding="UTF-8"?><wcs:GetCoverage xmlns:wcs="http://www.opengis.net/wcs/2.0" service="WCS" version="2.0.1"><wcs:format>image/tiff</wcs:format><wcs:CoverageId>multi_new</wcs:CoverageId><wcs:rangeSubset><wcs:band>1</wcs:band><wcs:band>5</wcs:band><wcs:band>9</wcs:band></wcs:rangeSubset></wcs:GetCoverage>[/POST] > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_post_bands_name_new.tif [MAPSERV] [POST]<?xml version="1.0" encoding="UTF-8"?><wcs:GetCoverage xmlns:wcs="http://www.opengis.net/wcs/2.0" service="WCS" version="2.0.1"><wcs:format>image/tiff</wcs:format><wcs:CoverageId>multi_new</wcs:CoverageId><wcs:rangeSubset><wcs:band>Band9</wcs:band><wcs:band>Band5</wcs:band><wcs:band>Band1</wcs:band></wcs:rangeSubset></wcs:GetCoverage>[/POST] > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_post_bands_name_new.dat [MAPSERV] [POST]<?xml version="1.0" encoding="UTF-8"?><wcs:GetCoverage xmlns:wcs="http://www.opengis.net/wcs/2.0" service="WCS" version="2.0.1"><wcs:format>image/tiff</wcs:format><wcs:CoverageId>multi_new</wcs:CoverageId><wcs:mediaType>multipart/related</wcs:mediaType><wcs:rangeSubset><wcs:band>Band9</wcs:band><wcs:band>Band5</wcs:band><wcs:band>Band1</wcs:band></wcs:rangeSubset></wcs:GetCoverage>[/POST] > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_post_bands_name_new.tif [MAPSERV] [POST]<?xml version="1.0" encoding="UTF-8"?><wcs:GetCoverage xmlns:wcs="http://www.opengis.net/wcs/2.0" service="WCS" version="2.0.1"><wcs:format>image/tiff</wcs:format><wcs:CoverageId>multi_new</wcs:CoverageId><wcs:rangeSubset><wcs:band>myBand9</wcs:band><wcs:band>Band5</wcs:band><wcs:band>Band1</wcs:band></wcs:rangeSubset></wcs:GetCoverage>[/POST] > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_post_bands_name_new.dat [MAPSERV] [POST]<?xml version="1.0" encoding="UTF-8"?><wcs:GetCoverage xmlns:wcs="http://www.opengis.net/wcs/2.0" service="WCS" version="2.0.1"><wcs:format>image/tiff</wcs:format><wcs:CoverageId>multi_new</wcs:CoverageId><wcs:mediaType>multipart/related</wcs:mediaType><wcs:rangeSubset><wcs:band>myBand9</wcs:band><wcs:band>Band5</wcs:band><wcs:band>Band1</wcs:band></wcs:rangeSubset></wcs:GetCoverage>[/POST] > [RESULT_DEMIME]
#
# Trim to 1px (#3857):
# RUN_PARMS: wcs_20_multi_getcov_trim_y_to_1px.tif [MAPSERV] [POST]<?xml version="1.0" encoding="UTF-8"?><wcs:GetCoverage xmlns:wcs="http://www.opengis.net/wcs/2.0" xmlns:wcscrs="http://www.opengis.net/wcs/crs/1.0" service="WCS" version="2.0.1"><wcs:format>image/tiff</wcs:format><wcs:CoverageId>multi</wcs:CoverageId><wcs:DimensionTrim><wcs:Dimension>y</wcs:Dimension><wcs:TrimLow>10</wcs:TrimLow><wcs:TrimHigh>10.1</wcs:TrimHigh></wcs:DimensionTrim><wcs:Extension><wcscrs:subsettingCrs>imageCRS</wcscrs:subsettingCrs></wcs:Extension></wcs:GetCoverage>[/POST] > [RESULT_DEMIME]
@@ -37,7 +37,7 @@
# Updated API
#
# RUN_PARMS: wcs_20_getcov_bands_interval.tif [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&RANGESUBSET=Band2:Band5" > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_getcov_bands_intervals.tif [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&RANGESUBSET=Band2:Band5,Band7:Band9" > [RESULT_DEMIME]
# RUN_PARMS: wcs_20_getcov_bands_intervals.tif [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=2.0.1&REQUEST=GetCoverage&COVERAGEID=multi_new&FORMAT=image/tiff&RANGESUBSET=Band2:Band5,Band7:myBand9" > [RESULT_DEMIME]
#
#
# RUN_PARMS: wcs_20_post_bands_interval_component.tif [MAPSERV] [POST]<?xml version="1.0" encoding="UTF-8"?><wcs:GetCoverage xmlns:wcs="http://www.opengis.net/wcs/2.0" xmlns:rsub="http://www.opengis.net/wcs/range-subsetting/1.0" service="WCS" version="2.0.1"><wcs:format>image/tiff</wcs:format><wcs:CoverageId>multi_new</wcs:CoverageId><wcs:Extension><rsub:RangeSubset><rsub:RangeItem><rsub:RangeComponent>Band1</rsub:RangeComponent></rsub:RangeItem><rsub:RangeItem><rsub:RangeInterval><rsub:startComponent>Band3</rsub:startComponent><rsub:endComponent>Band8</rsub:endComponent></rsub:RangeInterval></rsub:RangeItem></rsub:RangeSubset></wcs:Extension></wcs:GetCoverage>[/POST] > [RESULT_DEMIME]
@@ -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,7 +153,8 @@ LAYER
"wcs_imagemode" "BYTE"
"wcs_bandcount" "9"
"wcs_band_names" "Band1 Band2 Band3 Band4 Band5 Band6 Band7 Band8 Band9"
"wcs_rangeset_axes" "bands"
"wcs_band_names" "Band1 Band2 Band3 Band4 Band5 Band6 Band7 Band8 myBand9"
#default values
"wcs_band_interpretation" "Default interpretation"

0 comments on commit fc06d45

Please sign in to comment.