[svn-commits] r191 - branches/geospatial/wkt-wkb

thich01 at ingres.com thich01 at ingres.com
Wed Aug 13 12:28:10 PDT 2008


Author: thich01
Date: 2008-08-13 12:28:10 -0700 (Wed, 13 Aug 2008)
New Revision: 191

Modified:
   branches/geospatial/wkt-wkb/main.c
   branches/geospatial/wkt-wkb/wkbOps.c
   branches/geospatial/wkt-wkb/wkbOps.h
   branches/geospatial/wkt-wkb/wktToWkb.y
Log:
#107 - Clean up some parameter validation.  Complete binary parse to file or string.  Error checking on bison calls to inserts.

Modified: branches/geospatial/wkt-wkb/main.c
===================================================================
--- branches/geospatial/wkt-wkb/main.c	2008-08-13 14:52:22 UTC (rev 190)
+++ branches/geospatial/wkt-wkb/main.c	2008-08-13 19:28:10 UTC (rev 191)
@@ -1,45 +1,127 @@
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 #include "wkbOps.h"
 
-int main(int argc,char *argv[])
+void printHelp( void )
 {
+    printf( "Usage: testMain options\n" );
+    printf( "Options:\n" );
+    printf( "\t-i inputFile for parsing.\n" );
+    printf( "\t-s inputString for parsing.\n" );
+    printf( "\t\t-i and -s are mutually exclusive.\n" );
+    printf( "\t-o outputFile\n" );
+    printf( "\t\t optional, if not specified a string will be printed.\n" );
+
+    exit( 1 );
+}
+
+int main( int argc, char *argv[] )
+{
     FILE *fp;
     char *wkbStream;
     size_t streamSize = 0;
-    int parsed = 5;
+    int parsed = -1;
+    char *outFileName = NULL;
+    char *inFileName = NULL;
+    char *inputString = NULL;
+    char *outputString;
+    int c;
 
-    if( argc == 2 )
+    while(( c = getopt( argc, argv, "i:o:s:" )) != -1 )
     {
-        fp = fopen( argv[1],"r" );
-        if( !fp )
+        switch( c )
         {
-            parsed = wkbParseString( argv[1], &wkbStream, &streamSize );
+            case 'i':
+                if( inputString != NULL )
+                {
+                    printf( "Only one of -i and -s can be specified.\n" );
+                    printHelp();
+                }
+                inFileName = optarg;
+                break;
+            case 's':
+                if( inFileName != NULL )
+                {
+                    printf( "Only one of -i and -s can be specified.\n" );
+                    printHelp();
+                }
+                inputString = optarg;
+                break;
+            case 'o':
+                outFileName = optarg;
+                break;
+            default:
+                printHelp();
+                break;
         }
+    }
+
+    if(( inputString == NULL ) && ( inFileName == NULL ))
+    {
+        printf( "One of -i or -s must be specified.\n" );
+        printHelp();
+    }
+
+    if( inFileName != NULL )
+    {
+        fp = fopen( inFileName, "r" );
+        if( fp == NULL )
+        {
+            printf( "Error opening file %s.\n", inFileName );
+            exit( 1 );
+        }
         else
         {
-            parsed = wkbParseFile( fp, &wkbStream, &streamSize );
+            parsed = wkbParseTextFile( fp, &wkbStream, &streamSize );
             fclose( fp );
         }
-        if( parsed == 0 )
+    }
+    else
+    {
+        parsed = wkbParseTextString( inputString, &wkbStream, &streamSize );
+    }
+
+    if( parsed == 0 )
+    {
+        if( outFileName != NULL )
         {
-            wkbParseBinary( wkbStream, NULL );
+            fp = fopen( outFileName, "w+" );
+            if( fp == NULL )
+            {
+                printf( "Error opening file %s.\n", outFileName );
+                exit( 1 );
+            }
+            else
+            {
+                parsed = wkbParseBinaryToFile( wkbStream, fp );
+                fclose( fp );
+            }
         }
         else
         {
-            printf( "Error while parsing %d.\n", parsed );
+            parsed = wkbParseBinaryToString( wkbStream, &outputString );
+            printf( "Output string:\n%s\n", outputString );
+            if( outputString != NULL )
+            {
+                free( outputString );
+            }
         }
-
-        if( wkbStream != NULL )
-        {
-            free( wkbStream );
-        }
     }
     else
     {
-        printf( "Incorrect arguments.\n" );
-        return 0;
+        printf( "Error while parsing %d.\n", parsed );
     }
 
-    return 1;
+    if( parsed != 0 )
+    {
+        printf( "Error %d while parsing binary stream.\n", parsed);
+    }
+
+    if( wkbStream != NULL )
+    {
+        free( wkbStream );
+    }
+
+    return 0;
 }

