| 941 | } |
| 942 | |
| 943 | int msQueryByRect(mapObj *map) |
| 944 | { |
| 945 | int l; /* counters */ |
| 946 | int start, stop=0; |
| 947 | |
| 948 | layerObj *lp; |
| 949 | |
| 950 | char status; |
| 951 | shapeObj shape, searchshape; |
| 952 | rectObj searchrect; |
| 953 | double layer_tolerance = 0, tolerance = 0; |
| 954 | |
| 955 | int nclasses = 0; |
| 956 | int *classgroup = NULL; |
| 957 | double minfeaturesize = -1; |
| 958 | |
| 959 | if(map->query.type != MS_QUERY_BY_RECT) { |
| 960 | msSetError(MS_QUERYERR, "The query is not properly defined.", "msQueryByRect()"); |
| 961 | return(MS_FAILURE); |
| 962 | } |
| 963 | |
| 964 | msInitShape(&shape); |
| 965 | msInitShape(&searchshape); |
| 966 | |
| 967 | if(map->query.layer < 0 || map->query.layer >= map->numlayers) |
| 968 | start = map->numlayers-1; |
| 969 | else |
| 970 | start = stop = map->query.layer; |
| 971 | |
| 972 | for(l=start; l>=stop; l--) { |
| 973 | lp = (GET_LAYER(map, l)); |
| 974 | |
| 975 | /* conditions may have changed since this layer last drawn, so set |
| 976 | layer->project true to recheck projection needs (Bug #673) */ |
| 977 | lp->project = MS_TRUE; |
| 978 | |
| 979 | /* free any previous search results, do it now in case one of the next few tests fail */ |
| 980 | if(lp->resultcache) { |
| 981 | if(lp->resultcache->results) free(lp->resultcache->results); |
| 982 | free(lp->resultcache); |
| 983 | lp->resultcache = NULL; |
| 984 | } |
| 985 | |
| 986 | if(!msIsLayerQueryable(lp)) continue; |
| 987 | if(lp->status == MS_OFF) continue; |
| 988 | |
| 989 | if(map->scaledenom > 0) { |
| 990 | if((lp->maxscaledenom > 0) && (map->scaledenom > lp->maxscaledenom)) continue; |
| 991 | if((lp->minscaledenom > 0) && (map->scaledenom <= lp->minscaledenom)) continue; |
| 992 | } |
| 993 | |
| 994 | if (lp->maxscaledenom <= 0 && lp->minscaledenom <= 0) { |
| 995 | if((lp->maxgeowidth > 0) && ((map->extent.maxx - map->extent.minx) > lp->maxgeowidth)) continue; |
| 996 | if((lp->mingeowidth > 0) && ((map->extent.maxx - map->extent.minx) < lp->mingeowidth)) continue; |
| 997 | } |
| 998 | |
| 999 | searchrect = map->query.rect; |
| 1000 | if(lp->tolerance > 0) { |
no test coverage detected