[GRASS-SVN] r32648 - in grass/trunk/lib: cairodriver driver
htmldriver pngdriver psdriver raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 8 19:02:24 EDT 2008
Author: glynn
Date: 2008-08-08 19:02:24 -0400 (Fri, 08 Aug 2008)
New Revision: 32648
Added:
grass/trunk/lib/htmldriver/Polygon.c
Removed:
grass/trunk/lib/cairodriver/Client.c
grass/trunk/lib/driver/Client.c
grass/trunk/lib/htmldriver/Polygn_abs.c
grass/trunk/lib/pngdriver/Client.c
grass/trunk/lib/psdriver/Client.c
Modified:
grass/trunk/lib/cairodriver/Box.c
grass/trunk/lib/cairodriver/Driver.c
grass/trunk/lib/cairodriver/Poly.c
grass/trunk/lib/cairodriver/cairodriver.h
grass/trunk/lib/driver/Box.c
grass/trunk/lib/driver/Polydots.c
grass/trunk/lib/driver/Polygon.c
grass/trunk/lib/driver/Polyline.c
grass/trunk/lib/driver/driver.h
grass/trunk/lib/htmldriver/Driver.c
grass/trunk/lib/htmldriver/htmlmap.h
grass/trunk/lib/pngdriver/Box.c
grass/trunk/lib/pngdriver/Driver.c
grass/trunk/lib/pngdriver/Makefile
grass/trunk/lib/pngdriver/pngdriver.h
grass/trunk/lib/psdriver/Box.c
grass/trunk/lib/psdriver/Driver.c
grass/trunk/lib/psdriver/Polygon.c
grass/trunk/lib/psdriver/Polyline.c
grass/trunk/lib/psdriver/psdriver.h
grass/trunk/lib/raster/raster.c
Log:
Remove Client_{Open,Close} methods
Remove *_rel methods, remove _abs suffix from *_abs methods
Modified: grass/trunk/lib/cairodriver/Box.c
===================================================================
--- grass/trunk/lib/cairodriver/Box.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/cairodriver/Box.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -2,7 +2,7 @@
/* Box_abs: Draw a (filled) rectangle */
-void Cairo_Box_abs(int x1, int y1, int x2, int y2)
+void Cairo_Box(int x1, int y1, int x2, int y2)
{
G_debug(3, "Cairo_Box_abs %d %d %d %d\n", x1, y1, x2, y2);
Deleted: grass/trunk/lib/cairodriver/Client.c
===================================================================
--- grass/trunk/lib/cairodriver/Client.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/cairodriver/Client.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -1,8 +0,0 @@
-#include "cairodriver.h"
-
-void Cairo_Client_Close(void)
-{
- G_debug(1, "Cairo_Client_Close");
- if (auto_write)
- write_image();
-}
Modified: grass/trunk/lib/cairodriver/Driver.c
===================================================================
--- grass/trunk/lib/cairodriver/Driver.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/cairodriver/Driver.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -27,20 +27,14 @@
if (initialized)
return &drv;
- drv.Box_abs = Cairo_Box_abs;
- drv.Box_rel = NULL;
- drv.Client_Open = NULL;
- drv.Client_Close = Cairo_Client_Close;
+ drv.Box = Cairo_Box;
drv.Erase = Cairo_Erase;
drv.Graph_set = Cairo_Graph_set;
drv.Graph_close = Cairo_Graph_close;
drv.Line_width = Cairo_Line_width;
- drv.Polydots_abs = NULL;
- drv.Polydots_rel = NULL;
- drv.Polyline_abs = Cairo_Polyline_abs;
- drv.Polyline_rel = NULL;
- drv.Polygon_abs = Cairo_Polygon_abs;
- drv.Polygon_rel = NULL;
+ drv.Polydots = NULL;
+ drv.Polyline = Cairo_Polyline;
+ drv.Polygon = Cairo_Polygon;
drv.Set_window = Cairo_Set_window;
drv.Begin_scaled_raster = Cairo_begin_scaled_raster;
drv.Scaled_raster = Cairo_scaled_raster;
Modified: grass/trunk/lib/cairodriver/Poly.c
===================================================================
--- grass/trunk/lib/cairodriver/Poly.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/cairodriver/Poly.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -9,16 +9,16 @@
cairo_line_to(cairo, xarray[i], yarray[i]);
}
-void Cairo_Polygon_abs(const int *xarray, const int *yarray, int count)
+void Cairo_Polygon(const int *xarray, const int *yarray, int count)
{
- G_debug(3, "Cairo_Polygon_abs (%d points)", count);
+ G_debug(3, "Cairo_Polygon (%d points)", count);
do_polygon(xarray, yarray, count);
cairo_fill(cairo);
}
-void Cairo_Polyline_abs(const int *xarray, const int *yarray, int count)
+void Cairo_Polyline(const int *xarray, const int *yarray, int count)
{
- G_debug(3, "Cairo_Polyline_abs (%d points)", count);
+ G_debug(3, "Cairo_Polyline (%d points)", count);
do_polygon(xarray, yarray, count);
cairo_stroke(cairo);
}
Modified: grass/trunk/lib/cairodriver/cairodriver.h
===================================================================
--- grass/trunk/lib/cairodriver/cairodriver.h 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/cairodriver/cairodriver.h 2008-08-08 23:02:24 UTC (rev 32648)
@@ -49,7 +49,7 @@
extern void Cairo_Client_Close(void);
extern int Cairo_Graph_set(int, char **);
extern void Cairo_Graph_close(void);
-extern void Cairo_Box_abs(int, int, int, int);
+extern void Cairo_Box(int, int, int, int);
extern void Cairo_Set_window(int, int, int, int);
extern void Cairo_draw_line(int, int, int, int);
extern void Cairo_draw_bitmap(int, int, int, const unsigned char *);
@@ -63,8 +63,8 @@
const unsigned char *, const unsigned char *);
extern void Cairo_end_scaled_raster(void);
extern void Cairo_Line_width(int);
-extern void Cairo_Polygon_abs(const int *, const int *, int);
-extern void Cairo_Polyline_abs(const int *, const int *, int);
+extern void Cairo_Polygon(const int *, const int *, int);
+extern void Cairo_Polyline(const int *, const int *, int);
extern void Cairo_Respond(void);
/* read.c */
Modified: grass/trunk/lib/driver/Box.c
===================================================================
--- grass/trunk/lib/driver/Box.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/driver/Box.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -5,8 +5,8 @@
{
int x[4], y[4];
- if (driver->Box_abs) {
- (*driver->Box_abs) (x1, y1, x2, y2);
+ if (driver->Box) {
+ (*driver->Box) (x1, y1, x2, y2);
return;
}
@@ -24,10 +24,5 @@
void COM_Box_rel(int x, int y)
{
- if (driver->Box_rel) {
- (*driver->Box_rel) (x, y);
- return;
- }
-
COM_Box_abs(cur_x, cur_y, cur_x + x, cur_y + y);
}
Deleted: grass/trunk/lib/driver/Client.c
===================================================================
--- grass/trunk/lib/driver/Client.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/driver/Client.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -1,14 +0,0 @@
-#include "driver.h"
-#include "driverlib.h"
-
-void COM_Client_Open(void)
-{
- if (driver->Client_Open)
- (*driver->Client_Open) ();
-}
-
-void COM_Client_Close(void)
-{
- if (driver->Client_Close)
- (*driver->Client_Close) ();
-}
Modified: grass/trunk/lib/driver/Polydots.c
===================================================================
--- grass/trunk/lib/driver/Polydots.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/driver/Polydots.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -5,8 +5,8 @@
{
int i;
- if (driver->Polydots_abs) {
- (*driver->Polydots_abs) (xarray, yarray, number);
+ if (driver->Polydots) {
+ (*driver->Polydots) (xarray, yarray, number);
return;
}
@@ -20,11 +20,6 @@
{
int i;
- if (driver->Polydots_rel) {
- (*driver->Polydots_rel) (xarray, yarray, number);
- return;
- }
-
for (i = 0; i < number; i++) {
COM_Move_rel(xarray[i], yarray[i]);
COM_Cont_rel(0, 0);
Modified: grass/trunk/lib/driver/Polygon.c
===================================================================
--- grass/trunk/lib/driver/Polygon.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/driver/Polygon.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -121,8 +121,8 @@
void COM_Polygon_abs(const int *xarray, const int *yarray, int number)
{
- if (driver->Polygon_abs) {
- (*driver->Polygon_abs) (xarray, yarray, number);
+ if (driver->Polygon) {
+ (*driver->Polygon) (xarray, yarray, number);
return;
}
@@ -135,11 +135,6 @@
static int nalloc;
int i;
- if (driver->Polygon_rel) {
- (*driver->Polygon_rel) (xarray, yarray, number);
- return;
- }
-
if (number > nalloc) {
nalloc = number;
xa = G_realloc(xa, (size_t) nalloc * sizeof(int));
Modified: grass/trunk/lib/driver/Polyline.c
===================================================================
--- grass/trunk/lib/driver/Polyline.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/driver/Polyline.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -5,8 +5,8 @@
{
int i;
- if (driver->Polyline_abs) {
- (*driver->Polyline_abs) (xarray, yarray, number);
+ if (driver->Polyline) {
+ (*driver->Polyline) (xarray, yarray, number);
return;
}
@@ -20,11 +20,6 @@
{
int i;
- if (driver->Polyline_rel) {
- (*driver->Polyline_rel) (xarray, yarray, number);
- return;
- }
-
COM_Move_rel(xarray[0], yarray[0]);
for (i = 1; i < number; i++)
Modified: grass/trunk/lib/driver/driver.h
===================================================================
--- grass/trunk/lib/driver/driver.h 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/driver/driver.h 2008-08-08 23:02:24 UTC (rev 32648)
@@ -24,20 +24,14 @@
struct driver
{
- void (*Box_abs) (int, int, int, int);
- void (*Box_rel) (int, int);
- void (*Client_Open) (void);
- void (*Client_Close) (void);
+ void (*Box) (int, int, int, int);
void (*Erase) (void);
int (*Graph_set) (int, char **);
void (*Graph_close) (void);
void (*Line_width) (int);
- void (*Polydots_abs) (const int *, const int *, int);
- void (*Polydots_rel) (const int *, const int *, int);
- void (*Polyline_abs) (const int *, const int *, int);
- void (*Polyline_rel) (const int *, const int *, int);
- void (*Polygon_abs) (const int *, const int *, int);
- void (*Polygon_rel) (const int *, const int *, int);
+ void (*Polydots) (const int *, const int *, int);
+ void (*Polyline) (const int *, const int *, int);
+ void (*Polygon) (const int *, const int *, int);
void (*Set_window) (int, int, int, int);
void (*Begin_scaled_raster) (int, int[2][2], int[2][2]);
int (*Scaled_raster) (int, int,
@@ -69,10 +63,6 @@
extern void COM_Box_abs(int, int, int, int);
extern void COM_Box_rel(int, int);
-/* Client.c */
-extern void COM_Client_Open(void);
-extern void COM_Client_Close(void);
-
/* Color.c */
extern void COM_Color_RGB(unsigned char, unsigned char, unsigned char);
extern void COM_Standard_color(int);
Modified: grass/trunk/lib/htmldriver/Driver.c
===================================================================
--- grass/trunk/lib/htmldriver/Driver.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/htmldriver/Driver.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -25,20 +25,14 @@
if (initialized)
return &drv;
- drv.Box_abs = NULL;
- drv.Box_rel = NULL;
- drv.Client_Open = NULL;
- drv.Client_Close = NULL;
+ drv.Box = NULL;
drv.Erase = NULL;
drv.Graph_set = HTML_Graph_set;
drv.Graph_close = HTML_Graph_close;
drv.Line_width = NULL;
- drv.Polydots_abs = NULL;
- drv.Polydots_rel = NULL;
- drv.Polyline_abs = NULL;
- drv.Polyline_rel = NULL;
- drv.Polygon_abs = HTML_Polygon_abs;
- drv.Polygon_rel = NULL;
+ drv.Polydots = NULL;
+ drv.Polyline = NULL;
+ drv.Polygon = HTML_Polygon;
drv.Set_window = NULL;
drv.Begin_scaled_raster = NULL;
drv.Scaled_raster = NULL;
Deleted: grass/trunk/lib/htmldriver/Polygn_abs.c
===================================================================
--- grass/trunk/lib/htmldriver/Polygn_abs.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/htmldriver/Polygn_abs.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -1,211 +0,0 @@
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include <grass/gis.h>
-#include "driverlib.h"
-#include "htmlmap.h"
-
-#define RAD_DEG 57.29578
-
-/* max points & bbox minimum dimension defined in Graph_Set.c */
-extern int MAX_POINTS;
-extern int BBOX_MINIMUM;
-extern int MINIMUM_DIST;
-
-
-static void delete_point(int *x, int *y, int count)
-{
- int i;
-
- for (i = 0; i < count; i++) {
- x[i] = x[i + 1];
- y[i] = y[i + 1];
- }
-
-
-}
-
-static double find_azimuth(double x1, double y1, double x2, double y2)
-{
- double xx, yy;
-
- xx = x1 - x2;
- yy = y1 - y2;
-
- if (x1 == x2) {
- return (y2 > y1) ? 90.0 : 270.0;
- }
- else {
- if (y2 < y1) {
- if (x2 > x1) {
- return 360.0 + (RAD_DEG * atan(yy / xx));
- }
- else {
- return 180.0 + (RAD_DEG * atan(yy / xx));
- }
- }
- else {
- if (x2 > x1) {
- return (RAD_DEG * atan(yy / xx));
- }
- else {
- return 180.0 + (RAD_DEG * atan(yy / xx));
- }
- }
- }
-}
-
-
-void HTML_Polygon_abs(const int *px, const int *py, int n)
-{
- struct MapPoly *new;
- int i;
- int delta_x, delta_y;
- int min_x, max_x, min_y, max_y;
-
- double min_azimuth = 1.0;
- double azimuth1, azimuth2, diff1, diff2;
- int *x = G_malloc(n * sizeof(int));
- int *y = G_malloc(n * sizeof(int));
-
- memcpy(x, px, n * sizeof(int));
- memcpy(y, py, n * sizeof(int));
-
- /*
- * remove points that have adjacent duplicates or have differences of
- * less the the minimum allowed. remove end points that are same as
- * the begin point (ending point = starting point is added
- * during Graph_Clse)
- */
-
- i = 0;
- while (i < (n - 1)) {
- delta_x = x[i] - x[i + 1];
- if (delta_x < 0)
- delta_x = -delta_x;
- delta_y = y[i] - y[i + 1];
- if (delta_y < 0)
- delta_y = -delta_y;
-
- if ((x[i] == x[i + 1] && y[i] == y[i + 1]) ||
- (delta_x <= MINIMUM_DIST && delta_y <= MINIMUM_DIST)) {
- delete_point(&x[i + 1], &y[i + 1], n - i - 1);
- --n;
- }
- else {
- ++i;
- }
- }
-
- /* perform same checks for last point & first point */
- while (1) {
- delta_x = x[0] - x[n - 1];
- if (delta_x < 0)
- delta_x = -delta_x;
- delta_y = y[0] - y[n - 1];
- if (delta_y < 0)
- delta_y = -delta_y;
-
- if ((x[0] == x[n - 1] && y[0] == y[n - 1]) ||
- (delta_x <= MINIMUM_DIST && delta_y <= MINIMUM_DIST)) {
- --n;
- }
- else {
- break;
- }
- }
-
-
-
- /*
- * if a polygon has either x or y extents less than the bounding box
- * minimum, ignore it
- *
- */
-
- min_x = max_x = x[0];
- min_y = max_y = y[0];
- for (i = 0; i < n; i++) {
- if (x[i] < min_x)
- min_x = x[i];
- if (x[i] > max_x)
- max_x = x[i];
- if (y[i] < min_y)
- min_y = y[i];
- if (y[i] > max_y)
- max_y = y[i];
- }
- delta_x = max_x - min_x;
- delta_y = max_y - min_y;
- if (delta_x < BBOX_MINIMUM || delta_y < BBOX_MINIMUM) {
- n = 0;
- }
-
-
- /*
- * remove points in excess of MAX_POINTS vertices
- */
-
- while (n > MAX_POINTS) {
-
- for (i = 0; i < (n - 2); i++) {
-
- /*
- * see if middle point can be removed, by checking if the
- * relative bearing to the middle is less than our current tolerance
- */
-
- azimuth1 = find_azimuth((double)x[i], (double)y[i],
- (double)x[i + 1], (double)y[i + 1]);
- azimuth2 = find_azimuth((double)x[i], (double)y[i],
- (double)x[i + 2], (double)y[i + 2]);
-
- diff1 = fmod(fabs((azimuth2 + 360.0) - azimuth1), 360.0);
- diff2 = fmod(fabs((azimuth1 + 360.0) - azimuth2), 360.0);
-
- if (diff1 <= min_azimuth || diff2 <= min_azimuth) {
-
- delete_point(&x[i + 1], &y[i + 1], n - i - 1);
- --n;
- ++i;
- /* either stop deleting points because we're less than 100,
- or keep deleting points with the same difference as this
- one (which might make a smaller polygon yet).
- if (n <= 100) {
- break;
- }
- */
- }
-
- }
-
- /* increase minimum azimuth difference for next round */
- min_azimuth += 1.0;
- }
-
- /*
- * copy remaining points into a new MapPoly
- */
-
- if (n >= 3) {
-
- new = (struct MapPoly *)G_malloc(sizeof(struct MapPoly));
-
- /* grab the last text string written as url */
- new->url = G_store(last_text);
-
- /* hook up new MapPoly into list */
- new->next_poly = NULL;
- *tail = new;
- tail = &(new->next_poly);
-
- new->num_pts = n;
- new->x_pts = x;
- new->y_pts = y;
- }
- else {
- G_free(x);
- G_free(y);
- }
-}
Copied: grass/trunk/lib/htmldriver/Polygon.c (from rev 32646, grass/trunk/lib/htmldriver/Polygn_abs.c)
===================================================================
--- grass/trunk/lib/htmldriver/Polygon.c (rev 0)
+++ grass/trunk/lib/htmldriver/Polygon.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -0,0 +1,211 @@
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+
+#include <grass/gis.h>
+#include "driverlib.h"
+#include "htmlmap.h"
+
+#define RAD_DEG 57.29578
+
+/* max points & bbox minimum dimension defined in Graph_Set.c */
+extern int MAX_POINTS;
+extern int BBOX_MINIMUM;
+extern int MINIMUM_DIST;
+
+
+static void delete_point(int *x, int *y, int count)
+{
+ int i;
+
+ for (i = 0; i < count; i++) {
+ x[i] = x[i + 1];
+ y[i] = y[i + 1];
+ }
+
+
+}
+
+static double find_azimuth(double x1, double y1, double x2, double y2)
+{
+ double xx, yy;
+
+ xx = x1 - x2;
+ yy = y1 - y2;
+
+ if (x1 == x2) {
+ return (y2 > y1) ? 90.0 : 270.0;
+ }
+ else {
+ if (y2 < y1) {
+ if (x2 > x1) {
+ return 360.0 + (RAD_DEG * atan(yy / xx));
+ }
+ else {
+ return 180.0 + (RAD_DEG * atan(yy / xx));
+ }
+ }
+ else {
+ if (x2 > x1) {
+ return (RAD_DEG * atan(yy / xx));
+ }
+ else {
+ return 180.0 + (RAD_DEG * atan(yy / xx));
+ }
+ }
+ }
+}
+
+
+void HTML_Polygon(const int *px, const int *py, int n)
+{
+ struct MapPoly *new;
+ int i;
+ int delta_x, delta_y;
+ int min_x, max_x, min_y, max_y;
+
+ double min_azimuth = 1.0;
+ double azimuth1, azimuth2, diff1, diff2;
+ int *x = G_malloc(n * sizeof(int));
+ int *y = G_malloc(n * sizeof(int));
+
+ memcpy(x, px, n * sizeof(int));
+ memcpy(y, py, n * sizeof(int));
+
+ /*
+ * remove points that have adjacent duplicates or have differences of
+ * less the the minimum allowed. remove end points that are same as
+ * the begin point (ending point = starting point is added
+ * during Graph_Clse)
+ */
+
+ i = 0;
+ while (i < (n - 1)) {
+ delta_x = x[i] - x[i + 1];
+ if (delta_x < 0)
+ delta_x = -delta_x;
+ delta_y = y[i] - y[i + 1];
+ if (delta_y < 0)
+ delta_y = -delta_y;
+
+ if ((x[i] == x[i + 1] && y[i] == y[i + 1]) ||
+ (delta_x <= MINIMUM_DIST && delta_y <= MINIMUM_DIST)) {
+ delete_point(&x[i + 1], &y[i + 1], n - i - 1);
+ --n;
+ }
+ else {
+ ++i;
+ }
+ }
+
+ /* perform same checks for last point & first point */
+ while (1) {
+ delta_x = x[0] - x[n - 1];
+ if (delta_x < 0)
+ delta_x = -delta_x;
+ delta_y = y[0] - y[n - 1];
+ if (delta_y < 0)
+ delta_y = -delta_y;
+
+ if ((x[0] == x[n - 1] && y[0] == y[n - 1]) ||
+ (delta_x <= MINIMUM_DIST && delta_y <= MINIMUM_DIST)) {
+ --n;
+ }
+ else {
+ break;
+ }
+ }
+
+
+
+ /*
+ * if a polygon has either x or y extents less than the bounding box
+ * minimum, ignore it
+ *
+ */
+
+ min_x = max_x = x[0];
+ min_y = max_y = y[0];
+ for (i = 0; i < n; i++) {
+ if (x[i] < min_x)
+ min_x = x[i];
+ if (x[i] > max_x)
+ max_x = x[i];
+ if (y[i] < min_y)
+ min_y = y[i];
+ if (y[i] > max_y)
+ max_y = y[i];
+ }
+ delta_x = max_x - min_x;
+ delta_y = max_y - min_y;
+ if (delta_x < BBOX_MINIMUM || delta_y < BBOX_MINIMUM) {
+ n = 0;
+ }
+
+
+ /*
+ * remove points in excess of MAX_POINTS vertices
+ */
+
+ while (n > MAX_POINTS) {
+
+ for (i = 0; i < (n - 2); i++) {
+
+ /*
+ * see if middle point can be removed, by checking if the
+ * relative bearing to the middle is less than our current tolerance
+ */
+
+ azimuth1 = find_azimuth((double)x[i], (double)y[i],
+ (double)x[i + 1], (double)y[i + 1]);
+ azimuth2 = find_azimuth((double)x[i], (double)y[i],
+ (double)x[i + 2], (double)y[i + 2]);
+
+ diff1 = fmod(fabs((azimuth2 + 360.0) - azimuth1), 360.0);
+ diff2 = fmod(fabs((azimuth1 + 360.0) - azimuth2), 360.0);
+
+ if (diff1 <= min_azimuth || diff2 <= min_azimuth) {
+
+ delete_point(&x[i + 1], &y[i + 1], n - i - 1);
+ --n;
+ ++i;
+ /* either stop deleting points because we're less than 100,
+ or keep deleting points with the same difference as this
+ one (which might make a smaller polygon yet).
+ if (n <= 100) {
+ break;
+ }
+ */
+ }
+
+ }
+
+ /* increase minimum azimuth difference for next round */
+ min_azimuth += 1.0;
+ }
+
+ /*
+ * copy remaining points into a new MapPoly
+ */
+
+ if (n >= 3) {
+
+ new = (struct MapPoly *)G_malloc(sizeof(struct MapPoly));
+
+ /* grab the last text string written as url */
+ new->url = G_store(last_text);
+
+ /* hook up new MapPoly into list */
+ new->next_poly = NULL;
+ *tail = new;
+ tail = &(new->next_poly);
+
+ new->num_pts = n;
+ new->x_pts = x;
+ new->y_pts = y;
+ }
+ else {
+ G_free(x);
+ G_free(y);
+ }
+}
Modified: grass/trunk/lib/htmldriver/htmlmap.h
===================================================================
--- grass/trunk/lib/htmldriver/htmlmap.h 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/htmldriver/htmlmap.h 2008-08-08 23:02:24 UTC (rev 32648)
@@ -41,8 +41,8 @@
/* Graph_Set.c */
extern int HTML_Graph_set(int, char **);
-/* Polygn_abs.c */
-extern void HTML_Polygon_abs(const int *, const int *, int);
+/* Polygon.c */
+extern void HTML_Polygon(const int *, const int *, int);
/* Text.c */
extern void HTML_Text(const char *);
Modified: grass/trunk/lib/pngdriver/Box.c
===================================================================
--- grass/trunk/lib/pngdriver/Box.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/pngdriver/Box.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -1,7 +1,7 @@
#include "pngdriver.h"
-void PNG_Box_abs(int x1, int y1, int x2, int y2)
+void PNG_Box(int x1, int y1, int x2, int y2)
{
int tmp;
int x, y;
Deleted: grass/trunk/lib/pngdriver/Client.c
===================================================================
--- grass/trunk/lib/pngdriver/Client.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/pngdriver/Client.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -1,8 +0,0 @@
-
-#include "pngdriver.h"
-
-void PNG_Client_Close(void)
-{
- if (auto_write)
- write_image();
-}
Modified: grass/trunk/lib/pngdriver/Driver.c
===================================================================
--- grass/trunk/lib/pngdriver/Driver.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/pngdriver/Driver.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -27,20 +27,14 @@
if (initialized)
return &drv;
- drv.Box_abs = PNG_Box_abs;
- drv.Box_rel = NULL;
- drv.Client_Open = NULL;
- drv.Client_Close = PNG_Client_Close;
+ drv.Box = PNG_Box;
drv.Erase = PNG_Erase;
drv.Graph_set = PNG_Graph_set;
drv.Graph_close = PNG_Graph_close;
drv.Line_width = PNG_Line_width;
- drv.Polydots_abs = NULL;
- drv.Polydots_rel = NULL;
- drv.Polyline_abs = NULL;
- drv.Polyline_rel = NULL;
- drv.Polygon_abs = NULL;
- drv.Polygon_rel = NULL;
+ drv.Polydots = NULL;
+ drv.Polyline = NULL;
+ drv.Polygon = NULL;
drv.Set_window = PNG_Set_window;
drv.Begin_scaled_raster = PNG_begin_scaled_raster;
drv.Scaled_raster = PNG_scaled_raster;
Modified: grass/trunk/lib/pngdriver/Makefile
===================================================================
--- grass/trunk/lib/pngdriver/Makefile 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/pngdriver/Makefile 2008-08-08 23:02:24 UTC (rev 32648)
@@ -11,7 +11,6 @@
LIB_OBJS = \
Box.o \
- Client.o \
Color.o \
Color_table.o \
Draw_bitmap.o \
Modified: grass/trunk/lib/pngdriver/pngdriver.h
===================================================================
--- grass/trunk/lib/pngdriver/pngdriver.h 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/pngdriver/pngdriver.h 2008-08-08 23:02:24 UTC (rev 32648)
@@ -44,7 +44,7 @@
extern const struct driver *PNG_Driver(void);
-extern void PNG_Box_abs(int, int, int, int);
+extern void PNG_Box(int, int, int, int);
extern void PNG_Client_Close(void);
extern void PNG_Erase(void);
extern void PNG_Graph_close(void);
Modified: grass/trunk/lib/psdriver/Box.c
===================================================================
--- grass/trunk/lib/psdriver/Box.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/psdriver/Box.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -1,7 +1,7 @@
#include "psdriver.h"
-void PS_Box_abs(int x1, int y1, int x2, int y2)
+void PS_Box(int x1, int y1, int x2, int y2)
{
output("%d %d %d %d BOX\n", x1, y1, x2, y2);
}
Deleted: grass/trunk/lib/psdriver/Client.c
===================================================================
--- grass/trunk/lib/psdriver/Client.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/psdriver/Client.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -1,7 +0,0 @@
-
-#include "psdriver.h"
-
-void PS_Client_Close(void)
-{
- fflush(outfp);
-}
Modified: grass/trunk/lib/psdriver/Driver.c
===================================================================
--- grass/trunk/lib/psdriver/Driver.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/psdriver/Driver.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -27,20 +27,14 @@
if (initialized)
return &drv;
- drv.Box_abs = PS_Box_abs;
- drv.Box_rel = NULL;
- drv.Client_Open = NULL;
- drv.Client_Close = PS_Client_Close;
+ drv.Box = PS_Box;
drv.Erase = PS_Erase;
drv.Graph_set = PS_Graph_set;
drv.Graph_close = PS_Graph_close;
drv.Line_width = PS_Line_width;
- drv.Polydots_abs = NULL;
- drv.Polydots_rel = NULL;
- drv.Polyline_abs = PS_Polyline_abs;
- drv.Polyline_rel = NULL;
- drv.Polygon_abs = PS_Polygon_abs;
- drv.Polygon_rel = NULL;
+ drv.Polydots = NULL;
+ drv.Polyline = PS_Polyline;
+ drv.Polygon = PS_Polygon;
drv.Set_window = PS_Set_window;
drv.Begin_scaled_raster = PS_begin_scaled_raster;
drv.Scaled_raster = PS_scaled_raster;
Modified: grass/trunk/lib/psdriver/Polygon.c
===================================================================
--- grass/trunk/lib/psdriver/Polygon.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/psdriver/Polygon.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -1,7 +1,7 @@
#include "psdriver.h"
-void PS_Polygon_abs(const int *xarray, const int *yarray, int number)
+void PS_Polygon(const int *xarray, const int *yarray, int number)
{
int i;
Modified: grass/trunk/lib/psdriver/Polyline.c
===================================================================
--- grass/trunk/lib/psdriver/Polyline.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/psdriver/Polyline.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -1,7 +1,7 @@
#include "psdriver.h"
-void PS_Polyline_abs(const int *xarray, const int *yarray, int number)
+void PS_Polyline(const int *xarray, const int *yarray, int number)
{
int i;
Modified: grass/trunk/lib/psdriver/psdriver.h
===================================================================
--- grass/trunk/lib/psdriver/psdriver.h 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/psdriver/psdriver.h 2008-08-08 23:02:24 UTC (rev 32648)
@@ -21,7 +21,7 @@
extern const struct driver *PS_Driver(void);
-extern void PS_Box_abs(int, int, int, int);
+extern void PS_Box(int, int, int, int);
extern void PS_Client_Close(void);
extern void PS_Erase(void);
extern void PS_Graph_close(void);
@@ -39,7 +39,7 @@
const unsigned char *, const unsigned char *,
const unsigned char *);
extern void PS_end_scaled_raster(void);
-extern void PS_Polygon_abs(const int *, const int *, int);
-extern void PS_Polyline_abs(const int *, const int *, int);
+extern void PS_Polygon(const int *, const int *, int);
+extern void PS_Polyline(const int *, const int *, int);
#endif /* __PSDRIVER_H__ */
Modified: grass/trunk/lib/raster/raster.c
===================================================================
--- grass/trunk/lib/raster/raster.c 2008-08-08 22:44:39 UTC (rev 32647)
+++ grass/trunk/lib/raster/raster.c 2008-08-08 23:02:24 UTC (rev 32648)
@@ -54,8 +54,6 @@
init();
- COM_Client_Open();
-
return 0;
}
@@ -69,7 +67,6 @@
char *cmd = getenv("GRASS_NOTIFY");
COM_Respond();
- COM_Client_Close();
COM_Graph_close();
if (cmd)
More information about the grass-commit
mailing list