Modified: branches/geospatial/wkt-wkb/wkbOps.c
===================================================================
--- branches/geospatial/wkt-wkb/wkbOps.c	2008-08-13 14:52:22 UTC (rev 190)
+++ branches/geospatial/wkt-wkb/wkbOps.c	2008-08-13 19:28:10 UTC (rev 191)
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/stat.h>
 #include "wktToWkb.tab.h"
 #include "wktToWkb.Flex.h"
 #include "wkbOps.h"
@@ -44,7 +45,7 @@
     uint32_t tempNum;
     double x, y;
 
-    printf( "Stream size %d.\n", *streamSize );
+    // printf( "Stream size %d.\n", *streamSize );
     // Allocate the binary stream size.
     *stream = malloc( *streamSize );
     if( stream == NULL )
@@ -584,13 +585,19 @@
  * Given a string, attempt to convert the contents from well known text
  * to a well known binary stream.
  ****************************************************************************/
-int wkbParseString( char* input, char **wkbStream, size_t *streamSize )
+int wkbParseTextString( char* input, char **wkbStream, size_t *streamSize )
 {
     extern int yyparse( void*, void*, size_t* );
     yyscan_t scanner;
     wkbGeometryCollectionT *geoCollection;
     YY_BUFFER_STATE buffState;
 
+    if(( input == NULL ) || ( wkbStream == NULL ) || ( streamSize == NULL ))
+    {
+        printf( "Invalid arguments.\n" );
+        return -1;
+    }
+
     // Allocate the start of the geometry collection.
     geoCollection = malloc( sizeof( wkbGeometryCollectionT ));
     if( geoCollection == NULL )
@@ -640,9 +647,9 @@
         return 2;
     }
 
-    printf( "Geocollection size for wkb is %d.\n", *streamSize );
+    // printf( "Geocollection size for wkb is %d.\n", *streamSize );
     // Display the linked list for debugging.
-    wkbTraverseGeoDisplay( geoCollection );
+    // wkbTraverseGeoDisplay( geoCollection );
 
     // Clean up the memory allocated for the linked lists.
     traverseGeoFree( geoCollection );
@@ -654,12 +661,18 @@
  * Given a file pointer, attempt to convert the contents from well known text
  * to a well known binary stream.
  ****************************************************************************/
-int wkbParseFile( FILE* fp, char **wkbStream, size_t *streamSize )
+int wkbParseTextFile( FILE* fp, char **wkbStream, size_t *streamSize )
 {
     extern int yyparse( void*, void*, size_t* );
     yyscan_t scanner;
     wkbGeometryCollectionT *geoCollection;
 
+    if(( fp == NULL ) || ( wkbStream == NULL ) || ( streamSize == NULL ))
+    {
+        printf( "Invalid arguments.\n" );
+        return -1;
+    }
+
     // Allocate the start of the geometry collection.
     geoCollection = malloc( sizeof( wkbGeometryCollectionT ));
     if( geoCollection == NULL )
@@ -707,9 +720,9 @@
         return 2;
     }
 
-    printf( "Geocollection size for wkb is %d.\n", *streamSize );
+    // printf( "Geocollection size for wkb is %d.\n", *streamSize );
     // Display the linked list for debugging.
-    wkbTraverseGeoDisplay( geoCollection );
+    // wkbTraverseGeoDisplay( geoCollection );
 
     // Clean up the memory allocated for the linked lists.
     traverseGeoFree( geoCollection );
@@ -721,11 +734,11 @@
  * Print the point data.  Returns the new location in the wkb stream that the
  * pointer is at. 
  ****************************************************************************/
