[GRASS-dev] display/drivers/HTMLMAP status

Glynn Clements glynn at gclements.plus.com
Wed Feb 14 08:44:42 EST 2007


Hamish wrote:

> > It's relying upon the fact that a specific sequence of horizontal
> > lines is indistinguishable from a filled polygon with the existing
> > X/PNG drivers.
> > 
> > > Will the current d.vect method be faster than using lib fns which
> > > will take time rendering polygons which will end up being off
> > > screen?
> > 
> > It depends upon the specific case.
> 
> I'll throw in my typical vector case: a high resolution vector coastline
> of the entire country + the 1000s of nearshore islands, all stored in
> a single vector map.

Could you apply the attached patch, and tell me how much difference it
makes in your typical cases?

-- 
Glynn Clements <glynn at gclements.plus.com>

-------------- next part --------------
? display/d.vect/OBJ.i686-pc-linux-gnu
Index: display/d.vect/area.c
===================================================================
RCS file: /grassrepository/grass6/display/d.vect/area.c,v
retrieving revision 1.28
diff -u -r1.28 area.c
--- display/d.vect/area.c	13 Feb 2007 18:04:56 -0000	1.28
+++ display/d.vect/area.c	14 Feb 2007 13:43:47 -0000
@@ -13,6 +13,28 @@
 #include "plot.h"
 #include "local_proto.h"
 
+static void plot_polygon(const double *xf, const double *yf, int n)
+{
+	static int *xi, *yi;
+	static int nalloc;
+	int i;
+
+	if (nalloc < n)
+	{
+		nalloc = n;
+		xi = G_realloc(xi, nalloc * sizeof(int));
+		yi = G_realloc(yi, nalloc * sizeof(int));
+	}
+
+	for (i = 0; i < n; i++)
+	{
+		xi[i] = (int) floor(0.5 + D_u_to_d_col(xf[i]));
+		yi[i] = (int) floor(0.5 + D_u_to_d_row(yf[i]));
+	}
+
+	R_polygon_abs(xi, yi, n);
+}
+
 int darea ( struct Map_info *Map, struct cat_list *Clist,
 	    const struct color_rgb *bcolor, const struct color_rgb *fcolor, 
 	    int chcat, int id_flag, int table_colors_flag, int cats_color_flag,
@@ -308,7 +330,7 @@
 	if ( fcolor ) {
 	  if (!table_colors_flag && !cats_color_flag) {
 	    R_RGB_color(fcolor->r, fcolor->g, fcolor->b);
-	    G_plot_polygon ( Points->x, Points->y, Points->n_points);
+	    plot_polygon ( Points->x, Points->y, Points->n_points);
 	  }
 	  else {
 	    if (rgb) {
@@ -318,7 +340,7 @@
 	      R_RGB_color(fcolor->r, fcolor->g, fcolor->b);
 	    }
 	    if (cat >= 0) {
-	      G_plot_polygon ( Points->x, Points->y, Points->n_points);
+	      plot_polygon ( Points->x, Points->y, Points->n_points);
 	    }
 	  }
 	}
Index: display/d.vect/plot1.c
===================================================================
RCS file: /grassrepository/grass6/display/d.vect/plot1.c,v
retrieving revision 1.24
diff -u -r1.24 plot1.c
--- display/d.vect/plot1.c	13 Feb 2007 18:04:56 -0000	1.24
+++ display/d.vect/plot1.c	14 Feb 2007 13:43:48 -0000
@@ -11,6 +11,28 @@
 #include <grass/glocale.h>
 #include <grass/dbmi.h>
 
+static void plot_polygon(const double *xf, const double *yf, int n)
+{
+	static int *xi, *yi;
+	static int nalloc;
+	int i;
+
+	if (nalloc < n)
+	{
+		nalloc = n;
+		xi = G_realloc(xi, nalloc * sizeof(int));
+		yi = G_realloc(yi, nalloc * sizeof(int));
+	}
+
+	for (i = 0; i < n; i++)
+	{
+		xi[i] = (int) floor(0.5 + D_u_to_d_col(xf[i]));
+		yi[i] = (int) floor(0.5 + D_u_to_d_row(yf[i]));
+	}
+
+	R_polygon_abs(xi, yi, n);
+}
+
 int plot1 (
     struct Map_info *Map, int type, int area,  struct cat_list *Clist,
     const struct color_rgb *color, const struct color_rgb *fcolor,
@@ -333,8 +355,8 @@
 				    Vect_append_point ( PPoints, xd0, yd0, 0.0);
 				}
 			    }
-			    
-			    G_plot_polygon ( PPoints->x, PPoints->y, PPoints->n_points);
+
+			    plot_polygon ( PPoints->x, PPoints->y, PPoints->n_points);
 
 			}
 			if ( (part->color.color == S_COL_DEFAULT && color ) ||


More information about the grass-dev mailing list