]> granicus.if.org Git - postgis/commitdiff
Add in tests and fixes for WKB emitter.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 3 Mar 2010 01:15:16 +0000 (01:15 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 3 Mar 2010 01:15:16 +0000 (01:15 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@5366 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/Makefile.in
liblwgeom/cunit/cu_tester.c
liblwgeom/cunit/cu_wkb.c [new file with mode: 0644]
liblwgeom/libgeom.h
liblwgeom/lwout_wkb.c
liblwgeom/lwout_wkt.c

index e58ca4ba040f390024b41e6f8ee80c91d63e4a94..b1b34104b7aa261d7b8e56cc289674d675f25802 100644 (file)
@@ -21,6 +21,7 @@ OBJS= \
        cu_algorithm.o \
        cu_print.o \
        cu_wkt.o \
+       cu_wkb.o \
        cu_geodetic.o \
        cu_measures.o \
        cu_libgeom.o \
index d26751a605ac331ab3c629eba101db07a2df62b9..4aa7392162d50ce3fd46299b543aeb12a43b3cd0 100644 (file)
@@ -22,6 +22,7 @@ extern CU_SuiteInfo print_suite;
 extern CU_SuiteInfo algorithms_suite;
 extern CU_SuiteInfo measures_suite;
 extern CU_SuiteInfo wkt_suite;
+extern CU_SuiteInfo wkb_suite;
 extern CU_SuiteInfo libgeom_suite;
 extern CU_SuiteInfo geodetic_suite;
 extern CU_SuiteInfo homogenize_suite;
@@ -43,6 +44,7 @@ int main(int argc, char *argv[])
                algorithms_suite,
                measures_suite,
                wkt_suite,
+               wkb_suite,
                libgeom_suite,
                geodetic_suite,
                homogenize_suite,
diff --git a/liblwgeom/cunit/cu_wkb.c b/liblwgeom/cunit/cu_wkb.c
new file mode 100644 (file)
index 0000000..98717d0
--- /dev/null
@@ -0,0 +1,103 @@
+/**********************************************************************
+ * $Id$
+ *
+ * PostGIS - Spatial Types for PostgreSQL
+ * http://postgis.refractions.net
+ * Copyright 2010 Olivier Courtin <olivier.courtin@oslandia.com>
+ *
+ * This is free software; you can redistribute and/or modify it under
+ * the terms of the GNU General Public Licence. See the COPYING file.
+ *
+ **********************************************************************/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "CUnit/Basic.h"
+
+#include "libgeom.h"
+#include "cu_tester.h"
+
+/*
+** Global variable to hold WKB strings
+*/
+char *s;
+
+/*
+** The suite initialization function.
+** Create any re-used objects.
+*/
+static int init_wkb_suite(void)
+{
+       s = NULL;
+       return 0;
+}
+
+/*
+** The suite cleanup function.
+** Frees any global objects.
+*/
+static int clean_wkb_suite(void)
+{
+       free(s);
+       s = NULL;
+       return 0;
+}
+
+static char* cu_wkb(char *wkt, uchar variant)
+{
+       LWGEOM *g = lwgeom_from_ewkt(wkt, PARSER_CHECK_NONE);
+       if ( s ) free(s);
+       s = lwgeom_to_wkb(g, variant | WKB_HEX, NULL);  
+       lwgeom_free(g);
+       return s;
+}
+
+static void test_wkb_point(void)
+{
+       //printf("%s\n", cu_wkb("POINT(0 0 0 0)", WKB_ISO ));
+}
+
+static void test_wkb_linestring(void){}
+
+static void test_wkb_polygon(void){}
+
+static void test_wkb_multipoint(void){}
+
+static void test_wkb_multilinestring(void){}
+
+static void test_wkb_multipolygon(void){}
+
+static void test_wkb_collection(void){}
+
+static void test_wkb_circularstring(void){}
+
+static void test_wkb_compoundcurve(void){}
+
+static void test_wkb_curvpolygon(void){}
+
+static void test_wkb_multicurve(void){}
+
+static void test_wkb_multisurface(void){}
+
+
+/*
+** Used by test harness to register the tests in this file.
+*/
+
+CU_TestInfo wkb_tests[] = {
+       PG_TEST(test_wkb_point),
+       PG_TEST(test_wkb_linestring),
+       PG_TEST(test_wkb_polygon),
+       PG_TEST(test_wkb_multipoint),
+       PG_TEST(test_wkb_multilinestring),
+       PG_TEST(test_wkb_multipolygon),
+       PG_TEST(test_wkb_collection),
+       PG_TEST(test_wkb_circularstring),
+       PG_TEST(test_wkb_compoundcurve),
+       PG_TEST(test_wkb_curvpolygon),
+       PG_TEST(test_wkb_multicurve),
+       PG_TEST(test_wkb_multisurface),
+       CU_TEST_INFO_NULL
+};
+CU_SuiteInfo wkb_suite = {"WKB Suite",  init_wkb_suite,  clean_wkb_suite, wkb_tests};
index ccd4582751d76745c8d4a420db6d3038868b1002..fd2b07497f6848d2249ff63fdfccbd70867c662d 100644 (file)
@@ -41,8 +41,8 @@
 #define WKT_ISO 0x01
 #define WKT_SFSQL 0x02
 #define WKT_EXTENDED 0x04
-#define WKT_NOTYPE 0x08
-#define WKT_NOPARENS 0x10
+#define WKT_NO_TYPE 0x08 /* Internal use only */
+#define WKT_NO_PARENS 0x10 /* Internal use only */
 
 /**
 * Well-Known Binary (WKB) Output Variant Types
@@ -51,6 +51,8 @@
 #define WKB_SFSQL 0x02
 #define WKB_EXTENDED 0x04
 #define WKB_NDR 0x08
+#define WKB_HEX 0x10
+#define WKB_NO_NPOINTS 0x20 /* Internal use only */
 
 /**
 * Maximum allowed SRID value. 
index 8bd22cce483f43e7670f7fd4648657ea2754fd7d..d89d665011d490b11e09bd534d8a4d173ebabdf4 100644 (file)
@@ -18,6 +18,12 @@ static size_t lwgeom_to_wkb_size(const LWGEOM *geom, uchar variant);
 #define WKB_INT_SIZE 4
 #define WKB_BYTE_SIZE 1
 
+/**
+* Look-up table for hex writer
+*/
+static char *hexchr = "0123456789ABCDEF";
+
+
 /**
 * Optional SRID
 */
@@ -35,7 +41,7 @@ static unsigned int lwgeom_wkb_type(const LWGEOM *geom, uchar variant)
 {
        unsigned int wkb_type = 0;
 
-       uchar type = geom->type;;
+       uchar type = geom->type;
        
        switch( TYPE_GETTYPE(type) )
        {
@@ -106,36 +112,78 @@ static unsigned int lwgeom_wkb_type(const LWGEOM *geom, uchar variant)
 */
 static char* endian_to_wkb_buf(char *buf, uchar variant)
 {
-       buf[0] = ((variant & WKB_NDR) ? 1 : 0);
-       return buf + 1;
+       if( variant & WKB_HEX )
+       {
+               buf[0] = '0';
+               buf[1] = ((variant & WKB_NDR) ? '1' : '0');
+               return buf + 2;
+       }
+       else 
+       {
+               buf[0] = ((variant & WKB_NDR) ? 1 : 0);
+               return buf + 1;
+       }
 }
 
+/**
+* SwapBytes?
+*/
+static int wkb_swap_bytes(uchar variant)
+{
+       /* If requested variant matches machine arch, we don't have to swap! */
+       if( ((variant & WKB_NDR) && (BYTE_ORDER == LITTLE_ENDIAN)) ||
+           ((! (variant & WKB_NDR)) && (BYTE_ORDER == BIG_ENDIAN)) )
+       {
+               return LW_FALSE;
+       }
+       return LW_TRUE;
+}
 
 /**
 * Integer32
 */
-static char* int32_to_wkb_buf(const int i, char *buf, uchar variant)
+static char* int32_to_wkb_buf(const int ival, char *buf, uchar variant)
 {
+       char *iptr = (char*)(&ival);
+       int i = 0;
+       
        if( sizeof(int) != WKB_INT_SIZE )
        {
                lwerror("Machine int size is not %d bytes!", WKB_INT_SIZE);
        }
-       /* If machine arch and requested arch match, don't flip byte order */
-       if( ((variant & WKB_NDR) && (BYTE_ORDER == LITTLE_ENDIAN)) ||
-           ((! (variant & WKB_NDR)) && (BYTE_ORDER == BIG_ENDIAN)) )
+       LWDEBUGF(4, "Writing value '%d'", ival);
+       if( variant & WKB_HEX )
        {
-               memcpy(buf, &i, WKB_INT_SIZE);
+               int swap =  wkb_swap_bytes(variant);
+               /* Machine/request arch mismatch, so flip byte order */
+               for( i = 0; i < WKB_INT_SIZE; i++ )
+               {
+                       int j = (swap ? WKB_INT_SIZE - 1 - i : i);
+                       uchar b = iptr[j];
+                       /* Top four bits to 0-F */
+                       buf[2*i] = hexchr[b >> 4];
+                       /* Bottom four bits to 0-F */
+                       buf[2*i+1] = hexchr[b & 0x0F];                  
+               }
+               return buf + (2 * WKB_INT_SIZE);
        }
-       /* Machine/request arch mismatch, so flip byte order */
        else
        {
-               int j = 0;
-               for ( j = 0; j < WKB_INT_SIZE; j++ )
+               /* Machine/request arch mismatch, so flip byte order */
+               if( wkb_swap_bytes(variant) )
+               {
+                       for ( i = 0; i < WKB_INT_SIZE; i++ )
+                       {
+                               buf[i] = iptr[WKB_INT_SIZE - 1 - i];
+                       }
+               }
+               /* If machine arch and requested arch match, don't flip byte order */
+               else
                {
-                       buf[j] = (&i)[WKB_INT_SIZE - j];
+                       memcpy(buf, iptr, WKB_INT_SIZE);
                }
+               return buf + WKB_INT_SIZE;
        }
-       return buf + WKB_INT_SIZE;
 }
 
 /**
@@ -143,26 +191,46 @@ static char* int32_to_wkb_buf(const int i, char *buf, uchar variant)
 */
 static char* double_to_wkb_buf(const double d, char *buf, uchar variant)
 {
+       char *dptr = (char*)(&d);
+       int i = 0;
+       
        if( sizeof(double) != WKB_DOUBLE_SIZE )
        {
                lwerror("Machine double size is not %d bytes!", WKB_DOUBLE_SIZE);
        }
-       /* If machine arch and requested arch match, don't flip byte order */
-       if( ((variant & WKB_NDR) && (BYTE_ORDER == LITTLE_ENDIAN)) ||
-           ((! (variant & WKB_NDR)) && (BYTE_ORDER == BIG_ENDIAN)) )
+       
+       if( variant & WKB_HEX )
        {
-               memcpy(buf, &d, WKB_DOUBLE_SIZE);
+               int swap =  wkb_swap_bytes(variant);
+               /* Machine/request arch mismatch, so flip byte order */
+               for( i = 0; i < WKB_DOUBLE_SIZE; i++ )
+               {
+                       int j = (swap ? WKB_DOUBLE_SIZE - 1 - i : i);
+                       uchar b = dptr[j];
+                       /* Top four bits to 0-F */
+                       buf[2*i] = hexchr[b >> 4];
+                       /* Bottom four bits to 0-F */
+                       buf[2*i+1] = hexchr[b & 0x0F];                  
+               }
+               return buf + (2 * WKB_DOUBLE_SIZE);
        }
-       /* Machine/request arch mismatch, so flip byte order */
        else
        {
-               int j = 0;
-               for ( j = 0; j < WKB_DOUBLE_SIZE; j++ )
+               /* Machine/request arch mismatch, so flip byte order */
+               if( wkb_swap_bytes(variant) )
+               {
+                       for ( i = 0; i < WKB_DOUBLE_SIZE; i++ )
+                       {
+                               buf[i] = dptr[WKB_DOUBLE_SIZE - 1 - i];
+                       }
+               }
+               /* If machine arch and requested arch match, don't flip byte order */
+               else
                {
-                       buf[j] = (&d)[WKB_DOUBLE_SIZE - j];
+                       memcpy(buf, dptr, WKB_DOUBLE_SIZE);
                }
+               return buf + WKB_DOUBLE_SIZE;
        }
-       return buf + WKB_DOUBLE_SIZE;
 }
 
 
@@ -207,13 +275,20 @@ static char* empty_to_wkb_buf(const LWGEOM *geom, char *buf, uchar variant)
 static size_t ptarray_to_wkb_size(const POINTARRAY *pa, uchar variant)
 {
        int dims = 2;
+       size_t size = 0;
        if( pa->npoints < 1 )
                return 0;
        if( variant & (WKB_ISO | WKB_EXTENDED) )
                dims = TYPE_NDIMS(pa->dims);
 
+       /* Include the npoints if it's not a POINT type) */
+       if( ! ( variant & WKB_NO_NPOINTS ) )
+               size += WKB_INT_SIZE;
+
        /* size of the double list */
-       return pa->npoints * dims * WKB_DOUBLE_SIZE;
+       size += pa->npoints * dims * WKB_DOUBLE_SIZE;
+
+       return size;
 }
 
 static char* ptarray_to_wkb_buf(const POINTARRAY *pa, char *buf, uchar variant)
@@ -227,8 +302,9 @@ static char* ptarray_to_wkb_buf(const POINTARRAY *pa, char *buf, uchar variant)
        if( (variant & WKB_ISO) || (variant & WKB_EXTENDED) )
                dims = TYPE_NDIMS(pa->dims);
 
-       /* Set the number of points */
-       buf = int32_to_wkb_buf(pa->npoints, buf, variant);
+       /* Set the number of points (if it's not a POINT type) */
+       if( ! ( variant & WKB_NO_NPOINTS ) )
+               buf = int32_to_wkb_buf(pa->npoints, buf, variant);
        
        /* Set the ordinates. */
        /* TODO: Ensure that getPoint_internal is always aligned so 
@@ -237,12 +313,15 @@ static char* ptarray_to_wkb_buf(const POINTARRAY *pa, char *buf, uchar variant)
                 the output endian/dims match the internal endian/dims */
        for( i = 0; i < pa->npoints; i++ )
        {
+               LWDEBUGF(4, "Writing point #%d", i);
                dbl_ptr = (double*)getPoint_internal(pa, i);
                for( j = 0; j < dims; j++ )
                {
+                       LWDEBUGF(4, "Writing dimension #%d (buf = %p)", j, buf);
                        buf = double_to_wkb_buf(dbl_ptr[j], buf, variant);
                }
        }
+       LWDEBUGF(4, "Done (buf = %p)", buf);    
        return buf;
 }
 
@@ -259,21 +338,28 @@ static size_t lwpoint_to_wkb_size(const LWPOINT *pt, uchar variant)
                size += WKB_INT_SIZE;
 
        /* Points */
-       size += ptarray_to_wkb_size(pt->point, variant);
+       size += ptarray_to_wkb_size(pt->point, variant | WKB_NO_NPOINTS);
        return size;
 }
 
 static char* lwpoint_to_wkb_buf(const LWPOINT *pt, char *buf, uchar variant)
 {
        /* Set the endian flag */
+       LWDEBUGF(4, "Entering function, buf = %p", buf);
        buf = endian_to_wkb_buf(buf, variant);
+       LWDEBUGF(4, "Endian set, buf = %p", buf);
        /* Set the geometry type */
        buf = int32_to_wkb_buf(lwgeom_wkb_type((LWGEOM*)pt, variant), buf, variant);
+       LWDEBUGF(4, "Type set, buf = %p", buf);
        /* Set the optional SRID for extended variant */
        if ( lwgeom_wkb_needs_srid((LWGEOM*)pt, variant) )
+       {
                buf = int32_to_wkb_buf(pt->SRID, buf, variant);
+               LWDEBUGF(4, "SRID set, buf = %p", buf);
+       }
        /* Set the coordinates */
-       buf = ptarray_to_wkb_buf(pt->point, buf, variant);
+       buf = ptarray_to_wkb_buf(pt->point, buf, variant | WKB_NO_NPOINTS);
+       LWDEBUGF(4, "Pointarray set, buf = %p", buf);
        return buf;
 }
 
@@ -289,8 +375,8 @@ static size_t lwline_to_wkb_size(const LWLINE *line, uchar variant)
        if ( lwgeom_wkb_needs_srid((LWGEOM*)line, variant) )
                size += WKB_INT_SIZE;
                        
-       /* Number of points + points */
-       size +=  WKB_INT_SIZE + ptarray_to_wkb_size(line->points, variant);
+       /* Size of point array */
+       size += ptarray_to_wkb_size(line->points, variant);
        return size;
 }
 
@@ -323,8 +409,8 @@ static size_t lwpoly_to_wkb_size(const LWPOLY *poly, uchar variant)
                        
        for( i = 0; i < poly->nrings; i++ )
        {
-               /* number of points + points */
-               size += WKB_INT_SIZE + ptarray_to_wkb_size(poly->rings[i], variant);
+               /* Size of ring point array */
+               size += ptarray_to_wkb_size(poly->rings[i], variant);
        }
        
        return size;
@@ -446,8 +532,8 @@ static size_t lwgeom_to_wkb_size(const LWGEOM *geom, uchar variant)
                default:
                        lwerror("Unsupported geometry type: %s [%d]", lwgeom_typename(geom->type), TYPE_GETTYPE(geom->type));
        }