-char *printWktPoint( char *streamPtr )
+char *printWktPoint(char *streamPtr, FILE *outFile )
 {
-    printf( "%f ", *(double*)streamPtr);
+    fprintf( outFile, "%f ", *(double*)streamPtr);
     streamPtr += sizeof( double );
-    printf( "%f", *(double*)streamPtr);
+    fprintf( outFile, "%f", *(double*)streamPtr);
     streamPtr += sizeof( double );
 
     return streamPtr;
@@ -735,7 +748,7 @@
  * Extract the number of points and process them.  Returns the
  * new location in the wkb stream that the pointer is at.
  ****************************************************************************/
-char *printWktLineString( char *streamPtr )
+char *printWktLineString(char *streamPtr, FILE *outFile )
 {
     uint32_t numPoints;
     uint32_t counter;
@@ -745,18 +758,18 @@
 
     if( numPoints == 0 )
     { 
-        printf( " EMPTY" );
+        fprintf( outFile, " EMPTY" );
         return streamPtr;
     }
 
-    printf( "(" );
+    fprintf( outFile, "(" );
     for( counter = 0; counter < numPoints - 1; ++counter )
     {
-        streamPtr = printWktPoint( streamPtr );
-        printf( "," );
+        streamPtr = printWktPoint( streamPtr, outFile );
+        fprintf( outFile, "," );
     }
-    streamPtr = printWktPoint( streamPtr );
-    printf( ")" );
+    streamPtr = printWktPoint( streamPtr, outFile );
+    fprintf( outFile, ")" );
 
     return streamPtr;
 }
@@ -765,7 +778,7 @@
  * Extract the number of lines and process them.  Returns the
  * new location in the wkb stream that the pointer is at.
  ****************************************************************************/
-char *printWktPolygon( char *streamPtr )
+char *printWktPolygon(char *streamPtr, FILE *outFile )
 {
     uint32_t numLines;
     uint32_t counter;
@@ -775,18 +788,18 @@
 
     if( numLines == 0 )
     {
-        printf( " EMPTY" );
+        fprintf( outFile, " EMPTY" );
         return streamPtr;
     }
 
-    printf( "(" );
+    fprintf( outFile, "(" );
     for( counter = 0; counter < numLines - 1; ++counter )
     {
-        streamPtr = printWktLineString( streamPtr );
-        printf( "," );
+        streamPtr = printWktLineString( streamPtr, outFile );
+        fprintf( outFile, "," );
     }
-    streamPtr = printWktLineString( streamPtr );
-    printf( ")" );
+    streamPtr = printWktLineString( streamPtr, outFile );
+    fprintf( outFile, ")" );
 
     return streamPtr;
 }
@@ -795,7 +808,7 @@
  * Extract the number of polygons and process them.  Returns the
  * new location in the wkb stream that the pointer is at.
  ****************************************************************************/
-char *printWktMultiPolygon( char *streamPtr )
+char *printWktMultiPolygon(char *streamPtr, FILE *outFile )
 {
     uint32_t numPolygons;
     uint32_t counter;
@@ -805,18 +818,18 @@
 
     if( numPolygons == 0 )
     {
-        printf( " EMPTY" );
+        fprintf( outFile, " EMPTY" );
         return streamPtr;
     }
 
-    printf( "(" );
+    fprintf( outFile, "(" );
     for( counter = 0; counter < numPolygons - 1; ++counter )
     {
-        streamPtr = printWktPolygon( streamPtr );
-        printf( "," );
+        streamPtr = printWktPolygon( streamPtr, outFile );
+        fprintf( outFile, "," );
     }
-    streamPtr = printWktPolygon( streamPtr );
-    printf( ")" );
+    streamPtr = printWktPolygon( streamPtr, outFile );
+    fprintf( outFile, ")" );
 
     return streamPtr;
 }
@@ -825,7 +838,7 @@
  * Extract the number of geometries and process the next type.  Returns the
  * new location in the wkb stream that the pointer is at.
  ****************************************************************************/
-char *printWktGeoCollection( char *streamPtr )
+char *printWktGeoCollection(char *streamPtr, FILE *outFile )
 {
     uint32_t numGeometries;
     uint32_t counter;
@@ -835,20 +848,23 @@
 
     if( numGeometries == 0 )
     {
-        printf( " EMPTY" );
+        fprintf( outFile, " EMPTY" );
         return streamPtr;
     }
 
-    printf( "(" );
+    fprintf( outFile, "(" );
     for( counter = 0; counter < numGeometries - 1; ++counter )
     {
-        printf( "\n" );
-        streamPtr = processType( streamPtr );
-        printf( "," );
+        streamPtr = processType( streamPtr, outFile );
+        if( streamPtr == NULL )
+        {
+            printf( "Error parsing binary stream.\n" );
+            return NULL;
+        }
+        fprintf( outFile, "," );
     }
-    printf( "\n" );
-    streamPtr = processType( streamPtr );
-    printf( ")" );
+    streamPtr = processType( streamPtr, outFile );
+    fprintf( outFile, ")" );
 
     return streamPtr;
 }
@@ -857,53 +873,64 @@
  * Process the geometry type from a wkb stream.  Returns the new location in
  * the wkb stream that the pointer is at.
  ****************************************************************************/
-char *processType( char *streamPtr )
+char *processType( char *streamPtr, FILE *outFile )
 {
     uint8_t geoType;
 
+    if(( streamPtr == NULL ) && ( outFile == NULL ))
+    {
+        printf( "Invalid arguments.\n" );
+        return NULL;
+    }
+
     geoType = *(uint8_t*)streamPtr;
     streamPtr += sizeof( uint8_t );
 
     switch( geoType )
     {
         case wkbPoint:
-            printf( "POINT(" );
-            streamPtr = printWktPoint( streamPtr );
-            printf( ")" );
+            fprintf( outFile, "POINT(" );
+            streamPtr = printWktPoint( streamPtr, outFile );
+            fprintf( outFile, ")" );
             break;
 
         case wkbLineString:
-            printf( "LINESTRING" );
-            streamPtr = printWktLineString( streamPtr );
+            fprintf( outFile, "LINESTRING" );
+            streamPtr = printWktLineString( streamPtr, outFile );
             break;
 
         case wkbPolygon:
-            printf( "POLYGON" );
-            streamPtr = printWktPolygon( streamPtr );
+            fprintf( outFile, "POLYGON" );
+            streamPtr = printWktPolygon( streamPtr, outFile );
             break;
 
         case wkbMultiPoint:
-            printf( "MULTIPOINT" );
-            streamPtr = printWktLineString( streamPtr );
+            fprintf( outFile, "MULTIPOINT" );
+            streamPtr = printWktLineString( streamPtr, outFile );
             break;
 
         case wkbMultiLineString:
-            printf( "MULTILINESTRING" );
-            streamPtr = printWktPolygon( streamPtr );
+            fprintf( outFile, "MULTILINESTRING" );
+            streamPtr = printWktPolygon( streamPtr, outFile );
             break;
 
         case wkbMultiPolygon:
-            printf( "MULTIPOLYGON" );
-            streamPtr = printWktMultiPolygon( streamPtr );
+            fprintf( outFile, "MULTIPOLYGON" );
+            streamPtr = printWktMultiPolygon( streamPtr, outFile );
             break;
 
         case wkbGeometryCollection:
-            printf( "GEOMETRYCOLLECTION" );
-            streamPtr = printWktGeoCollection( streamPtr );
+            fprintf( outFile, "GEOMETRYCOLLECTION" );
+            streamPtr = printWktGeoCollection( streamPtr, outFile );
+            if( streamPtr == NULL )
+            {
+                printf( "Error processing geo collection.\n" );
+                return NULL;
+            }
             break;
 
         case wkbEmptyPoint:
-            printf( "POINT EMPTY" );
+            fprintf( outFile, "POINT EMPTY" );
             break;
 
         default:
@@ -916,31 +943,102 @@
 /*****************************************************************************
  * Parse a well known binary stream by moving a pointer through the stream.
  ****************************************************************************/
-int wkbParseBinary( char *wkbStream, FILE *output )
+int wkbParseBinary( char *wkbStream, FILE *output, char **outString )
 {
-    //TODO: Output to a file.
-    //TODO: Output to a string.
-
     char *streamPtr;
     uint8_t byteOrder;
+    FILE *outFile, *fp;
+    int toString = 0;
+    char *tempFile = {"/tmp/wktTempFile"};
+    struct stat fileBuff;
 
+    if( wkbStream == NULL || (( output == NULL ) && ( outString == NULL )))
+    {
+        printf( "Invalid arguments.\n" );
+        return -1;
+    }
+
+    if( output == NULL )
+    {
+        outFile = fopen( tempFile, "w+" );
+        if( outFile == NULL )
+        {
+            printf( "Error opening temp file %s\n", tempFile );
+            return 10;
+        }
+        toString = 1;
+    }
+    else
+    {
+        outFile = output;
+        if( fprintf( outFile, "\n" ) < 0 )
+        {
+            printf( "Error writing to file.\n" );
+            return 11;
+        }
+    }
+
     streamPtr = wkbStream;
 
     //TODO: How to convert endian-ness.
     byteOrder = *(uint8_t*)streamPtr;
 
-    printf( "Byte order is %d\n", byteOrder );
+    // printf( "Byte order is %d\n", byteOrder );
     streamPtr += sizeof( uint8_t );
 
-    if( processType( streamPtr ) == NULL )
+    if( processType( streamPtr, outFile ) == NULL )
     {
         return 1;
     }
-    printf( "\n" );
+
+    fprintf( outFile, "\n" );
+    if( toString == 1 )
+    {
+        fclose( outFile );
+
+        if( stat( tempFile, &fileBuff ) != -1 )
+        {
+            *outString = malloc( fileBuff.st_size );
+            if( *outString != NULL )
+            {
+                fp = fopen( tempFile, "r" );
+                fgets( *outString, fileBuff.st_size, fp );
+                fclose( fp );
+            }
+            else
+            {
+                printf( "Error allocating memory for text.\n" );
+                return 2;
+            }
+        }
+        else
+        {
+            printf( "Error finding size of file %s.\n", tempFile );
+            *outString = NULL;
+            return 3;
+        }
+    }
+
     return 0;
 }
 
 /*****************************************************************************
+ * Parse a well known binary stream into a file.
+ ****************************************************************************/
+int wkbParseBinaryToFile( char *wkbStream, FILE *output )
+{
+    return( wkbParseBinary( wkbStream, output, NULL ));
+}
+
+/*****************************************************************************
+ * Parse a well known binary stream into a string.
+ ****************************************************************************/
+int wkbParseBinaryToString( char *wkbStream, char **outString )
+{
+    return( wkbParseBinary( wkbStream, NULL, outString ));
+}
+
+/*****************************************************************************
  * Insert a new geometry into the geometry collection.  Add to the stream
  * size as required.
  ****************************************************************************/

Modified: branches/geospatial/wkt-wkb/wkbOps.h
===================================================================
--- branches/geospatial/wkt-wkb/wkbOps.h	2008-08-13 14:52:22 UTC (rev 190)
+++ branches/geospatial/wkt-wkb/wkbOps.h	2008-08-13 19:28:10 UTC (rev 191)
@@ -1,6 +1,6 @@
 #ifndef WKBOPS_H
 #define WKBOPS_H
-
+//TODO test insert functions for bad inputs
 #include "wkbTypes.h"
 
 /*****************************************************************************
@@ -10,7 +10,7 @@
  * Process the geometry type from a wkb stream.  Returns the new location in
  * the wkb stream that the pointer is at.
  ***************************************************************************/
-char *processType( char *streamPtr );
+char *processType( char *streamPtr, FILE *outFile );
 
 /*****************************************************************************
  Public Functions
@@ -19,20 +19,25 @@
  * Given a string, attempt to convert the contents from well known text
  * to a well known binary stream.
  * ***************************************************************************/
-int wkbParseString( char* input, char **wkbStream, size_t *streamSize );
+int wkbParseTextString( char* input, char **wkbStream, size_t *streamSize );
 
 /*****************************************************************************
  * Given a file pointer, attempt to convert the contents from well known text
  * to a well known binary stream.
  ****************************************************************************/
-int wkbParseFile( FILE* fp, char **wkbStream, size_t *streamSize );
+int wkbParseTextFile( FILE* fp, char **wkbStream, size_t *streamSize );
 
 /*****************************************************************************
- * Parse a well known binary stream by moving a pointer through the stream.
+ * Parse a well known binary stream into a file.
  ****************************************************************************/
-int wkbParseBinary( char *wkbStream, FILE *output );
+int wkbParseBinaryToFile( char *wkbStream, FILE *output );
 
 /*****************************************************************************
+ * Parse a well known binary stream into a string.
+ ****************************************************************************/
+int wkbParseBinaryToString( char *wkbStream, char **outString );
+
+/*****************************************************************************
  * Insert a new geometry into the geometry collection.  Add to the stream
  * size as required.
  ****************************************************************************/

Modified: branches/geospatial/wkt-wkb/wktToWkb.y
===================================================================
--- branches/geospatial/wkt-wkb/wktToWkb.y	2008-08-13 14:52:22 UTC (rev 190)
+++ branches/geospatial/wkt-wkb/wktToWkb.y	2008-08-13 19:28:10 UTC (rev 191)
@@ -1,5 +1,4 @@
 /* TODO: Add OGC 1.2 types. */
-/* TODO: Error checking on insert calls. */
 %pure_parser
 
 %parse-param { void *scanner }
@@ -54,37 +53,55 @@
 
 pointTaggedText :
     {
-        wkbInsertGeo( geoColl, wkbPoint, streamSize );
+        if( wkbInsertGeo( geoColl, wkbPoint, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     POINT pointText
 
 lineStringTaggedText :
     { 
-        wkbInsertGeo( geoColl, wkbLineString, streamSize );
+        if( wkbInsertGeo( geoColl, wkbLineString, streamSize ) !=0 )
+        {
+            return 1;
+        }
     } 
     LINESTRING lineStringText 
 
 polygonTaggedText :
     { 
-        wkbInsertGeo( geoColl, wkbPolygon, streamSize );
+        if( wkbInsertGeo( geoColl, wkbPolygon, streamSize ) != 0 )
+        {
+            return 1;
+        }
     } 
     POLYGON polygonText 
 
 multiPointTaggedText :
     { 
-        wkbInsertGeo( geoColl, wkbMultiPoint, streamSize );
+        if( wkbInsertGeo( geoColl, wkbMultiPoint, streamSize ) != 0 )
+        {
+            return 1;
+        }
     } 
     MULTIPOINT multiPointText 
 
 multiLineStringTaggedText :
     { 
-        wkbInsertGeo( geoColl, wkbMultiLineString, streamSize );
+        if( wkbInsertGeo( geoColl, wkbMultiLineString, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     MULTILINESTRING multiLineStringText 
 
 multiPolygonTaggedText :
     { 
-        wkbInsertGeo( geoColl, wkbMultiPolygon, streamSize );
+        if( wkbInsertGeo( geoColl, wkbMultiPolygon, streamSize ) != 0 )
+        {
+            return 1;
+        }
     } 
     MULTIPOLYGON multiPolygonText 
 
@@ -94,7 +111,10 @@
 pointText :
     empty
     {
-        wkbInsertPoint( geoColl, NULL, streamSize );
+        if( wkbInsertPoint( geoColl, NULL, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     |
     LPAR point RPAR
@@ -108,17 +128,26 @@
         wkbPointT point;
         point.x = $1;
         point.y = $2;
-        wkbInsertPoint( geoColl, &point, streamSize );
+        if( wkbInsertPoint( geoColl, &point, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
 
 lineStringText :
     empty
     {
-        wkbInsertLine( geoColl, streamSize );
+        if( wkbInsertLine( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     |
     {
-        wkbInsertLine( geoColl, streamSize );
+        if( wkbInsertLine( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     LPAR lineString RPAR
 
@@ -130,11 +159,17 @@
 polygonText :
     empty
     {
-        wkbInsertPolygon( geoColl, streamSize );
+        if( wkbInsertPolygon( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     |
     {
-        wkbInsertPolygon( geoColl, streamSize );
+        if( wkbInsertPolygon( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     LPAR polygon RPAR
 
@@ -146,11 +181,17 @@
 multiPointText :
     empty
     {
-        wkbInsertLine( geoColl, streamSize );
+        if( wkbInsertLine( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     |
     {
-        wkbInsertLine( geoColl, streamSize );
+        if( wkbInsertLine( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     LPAR multiPoint RPAR
 
@@ -162,11 +203,17 @@
 multiLineStringText :
     empty
     {
-        wkbInsertPolygon( geoColl, streamSize );
+        if( wkbInsertPolygon( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     |
     {
-        wkbInsertPolygon( geoColl, streamSize );
+        if( wkbInsertPolygon( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     LPAR multiLineString RPAR
 
@@ -178,11 +225,17 @@
 multiPolygonText :
     empty
     {
-        wkbInsertMultiPolygon( geoColl, streamSize );
+        if( wkbInsertMultiPolygon( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     |
     {
-        wkbInsertMultiPolygon( geoColl, streamSize );
+        if( wkbInsertMultiPolygon( geoColl, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     LPAR multiPolygon RPAR
 
@@ -193,19 +246,31 @@
 
 geometryCollectionText :
     {
-        wkbInsertGeo( geoColl, wkbGeometryCollection, streamSize );
+        if( wkbInsertGeo( geoColl, wkbGeometryCollection, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     empty
     {
-        wkbInsertGeo( geoColl, wkbGeometryCollectionEnd, streamSize );
+        if( wkbInsertGeo( geoColl, wkbGeometryCollectionEnd, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     |
     {
-        wkbInsertGeo( geoColl, wkbGeometryCollection, streamSize );
+        if( wkbInsertGeo( geoColl, wkbGeometryCollection, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
     LPAR geometry RPAR
     {
-        wkbInsertGeo( geoColl, wkbGeometryCollectionEnd, streamSize );
+        if( wkbInsertGeo( geoColl, wkbGeometryCollectionEnd, streamSize ) != 0 )
+        {
+            return 1;
+        }
     }
 
 geometry :




More information about the svn-commits mailing list