[GRASS5] d.vect -a|c for all types ver2

Martin Landa landa.martin at gmail.com
Sun Oct 23 18:27:12 EDT 2005


Hi,

I have tried to solve this problem - I am really not sure, maybe I
don't understand correctly areas and isles...

There is a new patch for d.vect... I hope without any huge bugs;-)
Please test it ... I am ready for your comments.

Best regards,

Martin

2005/10/20, Markus Neteler <neteler at itc.it>:
> On Tue, Oct 18, 2005 at 07:12:38PM +0200, Markus Neteler wrote:
> > On Thu, Oct 06, 2005 at 09:18:33AM +0000, Martin Landa wrote:
> > > Hi all,
> > >
> > > I have rewritten the patch for d.vect which enables to use flags -a
> > > and -c for all vector types (not only for areas). I hope I did it
> > > better this time (for previous patch see
> > > http://grass.itc.it/pipermail/grass5/2005-September/019563.html).
>
> Hi Martin,
>
> I tested the new d.vect code (the Vlib/area.c fix is in CVS),
> but there is a bug in d.vect/area.c:
>
> d.vect delauney
> ERROR: Attempt to read topo for dead isle (2)
>
> The problem is the line:
>
>   if (Vect_get_isle_area(Map, area))
>
> Since this function ends with a fatal error for non-island
> areas, it must be used in a different way.
> However, for details better ask Radim...
>
> I am sure that you'll iron out this missing piece!
>
> Markus
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: d_vect_rgb_column-2005-10-23.diff.gz
Type: application/x-gzip
Size: 5522 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20051024/a9d12d52/d_vect_rgb_column-2005-10-23.diff.gz
-------------- next part --------------
--- d.vect.18/area.c	2005-10-24 00:03:10.000000000 +0200
+++ d.vect/area.c	2005-10-24 00:18:39.000000000 +0200
@@ -20,8 +20,9 @@
     struct line_cats *Cats;
     int cat, centroid = 0;
     int red, grn, blu;
+    struct ilist *isles = NULL;
 
-    struct field_info *fi=NULL;
+    struct field_info *fi = NULL;
     dbDriver *driver = NULL;
     dbCatValArray cvarr;
     dbCatVal *cv_rgb = NULL;
@@ -72,14 +73,26 @@
     
     num = Vect_get_num_areas(Map);
     G_debug (2, "n_areas = %d", num);
-    
+
+    /* initialize isles - needed? */
+    isles = Vect_new_list ();
+    for ( area = 1; area <= num; area++ ) {
+      n_isles = Vect_get_area_num_isles ( Map, area );   
+      for ( i = 0; i < n_isles; i++) {
+	isle = Vect_get_area_isle ( Map, area, i );   
+	if (isle > 0) {
+	  Vect_list_append (isles, isle);
+	}
+      }
+    }
+
     for ( area = 1; area <= num; area++ ) {
 	int i;
 	BOUND_BOX box;
         G_debug (3, "area = %d", area);
 
-	if ( !Vect_area_alive (Map, area) ) continue;
-	
+	if ( !Vect_area_alive (Map, area) || Vect_val_in_list(isles, area)) continue;
+
 	/* Check box */
 	Vect_get_area_box (Map, area, &box);
 	if ( box.N < window->south || box.S > window->north || 
@@ -136,7 +149,7 @@
 	    Vect_append_points ( Points, IPoints, GV_FORWARD);
 	    Vect_append_point ( Points, xl, yl, 0.0 ); /* ??? */
 	}
-	
+
 	if( table_colors_flag ) {
 	  cat=Vect_get_area_cat ( Map, area , Clist -> field );
 	  centroid = Vect_get_area_centroid ( Map, area );
@@ -196,20 +209,15 @@
 	}
 	
 	if ( fcolor > -1 ) {
-	  if (Vect_get_isle_area (Map, area)) { /* isle ? */
-	    R_RGB_color (255, 255, 255);
-	    }
+	  if (!table_colors_flag && !cats_color_flag) {
+	    R_color(fcolor) ;
+	  }
 	  else {
-	    if (!table_colors_flag && !cats_color_flag) {
-	      R_color(fcolor) ;
+	    if (rgb) {
+	      R_RGB_color ((unsigned char) red, (unsigned char) grn, (unsigned char) blu);
 	    }
 	    else {
-	      if (rgb) {
-		R_RGB_color ((unsigned char) red, (unsigned char) grn, (unsigned char) blu);
-	      }
-	      else {
 	      R_color (fcolor);
-	      }
 	    }
 	  }
 	  G_plot_polygon ( Points->x, Points->y, Points->n_points);
@@ -239,8 +247,10 @@
     } /* end for */
 
     Vect_destroy_line_struct (Points);
+    Vect_destroy_line_struct (IPoints);
     Vect_destroy_cats_struct (Cats);
-    
+    Vect_destroy_list (isles);
+
     return 0;
 }
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 9322 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20051024/a9d12d52/test.png


More information about the grass-dev mailing list