From: David Blasby Date: Thu, 28 Jun 2001 17:52:15 +0000 (+0000) Subject: converting a GEOMETRYCOLLECTION to wkb had the size of the wkb off by 9 X-Git-Tag: pgis_0_5_0~21 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=785fb36c3725c70a1eab147c70a77240b544f1c4;p=postgis converting a GEOMETRYCOLLECTION to wkb had the size of the wkb off by 9 bytes (size of the collection header). Fixed. git-svn-id: http://svn.osgeo.org/postgis/trunk@11 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/examples/wkb_reader/comp b/examples/wkb_reader/comp index b915e13c9..bf67b16d2 100644 --- a/examples/wkb_reader/comp +++ b/examples/wkb_reader/comp @@ -1,2 +1,2 @@ -gcc -g -I/usr/include/pgsql -I/usr/local/include/pgsql -L/data3/postgresql-7.1.2/lib readwkb.c -o readwkb -lpq +gcc -g -I/data3/postgresql-7.1.2/include -I/usr/include/pgsql -I/usr/local/include/pgsql -L/data3/postgresql-7.1.2/lib readwkb.c -o readwkb -lpq diff --git a/examples/wkb_reader/readwkb b/examples/wkb_reader/readwkb index 6d5e5313c..659cec97a 100755 Binary files a/examples/wkb_reader/readwkb and b/examples/wkb_reader/readwkb differ diff --git a/examples/wkb_reader/readwkb.c b/examples/wkb_reader/readwkb.c index be40e62c8..33c07cdbe 100644 --- a/examples/wkb_reader/readwkb.c +++ b/examples/wkb_reader/readwkb.c @@ -157,7 +157,7 @@ int WKB_OID; double *double_val; char *char_val; char *wkb_val; - char *table_name = "tt"; + char *table_name = "t"; char query_str[1000]; /* @@ -172,7 +172,7 @@ int WKB_OID; pgport = "5555"; pgoptions = "user=postgres"; pgtty = NULL; - dbName = "test1"; + dbName = "t2"; @@ -217,7 +217,9 @@ int WKB_OID; * fetch rows from the pg_database, the system catalog of * databases */ - sprintf(query_str, "DECLARE mycursor BINARY CURSOR FOR select interesting, comments, wkb_ndr(the_geom) as wkb from %s",table_name); + sprintf(query_str, "DECLARE mycursor BINARY CURSOR FOR select text(num), asbinary(the_geom,'ndr') as wkb from %s",table_name); + + printf(query_str); printf("\n"); res = PQexec(conn, query_str); @@ -271,7 +273,7 @@ int WKB_OID; double_val = (double *) PQgetvalue(res, row, field); printf("%s: %g\n",field_name,*double_val); } - if (field_type ==1043 )//varchar + if ( (field_type ==1043 ) || (field_type==25) )//varchar { char_val = (char *) PQgetvalue(res, row, field); printf("%s: %s\n",field_name,char_val); @@ -300,4 +302,4 @@ int WKB_OID; PQfinish(conn); return 0; -} \ No newline at end of file +} diff --git a/postgis_inout.c b/postgis_inout.c index f9df0bc3d..72b1f4e25 100644 --- a/postgis_inout.c +++ b/postgis_inout.c @@ -2490,7 +2490,7 @@ char *to_wkb_collection(GEOMETRY *geom, bool flip_endian, int32 *end_size) pfree( sizes); //total size of the wkb - *end_size = total_size; + *end_size = total_size+9;