** Query using common expression syntax. */
| 763 | ** Query using common expression syntax. |
| 764 | */ |
| 765 | int msQueryByFilter(mapObj *map) |
| 766 | { |
| 767 | int l; |
| 768 | int start, stop=0; |
| 769 | |
| 770 | layerObj *lp; |
| 771 | |
| 772 | char status; |
| 773 | |
| 774 | expressionObj old_filter; |
| 775 | |
| 776 | rectObj search_rect; |
| 777 | |
| 778 | shapeObj shape; |
| 779 | |
| 780 | int nclasses = 0; |
| 781 | int *classgroup = NULL; |
| 782 | double minfeaturesize = -1; |
| 783 | |
| 784 | if(map->query.type != MS_QUERY_BY_FILTER) { |
| 785 | msSetError(MS_QUERYERR, "The query is not properly defined.", "msQueryByFilter()"); |
| 786 | return(MS_FAILURE); |
| 787 | } |
| 788 | if(!map->query.filter) { // TODO: check filter type too |
| 789 | msSetError(MS_QUERYERR, "Filter is not set.", "msQueryByFilter()"); |
| 790 | return(MS_FAILURE); |
| 791 | } |
| 792 | |
| 793 | msInitShape(&shape); |
| 794 | |
| 795 | if(map->query.layer < 0 || map->query.layer >= map->numlayers) |
| 796 | start = map->numlayers-1; |
| 797 | else |
| 798 | start = stop = map->query.layer; |
| 799 | |
| 800 | for(l=start; l>=stop; l--) { |
| 801 | lp = (GET_LAYER(map, l)); |
| 802 | |
| 803 | /* conditions may have changed since this layer last drawn, so set |
| 804 | layer->project true to recheck projection needs (Bug #673) */ |
| 805 | lp->project = MS_TRUE; |
| 806 | |
| 807 | /* free any previous search results, do it now in case one of the next few tests fail */ |
| 808 | if(lp->resultcache) { |
| 809 | if(lp->resultcache->results) free(lp->resultcache->results); |
| 810 | free(lp->resultcache); |
| 811 | lp->resultcache = NULL; |
| 812 | } |
| 813 | |
| 814 | if(!msIsLayerQueryable(lp)) continue; |
| 815 | if(lp->status == MS_OFF) continue; |
| 816 | if(lp->type == MS_LAYER_RASTER) continue; /* ok to skip? */ |
| 817 | |
| 818 | if(map->scaledenom > 0) { |
| 819 | if((lp->maxscaledenom > 0) && (map->scaledenom > lp->maxscaledenom)) continue; |
| 820 | if((lp->minscaledenom > 0) && (map->scaledenom <= lp->minscaledenom)) continue; |
| 821 | } |
| 822 |
no test coverage detected