[GRASS-SVN] r57021 - in grass/trunk: include lib/symbol
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Jul 6 01:29:37 PDT 2013
Author: hamish
Date: 2013-07-06 01:29:37 -0700 (Sat, 06 Jul 2013)
New Revision: 57021
Modified:
grass/trunk/include/symbol.h
grass/trunk/lib/symbol/read.c
grass/trunk/lib/symbol/stroke.c
Log:
store stroked symbol coords as double not int to avoid some rounding wiggle
Modified: grass/trunk/include/symbol.h
===================================================================
--- grass/trunk/include/symbol.h 2013-07-05 11:43:12 UTC (rev 57020)
+++ grass/trunk/include/symbol.h 2013-07-06 08:29:37 UTC (rev 57021)
@@ -51,7 +51,7 @@
int count, alloc; /* number of elements */
SYMBEL **elem; /* array of elements */
int scount, salloc; /* number of points in stroked version */
- int *sx, *sy; /* coordinates in stroked version */
+ double *sx, *sy; /* coordinates in stroked version */
} SYMBCHAIN;
/* part */
Modified: grass/trunk/lib/symbol/read.c
===================================================================
--- grass/trunk/lib/symbol/read.c 2013-07-05 11:43:12 UTC (rev 57020)
+++ grass/trunk/lib/symbol/read.c 2013-07-06 08:29:37 UTC (rev 57021)
@@ -1,4 +1,3 @@
-
/****************************************************************************
*
* MODULE: Symbol library
@@ -14,6 +13,7 @@
* for details.
*
*****************************************************************************/
+
#include <stdlib.h>
#include <string.h>
#include <dirent.h>
Modified: grass/trunk/lib/symbol/stroke.c
===================================================================
--- grass/trunk/lib/symbol/stroke.c 2013-07-05 11:43:12 UTC (rev 57020)
+++ grass/trunk/lib/symbol/stroke.c 2013-07-06 08:29:37 UTC (rev 57021)
@@ -1,4 +1,3 @@
-
/****************************************************************************
*
* MODULE: Symbol library
@@ -14,6 +13,7 @@
* for details.
*
*****************************************************************************/
+
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
@@ -21,16 +21,14 @@
#define PI M_PI
-#define round(x) ((int) floor(0.5 + (x)))
-
-void add_coor(SYMBCHAIN *chain, int x, int y)
+void add_coor(SYMBCHAIN *chain, double x, double y)
{
- G_debug(5, " add_coor %d, %d", x, y);
+ G_debug(5, " add_coor %f, %f", x, y);
if (chain->scount == chain->salloc) {
chain->salloc += 10;
- chain->sx = (int *)G_realloc(chain->sx, chain->salloc * sizeof(int));
- chain->sy = (int *)G_realloc(chain->sy, chain->salloc * sizeof(int));
+ chain->sx = (double *)G_realloc(chain->sx, chain->salloc * sizeof(double));
+ chain->sy = (double *)G_realloc(chain->sy, chain->salloc * sizeof(double));
}
chain->sx[chain->scount] = x;
chain->sy[chain->scount] = y;
@@ -68,7 +66,7 @@
if (rotation != 0.0)
G_rotate_around_point(0, 0, &x, &y, rotation);
- add_coor(chain, round(x), round(y));
+ add_coor(chain, x, y);
if (first) {
x0 = x;
y0 = y;
@@ -101,7 +99,7 @@
if (rotation != 0.0)
G_rotate_around_point(0, 0, &x, &y, rotation);
- add_coor(chain, round(x), round(y));
+ add_coor(chain, x, y);
if (first) {
x0 = x;
y0 = y;
@@ -123,7 +121,7 @@
if (rotation != 0.0)
G_rotate_around_point(0, 0, &x, &y, rotation);
- add_coor(chain, round(x), round(y));
+ add_coor(chain, x, y);
if (first) {
x0 = x;
y0 = y;
@@ -140,7 +138,7 @@
}
}
if (part->type == S_POLYGON) {
- add_coor(chain, round(x0), round(y0)); /* Close ring */
+ add_coor(chain, x0, y0); /* Close ring */
}
return 0;
More information about the grass-commit
mailing list