| 1142 | } |
| 1143 | |
| 1144 | int msQueryByFeatures(mapObj *map) |
| 1145 | { |
| 1146 | int i, l; |
| 1147 | int start, stop=0; |
| 1148 | layerObj *lp, *slp; |
| 1149 | char status; |
| 1150 | |
| 1151 | double distance, tolerance, layer_tolerance; |
| 1152 | |
| 1153 | rectObj searchrect; |
| 1154 | shapeObj shape, selectshape; |
| 1155 | int nclasses = 0; |
| 1156 | int *classgroup = NULL; |
| 1157 | double minfeaturesize = -1; |
| 1158 | |
| 1159 | if(map->debug) msDebug("in msQueryByFeatures()\n"); |
| 1160 | |
| 1161 | /* is the selection layer valid and has it been queried */ |
| 1162 | if(map->query.slayer < 0 || map->query.slayer >= map->numlayers) { |
| 1163 | msSetError(MS_QUERYERR, "Invalid selection layer index.", "msQueryByFeatures()"); |
| 1164 | return(MS_FAILURE); |
| 1165 | } |
| 1166 | slp = (GET_LAYER(map, map->query.slayer)); |
| 1167 | if(!slp->resultcache) { |
| 1168 | msSetError(MS_QUERYERR, "Selection layer has not been queried.", "msQueryByFeatures()"); |
| 1169 | return(MS_FAILURE); |
| 1170 | } |
| 1171 | |
| 1172 | /* conditions may have changed since this layer last drawn, so set |
| 1173 | layer->project true to recheck projection needs (Bug #673) */ |
| 1174 | slp->project = MS_TRUE; |
| 1175 | |
| 1176 | if(map->query.layer < 0 || map->query.layer >= map->numlayers) |
| 1177 | start = map->numlayers-1; |
| 1178 | else |
| 1179 | start = stop = map->query.layer; |
| 1180 | |
| 1181 | /* selection layers should already be open */ |
| 1182 | /* status = msLayerOpen(slp); |
| 1183 | if(status != MS_SUCCESS) return(MS_FAILURE); */ |
| 1184 | |
| 1185 | msInitShape(&shape); /* initialize a few things */ |
| 1186 | msInitShape(&selectshape); |
| 1187 | |
| 1188 | for(l=start; l>=stop; l--) { |
| 1189 | if(l == map->query.slayer) continue; /* skip the selection layer */ |
| 1190 | |
| 1191 | lp = (GET_LAYER(map, l)); |
| 1192 | |
| 1193 | /* conditions may have changed since this layer last drawn, so set |
| 1194 | layer->project true to recheck projection needs (Bug #673) */ |
| 1195 | lp->project = MS_TRUE; |
| 1196 | |
| 1197 | /* free any previous search results, do it now in case one of the next few tests fail */ |
| 1198 | if(lp->resultcache) { |
| 1199 | if(lp->resultcache->results) free(lp->resultcache->results); |
| 1200 | free(lp->resultcache); |
| 1201 | lp->resultcache = NULL; |
no test coverage detected