Browse Source

symbols: add x and y scale attribute to get symbol size in both dimensions, which is needed for vector legend layout

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@68961 15284696-431f-4ddb-bdfa-cd5b030d7da7
Anna Petrášová 9 years ago
parent
commit
f583718100
2 changed files with 10 additions and 4 deletions
  1. 2 0
      include/symbol.h
  2. 8 4
      lib/symbol/read.c

+ 2 - 0
include/symbol.h

@@ -67,6 +67,8 @@ typedef struct
 typedef struct
 {
     double scale;		/* to get symbol of size 1, each vertex must be multiplied by this scale */
+    double yscale;		/* scale in x dimension */
+    double xscale;		/* scale in y dimension */
     int count, alloc;		/* numer of parts */
     SYMBPART **part;		/* objects ( parts ) */
 } SYMBOL;

+ 8 - 4
lib/symbol/read.c

@@ -312,10 +312,14 @@ SYMBOL *S_read(const char *sname)
 		sprintf(buf, "Incorrect box definition: '%s'", data);
 		return (err(fp, symb, buf));
 	    }
-	    if (x2 - x > y2 - y)
-		symb->scale = 1 / (x2 - x);
-	    else
-		symb->scale = 1 / (y2 - y);
+	    symb->xscale = 1 / (x2 - x);
+	    symb->yscale = 1 / (y2 - y);
+	    if (x2 - x > y2 - y) {
+		symb->scale = symb->xscale;
+	    }
+	    else {
+		symb->scale = symb->yscale;
+	    }
 	}
 	else if (strcmp(key, "STRING") == 0) {
 	    G_debug(4, "  STRING >");