Permalink
Browse files

Move filter translation into msLayerWhichShapes() and out of the draw…

…/query functions.
  • Loading branch information...
Steve Lime
Steve Lime committed Feb 11, 2015
1 parent 297fd5c commit a42c38a7dd9d749f3e20c978b1d716714a217e5f
Showing with 9 additions and 41 deletions.
  1. +2 −14 mapdraw.c
  2. +3 −0 maplayer.c
  3. +0 −2 mapogr.cpp
  4. +3 −24 mapquery.c
  5. +1 −1 msautotest
View
@@ -877,30 +877,18 @@ int msDrawVectorLayer(mapObj *map, layerObj *layer, imageObj *image)
if (layer->styleitem &&
(strncasecmp(layer->styleitem, "javascript://", 13) == 0)) {
status = msLayerWhichItems(layer, MS_TRUE, NULL);
- }
- else {
+ } else {
status = msLayerWhichItems(layer, MS_FALSE, NULL);
}
- /* translate filter (if necessary) */
- if(!msLayerSupportsCommonFilters(layer))
- status = msLayerTranslateFilter(layer, &layer->filter, layer->filteritem);
-
- /* we ignore the translation status here - MapServer will fall back to its own expression evaluation */
- // if(status != MS_SUCCESS) {
- // msLayerClose(layer);
- // return MS_FAILURE;
- // }
-
/* identify target shapes */
if(layer->transform == MS_TRUE) {
searchrect = map->extent;
#ifdef USE_PROJ
if((map->projection.numargs > 0) && (layer->projection.numargs > 0))
msProjectRect(&map->projection, &layer->projection, &searchrect); /* project the searchrect to source coords */
#endif
- }
- else {
+ } else {
searchrect.minx = searchrect.miny = 0;
searchrect.maxx = map->width-1;
searchrect.maxy = map->height-1;
View
@@ -281,6 +281,9 @@ int msLayerTranslateFilter(layerObj *layer, expressionObj *filter, char *filteri
*/
int msLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery)
{
+ if(!msLayerSupportsCommonFilters(layer))
+ msLayerTranslateFilter(layer, &layer->filter, layer->filteritem);
+
if ( ! layer->vtable) {
int rv = msInitializeVirtualTable(layer);
if (rv != MS_SUCCESS)
View
@@ -1576,8 +1576,6 @@ static int msOGRFileWhichShapes(layerObj *layer, rectObj rect, msOGRFileInfo *ps
char *pszOGRFilter = NULL;
- fprintf(stderr, "in msOGRFileWhichShapes()\n");
-
/* In case we have an odd filter combining both a OGR filter and MapServer */
/* filter, then separate things */
// msOGRSplitFilter(layer, &pszOGRFilter, &pszMSFilter);
View
@@ -747,7 +747,7 @@ int msQueryByFilter(mapObj *map)
if(msLayerSupportsCommonFilters(lp)) eval = MS_FALSE;
/*
- ** Set the lp->filter and lp->filteritem (may need to merge).
+ ** Set the lp->filter and lp->filteritem (may need to merge). Remember filters are *always* MapServer syntax.
*/
lp->filteritem = map->query.filteritem; /* re-point lp->filteritem */
if(old_filter.string != NULL) { /* need to merge filters to create one logical expression */
@@ -764,11 +764,6 @@ int msQueryByFilter(mapObj *map)
status = msLayerWhichItems(lp, MS_TRUE, NULL);
if(status != MS_SUCCESS) goto query_error;
- if(eval == MS_TRUE) {
- status = msLayerTranslateFilter(lp, &lp->filter, lp->filteritem); /* sets lp->filter.native_string */
- if(status == MS_SUCCESS) eval = MS_FALSE; /* driver will apply the filter */
- }
-
search_rect = map->query.rect;
#ifdef USE_PROJ
if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection))) {
@@ -794,16 +789,9 @@ int msQueryByFilter(mapObj *map)
if (lp->minfeaturesize > 0)
minfeaturesize = Pix2LayerGeoref(map, lp, lp->minfeaturesize);
- while((status = msLayerNextShape(lp, &shape)) == MS_SUCCESS) { /* step through the shapes */
+ while((status = msLayerNextShape(lp, &shape)) == MS_SUCCESS) { /* step through the shapes - if necessary the filter is applied in msLayerNextShape(...) */
- if(eval == MS_TRUE) { /* we have to apply the filter here instead of within the driver */
- if(msEvalExpression(lp, &shape, &lp->filter, -1) != MS_TRUE) { /* next shape (was using map->query.filter) */
- msFreeShape(&shape);
- continue;
- }
- }
-
- /* Check if the shape size is ok to be drawn */
+ /* Check if the shape size is ok to be drawn */
if ( (shape.type == MS_SHAPE_LINE || shape.type == MS_SHAPE_POLYGON) && (minfeaturesize > 0) ) {
if (msShapeCheckSize(&shape, minfeaturesize) == MS_FALSE) {
if( lp->debug >= MS_DEBUGLEVEL_V )
@@ -994,15 +982,6 @@ int msQueryByRect(mapObj *map)
return(MS_FAILURE);
}
- /* translate filter (if necessary) */
- if(!msLayerSupportsCommonFilters(lp)) {
- status = msLayerTranslateFilter(lp, &lp->filter, lp->filteritem);
- if(status != MS_SUCCESS) {
- msFreeShape(&searchshape);
- return(MS_FAILURE);
- }
- }
-
#ifdef USE_PROJ
if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
Submodule msautotest updated from 655bb4 to d41b2a

0 comments on commit a42c38a

Please sign in to comment.