[mapserver-commits] r10283 - sandbox/sdlime/common-expressions/mapserver

svn at osgeo.org svn at osgeo.org
Tue Jul 6 00:04:45 EDT 2010


Author: sdlime
Date: 2010-07-06 04:04:45 +0000 (Tue, 06 Jul 2010)
New Revision: 10283

Modified:
   sandbox/sdlime/common-expressions/mapserver/maplayer.c
   sandbox/sdlime/common-expressions/mapserver/mapparser.c
   sandbox/sdlime/common-expressions/mapserver/mapparser.h
   sandbox/sdlime/common-expressions/mapserver/mapparser.y
   sandbox/sdlime/common-expressions/mapserver/mapraster.c
   sandbox/sdlime/common-expressions/mapserver/maputil.c
Log:
Actually working code now, albeit with a bunch of debugging comments...

Modified: sandbox/sdlime/common-expressions/mapserver/maplayer.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/maplayer.c	2010-07-04 20:31:32 UTC (rev 10282)
+++ sandbox/sdlime/common-expressions/mapserver/maplayer.c	2010-07-06 04:04:45 UTC (rev 10283)
@@ -332,7 +332,7 @@
 extern double msyynumber;
 extern char *msyytext;
 
-static int tokenizeExpression(expressionObj *expression, char **list, int *listsize)
+static int tokenizeExpression(layerObj *layer, expressionObj *expression, char **list, int *listsize)
 {
   int n=0;
   int token;
@@ -418,6 +418,8 @@
   int i, j, k, rv;
   int nt=0;
 
+  printf("in msLayerWhichItems()\n");
+
   if (!layer->vtable) {
     rv =  msInitializeVirtualTable(layer);
     if (rv != MS_SUCCESS) return rv;

Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.c	2010-07-04 20:31:32 UTC (rev 10282)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.c	2010-07-06 04:04:45 UTC (rev 10283)
@@ -121,10 +121,12 @@
 #include "maptime.h" /* for time comparison routines */
 #include "mapprimitive.h" /* for shapeObj */
 
-// int yylex(void); /* lexer globals */
-// int yyerror(const char *);
+int yylex(void); /* lexer globals */
+int yyerror(const char *);
 
+colorObj *yycolor; /* these hold values specific to a shape or pixels expression evaluation */
 shapeObj *yyshape;
+
 layerObj *yylayer;
 expressionObj *yyexpr;
 
@@ -145,7 +147,7 @@
 #endif
 
 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 29 "mapparser.y"
+#line 31 "mapparser.y"
 typedef union YYSTYPE {
   double dblval;
   int intval;  
@@ -154,7 +156,7 @@
   shapeObj *shpval;
 } YYSTYPE;
 /* Line 185 of yacc.c.  */
-#line 158 "mapparser.c"
+#line 160 "mapparser.c"
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
 # define YYSTYPE_IS_TRIVIAL 1
@@ -166,7 +168,7 @@
 
 
 /* Line 213 of yacc.c.  */
-#line 170 "mapparser.c"
+#line 172 "mapparser.c"
 
 #if ! defined (yyoverflow) || YYERROR_VERBOSE
 
@@ -365,13 +367,13 @@
 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 static const unsigned short int yyrline[] =
 {
-       0,    67,    67,    68,    69,    77,    80,    88,    97,   105,
-     114,   122,   131,   139,   148,   149,   150,   163,   169,   175,
-     181,   187,   193,   199,   200,   208,   216,   225,   233,   241,
-     249,   255,   261,   267,   273,   279,   285,   306,   327,   333,
-     341,   347,   360,   361,   362,   363,   364,   365,   366,   373,
-     374,   375,   376,   386,   387,   388,   400,   401,   402,   405,
-     406
+       0,    69,    69,    70,    71,    79,    82,    90,    99,   107,
+     116,   124,   133,   141,   150,   151,   152,   165,   171,   177,
+     183,   189,   195,   201,   202,   210,   218,   227,   235,   243,
+     251,   257,   263,   269,   275,   281,   287,   308,   329,   335,
+     343,   349,   362,   363,   364,   365,   366,   367,   368,   375,
+     376,   377,   378,   388,   389,   390,   402,   403,   404,   407,
+     408
 };
 #endif
 
@@ -1197,12 +1199,12 @@
   switch (yyn)
     {
         case 3:
-#line 68 "mapparser.y"
+#line 70 "mapparser.y"
     { yypresult.intval = (yyvsp[0].intval); }
     break;
 
   case 4:
-#line 69 "mapparser.y"
+#line 71 "mapparser.y"
     {
      if((yyvsp[0].dblval) != 0)
        yypresult.intval = MS_TRUE;
@@ -1212,7 +1214,7 @@
     break;
 
   case 6:
-#line 80 "mapparser.y"
+#line 82 "mapparser.y"
     {
 	                                 if((yyvsp[-2].intval) == MS_TRUE)
 		                           (yyval.intval) = MS_TRUE;
@@ -1224,7 +1226,7 @@
     break;
 
   case 7:
-#line 88 "mapparser.y"
+#line 90 "mapparser.y"
     {
 	                                 if((yyvsp[-2].intval) == MS_TRUE) {
 			                   if((yyvsp[0].intval) == MS_TRUE)
@@ -1237,7 +1239,7 @@
     break;
 
   case 8:
-#line 97 "mapparser.y"
+#line 99 "mapparser.y"
     {
 	                                 if((yyvsp[-2].intval) == MS_TRUE)
 		                           (yyval.intval) = MS_TRUE;
@@ -1249,7 +1251,7 @@
     break;
 
   case 9:
-#line 105 "mapparser.y"
+#line 107 "mapparser.y"
     {
 	                                 if((yyvsp[-2].intval) == MS_TRUE) {
 			                   if((yyvsp[0].dblval) != 0)
@@ -1262,7 +1264,7 @@
     break;
 
   case 10:
-#line 114 "mapparser.y"
+#line 116 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != 0)
 		                           (yyval.intval) = MS_TRUE;
@@ -1274,7 +1276,7 @@
     break;
 
   case 11:
-#line 122 "mapparser.y"
+#line 124 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != 0) {
 			                   if((yyvsp[0].intval) == MS_TRUE)
@@ -1287,7 +1289,7 @@
     break;
 
   case 12:
-#line 131 "mapparser.y"
+#line 133 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != 0)
 		                           (yyval.intval) = MS_TRUE;
@@ -1299,7 +1301,7 @@
     break;
 
   case 13:
-#line 139 "mapparser.y"
+#line 141 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != 0) {
 			                   if((yyvsp[0].dblval) != 0)
@@ -1312,17 +1314,17 @@
     break;
 
   case 14:
-#line 148 "mapparser.y"
+#line 150 "mapparser.y"
     { (yyval.intval) = !(yyvsp[0].intval); }
     break;
 
   case 15:
-#line 149 "mapparser.y"
+#line 151 "mapparser.y"
     { (yyval.intval) = !(yyvsp[0].dblval); }
     break;
 
   case 16:
-#line 150 "mapparser.y"
+#line 152 "mapparser.y"
     {
                                          ms_regex_t re;
 
@@ -1339,7 +1341,7 @@
     break;
 
   case 17:
-#line 163 "mapparser.y"
+#line 165 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) == (yyvsp[0].dblval))
 	 		                   (yyval.intval) = MS_TRUE;
@@ -1349,7 +1351,7 @@
     break;
 
   case 18:
-#line 169 "mapparser.y"
+#line 171 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) != (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1359,7 +1361,7 @@
     break;
 
   case 19:
-#line 175 "mapparser.y"
+#line 177 "mapparser.y"
     {	                                 
 	                                 if((yyvsp[-2].dblval) > (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1369,7 +1371,7 @@
     break;
 
   case 20:
-#line 181 "mapparser.y"
+#line 183 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) < (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1379,7 +1381,7 @@
     break;
 
   case 21:
-#line 187 "mapparser.y"
+#line 189 "mapparser.y"
     {	                                 
 	                                 if((yyvsp[-2].dblval) >= (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1389,7 +1391,7 @@
     break;
 
   case 22:
-#line 193 "mapparser.y"
+#line 195 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) <= (yyvsp[0].dblval))
 			                   (yyval.intval) = MS_TRUE;
@@ -1399,12 +1401,12 @@
     break;
 
   case 23:
-#line 199 "mapparser.y"
+#line 201 "mapparser.y"
     { (yyval.intval) = (yyvsp[-1].intval); }
     break;
 
   case 24:
-#line 200 "mapparser.y"
+#line 202 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) == 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1416,7 +1418,7 @@
     break;
 
   case 25:
-#line 208 "mapparser.y"
+#line 210 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) != 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1428,7 +1430,7 @@
     break;
 
   case 26:
-#line 216 "mapparser.y"
+#line 218 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) > 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1441,7 +1443,7 @@
     break;
 
   case 27:
-#line 225 "mapparser.y"
+#line 227 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) < 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1453,7 +1455,7 @@
     break;
 
   case 28:
-#line 233 "mapparser.y"
+#line 235 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) >= 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1465,7 +1467,7 @@
     break;
 
   case 29:
-#line 241 "mapparser.y"
+#line 243 "mapparser.y"
     {
                                          if(strcmp((yyvsp[-2].strval), (yyvsp[0].strval)) <= 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1477,7 +1479,7 @@
     break;
 
   case 30:
-#line 249 "mapparser.y"
+#line 251 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) == 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1487,7 +1489,7 @@
     break;
 
   case 31:
-#line 255 "mapparser.y"
+#line 257 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) != 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1497,7 +1499,7 @@
     break;
 
   case 32:
-#line 261 "mapparser.y"
+#line 263 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) > 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1507,7 +1509,7 @@
     break;
 
   case 33:
-#line 267 "mapparser.y"
+#line 269 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) < 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1517,7 +1519,7 @@
     break;
 
   case 34:
-#line 273 "mapparser.y"
+#line 275 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) >= 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1527,7 +1529,7 @@
     break;
 
   case 35:
-#line 279 "mapparser.y"
+#line 281 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) <= 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1537,7 +1539,7 @@
     break;
 
   case 36:
-#line 285 "mapparser.y"
+#line 287 "mapparser.y"
     {
 					 char *delim,*bufferp;
 
@@ -1562,7 +1564,7 @@
     break;
 
   case 37:
-#line 306 "mapparser.y"
+#line 308 "mapparser.y"
     {
 					 char *delim,*bufferp;
 
@@ -1587,7 +1589,7 @@
     break;
 
   case 38:
-#line 327 "mapparser.y"
+#line 329 "mapparser.y"
     {
 	                                 if((yyvsp[-2].dblval) == (yyvsp[0].dblval))
 	 		                   (yyval.intval) = MS_TRUE;
@@ -1597,7 +1599,7 @@
     break;
 
   case 39:
-#line 333 "mapparser.y"
+#line 335 "mapparser.y"
     {
                                          if(strcasecmp((yyvsp[-2].strval), (yyvsp[0].strval)) == 0)
 					   (yyval.intval) = MS_TRUE;
@@ -1609,7 +1611,7 @@
     break;
 
   case 40:
-#line 341 "mapparser.y"
+#line 343 "mapparser.y"
     {
                                      if(msTimeCompare(&((yyvsp[-2].tmval)), &((yyvsp[0].tmval))) == 0)
 				       (yyval.intval) = MS_TRUE;
@@ -1619,7 +1621,7 @@
     break;
 
   case 41:
-#line 347 "mapparser.y"
+#line 349 "mapparser.y"
     {
       int rval;
       rval = msGEOSIntersects((yyvsp[-2].shpval), (yyvsp[0].shpval));      
@@ -1634,32 +1636,32 @@
     break;
 
   case 43:
-#line 361 "mapparser.y"
+#line 363 "mapparser.y"
     { (yyval.dblval) = (yyvsp[-1].dblval); }
     break;
 
   case 44:
-#line 362 "mapparser.y"
+#line 364 "mapparser.y"
     { (yyval.dblval) = (yyvsp[-2].dblval) + (yyvsp[0].dblval); }
     break;
 
   case 45:
-#line 363 "mapparser.y"
+#line 365 "mapparser.y"
     { (yyval.dblval) = (yyvsp[-2].dblval) - (yyvsp[0].dblval); }
     break;
 
   case 46:
-#line 364 "mapparser.y"
+#line 366 "mapparser.y"
     { (yyval.dblval) = (yyvsp[-2].dblval) * (yyvsp[0].dblval); }
     break;
 
   case 47:
-#line 365 "mapparser.y"
+#line 367 "mapparser.y"
     { (yyval.dblval) = (int)(yyvsp[-2].dblval) % (int)(yyvsp[0].dblval); }
     break;
 
   case 48:
-#line 366 "mapparser.y"
+#line 368 "mapparser.y"
     {
       if((yyvsp[0].dblval) == 0.0) {
         yyerror("Division by zero.");
@@ -1670,22 +1672,22 @@
     break;
 
   case 49:
-#line 373 "mapparser.y"
+#line 375 "mapparser.y"
     { (yyval.dblval) = (yyvsp[0].dblval); }
     break;
 
   case 50:
-#line 374 "mapparser.y"
+#line 376 "mapparser.y"
     { (yyval.dblval) = pow((yyvsp[-2].dblval), (yyvsp[0].dblval)); }
     break;
 
   case 51:
-#line 375 "mapparser.y"
+#line 377 "mapparser.y"
     { (yyval.dblval) = strlen((yyvsp[-1].strval)); }
     break;
 
   case 52:
-#line 376 "mapparser.y"
+#line 378 "mapparser.y"
     {
       if((yyvsp[-1].shpval)->type != MS_SHAPE_POLYGON) {
         yyerror("Area can only be computed for polygon shapes.");
@@ -1697,12 +1699,12 @@
     break;
 
   case 54:
-#line 387 "mapparser.y"
+#line 389 "mapparser.y"
     { (yyval.shpval) = (yyvsp[-1].shpval); }
     break;
 
   case 55:
-#line 388 "mapparser.y"
+#line 390 "mapparser.y"
     {
       shapeObj *s;
       s = msShapeFromWKT((yyvsp[-1].strval));
@@ -1716,17 +1718,17 @@
     break;
 
   case 57:
-#line 401 "mapparser.y"
+#line 403 "mapparser.y"
     { (yyval.strval) = (yyvsp[-1].strval); free((yyvsp[-1].strval)); }
     break;
 
   case 58:
-#line 402 "mapparser.y"
+#line 404 "mapparser.y"
     { sprintf((yyval.strval), "%s%s", (yyvsp[-2].strval), (yyvsp[0].strval)); free((yyvsp[-2].strval)); free((yyvsp[0].strval)); }
     break;
 
   case 60:
-#line 406 "mapparser.y"
+#line 408 "mapparser.y"
     { (yyval.tmval) = (yyvsp[-1].tmval); }
     break;
 
@@ -1734,7 +1736,7 @@
     }
 
 /* Line 1037 of yacc.c.  */
-#line 1738 "mapparser.c"
+#line 1740 "mapparser.c"
 
   yyvsp -= yylen;
   yyssp -= yylen;
@@ -1962,7 +1964,7 @@
 }
 
 
-#line 409 "mapparser.y"
+#line 411 "mapparser.y"
 
 
 /*
@@ -1973,6 +1975,8 @@
 {
   int token, i=yyexpr->curtoken;
 
+  printf("in yylex() - curtoken=%d...\n", i);
+
   if(yyexpr->curtoken == yyexpr->numtokens) return(0); /* done */
 
   token = yyexpr->tokens[i].token; /* may override if a binding token */
@@ -2004,7 +2008,7 @@
     token = TIME;
     msTimeInit(&(yylval.tmval));
     if(msParseTime(yyshape->values[yyexpr->tokens[i].tokenval.bindval.index], &(yylval.tmval)) != MS_TRUE) {
-      yyerror("Parsing time value failed.", "yylex()");
+      yyerror("Parsing time value failed.");
       return(-1);
     }
     break;
@@ -2020,7 +2024,7 @@
   return(token);
 }
 
-int yyerror(char *s) {
+int yyerror(const char *s) {
   msSetError(MS_PARSEERR, s, "yyparse()");
   return(0);
 }

Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.h
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.h	2010-07-04 20:31:32 UTC (rev 10282)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.h	2010-07-06 04:04:45 UTC (rev 10283)
@@ -84,7 +84,7 @@
 
 
 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
-#line 29 "mapparser.y"
+#line 31 "mapparser.y"
 typedef union YYSTYPE {
   double dblval;
   int intval;  

Modified: sandbox/sdlime/common-expressions/mapserver/mapparser.y
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapparser.y	2010-07-04 20:31:32 UTC (rev 10282)
+++ sandbox/sdlime/common-expressions/mapserver/mapparser.y	2010-07-06 04:04:45 UTC (rev 10283)
@@ -14,10 +14,12 @@
 #include "maptime.h" /* for time comparison routines */
 #include "mapprimitive.h" /* for shapeObj */
 
-// int yylex(void); /* lexer globals */
-// int yyerror(const char *);
+int yylex(void); /* lexer globals */
+int yyerror(const char *);
 
+colorObj *yycolor; /* these hold values specific to a shape or pixels expression evaluation */
 shapeObj *yyshape;
+
 layerObj *yylayer;
 expressionObj *yyexpr;
 
@@ -416,6 +418,8 @@
 {
   int token, i=yyexpr->curtoken;
 
+  printf("in yylex() - curtoken=%d...\n", i);
+
   if(yyexpr->curtoken == yyexpr->numtokens) return(0); /* done */
 
   token = yyexpr->tokens[i].token; /* may override if a binding token */
@@ -447,7 +451,7 @@
     token = TIME;
     msTimeInit(&(yylval.tmval));
     if(msParseTime(yyshape->values[yyexpr->tokens[i].tokenval.bindval.index], &(yylval.tmval)) != MS_TRUE) {
-      yyerror("Parsing time value failed.", "yylex()");
+      yyerror("Parsing time value failed.");
       return(-1);
     }
     break;
@@ -463,7 +467,7 @@
   return(token);
 }
 
-int yyerror(char *s) {
+int yyerror(const char *s) {
   msSetError(MS_PARSEERR, s, "yyparse()");
   return(0);
 }

Modified: sandbox/sdlime/common-expressions/mapserver/mapraster.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/mapraster.c	2010-07-04 20:31:32 UTC (rev 10282)
+++ sandbox/sdlime/common-expressions/mapserver/mapraster.c	2010-07-06 04:04:45 UTC (rev 10283)
@@ -113,9 +113,9 @@
       tmpstr1 = msReplaceSubstring(tmpstr1, "[pixel]", tmpstr2);
 
       msAcquireLock( TLOCK_PARSER );
-      msyystate = MS_TOKENIZE_EXPRESSION; msyystring = tmpstr1;
-      status = msyyparse();
-      expresult = msyyresult;
+      // msyystate = MS_TOKENIZE_EXPRESSION; msyystring = tmpstr1;
+      // status = msyyparse();
+      // expresult = msyyresult;
       msReleaseLock( TLOCK_PARSER );
 
       free(tmpstr1);
@@ -191,9 +191,9 @@
             tmpstr1 = msReplaceSubstring(tmpstr1, "[pixel]", tmpstr2);
 
             msAcquireLock( TLOCK_PARSER );
-            msyystate = MS_TOKENIZE_EXPRESSION; msyystring = tmpstr1;
-            status = msyyparse();
-            expresult = msyyresult;
+            // msyystate = MS_TOKENIZE_EXPRESSION; msyystring = tmpstr1;
+            // status = msyyparse();
+            // expresult = msyyresult;
             msReleaseLock( TLOCK_PARSER );
 
             free(tmpstr1);

Modified: sandbox/sdlime/common-expressions/mapserver/maputil.c
===================================================================
--- sandbox/sdlime/common-expressions/mapserver/maputil.c	2010-07-04 20:31:32 UTC (rev 10282)
+++ sandbox/sdlime/common-expressions/mapserver/maputil.c	2010-07-06 04:04:45 UTC (rev 10283)
@@ -358,8 +358,7 @@
 int msEvalExpression(layerObj *layer, shapeObj *shape, expressionObj *expression, int itemindex)
 {
   int status;
-  int expresult;  /* result of logical expression parsing operation */
-  
+    
   if(!expression->string) return(MS_TRUE); /* empty expressions are ALWAYS true */
 
   switch(expression->type) {
@@ -384,6 +383,7 @@
     yyshape = shape;
     yylayer = layer;
     yyexpr = expression;
+    yyexpr->curtoken = 0; /* reset */
 
     status = yyparse();
     msReleaseLock( TLOCK_PARSER );



More information about the mapserver-commits mailing list