Skip to content

Commit

Permalink
TimeFilter: Allow time filter to append to an existing layer filter (#…
Browse files Browse the repository at this point in the history
…6408)

WCS: Don't remove existing TileIndexLayer filter when applying time filter.
Fixes #6406
Fixes #6407
  • Loading branch information
ashleysommer committed Oct 21, 2021
1 parent e5b1d7b commit 67b1f04
Show file tree
Hide file tree
Showing 15 changed files with 296 additions and 11 deletions.
33 changes: 23 additions & 10 deletions maplayer.c
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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, "(");
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);

Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion mapwcs.cpp
Expand Up @@ -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);
}

Expand Down
Binary file added msautotest/wxs/data/raster_timeseries/20200101a.tif
Binary file not shown.
Binary file added msautotest/wxs/data/raster_timeseries/20200101b.tif
Binary file not shown.
Binary file added msautotest/wxs/data/raster_timeseries/20200102a.tif
Binary file not shown.
Binary file added msautotest/wxs/data/raster_timeseries/20200102b.tif
Binary file not shown.
Binary file added msautotest/wxs/data/raster_timeseries/index.dbf
Binary file not shown.
1 change: 1 addition & 0 deletions msautotest/wxs/data/raster_timeseries/index.prj
@@ -0,0 +1 @@
GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
Binary file added msautotest/wxs/data/raster_timeseries/index.shp
Binary file not shown.
Binary file added msautotest/wxs/data/raster_timeseries/index.shx
Binary file not shown.
73 changes: 73 additions & 0 deletions msautotest/wxs/expected/wcs_describe_coverage_indexlayers_a.xml
@@ -0,0 +1,73 @@
Content-Type: text/xml; charset=UTF-8

<?xml version='1.0' encoding="UTF-8" ?>
<CoverageDescription
version="1.0.0"
updateSequence="0"
xmlns="http://www.opengis.net/wcs"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wcs http://schemas.opengis.net/wcs/1.0.0/describeCoverage.xsd">
<CoverageOffering>
<metadataLink metadataType="TC211" xlink:type="simple" xlink:href="http://localhost/path/to/?request=GetMetadata&amp;layer=a"/> <name>a</name>
<label>wcs_layer_a</label>
<lonLatEnvelope srsName="urn:ogc:def:crs:OGC:1.3:CRS84">
<gml:pos>110 -18</gml:pos>
<gml:pos>118 -10</gml:pos>
<gml:timePosition>2020-01-01</gml:timePosition>
<gml:timePosition>2020-01-02</gml:timePosition>
</lonLatEnvelope>
<domainSet>
<spatialDomain>
<gml:Envelope srsName="EPSG:4326">
<gml:pos>110 -18</gml:pos>
<gml:pos>118 -10</gml:pos>
</gml:Envelope>
<gml:Envelope srsName="EPSG:4326">
<gml:pos>110 -18</gml:pos>
<gml:pos>118 -10</gml:pos>
</gml:Envelope>
<gml:RectifiedGrid dimension="2">
<gml:limits>
<gml:GridEnvelope>
<gml:low>0 0</gml:low>
<gml:high>7 7</gml:high>
</gml:GridEnvelope>
</gml:limits>
<gml:axisName>x</gml:axisName>
<gml:axisName>y</gml:axisName>
<gml:origin>
<gml:pos>110 -10</gml:pos>
</gml:origin>
<gml:offsetVector>1 0</gml:offsetVector>
<gml:offsetVector>0 -1</gml:offsetVector>
</gml:RectifiedGrid>
</spatialDomain>
<temporalDomain>
<gml:timePosition>2020-01-01</gml:timePosition>
<gml:timePosition>2020-01-02</gml:timePosition>
</temporalDomain>
</domainSet>
<rangeSet>
<RangeSet>
<name>Range 1</name>
<label>My Label</label>
<nullValues>
<singleValue>-1.0</singleValue>
</nullValues>
</RangeSet>
</rangeSet>
<supportedCRSs>
<requestResponseCRSs>EPSG:4326</requestResponseCRSs>
<nativeCRSs>EPSG:4326</nativeCRSs>
</supportedCRSs>
<supportedFormats>
<formats>GTiff</formats>
</supportedFormats>
<supportedInterpolations default="nearest neighbor">
<interpolationMethod>nearest neighbor</interpolationMethod>
<interpolationMethod>bilinear</interpolationMethod>
</supportedInterpolations>
</CoverageOffering>
</CoverageDescription>
85 changes: 85 additions & 0 deletions msautotest/wxs/expected/wcs_get_capabilities_indexlayers.xml
@@ -0,0 +1,85 @@
Content-Type: text/xml; charset=UTF-8

