Opened 13 years ago

Closed 13 years ago

#3974 closed defect (fixed)

Wrong definition of contains in mapparser.y

Reported by: havatv Owned by: sdlime
Priority: normal Milestone:
Component: MapServer C Library Version: svn-trunk (development)
Severity: normal Keywords: parser, contains, definition
Cc: havatv

Description

In mapparse.y, the definition of the spatial predicate contains is identical to the definition of within (the one directly above in the code). Here is a suggestion for a fix (including a fix to the error message):

Index: mapserver/trunk/mapserver/mapparser.y
===================================================================
--- mapserver/trunk/mapserver/mapparser.y       (revisjon 11979)
+++ mapserver/trunk/mapserver/mapparser.y       (arbeidskopi)
@@ -474,11 +474,11 @@
     }
   | shape_exp CONTAINS shape_exp {
       int rval;
-      rval = msGEOSWithin($1, $3);
+      rval = msGEOSContains($1, $3);
       if($1->scratch == MS_TRUE) msFreeShape($1);
       if($3->scratch == MS_TRUE) msFreeShape($3);
       if(rval == -1) {
-        yyerror(p, "Within operator failed.");
+        yyerror(p, "Contains operator failed.");
         return(-1);
       } else
         $$ = rval;

If we do not want to use msGEOSContains (which also seems to be defined in mapgeos.c), contains could also be defined using msGEOSWithin, by just switching the parameters. Here is a suggestion for an alternative fix (including a fix to the error message):

Index: mapserver/trunk/mapserver/mapparser.y
===================================================================
--- mapserver/trunk/mapserver/mapparser.y       (revisjon 11979)
+++ mapserver/trunk/mapserver/mapparser.y       (arbeidskopi)
@@ -474,11 +474,11 @@
     }
   | shape_exp CONTAINS shape_exp {
       int rval;
-      rval = msGEOSWithin($1, $3);
+      rval = msGEOSWithin($3, $1);
       if($1->scratch == MS_TRUE) msFreeShape($1);
       if($3->scratch == MS_TRUE) msFreeShape($3);
       if(rval == -1) {
-        yyerror(p, "Within operator failed.");
+        yyerror(p, "Contains operator failed.");
         return(-1);
       } else
         $$ = rval;

Change History (1)

comment:1 by sdlime, 13 years ago

Resolution: fixed
Status: newclosed

It was a cut and paste issue... I seem to make a lot of those. Fixed in trunk (r12029) and branch-6-0 (r12030). Closing...

Steve

Note: See TracTickets for help on using tickets.