-       /* Return value to keep compiler happy. */
-       return 0;
+
+       return size;
 }
 
 static char* lwgeom_to_wkb_buf(const LWGEOM *geom, char *buf, uchar variant)
@@ -510,6 +596,7 @@ char* lwgeom_to_wkb(const LWGEOM *geom, uchar variant, size_t *size_out)
        
        if( geom == NULL ) 
        {
+               LWDEBUG(4,"Cannot convert NULL into WKB.");
                lwerror("Cannot convert NULL into WKB.");
                return NULL;
        }
@@ -520,14 +607,24 @@ char* lwgeom_to_wkb(const LWGEOM *geom, uchar variant, size_t *size_out)
 
        if( buf_size == 0 )
        {
+               LWDEBUG(4,"Error calculating output WKB buffer size.");
                lwerror("Error calculating output WKB buffer size.");
                return NULL;
        }
-       
+
+       /* Hex string takes twice as much space as binary + a null character */
+       if( variant & WKB_HEX )
+       {
+               buf_size = 2 * buf_size + 1;
+               LWDEBUGF(4, "Hex WKB output size: %d", buf_size);
+       }
+
+       /* Allocate the buffer */
        buf = lwalloc(buf_size);
        
        if( buf == NULL )
        {
+               LWDEBUGF(4,"Unable to allocate %d bytes for WKB output buffer.", buf_size);
                lwerror("Unable to allocate %d bytes for WKB output buffer.", buf_size);
                return NULL;
        }
