]> granicus.if.org Git - postgis/commitdiff
remove extra brackets from multipoints
authorRalph Mason <ralph.mason@telogis.com>
Thu, 29 Apr 2004 03:13:07 +0000 (03:13 +0000)
committerRalph Mason <ralph.mason@telogis.com>
Thu, 29 Apr 2004 03:13:07 +0000 (03:13 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@534 b70326c6-7e19-0410-871a-916f4a2858ee

lwgeom/wktunparse.c

index b8c34be0fd50420d9f4e4f9dfa209666682edfdc..f6df8be077ae58a9f60c4c35adb835b277f422ef 100644 (file)
@@ -119,14 +119,12 @@ double read_double(byte** geom){
        else{
                //double ret = *((double*)*geom);
                double ret;
-
-               memcpy(&ret, *geom, 8);
-
+               memcpy(&ret, *geom, 8);
                (*geom)+=8;
                return ret;
        }
 }
-
+           
 typedef byte* (*outfunc)(byte*,int);
 
 byte* output_point(byte* geom,int supress){
@@ -169,6 +167,24 @@ byte* output_collection_2(byte* geom,int suppress){
        return output_collection(geom,output_point,suppress);
 }
 
+byte* output_wkt(byte* geom, int supress);
+
+/* special case for multipoint to supress extra brackets */
+byte* output_multipoint(byte* geom,int suppress){
+       unsigned type = *geom & 0x0f;
+       
+       if ( type  == POINTTYPE )
+               return output_point(++geom,suppress);
+       else if ( type == POINTTYPEI ){
+               lwgi++;
+               geom=output_point(++geom,0);
+               lwgi--;
+               return geom;
+       }
+       
+       return output_wkt(geom,suppress);
+}
+
 byte* output_wkt(byte* geom, int supress){
 
        unsigned type=*geom++;
@@ -198,7 +214,7 @@ byte* output_wkt(byte* geom, int supress){
                        break;
                case MULTIPOINTTYPE:
                        if ( ! supress) write_str("MULTIPOINT");
-                       geom = output_collection(geom,output_wkt,1);
+                       geom = output_collection(geom,output_multipoint,1);
                        break;
                case MULTILINETYPE:
                        if ( ! supress) write_str("MULTILINESTRING");