Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WMS Service with layer with TileIndexLayer #6407

Closed
ashleysommer opened this issue Sep 8, 2021 · 3 comments · Fixed by #6408
Closed

WMS Service with layer with TileIndexLayer #6407

ashleysommer opened this issue Sep 8, 2021 · 3 comments · Fixed by #6408

Comments

@ashleysommer
Copy link
Contributor

Expected behavior and actual behavior.

Expected behavior:

  • Mapserver will append the Time filter to the existing filter in TileIndexLayer using msLayerSetTimeFilter
    Actual behavior:
  • Mapserver appends the Time filter to the current Raster Tile.

Similar to, but not the same as #6406

Steps to reproduce the problem.

Snippet of Mapfile:

LAYER
  NAME "MyTileIndex"
  TYPE TILEINDEX
  DATA "/path/to/my/index.shp"
  FILTER ( "[attrib]" eq "val" AND [attr2] ge 0 )
END
LAYER
  NAME "MyLayer"
  TYPE RASTER
  TILEINDEX "MyTileIndex"
  TILEITEM "location"
  PROJECTION
    "init=epsg:4326"
  END
  METADATA
    wms_enable_request "*"
    wms_title "TotalBucket"
    wms_timeextent "2015-11-20/2021-01-01/P1D"
    wms_timeitem "date"
    wms_timedefault "2015-11-20"
    wms_timeformat "YYYY-MM-DD"
  END
END

When querying the WMS service with TIME="2015-11-20", I expect the FILTER on MyTileIndex to become:

FILTER ((( "[attrib]" eq "val" AND [attr2] ge 0 )) AND (`[time]` = `2015-11-20`))

Instead, that filter is not affected, but instead a new FILTER is added to raster layer "MyLayer".

FILTER ( `[time]` = `2015-11-20`)

See the relevant code in msWMSApplyTime()

MapServer/mapwms.cpp

Lines 283 to 284 in 7c65ac4

/* build the time string */
msLayerSetTimeFilter(lp, time, timefield);

Notably, the code does not check if the given layer uses a TileIndexLayer, instead just applies the time filter to the current layer.

Note: The equivalent code for msWMSApplyDimension() does check for a Index layer, and applies it correctly.

MapServer/mapwms.cpp

Lines 791 to 792 in 7c65ac4

if (lp->tileindex && (tlpindex = msGetLayerIndex(lp->map, lp->tileindex)) != -1) {
result = FLTApplyExpressionToLayer((GET_LAYER(lp->map, tlpindex)), pszExpression) != MS_FALSE;

Operating system

Ubuntu 20.04

MapServer version and installation method

Mapserver 7.6.4

@ashleysommer
Copy link
Contributor Author

ashleysommer commented Sep 8, 2021

I've looked through the code, and I thought there might be a segment where the TLI Filter is eventually replaced by the filter in the raster layer. But I can't see it.

Interestingly, in my testing I find the response does still return a correct image for the given TIME, but I can't work out how it does.

@ashleysommer
Copy link
Contributor Author

Nevermind, I found the code I was looking for:

MapServer/maprasterquery.c

Lines 1412 to 1446 in 7c65ac4

int msRASTERLayerSetTimeFilter(layerObj *layer, const char *timestring,
const char *timefield)
{
int tilelayerindex;
/* -------------------------------------------------------------------- */
/* If we don't have a tileindex the time filter has no effect. */
/* -------------------------------------------------------------------- */
if( layer->tileindex == NULL )
return MS_SUCCESS;
/* -------------------------------------------------------------------- */
/* Find the tileindex layer. */
/* -------------------------------------------------------------------- */
tilelayerindex = msGetLayerIndex(layer->map, layer->tileindex);
/* -------------------------------------------------------------------- */
/* If we are using a local shapefile as our tileindex (that is */
/* to say, the tileindex name is not of another layer), then we */
/* just install a backtics style filter on the raster layer. */
/* This is propogated to the "working layer" created for the */
/* tileindex by code in mapraster.c. */
/* -------------------------------------------------------------------- */
if( tilelayerindex == -1 )
return msLayerMakeBackticsTimeFilter( layer, timestring, timefield );
/* -------------------------------------------------------------------- */
/* Otherwise we invoke the tileindex layers SetTimeFilter */
/* method. */
/* -------------------------------------------------------------------- */
if ( msCheckParentPointer(layer->map,"map")==MS_FAILURE )
return MS_FAILURE;
return msLayerSetTimeFilter( layer->GET_LAYER(map,tilelayerindex),
timestring, timefield );
}

This does directly call the msLayerSetTimeFilter() on the TileIndexLayer instead of the Raster layer.
Closing issue as invalid.

@ashleysommer
Copy link
Contributor Author

This is now a duplicate of #6406
If the FILTER on the TileIndexLayer is set (and is an expression) it gets overwritten with the time filter, rather than appended.

ashleysommer added a commit to ashleysommer/MapServer that referenced this issue Sep 8, 2021
…filter is an expression

WCS: Don't remove existing TileIndexLayer filter when applying time filter.
Fixes MapServer#6406
Fixes MapServer#6407
rouault pushed a commit that referenced this issue Oct 21, 2021
…6408)

WCS: Don't remove existing TileIndexLayer filter when applying time filter.
Fixes #6406
Fixes #6407
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant