]> granicus.if.org Git - postgis/commitdiff
It seems that invalid geometries where in the shapefile (as far as shapelib
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 18 Jun 2003 16:30:56 +0000 (16:30 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 18 Jun 2003 16:30:56 +0000 (16:30 +0000)
let shp2pgsql know). LINEZ objects with less then 2 vertices. I've
patched shp2pgsql to recognized such an inconsistence and use a NULL
geometry for that record printing a warning on stderr.
<strk@freek.keybit.net>

git-svn-id: http://svn.osgeo.org/postgis/trunk@277 b70326c6-7e19-0410-871a-916f4a2858ee

loader/shp2pgsql.c

index ea8fd14c907245289727572fbefbddc3c219aa70..2393d02c1b2ab25b6c03277d49b504111bc89a04 100644 (file)
@@ -4,6 +4,13 @@
  * Author: Jeff Lounsbury, jeffloun@refractions.net
  *
  * $Log$
+ * Revision 1.35  2003/06/18 16:30:56  pramsey
+ * It seems that invalid geometries where in the shapefile (as far as shapelib
+ * let shp2pgsql know). LINEZ objects with less then 2 vertices. I've
+ * patched shp2pgsql to recognized such an inconsistence and use a NULL
+ * geometry for that record printing a warning on stderr.
+ * <strk@freek.keybit.net>
+ *
  * Revision 1.34  2003/04/14 18:01:42  pramsey
  * Patch for optional case sensitivity respect. From strk.
  *
@@ -863,6 +870,22 @@ int main (int ARGC, char **ARGV){
 
                        Insert_attributes(hDBFHandle,j); //add the attributes of each shape to the insert statement
 
+                       /* Invalid (MULTI)Linestring */
+                       if ( obj->nVertices < 2 )
+                       {
+                               fprintf(stderr,
+       "MULTILINESTRING %d as %d vertices, set to NULL\n",
+       j, obj->nVertices);
+                               if (dump_format){
+                                       printf("\t\\N\n");
+                               }else{
+                                       printf(",NULL);\n");
+                               }
+
+                               SHPDestroyObject(obj);
+
+                               continue;
+                       }
 
                        if (dump_format){
                                printf("\tSRID=%s;MULTILINESTRING(",sr_id);
@@ -1088,9 +1111,26 @@ int main (int ARGC, char **ARGV){
 
                        Insert_attributes(hDBFHandle,j);//add the attributes of each shape to the insert statement
 
+                       /* Invalid (MULTI)Linestring */
+                       if ( obj->nVertices < 2 )
+                       {
+                               fprintf(stderr,
+       "MULTILINESTRING %d as %d vertices, set to NULL\n",
+       j, obj->nVertices);
+                               if (dump_format){
+                                       printf("\t\\N\n");
+                               }else{
+                                       printf(",NULL);\n");
+                               }
+
+                               SHPDestroyObject(obj);
+
+                               continue;
+                       }
+
 
                        if (dump_format){
-                               printf("MULTILINESTRING(");
+                               printf("\tSRID=%s;MULTILINESTRING(",sr_id);
                        }else{
                                printf(",GeometryFromText('MULTILINESTRING (");
                        }