@@ -538,9 +635,16 @@ char* lwgeom_to_wkb(const LWGEOM *geom, uchar variant, size_t *size_out)
        /* Write the WKB into the output buffer */
        buf = lwgeom_to_wkb_buf(geom, buf, variant);
        
-       /* The buffer pointer should land at the end of the allocated buffer space. Let's check. */
+       /* Null the last byte if this is a hex output */
+       *buf = '\0';
+       buf++;
+       
+       LWDEBUGF(4,"buf (%p) - wkb_out (%p) = %d", buf, wkb_out, buf - wkb_out);
+
+       /* The buffer pointer should now land at the end of the allocated buffer space. Let's check. */
        if( buf_size != (buf - wkb_out) )
        {
+               LWDEBUG(4,"Output WKB is not the same size as the allocated buffer.");
                lwerror("Output WKB is not the same size as the allocated buffer.");
                lwfree(wkb_out);
                return NULL;
index b4cf31477607825389def3b8f45f02c31e9e89a1..68c57d6a86be392e795629f9d7c86ec2bbf09b66 100644 (file)
@@ -58,7 +58,7 @@ static void ptarray_to_wkt_sb(const POINTARRAY *ptarray, stringbuffer_t *sb, int
                dimensions = TYPE_NDIMS(ptarray->dims);
 
        /* Opening paren? */
-       if( ! (variant & WKT_NOPARENS) )
+       if( ! (variant & WKT_NO_PARENS) )
                stringbuffer_append(sb, "(");
        
        /* Digits and commas */
@@ -82,7 +82,7 @@ static void ptarray_to_wkt_sb(const POINTARRAY *ptarray, stringbuffer_t *sb, int
        }
        
        /* Closing paren? */
-       if( ! (variant & WKT_NOPARENS) )
+       if( ! (variant & WKT_NO_PARENS) )
                stringbuffer_append(sb, ")");
 }
 
@@ -98,7 +98,7 @@ static void ptarray_to_wkt_sb(const POINTARRAY *ptarray, stringbuffer_t *sb, int
 */
 static void lwpoint_to_wkt_sb(const LWPOINT *pt, stringbuffer_t *sb, int precision, uchar variant)
 {
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "POINT"); /* "POINT" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)pt, sb, variant);
@@ -118,7 +118,7 @@ static void lwpoint_to_wkt_sb(const LWPOINT *pt, stringbuffer_t *sb, int precisi
 */
 static void lwline_to_wkt_sb(const LWLINE *line, stringbuffer_t *sb, int precision, uchar variant) 
 {
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "LINESTRING"); /* "LINESTRING" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)line, sb, variant);
@@ -138,7 +138,7 @@ static void lwline_to_wkt_sb(const LWLINE *line, stringbuffer_t *sb, int precisi
 static void lwpoly_to_wkt_sb(const LWPOLY *poly, stringbuffer_t *sb, int precision, uchar variant) 
 {
        int i = 0;
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "POLYGON"); /* "POLYGON" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)poly, sb, variant);
@@ -164,7 +164,7 @@ static void lwpoly_to_wkt_sb(const LWPOLY *poly, stringbuffer_t *sb, int precisi
 */
 static void lwcircstring_to_wkt_sb(const LWCIRCSTRING *circ, stringbuffer_t *sb, int precision, uchar variant) 
 {
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "CIRCULARSTRING"); /* "CIRCULARSTRING" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)circ, sb, variant);
@@ -185,7 +185,7 @@ static void lwcircstring_to_wkt_sb(const LWCIRCSTRING *circ, stringbuffer_t *sb,
 static void lwmpoint_to_wkt_sb(const LWMPOINT *mpoint, stringbuffer_t *sb, int precision, uchar variant) 
 {      
        int i = 0;
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "MULTIPOINT"); /* "MULTIPOINT" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)mpoint, sb, variant);
@@ -201,7 +201,7 @@ static void lwmpoint_to_wkt_sb(const LWMPOINT *mpoint, stringbuffer_t *sb, int p
                if( i > 0 )
                        stringbuffer_append(sb, ",");
                /* We don't want type strings or parens on our subgeoms */
-               lwpoint_to_wkt_sb(mpoint->geoms[i], sb, precision, variant | WKT_NOPARENS | WKT_NOTYPE );
+               lwpoint_to_wkt_sb(mpoint->geoms[i], sb, precision, variant | WKT_NO_PARENS | WKT_NO_TYPE );
        }
        stringbuffer_append(sb, ")");
 }
