]> granicus.if.org Git - postgis/commitdiff
Now accepts both types of multipoint - 'MULTIPOINT(0 0, 1 1)'::geometry and
authorDavid Blasby <dblasby@gmail.com>
Fri, 25 Oct 2002 16:13:18 +0000 (16:13 +0000)
committerDavid Blasby <dblasby@gmail.com>
Fri, 25 Oct 2002 16:13:18 +0000 (16:13 +0000)
'MULTIPOINT( (0 0), (1 1))'::geometry;

git-svn-id: http://svn.osgeo.org/postgis/trunk@205 b70326c6-7e19-0410-871a-916f4a2858ee

postgis_inout.c

index 2c53f5617625bacfd6b02535aacaab48c9d9888c..550ea89460ed07650e1b6603ea3bb61908a95704 100644 (file)
@@ -1512,6 +1512,37 @@ Datum geometry_in(PG_FUNCTION_ARGS)
                PG_RETURN_NULL() ;
        }
 
+       // handle the 2 variants of MULTIPOINT - 'MULTIPOINT(0 0, 1 1)'::geometry and 'MULTIPOINT( (0 0), (1 1))'::geometry;
+
+               // we cheat - if its the 2nd variant, we replace the internal parethesis with spaces!
+                       if (strstr(str,"MULTIPOINT") != NULL )
+                       {
+                               //its a multipoint - replace any internal parenthesis with spaces
+                               char *first_paren;
+                               char *last_paren;
+                               char *current_paren;
+
+                               first_paren= index (str,'(');
+                               last_paren = rindex(str,')');
+
+                               if  ( (first_paren == NULL) || (last_paren == NULL) || (first_paren >last_paren) )
+                               {
+                                               elog(ERROR,"couldnt parse objects in GEOMETRY (parenthesis related)\n");
+                                               PG_RETURN_NULL() ;
+                               }
+                               //now we can just got through the string
+                               for (current_paren = (first_paren+1); current_paren <(last_paren);current_paren++)
+                               {
+                                       if ( (current_paren[0] ==')') || (current_paren[0]=='(') )
+                                       {
+                                               current_paren[0] = ' ';
+                                       }
+                               }
+
+                       }
+
+
+//elog (NOTICE,"in:%s\n", str);
 
 //printf("geometry_in got string ''\n");