int lines,i,j,max_points,index;
int *points;
int *part_index;
+ int notnull;
double *x;
double *y;
double *totz;
SHPObject *obj;
-
+ notnull=1;
lines = num_lines(str);
points = (int *)malloc(sizeof(int) * lines);
index=0;
+ if(lines == 0 ){
+ notnull = 0;
+ }
for(i=0;i<lines;i++){
str = strchr(str,'(') ;
y = (double *)malloc(sizeof(double) * points[i]);
z = (double *)malloc(sizeof(double) * points[i]);
- parse_points(str,points[i],x,y,z);
+ notnull = parse_points(str,points[i],x,y,z);
str = scan_to_same_level(str);
part_index[i] = index;
for(j=0;j<points[i];j++){
obj = (SHPObject *)malloc(sizeof(SHPObject));
if(dims == 0){
- obj = SHPCreateObject(SHPT_ARC,shape_id,lines,part_index,NULL,max_points,totx,toty,totz,NULL);
+ if(notnull ==1){
+ obj = SHPCreateObject(SHPT_ARC,shape_id,lines,part_index,NULL,max_points,totx,toty,totz,NULL);
+ }else{
+ obj = SHPCreateObject(SHPT_NULL,shape_id,lines,part_index,NULL,max_points,totx,toty,totz,NULL);
+ }
}else{
- obj = SHPCreateObject(SHPT_ARCZ,shape_id,lines,part_index,NULL,max_points,totx,toty,totz,NULL);
+ if(notnull ==1){
+ obj = SHPCreateObject(SHPT_ARCZ,shape_id,lines,part_index,NULL,max_points,totx,toty,totz,NULL);
+ }else{
+ obj = SHPCreateObject(SHPT_NULL,shape_id,lines,part_index,NULL,max_points,totx,toty,totz,NULL);
+ }
}
free(part_index);
free(points);
int create_lines(char *str,int shape_id, SHPHandle shp,int dims){
int points;
int *part_index;
+ int notnull;
double *x,
*y,
*z;
SHPObject *obj;
-
+ notnull =1;
part_index = (int *)malloc(sizeof(int)); //we know lines only have 1 part so make the array of size 1
part_index[0] = 0;
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 = SHPCreateObject(SHPT_ARC,shape_id,1,part_index,NULL,points,x,y,z,NULL);
+ if(notnull ==1){
+ obj = SHPCreateObject(SHPT_ARC,shape_id,1,part_index,NULL,points,x,y,z,NULL);
+ }else{
+ obj = SHPCreateObject(SHPT_NULL,shape_id,1,part_index,NULL,points,x,y,z,NULL);
+ }
}else{
- obj = SHPCreateObject(SHPT_ARCZ,shape_id,1,part_index,NULL,points,x,y,z,NULL);
+ if(notnull ==1){
+ obj = SHPCreateObject(SHPT_ARCZ,shape_id,1,part_index,NULL,points,x,y,z,NULL);
+ }else{
+ obj = SHPCreateObject(SHPT_NULL,shape_id,1,part_index,NULL,points,x,y,z,NULL);
+ }
}
free(part_index);
free(x);
int rings,i,j,max_points,index;
int *points;
int *part_index;
+ int notnull;
double *x;
double *y;
double *totz;
SHPObject *obj;
+ notnull = 1;
+
rings = num_lines(str); //the number of rings in the polygon
points = (int *)malloc(sizeof(int) * rings);
totz = (double *)malloc(sizeof(double) * max_points);
index=0;
-
+ if (rings == 0){
+ notnull = 0;
+ }
for(i=0;i<rings;i++){
str = strchr(str,'(') ;
y = (double *)malloc(sizeof(double) * points[i]);
z = (double *)malloc(sizeof(double) * points[i]);
- parse_points(str,points[i],x,y,z);
+ notnull = parse_points(str,points[i],x,y,z);
str = scan_to_same_level(str);
part_index[i] = index;
for(j=0;j<points[i];j++){
obj = (SHPObject *)malloc(sizeof(SHPObject));
if(dims == 0){
- obj = SHPCreateObject(SHPT_POLYGON,shape_id,rings,part_index,NULL,max_points,totx,toty,totz,NULL);
+ if(notnull == 1){
+ obj = SHPCreateObject(SHPT_POLYGON,shape_id,rings,part_index,NULL,max_points,totx,toty,totz,NULL);
+ }else{
+ obj = SHPCreateObject(SHPT_NULL,shape_id,rings,part_index,NULL,max_points,totx,toty,totz,NULL);
+ }
}else{
- obj = SHPCreateObject(SHPT_POLYGONZ,shape_id,rings,part_index,NULL,max_points,totx,toty,totz,NULL);
+ if(notnull == 1){
+ obj = SHPCreateObject(SHPT_POLYGONZ,shape_id,rings,part_index,NULL,max_points,totx,toty,totz,NULL);
+ }else{
+ obj = SHPCreateObject(SHPT_NULL,shape_id,rings,part_index,NULL,max_points,totx,toty,totz,NULL);
+ }
}
free(part_index);
free(points);
int *points;
int *part_index;
int *final_part_index;
+ int notnull;
char *temp;
char *temp_addr;
SHPObject *obj;
points=0;
+ notnull = 1;
polys = num_lines(str); //the number of rings in the polygon
final_max_points =0;
finaly = (double *)malloc(sizeof(double) * final_max_points);
finalz = (double *)malloc(sizeof(double) * final_max_points);
+ if(polys == 0){
+ notnull = 0;
+ }
for(k=0;k<polys ; k++){ //for each polygon
totz = (double *)malloc(sizeof(double) * max_points);
index=0;
-
for(i=0;i<rings;i++){
str = strchr(str,'(') ;
if(str[0] =='(' && str[1] == '('){
y = (double *)malloc(sizeof(double) * points[i]);
z = (double *)malloc(sizeof(double) * points[i]);
- parse_points(str,points[i],x,y,z);
+ notnull = parse_points(str,points[i],x,y,z);
str = scan_to_same_level(str);
part_index[i] = index;
for(j=0;j<points[i];j++){
obj = (SHPObject *)malloc(sizeof(SHPObject));
if(dims == 0){
- obj = SHPCreateObject(SHPT_POLYGON,shape_id,tot_rings,final_part_index,NULL,final_max_points,finalx,finaly,finalz,NULL);
+ if(notnull == 1){
+ obj = SHPCreateObject(SHPT_POLYGON,shape_id,tot_rings,final_part_index,NULL,final_max_points,finalx,finaly,finalz,NULL);
+ }else{
+ obj = SHPCreateObject(SHPT_NULL,shape_id,tot_rings,final_part_index,NULL,final_max_points,finalx,finaly,finalz,NULL);
+ }
}else{
- obj = SHPCreateObject(SHPT_POLYGONZ,shape_id,tot_rings,final_part_index,NULL,final_max_points,finalx,finaly,finalz,NULL);
+ if(notnull == 1){
+ obj = SHPCreateObject(SHPT_POLYGONZ,shape_id,tot_rings,final_part_index,NULL,final_max_points,finalx,finaly,finalz,NULL);
+ }else{
+ obj = SHPCreateObject(SHPT_NULL,shape_id,tot_rings,final_part_index,NULL,final_max_points,finalx,finaly,finalz,NULL);
+ }
}
free(final_part_index);