From cdb361240db6b221a3dbad551d061d78405e73dd Mon Sep 17 00:00:00 2001 From: Jeff Lounsbury Date: Thu, 10 Oct 2002 17:11:30 +0000 Subject: [PATCH] Added support to write out Null geometries to point and mulitpoints git-svn-id: http://svn.osgeo.org/postgis/trunk@192 b70326c6-7e19-0410-871a-916f4a2858ee --- loader/pgsql2shp.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/loader/pgsql2shp.c b/loader/pgsql2shp.c index dbd684922..9294c3a27 100644 --- a/loader/pgsql2shp.c +++ b/loader/pgsql2shp.c @@ -405,13 +405,14 @@ printf(conn_string); //get what kind of Geometry type is in the table - query= (char *)malloc(strlen(table) + strlen("select distinct (geometrytype()) from ")+18); + query= (char *)malloc(strlen(table) + strlen("select distinct (geometrytype()) from where NOT geometrytype(geom) = NULL")+18); strcpy(query, "select distinct (geometrytype("); strcat(query, geo_col_name); strcat(query, ")) from ") ; strcat(query, table); + strcat(query," where NOT geometrytype(geom) = NULL"); res3 = PQexec(conn, query); - + //printf("\n\n-->%s\n\n",query); @@ -964,20 +965,30 @@ int create_points(char *str, SHPHandle shp,int dims){ *y, *z; SHPObject *obj; - + int notnull; + notnull = 1; x = (double *)malloc(sizeof(double)); y = (double *)malloc(sizeof(double)); z = (double *)malloc(sizeof(double)); - parse_points(str,1,x,y,z); + notnull = parse_points(str,1,x,y,z); + obj = (SHPObject *)malloc(sizeof(SHPObject)); if(dims == 0){ - obj = SHPCreateSimpleObject(SHPT_POINT,1,x,y,z); + if(notnull == 1){ + obj = SHPCreateSimpleObject(SHPT_POINT,1,x,y,z); + }else{ + obj = SHPCreateSimpleObject(SHPT_NULL,1,x,y,z); + } }else{ - obj = SHPCreateSimpleObject(SHPT_POINTZ,1,x,y,z); + if(notnull == 1){ + obj = SHPCreateSimpleObject(SHPT_POINTZ,1,x,y,z); + }else{ + obj = SHPCreateSimpleObject(SHPT_NULL,1,x,y,z); + } } free(x); free(y); @@ -1000,21 +1011,30 @@ int create_multipoints(char *str, SHPHandle shp,int dims){ *y, *z; SHPObject *obj; + int notnull; + notnull=1; - points = num_points(str); x = (double *)malloc(sizeof(double)*points); y = (double *)malloc(sizeof(double)*points); z = (double *)malloc(sizeof(double)*points); - parse_points(str,points,x,y,z); + notnull = parse_points(str,points,x,y,z); obj = (SHPObject *)malloc(sizeof(SHPObject)); if(dims == 0){ - obj = SHPCreateSimpleObject(SHPT_MULTIPOINT ,1,x,y,z); + if(notnull == 1){ + obj = SHPCreateSimpleObject(SHPT_MULTIPOINT ,1,x,y,z); + }else{ + obj = SHPCreateSimpleObject(SHPT_NULL ,1,x,y,z); + } }else{ - obj = SHPCreateSimpleObject(SHPT_MULTIPOINTZ ,1,x,y,z); + if(notnull == 1){ + obj = SHPCreateSimpleObject(SHPT_MULTIPOINTZ ,1,x,y,z); + }else{ + obj = SHPCreateSimpleObject(SHPT_NULL ,1,x,y,z); + } } free(x); -- 2.40.0