29static void fastline(
double,
double,
double,
double);
30static void slowline(
double,
double,
double,
double);
31static void plot_line(
double,
double,
double,
double,
32 void (*)(
double,
double,
double,
double));
33static double wrap_east(
double,
double);
34static int edge(
double,
double,
double,
double);
35static int edge_point(
double,
int);
37static int edge_order(
const void *,
const void *);
38static void row_solid_fill(
int,
double,
double);
39static void row_dotted_fill(
int,
double,
double);
40static int ifloor(
double);
41static int iceil(
double);
48#define POINT struct point
53 double left, right, top, bottom;
69#define TOO_FEW_EDGES 2
96 int (*Cont)(
int,
int))
105 st->xconv = (
st->right -
st->left) / (
st->window.east -
st->window.west);
106 st->yconv = (
st->bottom -
st->top) / (
st->window.north -
st->window.south);
108 if (
st->top <
st->bottom) {
109 st->ymin = iceil(
st->top);
110 st->ymax = ifloor(
st->bottom);
113 st->ymin = iceil(
st->bottom);
114 st->ymax = ifloor(
st->top);
134 st->row_fill = row_dotted_fill;
135 st->dotted_fill_gap =
gap + 1;
138 st->row_fill = row_solid_fill;
141#define X(e) (st->left + st->xconv * ((e) - st->window.west))
142#define Y(n) (st->top + st->yconv * (st->window.north - (n)))
144#define EAST(x) (st->window.west + ((x) - st->left) / st->xconv)
145#define NORTH(y) (st->window.north - ((y) - st->top) / st->yconv)
161 *y = ifloor(
Y(north) + 0.5);
229static void fastline(
double x1,
double y1,
double x2,
double y2)
231 st->move(ifloor(x1 + 0.5), ifloor(y1 + 0.5));
232 st->cont(ifloor(x2 + 0.5), ifloor(y2 + 0.5));
240static void slowline(
double x1,
double y1,
double x2,
double y2)
255 xstop = ifloor(x1 + 0.5);
259 xstop = ifloor(x2 + 0.5);
279 ystop = ifloor(y1 + 0.5);
283 ystop = ifloor(y2 + 0.5);
297 void (*line)(
double,
double,
double,
double))
299 double x1, x2, y1, y2;
311 while (
east1 >
st->window.east) {
322 line(x1, y1, x2, y2);
325 while (
east2 >
st->window.east) {
335 line(x1, y1, x2, y2);
341 line(x1, y1, x2, y2);
345static double wrap_east(
double e0,
double e1)
347 while (
e0 - e1 > 180)
349 while (e1 -
e0 > 180)
376 double shift, E,
W = 0L;
381 st->row_fill = row_solid_fill;
407 for (i = 0; i < n; i++) {
408 e1 = wrap_east(
e0,
x[i]);
417 if (!edge(x0,
y0, x1, y1))
428 while (E + shift >
st->window.east)
438 for (i = 0; i < n; i++) {
441 if (!edge(x0,
y0, x1, y1))
450 G_warning(
"Weird internal error: perimeter has odd number of points");
458 for (i = 1; i <
st->np; i += 2) {
459 if (
st->P[i].y !=
st->P[i - 1].y) {
460 G_warning(
"Weird internal error: edge leaves row");
469 while (
W + shift >
st->window.east)
473 for (i = 1; i <
st->np; i += 2) {
506 double shift, E,
W = 0L;
511 st->row_fill = row_solid_fill;
543 for (i = 0; i < n; i++) {
544 e1 = wrap_east(
e0,
x[i]);
553 if (!edge(x0,
y0, x1, y1))
564 while (E + shift >
st->window.east)
574 for (i = 0; i < n; i++) {
577 if (!edge(x0,
y0, x1, y1))
587 G_warning(
"Weird internal error: perimeter has odd number of points");
596 for (i = 1; i <
st->np; i += 2) {
597 if (
st->P[i].y !=
st->P[i - 1].y) {
598 G_warning(
"Weird internal error: edge leaves row");
612 while (
W + shift >
st->window.east)
616 for (i = 1; i <
st->np; i += 2) {
627static int edge(
double x0,
double y0,
double x1,
double y1)
666 m = (x0 - x1) / (
y0 - y1);
669 if (!edge_point(x,
ystart++))
677static int edge_point(
double x,
int y)
682 if (
st->np >=
st->npalloc) {
683 if (
st->npalloc > 0) {
697 st->P[
st->np++].y = y;
701static int edge_order(
const void *
aa,
const void *
bb)
703 const struct point *a =
aa, *
b =
bb;
718static void row_solid_fill(
int y,
double x1,
double x2)
730static void row_dotted_fill(
int y,
double x1,
double x2)
734 if (y != iceil(y /
st->dotted_fill_gap) *
st->dotted_fill_gap)
737 i1 = iceil(x1 /
st->dotted_fill_gap) *
st->dotted_fill_gap;
740 for (i =
i1; i <=
i2; i +=
st->dotted_fill_gap) {
747static int ifloor(
double x)
757static int iceil(
double x)
780 double east, north,
north1;
783 incr =
fabs(1.0 /
st->xconv);
void G_free(void *)
Free allocated memory.
void G_warning(const char *,...) __attribute__((format(printf
void G_get_set_window(struct Cell_head *)
Get the current working window (region)
double G_adjust_easting(double, const struct Cell_head *)
Returns east not smaller than west.
#define PROJECTION_LL
Projection code - Latitude-Longitude.
int G_plot_area(double *const *xs, double *const *ys, int *rpnts, int rings)
Plot multiple polygons.
void G_plot_line2(double east1, double north1, double east2, double north2)
Plot line between latlon coordinates (slowline)
int G_plot_polygon(const double *x, const double *y, int n)
Plot filled polygon with n vertices.
void G_plot_where_en(int x, int y, double *east, double *north)
Converts x,y to east,north.
void G_plot_where_xy(double east, double north, int *x, int *y)
Converts east,north to x,y.
void G_setup_fill(int gap)
Set row_fill routine to row_solid_fill or row_dotted_fill.
void G_setup_plot(double t, double b, double l, double r, int(*Move)(int, int), int(*Cont)(int, int))
Initialize plotting routines.
void G_plot_fx(double(*f)(double), double east1, double east2)
Plot f(east1) to f(east2)
void G_plot_line(double east1, double north1, double east2, double north2)
Plot line between latlon coordinates (fastline)
void G_plot_point(double east, double north)
Plot point.
2D/3D raster map header (used also for region)