[GRASS5] d.vect -a|c for all types ver2
Hamish
hamish_nospam at yahoo.com
Sun Dec 11 02:03:28 EST 2005
> 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
>
..
> 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
Is this patch ready to be committed to CVS?
What is the place of "area.diff"? It does not apply cleanly.
Hamish
-------------- next part --------------
diff -ru display/d.vect.cvs/area.c display/d.vect/area.c
--- display/d.vect.cvs/area.c 2005-08-09 13:26:59.000000000 +0200
+++ display/d.vect/area.c 2005-10-23 23:57:21.000000000 +0200
@@ -10,31 +10,7 @@
#include "plot.h"
#include "colors.h"
#include "dbmi.h"
-
-/* TODO: should use 24bit instead of 16 colors, maybe implement
- predefined color tables? */
-struct rgb_color {
- unsigned char R, G, B;
- };
-static const int palette_ncolors = 16;
-static struct rgb_color palette[16] = {
- {198, 198, 198}, /* 1: light gray */
- {127, 127, 127}, /* 2: medium/dark gray */
- {255, 0, 0}, /* 3: bright red */
- {139, 0, 0}, /* 4: dark red */
- { 0, 255, 0}, /* 5: bright green */
- { 0, 139, 0}, /* 6: dark green */
- { 0, 0, 255}, /* 7: bright blue */
- { 0, 0, 139}, /* 8: dark blue */
- {255, 255, 0}, /* 9: yellow */
- {139, 126, 10}, /* 10: olivey brown */
- {255, 165, 0}, /* 11: orange */
- {255, 192, 203}, /* 12: pink */
- {255, 0, 255}, /* 13: magenta */
- {139, 0, 139}, /* 14: dark magenta */
- { 0, 255, 255}, /* 15: cyan */
- { 0, 139, 139} /* 16: dark cyan */
-};
+#include "glocale.h"
int darea ( struct Map_info *Map, struct cat_list *Clist, int bcolor, int fcolor,
int chcat, int id_flag, int table_colors_flag, int cats_color_flag, struct Cell_head *window) {
@@ -44,16 +20,16 @@
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;
- dbHandle handle;
- dbString stmt, valstr;
- dbCursor cursor;
- dbTable *table;
- dbColumn *column;
- char buf[2000], colorstring[12]; /* RRR:GGG:BBB */
- int more, ret;
+ dbCatValArray cvarr;
+ dbCatVal *cv_rgb = NULL;
+ int nrec;
+
+ int i, rgb; /* 0|1 */
+ char colorstring[12]; /* RRR:GGG:BBB */
unsigned char which;
G_debug (1, "display areas:");
@@ -63,28 +39,60 @@
if( table_colors_flag ) {
/* for reading RRR:GGG:BBB color strings from table */
- db_init_string (&stmt);
- db_init_string (&valstr);
- fi = Vect_get_field( Map, Clist->field);
- if ( fi == NULL ) G_fatal_error ("Cannot read field info");
- driver = db_start_driver(fi->driver);
- if (driver == NULL) G_fatal_error("Cannot open driver %s", fi->driver);
- db_init_handle (&handle);
- db_set_handle (&handle, fi->database, NULL);
- if (db_open_database(driver, &handle) != DB_OK)
- G_fatal_error("Cannot open database %s", fi->database);
+ db_CatValArray_init (&cvarr);
+
+ fi = Vect_get_field (Map, Clist -> field);
+ if (fi == NULL) {
+ G_fatal_error(_("Cannot read field info"));
+ }
+
+ driver = db_start_driver_open_database(fi->driver, fi->database);
+ if (driver == NULL)
+ G_fatal_error(_("Cannot open database %s by driver %s"), fi->database, fi->driver);
+
+ nrec = db_select_CatValArray(driver, fi->table, fi->key,
+ "GRASSRGB", NULL, &cvarr);
+
+ G_debug (3, "nrec (grassrgb) = %d", nrec);
+
+ if (cvarr.ctype != DB_C_TYPE_STRING)
+ G_fatal_error (_("Column type (grassrgb) not supported"));
+
+ if ( nrec < 0 ) G_fatal_error (_("Cannot select data (grassrgb) from table"));
+
+ G_debug(2, "\n%d records selected from table", nrec);
+
+ db_close_database_shutdown_driver(driver);
+
+
+ for ( i = 0; i < cvarr.n_values; i++ ) {
+ G_debug (4, "cat = %d grassrgb = %d", cvarr.value[i].cat,
+ db_get_string(cvarr.value[i].val.s));
+ }
}
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 ||
@@ -141,67 +149,90 @@
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 );
- if( cat >= 0 ){
- G_debug (3, "display area %d, centroid %d, cat %d", area, centroid, cat);
-
- /* Read RGB colors from db for current area # */
- db_init_string (&stmt);
- db_init_string (&valstr);
- sprintf ( buf, "select %s from %s where %s = %d", "GRASSRGB", fi->table, fi->key, cat);
- G_debug (3, "SQL: %s", buf);
- db_append_string ( &stmt, buf);
- if (db_open_select_cursor(driver, &stmt, &cursor, DB_SEQUENTIAL) != DB_OK)
- G_fatal_error ("Cannot select attributes for area # %d.", area);
-
- table = db_get_cursor_table (&cursor);
- column = db_get_table_column(table, 0); /* first column */
-
- if(db_fetch (&cursor, DB_NEXT, &more) != DB_OK) continue;
- db_convert_column_value_to_string (column, &valstr);
- sprintf (colorstring, "%s", db_get_string(&valstr));
-
- /* only draw if GRASSRGB was defined */
- if (strlen(colorstring) != 0) {
- G_debug(3, "area centroid %d: colorstring: %s", centroid, colorstring);
-
- ret = G_str_to_color(colorstring, &red, &grn, &blu);
- if ( ret == 1 ) {
- R_RGB_color ((unsigned char) red, (unsigned char) grn, (unsigned char) blu);
- G_debug(3, "area:%d cat %d r:%d g:%d b:%d", area, cat, red, grn, blu);
- G_plot_polygon ( Points->x, Points->y, Points->n_points);
- } else if ( ret == 0 ) { /* error */
- G_warning("Error in color definition column GRASSRGB, area %d with cat %d: colorstring %s (not drawing this area)", area, cat, colorstring);
- }
- }
- } /* end if cat */
+ cat=Vect_get_area_cat ( Map, area , Clist -> field );
+ centroid = Vect_get_area_centroid ( Map, area );
+ if( cat >= 0 ){
+ G_debug (3, "display area %d, centroid %d, cat %d", area, centroid, cat);
+
+ /* Read RGB colors from db for current area # */
+ if (db_CatValArray_get_value (&cvarr, cat, &cv_rgb) != DB_OK) {
+ rgb = 0;
+ }
+ else {
+ sprintf (colorstring, "%s", db_get_string(cv_rgb -> val.s));
+
+ if (strlen(colorstring) != 0) {
+
+ G_debug(3, "area %d: colorstring: %s", area, colorstring);
+
+ if ( G_str_to_color(colorstring, &red, &grn, &blu) ) {
+ rgb = 1;
+ G_debug(3, "area:%d cat %d r:%d g:%d b:%d", area, cat, red, grn, blu);
+ }
+ else {
+ rgb = 0;
+ G_warning(_("Error in color definition column GRASSRGB, area %d with cat %d: colorstring %s"),
+ area, cat, colorstring);
+ }
+ }
+ else {
+ G_warning(_("Error in color definition column GRASSRGB, area %d with cat %d"),
+ area, cat);
+ rgb = 0;
+ }
+ }
+ } /* end if cat */
+ else {
+ rgb = 0;
+ }
} /* end if table_colors_flag */
/* random colors */
if( cats_color_flag ) {
cat=Vect_get_area_cat ( Map, area, Clist->field );
- if( cat >= 0 ){
- G_debug (3, "display area %d, centroid %d, cat %d", area, centroid, cat);
- /* fetch color number from category */
- which = (cat % palette_ncolors);
- G_debug(3,"cat:%d which color:%d r:%d g:%d b:%d",cat, which,palette[which].R,palette[which].G,palette[which].B);
- R_RGB_color (palette[which].R,palette[which].G,palette[which].B);
- G_plot_polygon ( Points->x, Points->y, Points->n_points);
- }
+ centroid = Vect_get_area_centroid ( Map, area );
+ if( cat >= 0 ){
+ G_debug (3, "display area %d, centroid %d, cat %d", area, centroid, cat);
+ /* fetch color number from category */
+ which = (cat % palette_ncolors);
+ G_debug(3,"cat:%d which color:%d r:%d g:%d b:%d",cat, which,palette[which].R,palette[which].G,palette[which].B);
+ rgb = 1;
+ red = palette[which].R;
+ grn = palette[which].G;
+ blu = palette[which].B;
+ }
+ else {
+ rgb = 0;
+ }
}
- if ( fcolor > -1 && !table_colors_flag && !cats_color_flag) {
- R_color(fcolor) ;
- G_plot_polygon ( Points->x, Points->y, Points->n_points);
+ if ( fcolor > -1 ) {
+ if (!table_colors_flag && !cats_color_flag) {
+ R_color(fcolor) ;
+ }
+ 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);
}
-
+
/* boundary */
if ( bcolor > -1 ) {
int i, j;
Vect_get_area_points ( Map, area, Points );
- R_color(bcolor) ;
+ if (rgb) {
+ R_RGB_color ((unsigned char) red, (unsigned char) grn, (unsigned char) blu);
+ }
+ else {
+ R_color (bcolor);
+ }
for ( i = 0; i < Points->n_points - 1; i++) {
G_plot_line (Points->x[i], Points->y[i], Points->x[i+1], Points->y[i+1]);
}
@@ -215,14 +246,11 @@
}
} /* end for */
- if( table_colors_flag ) {
- db_close_database(driver);
- db_shutdown_driver(driver);
- }
-
Vect_destroy_line_struct (Points);
+ Vect_destroy_line_struct (IPoints);
Vect_destroy_cats_struct (Cats);
-
+ Vect_destroy_list (isles);
+
return 0;
}
diff -ru display/d.vect.cvs/description.html display/d.vect/description.html
--- display/d.vect.cvs/description.html 2005-04-05 09:56:15.000000000 +0200
+++ display/d.vect/description.html 2005-10-20 18:34:13.000000000 +0200
@@ -10,12 +10,11 @@
specify vector type, colors, data fields, SQL queries, label size and
justification, etc.
<P>
-Vector area fill-colors may be specified in an attribute table column
-named 'GRASSRGB' (which is a <tt>varchar</tt> column containing <tt>RRR:GGG:BBB</tt> values).
-The <em>-a</em> flag is then used to fill areas based upon the color value
-associated with each category number.
+Colors may be specified in an attribute table column
+named 'GRASSRGB' (which is a <tt>varchar</tt> column containing <tt>RRR:GGG:BBB</tt> values),
+see the flag <em>-a</em>.
<P>
-A table for a vector area map might look like this:
+A table for a vector map might look like this:
<PRE>
echo "select * from testisola" | db.select
@@ -39,7 +38,7 @@
</PRE>
<P>
A much simpler method of color coding is by using the <em>-c</em> flag which
-fills areas of like category number with a random color.
+displays vector elements of like category number with a random color.
<P>
This module can use FreeType/TrueType fonts if they have already been selected with
<em>d.font.freetype</em>.
diff -ru display/d.vect.cvs/local_proto.h display/d.vect/local_proto.h
--- display/d.vect.cvs/local_proto.h 2004-02-25 18:15:01.000000000 +0100
+++ display/d.vect/local_proto.h 2005-10-20 18:34:13.000000000 +0200
@@ -1,6 +1,6 @@
FILE *open_vect(char *, char *);
int close_vect(FILE *);
-int plot1(struct Map_info *, int, int, struct cat_list *, int, int, int, SYMBOL *, int, int);
+int plot1(struct Map_info *, int, int, struct cat_list *, int, int, int, SYMBOL *, int, int, int, int);
int label(struct Map_info *, int, int, struct cat_list *, LATTR *, int);
int topo(struct Map_info *, int, int, LATTR *);
int dir(struct Map_info *, int, struct cat_list *, int);
diff -ru display/d.vect.cvs/main.c display/d.vect/main.c
--- display/d.vect.cvs/main.c 2005-08-16 21:32:39.000000000 +0200
+++ display/d.vect/main.c 2005-10-20 18:34:13.000000000 +0200
@@ -242,12 +242,12 @@
table_acolors_flag = G_define_flag ();
table_acolors_flag->key = 'a';
table_acolors_flag->description =
- _("Get area fill colors from map table column 'GRASSRGB' (RRR:GGG:BBB)");
+ _("Get colors from map table column 'GRASSRGB' (RRR:GGG:BBB)");
cats_acolors_flag = G_define_flag ();
cats_acolors_flag->key = 'c';
cats_acolors_flag->description =
- _("Fill areas with random colors according to category number");
+ _("Random colors according to category number");
id_flag = G_define_flag ();
id_flag->key = 'i';
@@ -518,7 +518,7 @@
if ( id_flag->answer && level < 2 ) {
G_warning(_("Cannot display lines by id, topology not available"));
} else {
- stat = plot1 ( &Map, type, area, Clist, color, fcolor, chcat, Symb, size, (int) id_flag->answer );
+ stat = plot1 ( &Map, type, area, Clist, color, fcolor, chcat, Symb, size, (int) id_flag->answer, table_acolors_flag->answer, cats_acolors_flag->answer);
}
}
Binární soubory display/d.vect.cvs/OBJ.i686-pc-linux-gnu/area.o a display/d.vect/OBJ.i686-pc-linux-gnu/area.o jsou rùzné
Binární soubory display/d.vect.cvs/OBJ.i686-pc-linux-gnu/attr.o a display/d.vect/OBJ.i686-pc-linux-gnu/attr.o jsou rùzné
Binární soubory display/d.vect.cvs/OBJ.i686-pc-linux-gnu/dir.o a display/d.vect/OBJ.i686-pc-linux-gnu/dir.o jsou rùzné
Binární soubory display/d.vect.cvs/OBJ.i686-pc-linux-gnu/label.o a display/d.vect/OBJ.i686-pc-linux-gnu/label.o jsou rùzné
Binární soubory display/d.vect.cvs/OBJ.i686-pc-linux-gnu/main.o a display/d.vect/OBJ.i686-pc-linux-gnu/main.o jsou rùzné
Binární soubory display/d.vect.cvs/OBJ.i686-pc-linux-gnu/plot1.o a display/d.vect/OBJ.i686-pc-linux-gnu/plot1.o jsou rùzné
Binární soubory display/d.vect.cvs/OBJ.i686-pc-linux-gnu/topo.o a display/d.vect/OBJ.i686-pc-linux-gnu/topo.o jsou rùzné
Binární soubory display/d.vect.cvs/OBJ.i686-pc-linux-gnu/zcoor.o a display/d.vect/OBJ.i686-pc-linux-gnu/zcoor.o jsou rùzné
diff -ru display/d.vect.cvs/plot.h display/d.vect/plot.h
--- display/d.vect.cvs/plot.h 2003-03-21 19:01:19.000000000 +0100
+++ display/d.vect/plot.h 2005-10-20 18:34:13.000000000 +0200
@@ -1,3 +1,28 @@
+/* TODO: should use 24bit instead of 16 colors, maybe implement
+ predefined color tables? */
+struct rgb_color {
+ unsigned char R, G, B;
+ };
+static const int palette_ncolors = 16;
+
+static struct rgb_color palette[16] = {
+ {198, 198, 198}, /* 1: light gray */
+ {127, 127, 127}, /* 2: medium/dark gray */
+ {255, 0, 0}, /* 3: bright red */
+ {139, 0, 0}, /* 4: dark red */
+ { 0, 255, 0}, /* 5: bright green */
+ { 0, 139, 0}, /* 6: dark green */
+ { 0, 0, 255}, /* 7: bright blue */
+ { 0, 0, 139}, /* 8: dark blue */
+ {255, 255, 0}, /* 9: yellow */
+ {139, 126, 10}, /* 10: olivey brown */
+ {255, 165, 0}, /* 11: orange */
+ {255, 192, 203}, /* 12: pink */
+ {255, 0, 255}, /* 13: magenta */
+ {139, 0, 139}, /* 14: dark magenta */
+ { 0, 255, 255}, /* 15: cyan */
+ { 0, 139, 139} /* 16: dark cyan */
+};
typedef struct {
int field;
diff -ru display/d.vect.cvs/plot1.c display/d.vect/plot1.c
--- display/d.vect.cvs/plot1.c 2005-08-09 13:26:59.000000000 +0200
+++ display/d.vect/plot1.c 2005-10-20 18:34:13.000000000 +0200
@@ -7,12 +7,14 @@
#include "plot.h"
#include "symbol.h"
#include "glocale.h"
+#include "dbmi.h"
int plot1 (
struct Map_info *Map, int type, int area,
- struct cat_list *Clist, int color, int fcolor, int chcat, SYMBOL *Symb, int size, int id_flag)
+ struct cat_list *Clist, int color, int fcolor, int chcat, SYMBOL *Symb, int size, int id_flag,
+ int table_colors_flag, int cats_color_flag)
{
- int i, j, k, ltype, nlines = 0, line;
+ int i, j, k, ltype, nlines = 0, line, cat = -1;
double *x, *y, xd, yd, xd0 = 0, yd0 = 0;
struct line_pnts *Points, *PPoints;
struct line_cats *Cats;
@@ -21,17 +23,61 @@
SYMBCHAIN *chain;
int x0, y0, xp, yp;
- msize = size * ( D_d_to_u_col(2.0) - D_d_to_u_col(1.0) ); /* do it better */
+ struct field_info *fi = NULL;
+ dbDriver *driver = NULL;
+ dbCatValArray cvarr;
+ dbCatVal *cv_rgb = NULL;
+ int nrec;
+
+ int rgb; /* 0|1 */
+ char colorstring[12]; /* RRR:GGG:BBB */
+ int red, grn, blu;
+ unsigned char which;
+
+ msize = size * ( D_d_to_u_col(2.0) - D_d_to_u_col(1.0 ) ); /* do it better */
Points = Vect_new_line_struct ();
PPoints = Vect_new_line_struct ();
Cats = Vect_new_cats_struct ();
-
+
+ if( table_colors_flag ) {
+ /* for reading RRR:GGG:BBB color strings from table */
+ db_CatValArray_init (&cvarr);
+
+ fi = Vect_get_field (Map, Clist -> field);
+ if (fi == NULL) {
+ G_fatal_error(_("Cannot read field info"));
+ }
+
+ driver = db_start_driver_open_database(fi->driver, fi->database);
+ if (driver == NULL)
+ G_fatal_error(_("Cannot open database %s by driver %s"), fi->database, fi->driver);
+
+ nrec = db_select_CatValArray(driver, fi->table, fi->key,
+ "GRASSRGB", NULL, &cvarr);
+
+ G_debug (3, "nrec (grassrgb) = %d", nrec);
+
+ if (cvarr.ctype != DB_C_TYPE_STRING)
+ G_fatal_error (_("Column type (grassrgb) not supported"));
+
+ if ( nrec < 0 ) G_fatal_error (_("Cannot select data (grassrgb) from table"));
+
+ G_debug(2, "\n%d records selected from table", nrec);
+
+ db_close_database_shutdown_driver(driver);
+
+ for ( i = 0; i < cvarr.n_values; i++ ) {
+ G_debug (4, "cat = %d grassrgb = %d", cvarr.value[i].cat,
+ db_get_string(cvarr.value[i].val.s));
+ }
+ }
+
Vect_rewind ( Map );
/* Is it necessary to reset line/label color in each loop ? */
- if ( color > -1 ) R_color(color) ;
+ if ( color > -1 && !table_colors_flag && !cats_color_flag) R_color(color) ;
if ( Vect_level ( Map ) >= 2 )
nlines = Vect_get_num_lines ( Map );
@@ -67,12 +113,72 @@
for ( i = 0; i < Cats->n_cats; i++ ) {
if ( Cats->field[i] == Clist->field && Vect_cat_in_cat_list ( Cats->cat[i], Clist) ) {
found = 1;
+ cat = Cats->cat[i];
break;
}
}
if (!found) continue;
}
}
+
+ if( table_colors_flag ) {
+
+ cat=Vect_get_line_cat ( Map, line, Clist->field ); /* only first category */
+
+ if (cat >= 0) {
+ G_debug (3, "display element %d, cat %d", line, cat);
+
+ /* Read RGB colors from db for current area # */
+
+ if (db_CatValArray_get_value (&cvarr, cat, &cv_rgb) != DB_OK) {
+ rgb = 0;
+ }
+ else {
+ sprintf (colorstring, "%s", db_get_string(cv_rgb -> val.s));
+
+ if (strlen(colorstring) != 0) {
+ G_debug(3, "element %d: colorstring: %s", line, colorstring);
+
+ if ( G_str_to_color(colorstring, &red, &grn, &blu) ) {
+ rgb = 1;
+ G_debug(3, "element:%d cat %d r:%d g:%d b:%d", line, cat, red, grn, blu);
+ }
+ else {
+ rgb = 0;
+ G_warning(_("Error in color definition column GRASSRGB, element %d with cat %d: colorstring %s"), line, cat, colorstring);
+ }
+ }
+ else {
+ rgb = 0;
+ G_warning(_("Error in color definition column GRASSRGB, element %d with cat %d"), line, cat);
+ }
+ }
+ } /* end if cat */
+ else {
+ rgb = 0;
+ }
+ } /* end if table_colors_flag */
+
+ /* random colors */
+ if( cats_color_flag ) {
+ cat=Vect_get_line_cat ( Map, line, Clist->field );
+ if( cat >= 0 ){
+ G_debug (3, "display element %d, cat %d", line, cat);
+ /* fetch color number from category */
+ which = (cat % palette_ncolors);
+ G_debug(3,"cat:%d which color:%d r:%d g:%d b:%d", cat, which,
+ palette[which].R, palette[which].G, palette[which].B);
+
+ rgb = 1;
+ red = palette[which].R;
+ grn = palette[which].G;
+ blu = palette[which].B;
+
+ }
+ else {
+ rgb = 0;
+ }
+ }
x = Points->x;
y = Points->y;
@@ -91,10 +197,20 @@
if ( (part->fcolor.color == S_COL_DEFAULT && fcolor > -1) ||
part->fcolor.color == S_COL_DEFINED )
{
- if ( part->fcolor.color == S_COL_DEFAULT )
+ if (!table_colors_flag && !cats_color_flag) {
+ if ( part->fcolor.color == S_COL_DEFAULT )
R_color(fcolor);
- else
+ else
R_RGB_color ( part->fcolor.r, part->fcolor.g, part->fcolor.b );
+ }
+ else {
+ if (rgb) {
+ R_RGB_color ((unsigned char) red, (unsigned char) grn, (unsigned char) blu);
+ }
+ else {
+ R_color (fcolor);
+ }
+ }
Vect_reset_line ( PPoints );
@@ -124,7 +240,7 @@
} else {
R_RGB_color ( part->color.r, part->color.g, part->color.b );
}
-
+
for ( j = 0; j < part->count; j++ ) {
chain = part->chain[j];
for ( k = 0; k < chain->scount; k++ ) {
@@ -141,8 +257,25 @@
break;
case S_STRING:
if ( part->color.color == S_COL_NONE ) break;
- else if ( part->color.color == S_COL_DEFAULT ) R_color(color) ;
- else R_RGB_color ( part->color.r, part->color.g, part->color.b );
+ else {
+ if (!table_colors_flag && !cats_color_flag) {
+ if ( part->color.color == S_COL_DEFAULT ) R_color(color) ;
+ else R_RGB_color ( part->color.r, part->color.g, part->color.b );
+ }
+ else {
+ if (ltype == GV_CENTROID) {
+ R_color (color);
+ }
+ else {
+ if (rgb) {
+ R_RGB_color ((unsigned char) red, (unsigned char) grn, (unsigned char) blu);
+ }
+ else {
+ R_color (color);
+ }
+ }
+ }
+ }
chain = part->chain[0];
@@ -156,8 +289,18 @@
break;
}
}
- if (color > -1) R_color(color) ; /* Reset color */
- } else if (color > -1 ) {
+ } else if (color > -1 ) {
+ if (!table_colors_flag && !cats_color_flag) {
+ R_color (color);
+ }
+ else {
+ if (rgb) {
+ R_RGB_color ((unsigned char) red, (unsigned char) grn, (unsigned char) blu);
+ }
+ else {
+ R_color (color);
+ }
+ }
if ( Points->n_points == 1 ) { /* line with one coor */
G_plot_line(x[0], y[0], x[0], y[0]);
} else {
-------------- 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;
}
More information about the grass-dev
mailing list