[GRASS-SVN] r29880 - grass/trunk/display/d.grid

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 28 08:44:17 EST 2008


Author: hamish
Date: 2008-01-28 08:44:17 -0500 (Mon, 28 Jan 2008)
New Revision: 29880

Modified:
   grass/trunk/display/d.grid/local_proto.h
   grass/trunk/display/d.grid/main.c
   grass/trunk/display/d.grid/plot.c
Log:
second pass at adding support for cross marks instead of grid lines

Modified: grass/trunk/display/d.grid/local_proto.h
===================================================================
--- grass/trunk/display/d.grid/local_proto.h	2008-01-28 13:40:03 UTC (rev 29879)
+++ grass/trunk/display/d.grid/local_proto.h	2008-01-28 13:44:17 UTC (rev 29880)
@@ -1,8 +1,8 @@
 #include <grass/gprojects.h>
 
 /* plot.c */
-int plot_grid(double, double, double, int, int, int, int);
-int plot_geogrid(double, struct pj_info, struct pj_info, int, int, int, int);
+int plot_grid(double, double, double, int, int, int, int, int);
+int plot_geogrid(double, struct pj_info, struct pj_info, int, int, int, int, int);
 void init_proj(struct pj_info *, struct pj_info *, int);
 void get_ll_bounds(double *, double *, double *, double *, struct Cell_head, struct pj_info, struct pj_info);
 void check_coords(double, double, double *, double *, int, struct Cell_head, struct pj_info, struct pj_info);

Modified: grass/trunk/display/d.grid/main.c
===================================================================
--- grass/trunk/display/d.grid/main.c	2008-01-28 13:40:03 UTC (rev 29879)
+++ grass/trunk/display/d.grid/main.c	2008-01-28 13:44:17 UTC (rev 29880)
@@ -37,7 +37,7 @@
 	int colort = 0;
 	double size=0., gsize=0.; /* initialize to zero */
 	double east, north;
-	int do_text, fontsize;
+	int do_text, fontsize, mark_type;
 	struct GModule *module;
 	struct Option *opt1, *opt2, *opt3, *opt4, *fsize, *tcolor;
 	struct Flag *noborder, *notext, *geogrid, *nogrid, *wgs84, *cross, *fiducial;
@@ -101,7 +101,6 @@
 	wgs84->description =
 	    _("Draw geographic grid (referenced to WGS84 ellipsoid)");
 
-#ifdef NOTYET
 	cross = G_define_flag();
 	cross->key = 'c';
 	cross->description = _("Draw '+' marks instead of grid lines");
@@ -109,7 +108,6 @@
 	fiducial = G_define_flag();
 	fiducial->key = 'f';
 	fiducial->description = _("Draw fiducial marks instead of grid lines");
-#endif
 
 	nogrid = G_define_flag();
 	nogrid->key = 'n';
@@ -142,8 +140,9 @@
 	if(notext->answer) do_text = FALSE;
 	else do_text = TRUE;
 
-#ifdef NOTYET
-	int mark_type = MARK_GRID;
+	fontsize = atoi(fsize->answer);
+
+	mark_type = MARK_GRID;
 	if (cross->answer && fiducial->answer)
 		G_fatal_error(_("Chose a single mark style"));
 	if (cross->answer)
@@ -151,11 +150,6 @@
 	if (fiducial->answer)
 		mark_type = MARK_FIDUCIAL;
 
-	/* then pass mark_type to plot_grid() and plot_geogrid() */
-#endif
-
-	fontsize = atoi(fsize->answer);
-
 	/* get grid size */
 	if (geogrid->answer)
 	{
@@ -204,10 +198,10 @@
 		{
 			/* initialzie proj stuff */
 			init_proj(&info_in, &info_out, wgs84->answer);
-			plot_geogrid(gsize, info_in, info_out, do_text, colorg, colort, fontsize);
+			plot_geogrid(gsize, info_in, info_out, do_text, colorg, colort, fontsize, mark_type);
 		} else {
 			/* Do the grid plotting */
-			plot_grid(size, east, north, do_text, colorg, colort, fontsize);
+			plot_grid(size, east, north, do_text, colorg, colort, fontsize, mark_type);
 		}
 	}
 

Modified: grass/trunk/display/d.grid/plot.c
===================================================================
--- grass/trunk/display/d.grid/plot.c	2008-01-28 13:40:03 UTC (rev 29879)
+++ grass/trunk/display/d.grid/plot.c	2008-01-28 13:44:17 UTC (rev 29880)
@@ -10,9 +10,10 @@
 #include "local_proto.h"
 
 
-int plot_grid (double grid_size, double east, double north, int do_text, int gcolor, int tcolor, int fontsize)
+int plot_grid (double grid_size, double east, double north, int do_text,
+	       int gcolor, int tcolor, int fontsize, int mark_type)
 {
-	double x,y;
+	double x,y,y0;
 	double e1,e2;
 	struct Cell_head window ;
 	double row_dist, colm_dist;
@@ -39,9 +40,12 @@
 
 	while (x <= window.east)
 	{
-		D_raster_use_color(gcolor);
-		G_plot_line (x, window.north, x, window.south);
 
+		if(mark_type == MARK_GRID) {
+		    D_raster_use_color(gcolor);
+		    G_plot_line (x, window.north, x, window.south);
+		}
+
 		if(do_text) {
 		    D_raster_use_color(tcolor);
 		    G_format_easting(x, text, G_projection());
@@ -79,10 +83,12 @@
 
 	while (y <= window.north)
 	{
-		D_raster_use_color(gcolor);
-		G_plot_line (window.east, y, e1, y);
-		G_plot_line (e1, y, e2, y);
-		G_plot_line (e2, y, window.west, y);
+		if(mark_type == MARK_GRID) {
+		    D_raster_use_color(gcolor);
+		    G_plot_line (window.east, y, e1, y);
+		    G_plot_line (e1, y, e2, y);
+		    G_plot_line (e2, y, window.west, y);
+		}
 
 		if(do_text) {
 		    D_raster_use_color(tcolor);
@@ -102,12 +108,38 @@
 		y += grid_size;
 	}
 
+	/* draw marks not grid lines */
+	if(mark_type != MARK_GRID) {
+	    /* reset x and y */
+	    if (window.west > east)
+		x = ceil((window.west - east)/grid_size) * grid_size + east ;
+	    else
+		x = east - ceil((east - window.west)/grid_size) * grid_size ;
+	    if (window.south > north)
+		y0 = ceil((window.south - north)/grid_size) * grid_size + north ;
+	    else
+		y0 = north - ceil((north - window.south)/grid_size) * grid_size ;
+
+	    /* plot marks */
+	    while (x <= window.east) {
+	        y = y0; /* reset */
+		while (y <= window.north) {
+		    if(mark_type == MARK_CROSS)
+			plot_cross(x, y, gcolor, 0.0);
+		    if(mark_type == MARK_FIDUCIAL)
+			plot_fiducial(x, y, gcolor, 0.0);
+		    y += grid_size;
+		}
+		x += grid_size;
+	    }
+	}
+
 	return 0;
 }
 
 
 int plot_geogrid(double size, struct pj_info info_in, struct pj_info info_out,
-		 int do_text, int gcolor, int tcolor, int fontsize)
+		 int do_text, int gcolor, int tcolor, int fontsize, int mark_type)
 {
 	double g;
 	double e1, e2, n1, n2;



More information about the grass-commit mailing list