<?xml version='1.0' encoding="UTF-8" standalone="no" ?>
<WCS_Capabilities
version="1.0.0"
updateSequence="0"
xmlns="http://www.opengis.net/wcs"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gml="http://www.opengis.net/gml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wcs http://schemas.opengis.net/wcs/1.0.0/wcsCapabilities.xsd">
<Service>
<name>MapServer WCS</name>
<label>title</label>
<fees>NONE</fees>
<accessConstraints>
NONE
</accessConstraints>
</Service>
<Capability>
<Request>
<GetCapabilities>
<DCPType>
<HTTP>
<Get><OnlineResource xlink:type="simple" xlink:href="http://localhost/path/to/?" /></Get>
</HTTP>
</DCPType>
<DCPType>
<HTTP>
<Post><OnlineResource xlink:type="simple" xlink:href="http://localhost/path/to/?" /></Post>
</HTTP>
</DCPType>
</GetCapabilities>
<DescribeCoverage>
<DCPType>
<HTTP>
<Get><OnlineResource xlink:type="simple" xlink:href="http://localhost/path/to/?" /></Get>
</HTTP>
</DCPType>
<DCPType>
<HTTP>
<Post><OnlineResource xlink:type="simple" xlink:href="http://localhost/path/to/?" /></Post>
</HTTP>
</DCPType>
</DescribeCoverage>
<GetCoverage>
<DCPType>
<HTTP>
<Get><OnlineResource xlink:type="simple" xlink:href="http://localhost/path/to/?" /></Get>
</HTTP>
</DCPType>
<DCPType>
<HTTP>
<Post><OnlineResource xlink:type="simple" xlink:href="http://localhost/path/to/?" /></Post>
</HTTP>
</DCPType>
</GetCoverage>
</Request>
<Exception>
<Format>application/vnd.ogc.se_xml</Format>
</Exception>
</Capability>
<ContentMetadata>
<CoverageOfferingBrief>
<metadataLink metadataType="TC211" xlink:type="simple" xlink:href="http://localhost/path/to/?request=GetMetadata&amp;layer=a"/> <name>a</name>
<label>wcs_layer_a</label>
<lonLatEnvelope srsName="urn:ogc:def:crs:OGC:1.3:CRS84">
<gml:pos>110 -18</gml:pos>
<gml:pos>118 -10</gml:pos>
<gml:timePosition>2020-01-01</gml:timePosition>
<gml:timePosition>2020-01-02</gml:timePosition>
</lonLatEnvelope>
</CoverageOfferingBrief>
<CoverageOfferingBrief>
<metadataLink metadataType="TC211" xlink:type="simple" xlink:href="http://localhost/path/to/?request=GetMetadata&amp;layer=b"/> <name>b</name>
<label>wcs_layer_b</label>
<lonLatEnvelope srsName="urn:ogc:def:crs:OGC:1.3:CRS84">
<gml:pos>110 -18</gml:pos>
<gml:pos>118 -10</gml:pos>
<gml:timePosition>2020-01-01</gml:timePosition>
<gml:timePosition>2020-01-02</gml:timePosition>
</lonLatEnvelope>
</CoverageOfferingBrief>
</ContentMetadata>
</WCS_Capabilities>
Binary file not shown.
Binary file not shown.
114 changes: 114 additions & 0 deletions 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

0 comments on commit 67b1f04

Please sign in to comment.