PS.MAP LINE CATEGORY SELECTION

Janne Soimasuo jsoi at gis.joensuu.fi
Thu Sep 1 10:23:07 EDT 1994


Here is my patches for ps.map.
It enables user to choose a category of a line for printing.
So you can print lines in the same file with different styles.
It works only for level 2 or higher lines (both lines and area edges).
And you can use it only with non-interactive mode.

vector section has now a new option: line_cat #
here is an example:
vect example
  color red
  width 1
  line_cat 10
  end

********************************************************************************
* Janne Soimasuo            *     phone +358-73-151 4519                       *
* GIS & RS lab.             *     fax   +358-73-151 3590                       *
* Faculty of Forestry       *                                                  *
* University of Joensuu     *     email janne.soimasuo at joensuu.fi              *
*                           *           jsoi at gis.joensuu.fi                    *
* P.O.BOX 111               *                                                  *
* FIN-80101 JOENSUU         * "There never enough time to do all the nothing   *
* FINLAND                   *  you want"  Calvin                               *
********************************************************************************
The patch file:

diff -u --recursive ../src.alpha/ps.map/ps.map/cmd/do_vectors.c ps.map/cmd/do_vectors.c
--- ../src.alpha/ps.map/ps.map/cmd/do_vectors.c	Tue May 10 13:05:26 1994
+++ ps.map/cmd/do_vectors.c	Thu Sep  1 09:41:02 1994
@@ -1,6 +1,7 @@
 /* Function: do_vectors
 **
 ** Author: Paul W. Carlson	March 1992
+** Modified by: Janne Soimasuo August 1994 line_cat added
 */
 
 #include "ps_info.h"
@@ -27,7 +28,9 @@
 	    fflush(stdout);
 	}
 
+/*
 	Vect_set_open_level(1);
+*/
 	if (0 >= Vect_open_old(&Map, vector.name[n], vector.mapset[n]))
 	{
 	    char name[100];
@@ -96,7 +99,7 @@
 	strcat(dashes, buf);
 	fprintf(PS.fp, "%s setdash\n", dashes);
 	vector.setdash[n] = G_store(dashes);
-	PS_vector_plot(&Map);
+	PS_vector_plot(&Map,vector.line_cat[n]);
 	Vect_close(&Map);
 
 	fprintf(PS.fp, "[] 0 setdash\n");
diff -u --recursive ../src.alpha/ps.map/ps.map/cmd/ps_vector.c ps.map/cmd/ps_vector.c
--- ../src.alpha/ps.map/ps.map/cmd/ps_vector.c	Tue May 10 13:05:27 1994
+++ ps.map/cmd/ps_vector.c	Thu Sep  1 09:43:59 1994
@@ -2,16 +2,18 @@
 **
 ** Author: Paul W. Carlson	March 1992
 ** modified to use G_plot_line() by Olga Waupotitsch on dec,93
+** Modified by: Janne Soimasuo August 1994 line_cat added
 */
 
 #include "Vect.h"
 #include "ps_info.h"
 
-PS_vector_plot(P_map)
+PS_vector_plot(P_map,line_cat)
 struct Map_info *P_map;
+int line_cat;
 {
     struct line_pnts *Points;
-    int i, k, np;
+    int i, k, np, line=0;
     double *xarray, *yarray;
 
     /* allocate memory for coordinates */
@@ -20,19 +22,22 @@
     /* process only vectors in current window */
     Vect_set_constraint_region(P_map, PS.w.north, PS.w.south, 
 		PS.w.east, PS.w.west);
-
     /* read and plot vectors */
     k = 0;
     
     while (1)
     {
 	int ret;
-
-	if (0 > (ret = Vect_read_next_line(P_map, Points)))
+	line++;
+/*	if (0 > (ret = Vect_read_next_line(P_map, Points)))*/
+	if (0 > (ret = V2_read_line(P_map, Points,line)))
 	{
 	    if (ret == -1) G_warning("Read error in vector file\n");
 	    break;
 	}
+
+        if (line_cat< 0 || V2_line_att(P_map,line)==line_cat)
+        {
 	np = Points->n_points;
 	xarray = Points->x;
 	yarray = Points->y;
@@ -57,6 +62,7 @@
 	    yarray++;
 	}
 	fprintf(PS.fp, "D\n");
+        }
     }
     fprintf(PS.fp, "\n");
     return 0;
diff -u --recursive ../src.alpha/ps.map/ps.map/cmd/vectfile.c ps.map/cmd/vectfile.c
--- ../src.alpha/ps.map/ps.map/cmd/vectfile.c	Tue May 10 13:05:27 1994
+++ ps.map/cmd/vectfile.c	Thu Sep  1 09:41:46 1994
@@ -3,6 +3,7 @@
 ** This PostScript version is just slightly modified p.map code.
 **
 ** Modified by: Paul W. Carlson		March 1992
+** Modified by: Janne Soimasuo August 1994 line_cat added
 */
 #include "vector.h"
 #include "Vect.h"
@@ -12,12 +13,13 @@
 
 static char *help[]=
 {
-    "color   color",
-    "width   #",
-    "hcolor  color",
-    "hwidth  #",
-    "masked  [y|n]",
-    "style   solid|[0-9]...",
+    "color    color",
+    "width    #",
+    "hcolor   color",
+    "hwidth   #",
+    "masked   [y|n]",
+    "style    solid|[0-9]...",
+    "line_cat #",
     ""
 };
 
@@ -30,6 +32,7 @@
     char temp[100];
     char *key, *data, *dp;
     double  width;
+    int line_cat;
     int color;
     int r, g, b;
     int i;
@@ -62,7 +65,9 @@
     vector.linestyle[vector.count] = NULL;
     vector.hwidth[vector.count] = 0. ;
     vector.hcolor[vector.count] = WHITE;
+    vector.line_cat[vector.count] = -1 ;
 
+
     got_color = 0;
     while (input(2, buf, help))
     {
@@ -166,6 +171,18 @@
 	/*  if (!vector.hwidth[vector.count]) vector.hwidth[vector.count] = 1;*/
 	    continue;
 	}
+        if (KEY("line_cat"))
+        {
+            if (sscanf(data, "%d", &line_cat) < 1 )
+            {
+                line_cat = -1;
+                error(key, data, "illegal line_cat(egory)");
+                continue;
+            }
+            vector.line_cat[vector.count] = line_cat;
+	    continue;
+         }
+
 
 	error(key, "", "illegal request");
     }
diff -u --recursive ../src.alpha/ps.map/ps.map/cmd/vector.h ps.map/cmd/vector.h
--- ../src.alpha/ps.map/ps.map/cmd/vector.h	Tue May 10 13:05:27 1994
+++ ps.map/cmd/vector.h	Thu Sep  1 09:42:00 1994
@@ -1,3 +1,4 @@
+/** Modified by: Janne Soimasuo August 1994 line_cat added **/
 #define MAXVECTORS 20
 
 struct vector
@@ -16,6 +17,7 @@
     char masked[MAXVECTORS];
     char *name[MAXVECTORS];
     char *mapset[MAXVECTORS];
+    int line_cat[MAXVECTORS];
 } ;
 
 #ifdef MAIN



More information about the grass-user mailing list