Skip to content

Commit

Permalink
Move filter translation into msLayerWhichShapes() and out of the draw…
Browse files Browse the repository at this point in the history
…/query functions.
  • Loading branch information
sdlime committed Feb 11, 2015
1 parent 297fd5c commit a42c38a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 41 deletions.
16 changes: 2 additions & 14 deletions mapdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions maplayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions mapogr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 3 additions & 24 deletions mapquery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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))) {
Expand All @@ -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 )
Expand Down Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion msautotest
Submodule msautotest updated from 655bb4 to d41b2a

0 comments on commit a42c38a

Please sign in to comment.