From 67b1f043c25e97bb1ba649bf984bdca4a3381eb3 Mon Sep 17 00:00:00 2001 From: Ashley Sommer Date: Thu, 21 Oct 2021 20:18:31 +1000 Subject: [PATCH] TimeFilter: Allow time filter to append to an existing layer filter (#6408) WCS: Don't remove existing TileIndexLayer filter when applying time filter. Fixes #6406 Fixes #6407 --- maplayer.c | 33 +++-- mapwcs.cpp | 1 - .../wxs/data/raster_timeseries/20200101a.tif | Bin 0 -> 924 bytes .../wxs/data/raster_timeseries/20200101b.tif | Bin 0 -> 931 bytes .../wxs/data/raster_timeseries/20200102a.tif | Bin 0 -> 933 bytes .../wxs/data/raster_timeseries/20200102b.tif | Bin 0 -> 928 bytes .../wxs/data/raster_timeseries/index.dbf | Bin 0 -> 1297 bytes .../wxs/data/raster_timeseries/index.prj | 1 + .../wxs/data/raster_timeseries/index.shp | Bin 0 -> 644 bytes .../wxs/data/raster_timeseries/index.shx | Bin 0 -> 132 bytes .../wcs_describe_coverage_indexlayers_a.xml | 73 +++++++++++ .../wcs_get_capabilities_indexlayers.xml | 85 +++++++++++++ .../wcs_get_coverage_indexlayers_a.tif | Bin 0 -> 686 bytes ...cs_get_coverage_indexlayers_a_20200101.tif | Bin 0 -> 686 bytes msautotest/wxs/wcs_tileindexlayer.map | 114 ++++++++++++++++++ 15 files changed, 296 insertions(+), 11 deletions(-) create mode 100644 msautotest/wxs/data/raster_timeseries/20200101a.tif create mode 100644 msautotest/wxs/data/raster_timeseries/20200101b.tif create mode 100644 msautotest/wxs/data/raster_timeseries/20200102a.tif create mode 100644 msautotest/wxs/data/raster_timeseries/20200102b.tif create mode 100644 msautotest/wxs/data/raster_timeseries/index.dbf create mode 100644 msautotest/wxs/data/raster_timeseries/index.prj create mode 100644 msautotest/wxs/data/raster_timeseries/index.shp create mode 100644 msautotest/wxs/data/raster_timeseries/index.shx create mode 100644 msautotest/wxs/expected/wcs_describe_coverage_indexlayers_a.xml create mode 100644 msautotest/wxs/expected/wcs_get_capabilities_indexlayers.xml create mode 100644 msautotest/wxs/expected/wcs_get_coverage_indexlayers_a.tif create mode 100644 msautotest/wxs/expected/wcs_get_coverage_indexlayers_a_20200101.tif create mode 100644 msautotest/wxs/wcs_tileindexlayer.map diff --git a/maplayer.c b/maplayer.c index 4a56db0dfa..f8739e4528 100644 --- a/maplayer.c +++ b/maplayer.c @@ -994,7 +994,7 @@ int msLayerWhichItems(layerObj *layer, int get_all, const char *metadata) // check item set by mapwfs.cpp to restrict the number of columns selected metadata = msOWSLookupMetadata(&(layer->metadata), "G", "select_items"); if (metadata) { - /* get only selected items */ + /* get only selected items */ get_all = MS_FALSE; } } @@ -1425,12 +1425,18 @@ makeTimeFilter(layerObj *lp, /* if the filter is set and it's a sting type, concatenate it with the time. If not just free it */ - if (lp->filter.string && lp->filter.type == MS_STRING) { - pszBuffer = msStringConcatenate(pszBuffer, "(("); - pszBuffer = msStringConcatenate(pszBuffer, lp->filter.string); - pszBuffer = msStringConcatenate(pszBuffer, ") and "); + if (lp->filter.string && lp->filter.type == MS_STRING) { + pszBuffer = msStringConcatenate(pszBuffer, "(("); + pszBuffer = msStringConcatenate(pszBuffer, lp->filter.string); + pszBuffer = msStringConcatenate(pszBuffer, ") and "); + } else if (lp->filter.string && lp->filter.type == MS_EXPRESSION) { + char* pszExpressionString = msGetExpressionString(&(lp->filter)); + pszBuffer = msStringConcatenate(pszBuffer, "("); + pszBuffer = msStringConcatenate(pszBuffer, pszExpressionString); + pszBuffer = msStringConcatenate(pszBuffer, " and "); + msFree(pszExpressionString); } else { - msFreeExpression(&lp->filter); + msFreeExpression(&lp->filter); } pszBuffer = msStringConcatenate(pszBuffer, "("); @@ -1461,15 +1467,15 @@ makeTimeFilter(layerObj *lp, pszBuffer = msStringConcatenate(pszBuffer, ")"); /* if there was a filter, It was concatenate with an And ans should be closed*/ - if(lp->filter.string && lp->filter.type == MS_STRING) { + if (lp->filter.string && + (lp->filter.type == MS_STRING || lp->filter.type == MS_EXPRESSION)) pszBuffer = msStringConcatenate(pszBuffer, ")"); - } + msLoadExpressionString(&lp->filter, pszBuffer); if (pszBuffer) msFree(pszBuffer); - return MS_TRUE; } @@ -1487,6 +1493,13 @@ makeTimeFilter(layerObj *lp, existing filter. It is set to 0 when time filter parts are added to the buffer */ bOnlyExistingFilter = 1; + } else if (lp->filter.string && lp->filter.type == MS_EXPRESSION) { + char* pszExpressionString = msGetExpressionString(&(lp->filter)); + pszBuffer = msStringConcatenate(pszBuffer, "("); + pszBuffer = msStringConcatenate(pszBuffer, pszExpressionString); + pszBuffer = msStringConcatenate(pszBuffer, " and "); + msFree(pszExpressionString); + bOnlyExistingFilter = 1; } else msFreeExpression(&lp->filter); @@ -1604,7 +1617,7 @@ makeTimeFilter(layerObj *lp, /* load the string to the filter */ if (pszBuffer && strlen(pszBuffer) > 0) { - if(lp->filter.string && lp->filter.type == MS_STRING) + if(lp->filter.string && (lp->filter.type == MS_STRING || lp->filter.type == MS_EXPRESSION )) pszBuffer = msStringConcatenate(pszBuffer, ")"); /* if(lp->filteritem) diff --git a/mapwcs.cpp b/mapwcs.cpp index 62d5690578..fdefc9eefc 100644 --- a/mapwcs.cpp +++ b/mapwcs.cpp @@ -1941,7 +1941,6 @@ this request. Check wcs/ows_enable_request settings.", "msWCSGetCoverage()", par } /* finally set the filter */ - msFreeExpression(&tlp->filter); msLayerSetTimeFilter(tlp, params->time, value); } diff --git a/msautotest/wxs/data/raster_timeseries/20200101a.tif b/msautotest/wxs/data/raster_timeseries/20200101a.tif new file mode 100644 index 0000000000000000000000000000000000000000..6d2d4d0f811c8f93a401cf732d0125279578fd97 GIT binary patch literal 924 zcmebD)M7Zmz`)?{;^-3}91;}j91>IJ!87IK~HiM!DJ=7#J9u7$_uFmZTPQ z`8Y=UhlbdCy14|$JGr{~2f4*9B5sA$NWh(&1nW1b}Ae#-!2I&z+ zV#^@0ZIRecP__V2y)zQqg^>kpuOAZwgDaHn1vE4ms)iY;p0AmQ0Yt9?iZ`|JFt7pH zhk)$$?aT}cK=vmfdqX=91JDQ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2oLbt(79EQ0^Kk~pt=B^dq)6)%gFZ*>0ptFX#WOZWJ+(`9BJcjP77pD8-4)R-jC zZGU_11WS#DJG=Y)hIyG6o+(WDo3VN7aHlYSf$=uzc7G+~V{_hErE Tro4wIys_m!BFHtPp#g*e0x9dR literal 0 HcmV?d00001 diff --git a/msautotest/wxs/data/raster_timeseries/index.dbf b/msautotest/wxs/data/raster_timeseries/index.dbf new file mode 100644 index 0000000000000000000000000000000000000000..9c9188211e309ba35d1673043ae7ab40d6a67f2e GIT binary patch literal 1297 zcmZRs<2c@>Ndj0_A64Ga_YN;1 + + + a + + + 110 -18 + 118 -10 + 2020-01-01 + 2020-01-02 + + + + + 110 -18 + 118 -10 + + + 110 -18 + 118 -10 + + + + + 0 0 + 7 7 + + + x + y + + 110 -10 + + 1 0 + 0 -1 + + + + 2020-01-01 + 2020-01-02 + + + + + Range 1 + + + -1.0 + + + + + EPSG:4326 + EPSG:4326 + + + GTiff + + + nearest neighbor + bilinear + + + diff --git a/msautotest/wxs/expected/wcs_get_capabilities_indexlayers.xml b/msautotest/wxs/expected/wcs_get_capabilities_indexlayers.xml new file mode 100644 index 0000000000..01f8bb577f --- /dev/null +++ b/msautotest/wxs/expected/wcs_get_capabilities_indexlayers.xml @@ -0,0 +1,85 @@ +Content-Type: text/xml; charset=UTF-8 + + + + + MapServer WCS + + NONE + + NONE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + application/vnd.ogc.se_xml + + + + + a + + + 110 -18 + 118 -10 + 2020-01-01 + 2020-01-02 + + + + b + + + 110 -18 + 118 -10 + 2020-01-01 + 2020-01-02 + + + + diff --git a/msautotest/wxs/expected/wcs_get_coverage_indexlayers_a.tif b/msautotest/wxs/expected/wcs_get_coverage_indexlayers_a.tif new file mode 100644 index 0000000000000000000000000000000000000000..ef0bdad21e133364d8c10d4322598c3a70aca5de GIT binary patch literal 686 zcmebD)MDUZU|r5~4`rVo)~7 zOmV0hkU}X&RBfC0hC@JxV_V`Do|mVph-?^EXF*w7A= z=LXXZ3>~>8(`1(vIRKS7EDMQn40jJ!urR4%Xz>!Z7d#ehzhJGHee=71yH{DK>;gYn z*i}T{w%d2C%dYEDx;?*!y1nP=Z+4P%lI-2$80=S-irUX;vs?g(litw*0r#JeXx4cHhwciO?#$-)nE!omh0vwyOBG?YR(b`zhA@?Cu?~v7gj_ z*6#UNNBdy22z!|)#kO`g|Jy}-B-?jPUuNfJoo6q7Ioz)A6{CHIzM?%FU%buPmR)xK zvi8<7U-IqmmVUOI@3q8kfo_KVteKhi>wFaL?PZGW`%^{ie|5CmWuNA=x9p9yzjLbF m?wxt5UBy}xy9u6;>^A8n*>mJ9wL9$^XIJbRWM4j0$Q}SF^or;J literal 0 HcmV?d00001 diff --git a/msautotest/wxs/expected/wcs_get_coverage_indexlayers_a_20200101.tif b/msautotest/wxs/expected/wcs_get_coverage_indexlayers_a_20200101.tif new file mode 100644 index 0000000000000000000000000000000000000000..425cf383201ab68a3968ccfcd126ce26191dc70a GIT binary patch literal 686 zcmebD)MDUZU|r5~4`rVo)~7 zOmV0hkU}X&RBfC0hC@JxV_V`Do|mVph-?^EXF*w7A= z=LXXZ3>~>8(`1(vIRKS7EDMQn40jJ!urR4%c>ni?-PK|Z`#S{^_B&2G+dquDXV+`} z*KX$vVf*5u3i~6@Dt0V0pV%oo^V;k9GTYSXn%H-BB-<;V4Yj|Za^3Fn0tR~}=~uS< zz5DF~k|)`fiQTYk{%>RF_+z>4N8=LvNe5W$Jh!#jmG4foKi~P*u0HpLooIBjeel}~ z`-*%=``X2Yc3++v*?;;kVOR3R#lD-<#$G`6haG2=p#AS{0rodMr0j#TrR-mDSK7Z~ zjG^&%_&c mfA{>f`*UZ3&85Z8_5say_Sv(q+I_iEVm~8nshw=yDmwt{Adb@j literal 0 HcmV?d00001 diff --git a/msautotest/wxs/wcs_tileindexlayer.map b/msautotest/wxs/wcs_tileindexlayer.map new file mode 100644 index 0000000000..a643b81a46 --- /dev/null +++ b/msautotest/wxs/wcs_tileindexlayer.map @@ -0,0 +1,114 @@ +# +# REQUIRES: INPUT=GDAL OUTPUT=PNG SUPPORTS=WCS SUPPORTS=PROJ +# +# RUN_PARMS: wcs_get_capabilities_indexlayers.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCapabilities" > [RESULT_DEVERSION] +# +# RUN_PARMS: wcs_describe_coverage_indexlayers_a.xml [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=1.0.0&REQUEST=DescribeCoverage&COVERAGE=a" > [RESULT_DEVERSION] +# +# RUN_PARMS: wcs_get_coverage_indexlayers_a.tif [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&WIDTH=8&HEIGHT=8&FORMAT=image/tiff&BBOX=110.0,-18,118.0,-10.0&COVERAGE=a&CRS=EPSG:4326" > [RESULT_DEMIME] +# +# RUN_PARMS: wcs_get_coverage_indexlayers_a_20200101.tif [MAPSERV] QUERY_STRING="map=[MAPFILE]&SERVICE=WCS&VERSION=1.0.0&REQUEST=GetCoverage&WIDTH=8&HEIGHT=8&FORMAT=image/tiff&BBOX=110.0,-18,118.0,-10.0&COVERAGE=a&CRS=EPSG:4326&TIME=2020-01-01" > [RESULT_DEMIME] +# + +MAP + +NAME TEST +STATUS ON +SIZE 8 8 +EXTENT 110 -18 118 -10 +IMAGECOLOR 0 0 0 + +PROJECTION + "+init=epsg:4326" +END + +OUTPUTFORMAT + NAME GEOTIFF_F32 + DRIVER "GDAL/GTiff" + MIMETYPE "image/tiff" + IMAGEMODE FLOAT32 + EXTENSION "tif" +END + + +# +# Start of web interface definition +# +WEB + + IMAGEPATH "/tmp/ms_tmp/" + IMAGEURL "/ms_tmp/" + + METADATA + "wcs_onlineresource" "http://localhost/path/to/?" + "wcs_srs" "EPSG:4326" + "wcs_label" "title" + "ows_enable_request" "*" + END +END + +SHAPEPATH "data/raster_timeseries/" + +LAYER + NAME "a_index" + PROJECTION + "init=epsg:4326" + END + TYPE TILEINDEX + STATUS OFF + DATA "index.shp" + # This filter should be APPENDED to, by WCS or WMS time queries + FILTER ( "[layer]" eq "a" ) +END + +LAYER + NAME a + TYPE raster + STATUS ON + TILEINDEX a_index + TILEITEM "location" + PROJECTION + "+init=epsg:4326" + END + METADATA + "wcs_enable_request" "*" + "wcs_label" "wcs_layer_a" + "wcs_rangeset_name" "Range 1" ### required to support DescribeCoverage request + "wcs_rangeset_label" "My Label" ### required to support DescribeCoverage request + "wcs_extent" "110 -18 118 -10" + "wcs_rangeset_nullvalue" "-1.0" + "wcs_timeposition" "2020-01-01,2020-01-02" + "wcs_nilvalues" "-1.0" + "wcs_timeitem" "date" + "wcs_size" "8 8" + "wcs_resolution" "1 1" + "wcs_srs" "EPSG:4326" + END +END + +LAYER + NAME b + TYPE raster + STATUS ON + TILEINDEX b_index + TILEITEM "location" + PROJECTION + "+init=epsg:4326" + END + METADATA + "wcs_enable_request" "*" + "wcs_label" "wcs_layer_b" + "wcs_rangeset_name" "Range 1" ### required to support DescribeCoverage request + "wcs_rangeset_label" "My Label" ### required to support DescribeCoverage request + "wcs_extent" "110 -18 118 -10" + "wcs_rangeset_nullvalue" "-1.0" + "wcs_timeposition" "2020-01-01,2020-01-02" + "wcs_nilvalues" "-1.0" + "wcs_timeitem" "date" + "wcs_size" "8 8" + "wcs_resolution" "1 1" + "wcs_srs" "EPSG:4326" + END +END + +END # of map file