@@ -213,7 +213,7 @@ static void lwmline_to_wkt_sb(const LWMLINE *mline, stringbuffer_t *sb, int prec
 {
        int i = 0;
        
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "MULTILINESTRING"); /* "MULTILINESTRING" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)mline, sb, variant);
@@ -230,7 +230,7 @@ static void lwmline_to_wkt_sb(const LWMLINE *mline, stringbuffer_t *sb, int prec
                if( i > 0 )
                        stringbuffer_append(sb, ",");
                /* We don't want type strings on our subgeoms */
-               lwline_to_wkt_sb(mline->geoms[i], sb, precision, variant | WKT_NOTYPE );
+               lwline_to_wkt_sb(mline->geoms[i], sb, precision, variant | WKT_NO_TYPE );
        }
        stringbuffer_append(sb, ")");
 }
@@ -242,7 +242,7 @@ static void lwmpoly_to_wkt_sb(const LWMPOLY *mpoly, stringbuffer_t *sb, int prec
 {
        int i = 0;
        
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "MULTIPOLYGON"); /* "MULTIPOLYGON" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)mpoly, sb, variant);
@@ -259,7 +259,7 @@ static void lwmpoly_to_wkt_sb(const LWMPOLY *mpoly, stringbuffer_t *sb, int prec
                if( i > 0 )
                        stringbuffer_append(sb, ",");
                /* We don't want type strings on our subgeoms */
-               lwpoly_to_wkt_sb(mpoly->geoms[i], sb, precision, variant | WKT_NOTYPE );
+               lwpoly_to_wkt_sb(mpoly->geoms[i], sb, precision, variant | WKT_NO_TYPE );
        }
        stringbuffer_append(sb, ")");
 }
