Browse Source

r.to.vect: strip out duplicate points, free memory

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@58795 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 11 years ago
parent
commit
be1bee01f1
4 changed files with 25 additions and 7 deletions
  1. 3 0
      raster/r.to.vect/areas.c
  2. 3 7
      raster/r.to.vect/areas_io.c
  3. 5 0
      raster/r.to.vect/lines.c
  4. 14 0
      raster/r.to.vect/points.c

+ 3 - 0
raster/r.to.vect/areas.c

@@ -141,6 +141,9 @@ int extract_areas(void)
 
     G_free(a_list);
     G_free(e_list);
+    G_free(v_list);
+    G_free(buffer[0]);
+    G_free(buffer[1]);
 
     return 0;
 }				/* extract_areas */

+ 3 - 7
raster/r.to.vect/areas_io.c

@@ -210,8 +210,6 @@ static int write_smooth_bnd(struct COOR *line_begin, struct COOR *line_end,	/* s
 	x = cell_head.west + (p->col - dx) * cell_head.ew_res;
 	total++;
 	Vect_append_point(points, x, y, 0.0);
-
-	/* G_free (last); */
     }				/* end of for i */
 
     y = cell_head.north - (double)p->row * cell_head.ns_res;
@@ -220,15 +218,13 @@ static int write_smooth_bnd(struct COOR *line_begin, struct COOR *line_end,	/* s
     Vect_append_point(points, x, y, 0.0);
 
     /* strip out the duplicate points from the list */
-    y = cell_head.north - (double)p->row * cell_head.ns_res;
-    x = cell_head.west + (double)p->col * cell_head.ew_res;
-    total++;
-    Vect_append_point(points, x, y, 0.0);
+    Vect_line_prune(points);
+    G_debug(3, "removed duplicates: %d", total - points->n_points);
 
     /* write files */
     Vect_write_line(&Map, GV_BOUNDARY, points, Cats);
 
-    /* now free all thwe pointers */
+    /* now free all the pointers */
     p = line_begin;
 
     for (i = 1; i < n; i++) {

+ 5 - 0
raster/r.to.vect/lines.c

@@ -176,6 +176,11 @@ int extract_lines(void)
 	}
     }
 
+    G_free(top);
+    G_free(middle);
+    G_free(bottom);
+    G_free(v_list);
+
     return 0;
 }
 

+ 14 - 0
raster/r.to.vect/points.c

@@ -98,5 +98,19 @@ int extract_points(int z_flag)
 
     G_percent(row, n_rows, 2);
 
+    switch (data_type) {
+    case CELL_TYPE:
+	G_free(cellbuf);
+	break;
+    case FCELL_TYPE:
+	G_free(fcellbuf);
+	break;
+    case DCELL_TYPE:
+	G_free(dcellbuf);
+	break;
+    }
+    
+    Vect_destroy_line_struct(points);
+
     return (1);
 }