Browse Source

v.out.ogr: support transactions (major speed up)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@45911 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 14 years ago
parent
commit
124387e14d
1 changed files with 16 additions and 18 deletions
  1. 16 18
      vector/v.out.ogr/main.c

+ 16 - 18
vector/v.out.ogr/main.c

@@ -308,8 +308,7 @@ int main(int argc, char *argv[])
     }
     else {
 	if (otype & GV_POINT)
-	    num_to_export =
-		num_to_export + Vect_get_num_primitives(&In, GV_POINT);
+	    num_to_export += Vect_get_num_primitives(&In, GV_POINT);
     }
 
     if (Vect_get_num_primitives(&In, GV_LINE) < 1 && (otype & GV_LINE)) {
@@ -318,8 +317,7 @@ int main(int argc, char *argv[])
     }
     else {
 	if (otype & GV_LINE)
-	    num_to_export =
-		num_to_export + Vect_get_num_primitives(&In, GV_LINE);
+	    num_to_export += Vect_get_num_primitives(&In, GV_LINE);
     }
 
     if (Vect_get_num_primitives(&In, GV_BOUNDARY) < 1 &&
@@ -329,8 +327,7 @@ int main(int argc, char *argv[])
     }
     else {
 	if (otype & GV_BOUNDARY)
-	    num_to_export =
-		num_to_export + Vect_get_num_primitives(&In, GV_BOUNDARY);
+	    num_to_export += Vect_get_num_primitives(&In, GV_BOUNDARY);
     }
 
     if (Vect_get_num_areas(&In) < 1 && (otype & GV_AREA)) {
@@ -339,7 +336,7 @@ int main(int argc, char *argv[])
     }
     else {
 	if (otype & GV_AREA)
-	    num_to_export = num_to_export + Vect_get_num_areas(&In);
+	    num_to_export += Vect_get_num_areas(&In);
     }
 
     if (Vect_get_num_primitives(&In, GV_CENTROID) < 1 &&
@@ -349,8 +346,7 @@ int main(int argc, char *argv[])
     }
     else {
 	if (otype & GV_CENTROID)
-	    num_to_export =
-		num_to_export + Vect_get_num_primitives(&In, GV_CENTROID);
+	    num_to_export += Vect_get_num_primitives(&In, GV_CENTROID);
     }
 
     if (Vect_get_num_primitives(&In, GV_FACE) < 1 && (otype & GV_FACE)) {
@@ -359,8 +355,7 @@ int main(int argc, char *argv[])
     }
     else {
 	if (otype & GV_FACE)
-	    num_to_export =
-		num_to_export + Vect_get_num_primitives(&In, GV_FACE);
+	    num_to_export += Vect_get_num_primitives(&In, GV_FACE);
     }
 
     if (Vect_get_num_primitives(&In, GV_KERNEL) < 1 && (otype & GV_KERNEL)) {
@@ -369,8 +364,7 @@ int main(int argc, char *argv[])
     }
     else {
 	if (otype & GV_KERNEL)
-	    num_to_export =
-		num_to_export + Vect_get_num_primitives(&In, GV_KERNEL);
+	    num_to_export += Vect_get_num_primitives(&In, GV_KERNEL);
     }
 
     if (Vect_get_num_volumes(&In) < 1 && (otype & GV_VOLUME)) {
@@ -379,7 +373,7 @@ int main(int argc, char *argv[])
     }
     else {
 	if (otype & GV_VOLUME)
-	    num_to_export = num_to_export + Vect_get_num_volumes(&In);
+	    num_to_export += Vect_get_num_volumes(&In);
     }
 
     G_debug(1, "Requested to export %d features", num_to_export);
@@ -534,7 +528,7 @@ int main(int argc, char *argv[])
 	else
 	    G_fatal_error(_("Unable to create OGR layer"));
     }
-
+    
     db_init_string(&dbstring);
 
     /* Vector attributes -> OGR fields */
@@ -644,7 +638,6 @@ int main(int argc, char *argv[])
 
     fout = fskip = nocat = noatt = nocatskip = 0;
 
-
     /* Fetch all attribute records */
     if (doatt) {
     	sprintf(buf, "SELECT * FROM %s", Fi->table);
@@ -656,8 +649,10 @@ int main(int argc, char *argv[])
     	      cat);
     	}
     }
-
-
+    
+    if (OGR_L_TestCapability(Ogr_layer, OLCTransactions))
+	OGR_L_StartTransaction(Ogr_layer);
+    
     /* Lines (run always to count features of different type) */
     if ((otype & GV_POINTS) || (otype & GV_LINES)) {
 	G_message(_("Exporting %i features..."), Vect_get_num_lines(&In));
@@ -941,6 +936,9 @@ int main(int argc, char *argv[])
 	G_warning(_("Export of volumes not implemented yet. Skipping."));
     }
 
+    if (OGR_L_TestCapability(Ogr_layer, OLCTransactions))
+	OGR_L_CommitTransaction(Ogr_layer);
+
     OGR_DS_Destroy(Ogr_ds);
 
     Vect_close(&In);