[GRASS-SVN] r36690 - grass/trunk/display/d.grid
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Apr 11 21:15:12 EDT 2009
Author: hcho
Date: 2009-04-11 21:15:12 -0400 (Sat, 11 Apr 2009)
New Revision: 36690
Modified:
grass/trunk/display/d.grid/fiducial.c
grass/trunk/display/d.grid/main.c
Log:
Fixed text placement.
Added -a flag to align the origin to the upper-right corner of the current region.
size=0 sets grid size to the north-south resolution of the current region.
"g.region rast=dem; d.grid size=0 -a" will draw grids that align with dem cells.
Modified: grass/trunk/display/d.grid/fiducial.c
===================================================================
--- grass/trunk/display/d.grid/fiducial.c 2009-04-12 01:01:54 UTC (rev 36689)
+++ grass/trunk/display/d.grid/fiducial.c 2009-04-12 01:15:12 UTC (rev 36690)
@@ -25,13 +25,9 @@
SYMBOL *Symb;
RGBA_Color *line_color, *fill_color;
int R, G, B;
- int x0, y0;
int size = 16;
int tolerance = 0;
- x0 = (int)(D_u_to_d_col(easting) + 0.5);
- y0 = (int)(D_u_to_d_row(northing) + 0.5);
-
line_color = G_malloc(sizeof(RGBA_Color));
fill_color = G_malloc(sizeof(RGBA_Color));
@@ -52,7 +48,7 @@
G_fatal_error(_("Reading symbol"));
S_stroke(Symb, size, rotation, tolerance);
- D_symbol(Symb, x0, y0, line_color, fill_color);
+ D_symbol(Symb, easting, northing, line_color, fill_color);
G_free(line_color);
G_free(fill_color);
Modified: grass/trunk/display/d.grid/main.c
===================================================================
--- grass/trunk/display/d.grid/main.c 2009-04-12 01:01:54 UTC (rev 36689)
+++ grass/trunk/display/d.grid/main.c 2009-04-12 01:15:12 UTC (rev 36690)
@@ -40,9 +40,10 @@
struct GModule *module;
struct Option *opt1, *opt2, *opt3, *opt4, *fsize, *tcolor;
struct Flag *noborder, *notext, *geogrid, *nogrid, *wgs84, *cross,
- *fiducial;
+ *fiducial, *align;
struct pj_info info_in; /* Proj structures */
struct pj_info info_out; /* Proj structures */
+ struct Cell_head wind;
/* Initialize the GIS calls */
G_gisinit(argv[0]);
@@ -58,7 +59,7 @@
opt2->key_desc = "value";
opt2->type = TYPE_STRING;
opt2->required = YES;
- opt2->label = _("Size of grid to be drawn");
+ opt2->label = _("Size of grid to be drawn (0: north-south resolution of the current region)");
opt2->description = _("In map units or DDD:MM:SS format. "
"Example: \"1000\" or \"0:10\"");
@@ -94,6 +95,10 @@
fsize->options = "1-72";
fsize->description = _("Font size for gridline coordinate labels");
+ align = G_define_flag();
+ align->key = 'a';
+ align->description = _("Align the origin to the east-north vertex of the current region");
+
geogrid = G_define_flag();
geogrid->key = 'g';
geogrid->description =
@@ -157,28 +162,43 @@
if (fiducial->answer)
mark_type = MARK_FIDUCIAL;
- /* get grid size */
- if (geogrid->answer) {
- if (!G_scan_resolution(opt2->answer, &gsize, PROJECTION_LL) ||
- gsize <= 0.0)
- G_fatal_error(_("Invalid geo-grid size <%s>"), opt2->answer);
- }
- else {
- if (!G_scan_resolution(opt2->answer, &size, G_projection()) ||
- size <= 0.0)
- G_fatal_error(_("Invalid grid size <%s>"), opt2->answer);
- }
+ if (align->answer || strcmp(opt2->answer, "0") == 0)
+ G__get_window(&wind, "", "WIND", G_mapset());
- /* get grid easting start */
- if (!G_scan_easting(opt3->answers[0], &east, G_projection())) {
- G_usage();
- G_fatal_error(_("Illegal east coordinate <%s>"), opt3->answers[0]);
+ if (strcmp(opt2->answer, "0") == 0) {
+ if (geogrid->answer)
+ gsize = wind.ns_res;
+ else
+ size = wind.ns_res;
+ } else {
+ /* get grid size */
+ if (geogrid->answer) {
+ if (!G_scan_resolution(opt2->answer, &gsize, PROJECTION_LL) ||
+ gsize <= 0.0)
+ G_fatal_error(_("Invalid geo-grid size <%s>"), opt2->answer);
+ }
+ else {
+ if (!G_scan_resolution(opt2->answer, &size, G_projection()) ||
+ size <= 0.0)
+ G_fatal_error(_("Invalid grid size <%s>"), opt2->answer);
+ }
}
- /* get grid northing start */
- if (!G_scan_northing(opt3->answers[1], &north, G_projection())) {
- G_usage();
- G_fatal_error(_("Illegal north coordinate <%s>"), opt3->answers[1]);
+ if (align->answer) {
+ east = wind.east;
+ north = wind.north;
+ } else {
+ /* get grid easting start */
+ if (!G_scan_easting(opt3->answers[0], &east, G_projection())) {
+ G_usage();
+ G_fatal_error(_("Illegal east coordinate <%s>"), opt3->answers[0]);
+ }
+
+ /* get grid northing start */
+ if (!G_scan_northing(opt3->answers[1], &north, G_projection())) {
+ G_usage();
+ G_fatal_error(_("Illegal north coordinate <%s>"), opt3->answers[1]);
+ }
}
/* Setup driver and check important information */
More information about the grass-commit
mailing list