@@ -273,7 +273,7 @@ static void lwcompound_to_wkt_sb(const LWCOMPOUND *comp, stringbuffer_t *sb, int
 {
        int i = 0;
        
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "COMPOUNDCURVE"); /* "COMPOUNDCURVE" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)comp, sb, variant);
@@ -293,7 +293,7 @@ static void lwcompound_to_wkt_sb(const LWCOMPOUND *comp, stringbuffer_t *sb, int
                /* Linestring subgeoms don't get type identifiers */
                if( type == LINETYPE )
                {
-                       lwline_to_wkt_sb((LWLINE*)comp->geoms[i], sb, precision, variant | WKT_NOTYPE );
+                       lwline_to_wkt_sb((LWLINE*)comp->geoms[i], sb, precision, variant | WKT_NO_TYPE );
                }
                /* But circstring subgeoms *do* get type identifiers */
                else if( type == CIRCSTRINGTYPE )
@@ -317,7 +317,7 @@ static void lwcurvepoly_to_wkt_sb(const LWCURVEPOLY *cpoly, stringbuffer_t *sb,
 {
        int i = 0;
        
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "CURVEPOLYGON"); /* "CURVEPOLYGON" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)cpoly, sb, variant);
@@ -337,7 +337,7 @@ static void lwcurvepoly_to_wkt_sb(const LWCURVEPOLY *cpoly, stringbuffer_t *sb,
                {
                        case LINETYPE:
                                /* Linestring subgeoms don't get type identifiers */
-                               lwline_to_wkt_sb((LWLINE*)cpoly->rings[i], sb, precision, variant | WKT_NOTYPE );
+                               lwline_to_wkt_sb((LWLINE*)cpoly->rings[i], sb, precision, variant | WKT_NO_TYPE );
                                break;
                        case CIRCSTRINGTYPE:
                                /* But circstring subgeoms *do* get type identifiers */
@@ -364,7 +364,7 @@ static void lwmcurve_to_wkt_sb(const LWMCURVE *mcurv, stringbuffer_t *sb, int pr
 {
        int i = 0;
 
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "MULTICURVE"); /* "MULTICURVE" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)mcurv, sb, variant);
@@ -384,7 +384,7 @@ static void lwmcurve_to_wkt_sb(const LWMCURVE *mcurv, stringbuffer_t *sb, int pr
                {
                        case LINETYPE:
                                /* Linestring subgeoms don't get type identifiers */
-                               lwline_to_wkt_sb((LWLINE*)mcurv->geoms[i], sb, precision, variant | WKT_NOTYPE );
+                               lwline_to_wkt_sb((LWLINE*)mcurv->geoms[i], sb, precision, variant | WKT_NO_TYPE );
                                break;
                        case CIRCSTRINGTYPE:
                                /* But circstring subgeoms *do* get type identifiers */
@@ -411,7 +411,7 @@ static void lwmsurface_to_wkt_sb(const LWMSURFACE *msurf, stringbuffer_t *sb, in
 {
        int i = 0;
 
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "MULTISURFACE"); /* "MULTISURFACE" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)msurf, sb, variant);
@@ -431,7 +431,7 @@ static void lwmsurface_to_wkt_sb(const LWMSURFACE *msurf, stringbuffer_t *sb, in
                {
                        case POLYGONTYPE:
                                /* Linestring subgeoms don't get type identifiers */
-                               lwpoly_to_wkt_sb((LWPOLY*)msurf->geoms[i], sb, precision, variant | WKT_NOTYPE );
+                               lwpoly_to_wkt_sb((LWPOLY*)msurf->geoms[i], sb, precision, variant | WKT_NO_TYPE );
                                break;
                        case CURVEPOLYTYPE:
                                /* But circstring subgeoms *do* get type identifiers */
@@ -453,7 +453,7 @@ static void lwcollection_to_wkt_sb(const LWCOLLECTION *collection, stringbuffer_
 {
        int i = 0;
        
-       if( ! (variant & WKT_NOTYPE) )
+       if( ! (variant & WKT_NO_TYPE) )
        {
                stringbuffer_append(sb, "GEOMETRYCOLLECTION"); /* "GEOMETRYCOLLECTION" */
                dimension_qualifiers_to_wkt_sb((LWGEOM*)collection, sb, variant);