[GRASS-SVN] r46385 - grass/branches/releasebranch_6_4/ps/ps.map
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 23 08:11:49 EDT 2011
Author: hamish
Date: 2011-05-23 05:11:48 -0700 (Mon, 23 May 2011)
New Revision: 46385
Modified:
grass/branches/releasebranch_6_4/ps/ps.map/description.html
grass/branches/releasebranch_6_4/ps/ps.map/eps.c
grass/branches/releasebranch_6_4/ps/ps.map/labels.h
grass/branches/releasebranch_6_4/ps/ps.map/map_info.c
grass/branches/releasebranch_6_4/ps/ps.map/ps_header.c
grass/branches/releasebranch_6_4/ps/ps.map/r_labels.c
grass/branches/releasebranch_6_4/ps/ps.map/r_plt.c
grass/branches/releasebranch_6_4/ps/ps.map/r_vareas.c
Log:
merge various enhancements from devbr6
Modified: grass/branches/releasebranch_6_4/ps/ps.map/description.html
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/description.html 2011-05-23 11:35:07 UTC (rev 46384)
+++ grass/branches/releasebranch_6_4/ps/ps.map/description.html 2011-05-23 12:11:48 UTC (rev 46385)
@@ -924,7 +924,9 @@
<EM>rgb</EM> option, count as a raster map layer for the
purposes of the preceding paragraph.
<P>
-
+The PostScript file's internal title will be set to the raster map's
+title, which in turn may be set with the <em>r.suppport</em> module.
+<P>
This example would paint a map of the raster map layer <EM>soils</EM>.
<PRE>
@@ -1614,7 +1616,7 @@
The following are examples of <EM>ps.map</EM> script files.
<P>
-<h3>Simple example</h3>
+<h4>Simple example</h4>
The file has been named <EM>spear.basic</EM>:
<PRE>
@@ -1634,7 +1636,7 @@
</PRE>
-<h3>More complicated example</h3>
+<h4>More complicated example</h4>
The file has been named <EM>spear.soils</EM>:
<PRE>
Modified: grass/branches/releasebranch_6_4/ps/ps.map/eps.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/eps.c 2011-05-23 11:35:07 UTC (rev 46384)
+++ grass/branches/releasebranch_6_4/ps/ps.map/eps.c 2011-05-23 12:11:48 UTC (rev 46385)
@@ -1,5 +1,6 @@
#include <math.h>
#include <string.h>
+#include <grass/glocale.h>
#include "ps_info.h"
#include "local_proto.h"
@@ -15,7 +16,7 @@
/* test if file is realy eps and find bbox */
if ((fp = fopen(eps, "r")) == NULL) {
- fprintf(stderr, "can't open eps file <%s>\n", eps);
+ G_warning(_("Can't open eps file <%s>"), eps);
return (0);
}
/* test if first row contains '%!PS-Adobe-m.n EPSF-m.n' string */
@@ -34,7 +35,7 @@
return (1);
}
}
- fprintf(stderr, "Bounding box in eps file <%s> was not found\n", eps);
+ G_warning(_("Bounding box in eps file <%s> was not found"), eps);
fclose(fp);
return (0);
}
Modified: grass/branches/releasebranch_6_4/ps/ps.map/labels.h
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/labels.h 2011-05-23 11:35:07 UTC (rev 46384)
+++ grass/branches/releasebranch_6_4/ps/ps.map/labels.h 2011-05-23 12:11:48 UTC (rev 46385)
@@ -1,4 +1,4 @@
-#define MAXLABELS 10
+#define MAXLABELS 50
struct labels
{
Modified: grass/branches/releasebranch_6_4/ps/ps.map/map_info.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/map_info.c 2011-05-23 11:35:07 UTC (rev 46384)
+++ grass/branches/releasebranch_6_4/ps/ps.map/map_info.c 2011-05-23 12:11:48 UTC (rev 46385)
@@ -26,6 +26,7 @@
/* get text location */
dy = fontsize;
+
if (m_info.x > 0.0)
x = 72.0 * m_info.x;
else
@@ -34,7 +35,9 @@
y = 72.0 * (PS.page_height - m_info.y);
else
y = PS.min_y;
+
margin = 0.2 * fontsize;
+
if (x < PS.map_left + margin)
x = PS.map_left + margin;
Modified: grass/branches/releasebranch_6_4/ps/ps.map/ps_header.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/ps_header.c 2011-05-23 11:35:07 UTC (rev 46384)
+++ grass/branches/releasebranch_6_4/ps/ps.map/ps_header.c 2011-05-23 12:11:48 UTC (rev 46385)
@@ -5,6 +5,7 @@
#include <stdio.h>
#include <unistd.h>
+#include <grass/gis.h>
#include "ps_info.h"
static long bb_offset;
@@ -13,6 +14,12 @@
int write_PS_header(void)
{
+ struct Categories cats;
+ int cats_ok;
+
+ if (PS.do_raster)
+ cats_ok = G_read_cats(PS.cell_name, PS.cell_mapset, &cats) >= 0;
+
/* write PostScript header */
/*fprintf(PS.fp, "%%!PS-Adobe-2.0 EPSF-1.2\n"); */
if (eps_output)
@@ -24,9 +31,10 @@
fprintf(PS.fp, " ");
fprintf(PS.fp, " \n");
fprintf(PS.fp, "%%%%Title: ");
- if (PS.do_raster)
- fprintf(PS.fp, "Map layer = %s ", PS.cell_name);
- fprintf(PS.fp, "Mapset = %s\n", PS.cell_mapset);
+ if (PS.do_raster && cats_ok)
+ fprintf(PS.fp, "%s\n", cats.title);
+ else
+ fprintf(PS.fp, "Mapset = %s\n", PS.cell_mapset);
fprintf(PS.fp, "%%%%EndComments\n");
return 0;
Modified: grass/branches/releasebranch_6_4/ps/ps.map/r_labels.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/r_labels.c 2011-05-23 11:35:07 UTC (rev 46384)
+++ grass/branches/releasebranch_6_4/ps/ps.map/r_labels.c 2011-05-23 12:11:48 UTC (rev 46385)
@@ -12,7 +12,7 @@
int read_labels(char *name, char *mapset)
{
- char fullname[100];
+ char fullname[GNAME_MAX+GMAPSET_MAX+5];
char buf[1024];
char *key, *data;
Modified: grass/branches/releasebranch_6_4/ps/ps.map/r_plt.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/r_plt.c 2011-05-23 11:35:07 UTC (rev 46384)
+++ grass/branches/releasebranch_6_4/ps/ps.map/r_plt.c 2011-05-23 12:11:48 UTC (rev 46385)
@@ -1,5 +1,6 @@
#include <string.h>
#include "ps_info.h"
+#include <grass/glocale.h>
#include "local_proto.h"
#define KEY(x)(strcmp(key,x)==0)
@@ -106,7 +107,7 @@
int read_eps(double e, double n)
{
- char buf[1024];
+ char buf[1024], eps_file[GPATH_MAX];
char *eps;
double scale, rotate;
int have_eps;
@@ -140,10 +141,21 @@
if (KEY("epsfile")) {
G_chop(data);
- eps = G_store(data);
+
+ /* expand "$GISBASE" if present */
+ if (strncmp(data, "$GISBASE", 8) != 0)
+ strcpy(eps_file, data);
+ else {
+ strcpy(eps_file, G_gisbase());
+ data += 8;
+ strcat(eps_file, data);
+ }
+
+ eps = G_store(eps_file);
+
/* test if file is accessible */
if ((fp = fopen(eps, "r")) == NULL)
- error(key, data, "Can't open eps file");
+ error(key, data, _("Can't open eps file"));
have_eps = 1;
fclose(fp);
Modified: grass/branches/releasebranch_6_4/ps/ps.map/r_vareas.c
===================================================================
--- grass/branches/releasebranch_6_4/ps/ps.map/r_vareas.c 2011-05-23 11:35:07 UTC (rev 46384)
+++ grass/branches/releasebranch_6_4/ps/ps.map/r_vareas.c 2011-05-23 12:11:48 UTC (rev 46385)
@@ -34,7 +34,7 @@
int read_vareas(char *name, char *mapset)
{
char fullname[GNAME_MAX + GMAPSET_MAX + 5];
- char buf[1024];
+ char buf[1024], eps_file[GPATH_MAX];
char *key, *data;
double width;
int itmp, vec;
@@ -172,7 +172,17 @@
if (KEY("pat") || KEY("pattern")) {
G_chop(data);
- vector.layer[vec].pat = G_store(data);
+
+ /* expand "$GISBASE" if present */
+ if (strncmp(data, "$GISBASE", 8) != 0)
+ strcpy(eps_file, data);
+ else {
+ strcpy(eps_file, G_gisbase());
+ data += 8;
+ strcat(eps_file, data);
+ }
+
+ vector.layer[vec].pat = G_store(eps_file);
continue;
}
More information about the grass-commit
mailing list