[GRASSLIST:3997] Re: ps.map grid in Lat/Lon
Hamish
hamish_nospam at yahoo.com
Thu Jul 22 20:18:19 EDT 2004
> > i'm want to overlay a map of a Lat/Lon location with a grid that
> > has less than 1 degree spacing.
> > is that possible? (geogrid is not available for lat/lon and if i use
> >
> > grid nothing happens when i choose a spacing less than 1)
> >
> I had a similar problem back with GRASS 5.0.0. I was told at the time
>
> that ps.map did not support floating point grids, hence the problem
> with lat-long locations. I don't know if it has been fixed, but a
> simple workaround is to make a vector grid with v.mkgrid and just
> display that along with whatever else you want with ps.map. Thanks to
>
> whomever suggested that to me.
The attached patch adds this to ps.map in GRASS 5.7.
Before trying that though you might try the "geogrid" command [5.7
only], which will draw a lat/lon grid over a non-Lat/Lon location map.
I haven't put this in CVS as it needs some checking over to make sure it
doesn't cause other problems (eg it tests grid==0 when 0 is now floating
point). Maybe someone with a keener eye for C than me can comment.
It might be better to just work on getting geogrid to do lat/lon?
Results on the map look great, formats text into deg:minutes, but you
may need to use a lot of precision to get 5-minute ticks to round
correctly. e.g., for 5' use something like "grid 0.08333333333333"
This makes the mapinfo command look pretty wonky for anything smaller
than 0.25 of a degree though. I guess G_format_easting() could fix that?
e.g., for the global lat/lon dataset: [zoom in]
ps.map out=test.ps << EOF
raster nations
grid 0.25
numbers 1
end
mapinfo
where 0.5 8.5
end
end
EOF
gv test.ps
Hamish
-------------- next part --------------
Index: main.c
===================================================================
RCS file: /home/grass/grassrepository/grass51/ps/ps.map/main.c,v
retrieving revision 1.6
diff -u -r1.6 main.c
--- main.c 27 Jan 2004 12:59:16 -0000 1.6
+++ main.c 22 Jul 2004 23:21:38 -0000
@@ -625,7 +625,7 @@
{
PS.grid = -1;
PS.grid_numbers = 0;
- sscanf(data, "%d", &PS.grid);
+ sscanf(data, "%lf", &PS.grid);
if (PS.grid < 0)
{
PS.grid = 0;
Index: ps_info.h
===================================================================
RCS file: /home/grass/grassrepository/grass51/ps/ps.map/ps_info.h,v
retrieving revision 1.3
diff -u -r1.3 ps_info.h
--- ps_info.h 27 Jan 2004 12:59:16 -0000 1.3
+++ ps_info.h 22 Jul 2004 23:21:38 -0000
@@ -41,12 +41,12 @@
int do_colortable;
int do_scalebar;
int num_psfiles;
- int grid, grid_color, grid_numbers, grid_numbers_color, grid_fontsize;
+ int grid_color, grid_numbers, grid_numbers_color, grid_fontsize;
float grid_cross;
+ double grid, grid_width, geogrid_width;
char geogridunit[64];
int geogrid, geogrid_color, geogrid_numbers;
int geogrid_numbers_color, geogrid_fontsize;
- double grid_width, geogrid_width;
int do_outline, outline_color;
int cell_fd;
int row_delta, col_delta;
Index: do_grid.c
===================================================================
RCS file: /home/grass/grassrepository/grass51/ps/ps.map/do_grid.c,v
retrieving revision 1.2
diff -u -r1.2 do_grid.c
--- do_grid.c 10 Jul 2003 17:59:32 -0000 1.2
+++ do_grid.c 22 Jul 2004 23:21:39 -0000
@@ -109,7 +109,8 @@
{
double g;
char num_text[50];
- int grid, vy, vx, hy=0, hx=0;
+ double grid;
+ int vy, vx, hy=0, hx=0;
int first, len, x, y, last_bottom, last_right;
int rounded_grid, margin;
@@ -120,7 +121,7 @@
rounded_grid = 1;
if (PS.w.proj != PROJECTION_LL)
{
- sprintf(num_text, "%d", PS.grid);
+ sprintf(num_text, "%lf", PS.grid);
len = strlen(num_text);
while (len-- && num_text[len] == '0') rounded_grid *= 10;
if (rounded_grid == 10) rounded_grid = 1;
Index: map_info.c
===================================================================
RCS file: /home/grass/grassrepository/grass51/ps/ps.map/map_info.c,v
retrieving revision 1.1
diff -u -r1.1 map_info.c
--- map_info.c 26 Mar 2003 15:56:15 -0000 1.1
+++ map_info.c 22 Jul 2004 23:21:39 -0000
@@ -47,7 +47,7 @@
{
k = 5.5;
sprintf(buf,
- "%d %s", PS.grid, G_database_unit_name(PS.grid != 1));
+ "%g %s", PS.grid, G_database_unit_name(PS.grid != 1));
fprintf(PS.fp, "(%s) SW pop /t2 XD\n", buf);
fprintf(PS.fp, "t1 t2 lt {/t1 t2 def} if \n");
}
@@ -74,7 +74,7 @@
if (PS.grid)
{
sprintf(buf,
- "%d %s", PS.grid, G_database_unit_name(PS.grid != 1));
+ "%g %s", PS.grid, G_database_unit_name(PS.grid != 1));
show_text(x, y - dy, "GRID:");
fprintf(PS.fp, "(%s) sx %.1f MS\n", buf, y - dy);
y -= dy;
More information about the grass-user
mailing list