[mapserver-commits] r10423 -
sandbox/sdlime/common-expressions/mapserver
svn at osgeo.org
svn at osgeo.org
Fri Jul 30 00:27:01 EDT 2010
Author: sdlime
Date: 2010-07-30 04:27:01 +0000 (Fri, 30 Jul 2010)
New Revision: 10423
Modified:
sandbox/sdlime/common-expressions/mapserver/mapparser.c
sandbox/sdlime/common-expressions/mapserver/mapparser.y
sandbox/sdlime/common-expressions/mapserver/mapquery.c
Log:
Added default double => string conversion for string parsing context.
Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.c 2010-07-30 04:03:30 UTC (rev 10422)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.c 2010-07-30 04:27:01 UTC (rev 10423)
@@ -394,14 +394,14 @@
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const unsigned short int yyrline[] =
{
- 0, 66, 66, 67, 80, 86, 102, 110, 119, 127,
- 136, 144, 153, 161, 170, 171, 172, 185, 198, 204,
- 210, 216, 222, 228, 234, 235, 243, 251, 260, 268,
- 276, 284, 290, 296, 302, 308, 314, 320, 341, 362,
- 368, 376, 383, 394, 405, 416, 427, 438, 449, 460,
- 471, 481, 493, 494, 495, 496, 497, 498, 499, 506,
- 507, 508, 509, 517, 520, 521, 522, 534, 535, 536,
- 540, 544, 550, 551
+ 0, 66, 66, 67, 80, 94, 110, 118, 127, 135,
+ 144, 152, 161, 169, 178, 179, 180, 193, 206, 212,
+ 218, 224, 230, 236, 242, 243, 251, 259, 268, 276,
+ 284, 292, 298, 304, 310, 316, 322, 328, 349, 370,
+ 376, 384, 391, 402, 413, 424, 435, 446, 457, 468,
+ 479, 489, 501, 502, 503, 504, 505, 506, 507, 514,
+ 515, 516, 517, 525, 528, 529, 530, 542, 543, 544,
+ 548, 552, 558, 559
};
#endif
@@ -1282,15 +1282,23 @@
case 4:
#line 80 "mapparser.y"
{
- if((yyvsp[0].dblval) != 0)
- yypresult.intval = MS_TRUE;
- else
- yypresult.intval = MS_FALSE;
+ switch(yypresult_type) {
+ case(MS_PARSE_RESULT_BOOLEAN):
+ if((yyvsp[0].dblval) != 0)
+ yypresult.intval = MS_TRUE;
+ else
+ yypresult.intval = MS_FALSE;
+ break;
+ case(MS_PARSE_RESULT_STRING):
+ yypresult.strval = (char *)malloc(64); // ok?
+ snprintf(yypresult.strval, 64, "%g", (yyvsp[0].dblval));
+ break;
+ }
}
break;
case 5:
-#line 86 "mapparser.y"
+#line 94 "mapparser.y"
{
switch(yypresult_type) {
case(MS_PARSE_RESULT_BOOLEAN):
@@ -1307,7 +1315,7 @@
break;
case 6:
-#line 102 "mapparser.y"
+#line 110 "mapparser.y"
{
if((yyvsp[-2].intval) == MS_TRUE)
(yyval.intval) = MS_TRUE;
@@ -1319,7 +1327,7 @@
break;
case 7:
-#line 110 "mapparser.y"
+#line 118 "mapparser.y"
{
if((yyvsp[-2].intval) == MS_TRUE) {
if((yyvsp[0].intval) == MS_TRUE)
@@ -1332,7 +1340,7 @@
break;
case 8:
-#line 119 "mapparser.y"
+#line 127 "mapparser.y"
{
if((yyvsp[-2].intval) == MS_TRUE)
(yyval.intval) = MS_TRUE;
@@ -1344,7 +1352,7 @@
break;
case 9:
-#line 127 "mapparser.y"
+#line 135 "mapparser.y"
{
if((yyvsp[-2].intval) == MS_TRUE) {
if((yyvsp[0].dblval) != 0)
@@ -1357,7 +1365,7 @@
break;
case 10:
-#line 136 "mapparser.y"
+#line 144 "mapparser.y"
{
if((yyvsp[-2].dblval) != 0)
(yyval.intval) = MS_TRUE;
@@ -1369,7 +1377,7 @@
break;
case 11:
-#line 144 "mapparser.y"
+#line 152 "mapparser.y"
{
if((yyvsp[-2].dblval) != 0) {
if((yyvsp[0].intval) == MS_TRUE)
@@ -1382,7 +1390,7 @@
break;
case 12:
-#line 153 "mapparser.y"
+#line 161 "mapparser.y"
{
if((yyvsp[-2].dblval) != 0)
(yyval.intval) = MS_TRUE;
@@ -1394,7 +1402,7 @@
break;
case 13:
-#line 161 "mapparser.y"
+#line 169 "mapparser.y"
{
if((yyvsp[-2].dblval) != 0) {
if((yyvsp[0].dblval) != 0)
@@ -1407,17 +1415,17 @@
break;
case 14:
-#line 170 "mapparser.y"
+#line 178 "mapparser.y"
{ (yyval.intval) = !(yyvsp[0].intval); }
break;
case 15:
-#line 171 "mapparser.y"
+#line 179 "mapparser.y"
{ (yyval.intval) = !(yyvsp[0].dblval); }
break;
case 16:
-#line 172 "mapparser.y"
+#line 180 "mapparser.y"
{
ms_regex_t re;
@@ -1434,7 +1442,7 @@
break;
case 17:
-#line 185 "mapparser.y"
+#line 193 "mapparser.y"
{
ms_regex_t re;
@@ -1451,7 +1459,7 @@
break;
case 18:
-#line 198 "mapparser.y"
+#line 206 "mapparser.y"
{
if((yyvsp[-2].dblval) == (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1461,7 +1469,7 @@
break;
case 19:
-#line 204 "mapparser.y"
+#line 212 "mapparser.y"
{
if((yyvsp[-2].dblval) != (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1471,7 +1479,7 @@
break;
case 20:
-#line 210 "mapparser.y"
+#line 218 "mapparser.y"
{
if((yyvsp[-2].dblval) > (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1481,7 +1489,7 @@
break;
case 21:
-#line 216 "mapparser.y"
+#line 224 "mapparser.y"
{
if((yyvsp[-2].dblval) < (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1491,7 +1499,7 @@
break;
case 22:
-#line 222 "mapparser.y"
+#line 230 "mapparser.y"
{
if((yyvsp[-2].dblval) >= (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1501,7 +1509,7 @@
break;
case 23:
-#line 228 "mapparser.y"
+#line 236 "mapparser.y"
{
if((yyvsp[-2].dblval) <= (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1511,12 +1519,12 @@
break;
case 24:
-#line 234 "mapparser.y"
+#line 242 "mapparser.y"
{ (yyval.intval) = (yyvsp[-1].intval); }
break;
case 25:
-#line 235 "mapparser.y"
+#line 243 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) == 0)
(yyval.intval) = MS_TRUE;
@@ -1528,7 +1536,7 @@
break;
case 26:
-#line 243 "mapparser.y"
+#line 251 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) != 0)
(yyval.intval) = MS_TRUE;
@@ -1540,7 +1548,7 @@
break;
case 27:
-#line 251 "mapparser.y"
+#line 259 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) > 0)
(yyval.intval) = MS_TRUE;
@@ -1553,7 +1561,7 @@
break;
case 28:
-#line 260 "mapparser.y"
+#line 268 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) < 0)
(yyval.intval) = MS_TRUE;
@@ -1565,7 +1573,7 @@
break;
case 29:
-#line 268 "mapparser.y"
+#line 276 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) >= 0)
(yyval.intval) = MS_TRUE;
@@ -1577,7 +1585,7 @@
break;
case 30:
-#line 276 "mapparser.y"
+#line 284 "mapparser.y"
{
if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) <= 0)
(yyval.intval) = MS_TRUE;
@@ -1589,7 +1597,7 @@
break;
case 31:
-#line 284 "mapparser.y"
+#line 292 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) == 0)
(yyval.intval) = MS_TRUE;
@@ -1599,7 +1607,7 @@
break;
case 32:
-#line 290 "mapparser.y"
+#line 298 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) != 0)
(yyval.intval) = MS_TRUE;
@@ -1609,7 +1617,7 @@
break;
case 33:
-#line 296 "mapparser.y"
+#line 304 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) > 0)
(yyval.intval) = MS_TRUE;
@@ -1619,7 +1627,7 @@
break;
case 34:
-#line 302 "mapparser.y"
+#line 310 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) < 0)
(yyval.intval) = MS_TRUE;
@@ -1629,7 +1637,7 @@
break;
case 35:
-#line 308 "mapparser.y"
+#line 316 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) >= 0)
(yyval.intval) = MS_TRUE;
@@ -1639,7 +1647,7 @@
break;
case 36:
-#line 314 "mapparser.y"
+#line 322 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) <= 0)
(yyval.intval) = MS_TRUE;
@@ -1649,7 +1657,7 @@
break;
case 37:
-#line 320 "mapparser.y"
+#line 328 "mapparser.y"
{
char *delim,*bufferp;
@@ -1674,7 +1682,7 @@
break;
case 38:
-#line 341 "mapparser.y"
+#line 349 "mapparser.y"
{
char *delim,*bufferp;
@@ -1699,7 +1707,7 @@
break;
case 39:
-#line 362 "mapparser.y"
+#line 370 "mapparser.y"
{
if((yyvsp[-2].dblval) == (yyvsp[0].dblval))
(yyval.intval) = MS_TRUE;
@@ -1709,7 +1717,7 @@
break;
case 40:
-#line 368 "mapparser.y"
+#line 376 "mapparser.y"
{
if(strcasecmp((yyvsp[-2].strval), (yyvsp[0].strval)) == 0)
(yyval.intval) = MS_TRUE;
@@ -1721,7 +1729,7 @@
break;
case 41:
-#line 376 "mapparser.y"
+#line 384 "mapparser.y"
{
if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) == 0)
(yyval.intval) = MS_TRUE;
@@ -1731,7 +1739,7 @@
break;
case 42:
-#line 383 "mapparser.y"
+#line 391 "mapparser.y"
{
int rval;
rval = msGEOSEquals((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1746,7 +1754,7 @@
break;
case 43:
-#line 394 "mapparser.y"
+#line 402 "mapparser.y"
{
int rval;
rval = msGEOSIntersects((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1761,7 +1769,7 @@
break;
case 44:
-#line 405 "mapparser.y"
+#line 413 "mapparser.y"
{
int rval;
rval = msGEOSDisjoint((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1776,7 +1784,7 @@
break;
case 45:
-#line 416 "mapparser.y"
+#line 424 "mapparser.y"
{
int rval;
rval = msGEOSTouches((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1791,7 +1799,7 @@
break;
case 46:
-#line 427 "mapparser.y"
+#line 435 "mapparser.y"
{
int rval;
rval = msGEOSOverlaps((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1806,7 +1814,7 @@
break;
case 47:
-#line 438 "mapparser.y"
+#line 446 "mapparser.y"
{
int rval;
rval = msGEOSCrosses((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1821,7 +1829,7 @@
break;
case 48:
-#line 449 "mapparser.y"
+#line 457 "mapparser.y"
{
int rval;
rval = msGEOSWithin((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1836,7 +1844,7 @@
break;
case 49:
-#line 460 "mapparser.y"
+#line 468 "mapparser.y"
{
int rval;
rval = msGEOSWithin((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1851,7 +1859,7 @@
break;
case 50:
-#line 471 "mapparser.y"
+#line 479 "mapparser.y"
{
double d;
d = msGEOSDistance((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1865,7 +1873,7 @@
break;
case 51:
-#line 481 "mapparser.y"
+#line 489 "mapparser.y"
{
double d;
d = msGEOSDistance((yyvsp[-2].shpval), (yyvsp[0].shpval));
@@ -1879,32 +1887,32 @@
break;
case 53:
-#line 494 "mapparser.y"
+#line 502 "mapparser.y"
{ (yyval.dblval) = (yyvsp[-1].dblval); }
break;
case 54:
-#line 495 "mapparser.y"
+#line 503 "mapparser.y"
{ (yyval.dblval) = (yyvsp[-2].dblval) + (yyvsp[0].dblval); }
break;
case 55:
-#line 496 "mapparser.y"
+#line 504 "mapparser.y"
{ (yyval.dblval) = (yyvsp[-2].dblval) - (yyvsp[0].dblval); }
break;
case 56:
-#line 497 "mapparser.y"
+#line 505 "mapparser.y"
{ (yyval.dblval) = (yyvsp[-2].dblval) * (yyvsp[0].dblval); }
break;
case 57:
-#line 498 "mapparser.y"
+#line 506 "mapparser.y"
{ (yyval.dblval) = (int)(yyvsp[-2].dblval) % (int)(yyvsp[0].dblval); }
break;
case 58:
-#line 499 "mapparser.y"
+#line 507 "mapparser.y"
{
if((yyvsp[0].dblval) == 0.0) {
yyerror("Division by zero.");
@@ -1915,22 +1923,22 @@
break;
case 59:
-#line 506 "mapparser.y"
+#line 514 "mapparser.y"
{ (yyval.dblval) = (yyvsp[0].dblval); }
break;
case 60:
-#line 507 "mapparser.y"
+#line 515 "mapparser.y"
{ (yyval.dblval) = pow((yyvsp[-2].dblval), (yyvsp[0].dblval)); }
break;
case 61:
-#line 508 "mapparser.y"
+#line 516 "mapparser.y"
{ (yyval.dblval) = strlen((yyvsp[-1].strval)); }
break;
case 62:
-#line 509 "mapparser.y"
+#line 517 "mapparser.y"
{
if((yyvsp[-1].shpval)->type != MS_SHAPE_POLYGON) {
yyerror("Area can only be computed for polygon shapes.");
@@ -1942,17 +1950,17 @@
break;
case 63:
-#line 517 "mapparser.y"
+#line 525 "mapparser.y"
{ (yyval.dblval) = (MS_NINT((yyvsp[-3].dblval)/(yyvsp[-1].dblval)))*(yyvsp[-1].dblval); }
break;
case 65:
-#line 521 "mapparser.y"
+#line 529 "mapparser.y"
{ (yyval.shpval) = (yyvsp[-1].shpval); }
break;
case 66:
-#line 522 "mapparser.y"
+#line 530 "mapparser.y"
{
shapeObj *s;
s = msShapeFromWKT((yyvsp[-1].strval));
@@ -1966,12 +1974,12 @@
break;
case 68:
-#line 535 "mapparser.y"
+#line 543 "mapparser.y"
{ (yyval.strval) = (yyvsp[-1].strval); }
break;
case 69:
-#line 536 "mapparser.y"
+#line 544 "mapparser.y"
{
(yyval.strval) = (char *)malloc(strlen((yyvsp[-2].strval)) + strlen((yyvsp[0].strval)) + 1);
sprintf((yyval.strval), "%s%s", (yyvsp[-2].strval), (yyvsp[0].strval)); free((yyvsp[-2].strval)); free((yyvsp[0].strval));
@@ -1979,7 +1987,7 @@
break;
case 70:
-#line 540 "mapparser.y"
+#line 548 "mapparser.y"
{
(yyval.strval) = (char *) malloc(strlen((yyvsp[-1].strval)) + 64); /* Plenty big? Should use snprintf below... */
sprintf((yyval.strval), (yyvsp[-1].strval), (yyvsp[-3].dblval));
@@ -1987,7 +1995,7 @@
break;
case 71:
-#line 544 "mapparser.y"
+#line 552 "mapparser.y"
{
(yyvsp[-1].strval) = msCommifyString((yyvsp[-1].strval));
(yyval.strval) = (yyvsp[-1].strval);
@@ -1995,7 +2003,7 @@
break;
case 73:
-#line 551 "mapparser.y"
+#line 559 "mapparser.y"
{ (yyval.tmval) = (yyvsp[-1].tmval); }
break;
@@ -2003,7 +2011,7 @@
}
/* Line 1037 of yacc.c. */
-#line 2007 "mapparser.c"
+#line 2015 "mapparser.c"
yyvsp -= yylen;
yyssp -= yylen;
@@ -2231,7 +2239,7 @@
}
-#line 554 "mapparser.y"
+#line 562 "mapparser.y"
/*
Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.y
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.y 2010-07-30 04:03:30 UTC (rev 10422)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.y 2010-07-30 04:27:01 UTC (rev 10423)
@@ -78,10 +78,18 @@
}
}
| math_exp {
- if($1 != 0)
- yypresult.intval = MS_TRUE;
- else
- yypresult.intval = MS_FALSE;
+ switch(yypresult_type) {
+ case(MS_PARSE_RESULT_BOOLEAN):
+ if($1 != 0)
+ yypresult.intval = MS_TRUE;
+ else
+ yypresult.intval = MS_FALSE;
+ break;
+ case(MS_PARSE_RESULT_STRING):
+ yypresult.strval = (char *)malloc(64); // ok?
+ snprintf(yypresult.strval, 64, "%g", $1);
+ break;
+ }
}
| string_exp {
switch(yypresult_type) {
Modified: sandbox/sdlime/common-expressions/mapserver/mapquery.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapquery.c 2010-07-30 04:03:30 UTC (rev 10422)
+++ sandbox/sdlime/common-expressions/mapserver/mapquery.c 2010-07-30 04:27:01 UTC (rev 10423)
@@ -677,6 +677,171 @@
return(MS_FAILURE);
}
+/*
+**
+*/
+int msQueryByFilter(mapObj *map)
+{
+ layerObj *lp;
+ int status;
+
+ int old_filtertype=-1;
+ char *old_filterstring=NULL, *old_filteritem=NULL;
+
+ rectObj searchrect;
+
+ shapeObj shape;
+
+ int nclasses = 0;
+ int *classgroup = NULL;
+
+ if(map->query.type != MS_QUERY_BY_ATTRIBUTE) {
+ msSetError(MS_QUERYERR, "The query is not properly defined.", "msQueryByAttribute()");
+ return(MS_FAILURE);
+ }
+
+ if(map->query.layer < 0 || map->query.layer >= map->numlayers) {
+ msSetError(MS_MISCERR, "No query layer defined.", "msQueryByAttributes()");
+ return(MS_FAILURE);
+ }
+
+ lp = (GET_LAYER(map, map->query.layer));
+
+ /* conditions may have changed since this layer last drawn, so set
+ layer->project true to recheck projection needs (Bug #673) */
+ lp->project = MS_TRUE;
+
+ /* free any previous search results, do now in case one of the following tests fails */
+ if(lp->resultcache) {
+ if(lp->resultcache->results) free(lp->resultcache->results);
+ free(lp->resultcache);
+ lp->resultcache = NULL;
+ }
+
+ if(!msIsLayerQueryable(lp)) {
+ msSetError(MS_QUERYERR, "Requested layer has no templates defined so is not queryable.", "msQueryByAttributes()");
+ return(MS_FAILURE);
+ }
+
+ if(!map->query.str) {
+ msSetError(MS_QUERYERR, "No query expression defined.", "msQueryByAttributes()");
+ return(MS_FAILURE);
+ }
+
+ /* save any previously defined filter */
+ if(lp->filter.string) {
+ old_filtertype = lp->filter.type;
+ old_filterstring = strdup(lp->filter.string);
+ if(lp->filteritem)
+ old_filteritem = strdup(lp->filteritem);
+ }
+
+ /* apply the passed query parameters */
+ if(map->query.item && map->query.item[0] != '\0')
+ lp->filteritem = strdup(map->query.item);
+ else
+ lp->filteritem = NULL;
+ msLoadExpressionString(&(lp->filter), map->query.str);
+
+ msInitShape(&shape);
+
+ /* open this layer */
+ status = msLayerOpen(lp);
+ if(status != MS_SUCCESS) {
+ msRestoreOldFilter(lp, old_filtertype, old_filteritem, old_filterstring); /* manually reset the filter */
+ return(MS_FAILURE);
+ }
+
+ /* build item list, we want *all* items */
+ status = msLayerWhichItems(lp, MS_TRUE, NULL);
+ if(status != MS_SUCCESS) {
+ msRestoreOldFilter(lp, old_filtertype, old_filteritem, old_filterstring); /* manually reset the filter */
+ return(MS_FAILURE);
+ }
+
+ /* identify candidate shapes */
+ searchrect = map->query.rect;
+#ifdef USE_PROJ
+ if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
+ msProjectRect(&(map->projection), &(lp->projection), &searchrect); /* project the searchrect to source coords */
+ else
+ lp->project = MS_FALSE;
+#endif
+
+ status = msLayerWhichShapes(lp, searchrect);
+ if(status == MS_DONE) { /* no overlap */
+ msRestoreOldFilter(lp, old_filtertype, old_filteritem, old_filterstring); /* manually reset the filter */
+ msLayerClose(lp);
+ msSetError(MS_NOTFOUND, "No matching record(s) found, layer and area of interest do not overlap.", "msQueryByAttributes()");
+ return(MS_FAILURE);
+ } else if(status != MS_SUCCESS) {
+ msRestoreOldFilter(lp, old_filtertype, old_filteritem, old_filterstring); /* manually reset the filter */
+ msLayerClose(lp);
+ return(MS_FAILURE);
+ }
+
+ lp->resultcache = (resultCacheObj *)malloc(sizeof(resultCacheObj)); /* allocate and initialize the result cache */
+ initResultCache( lp->resultcache);
+
+ nclasses = 0;
+ classgroup = NULL;
+ if (lp->classgroup && lp->numclasses > 0)
+ classgroup = msAllocateValidClassGroups(lp, &nclasses);
+
+ while((status = msLayerNextShape(lp, &shape)) == MS_SUCCESS) { /* step through the shapes */
+
+ shape.classindex = msShapeGetClass(lp, &shape, map->scaledenom, classgroup, nclasses);
+ if(!(lp->template) && ((shape.classindex == -1) || (lp->class[shape.classindex]->status == MS_OFF))) { /* not a valid shape */
+ msFreeShape(&shape);
+ continue;
+ }
+
+ if(!(lp->template) && !(lp->class[shape.classindex]->template)) { /* no valid template */
+ msFreeShape(&shape);
+ continue;
+ }
+
+#ifdef USE_PROJ
+ if(lp->project && msProjectionsDiffer(&(lp->projection), &(map->projection)))
+ msProjectShape(&(lp->projection), &(map->projection), &shape);
+ else
+ lp->project = MS_FALSE;
+#endif
+
+ addResult(lp->resultcache, shape.classindex, shape.index, shape.tileindex);
+
+ if(lp->resultcache->numresults == 1)
+ lp->resultcache->bounds = shape.bounds;
+ else
+ msMergeRect(&(lp->resultcache->bounds), &shape.bounds);
+
+ msFreeShape(&shape);
+
+ if(map->query.mode == MS_QUERY_SINGLE) { /* no need to look any further */
+ status = MS_DONE;
+ break;
+ }
+ }
+
+ if (classgroup)
+ msFree(classgroup);
+
+ msRestoreOldFilter(lp, old_filtertype, old_filteritem, old_filterstring); /* manually reset the filter */
+
+ if(status != MS_DONE) {
+ msLayerClose(lp);
+ return(MS_FAILURE);
+ }
+
+ /* was anything found? (if yes, don't close the layer) */
+ if(lp->resultcache && lp->resultcache->numresults > 0)
+ return(MS_SUCCESS);
+
+ msLayerClose(lp);
+ msSetError(MS_NOTFOUND, "No matching record(s) found.", "msQueryByAttributes()");
+ return(MS_FAILURE);
+}
+
int msQueryByRect(mapObj *map)
{
int l; /* counters */
More information about the mapserver-commits
mailing list