[postgis-users] some wrong about Geometry_in function!

fxb echofxb at netnation.refractions.net
Wed Apr 21 06:24:00 PDT 2004


Hi:
   When I use the MULTIPOINT,I found some bug in geometry_in function!it can execute correctly the following selection:
    
  select  'GEOMETRYCOLLECTION(MULTIPOINT( 1 2))'::GEOMETRY as geom;
  select  'GEOMETRYCOLLECTION(MULTIPOINT( 1 2 3))'::GEOMETRY as geom;
  select  'GEOMETRYCOLLECTION(MULTIPOINT( 1 2 3, 5 6 7, 8 9 10, 11 12 13))'::GEOMETRY as geom;
  select  'GEOMETRYCOLLECTION(POINT( 1 2 ),MULTIPOINT( 1 2 3))'::GEOMETRY as geom;
  select  'GEOMETRYCOLLECTION(( 1 2, 3 4, 5 6),POINT( 1 2 3))'::GEOMETRY as geom;
   ..............
  I think the error is the following code!
  
-----------------------------------------------------------------------------------
PG_FUNCTION_INFO_V1(geometry_in);
Datum geometry_in(PG_FUNCTION_ARGS)
{


 // 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] = ' ';
     }
    }

   }



}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20040421/8ec34288/attachment.html>


More information about the postgis-users mailing list