GRASS 8 Programmer's Manual 8.6.0dev(2026)-88f4ac5790
Loading...
Searching...
No Matches
plot.c
Go to the documentation of this file.
1/*!
2 * \file lib/gis/plot.c
3 *
4 * \brief GIS Library - Plotting functions.
5 *
6 * Plot lines and filled polygons. Input space is current
7 * window. Output space and output functions are user
8 * defined. Converts input east,north lines and polygons to output x,y
9 * and calls user supplied line drawing routines to do the plotting.
10 *
11 * Handles global wrap-around for lat-lon locations.
12 *
13 * Does not perform window clipping.
14 * Clipping must be done by the line draw routines supplied by the user.
15 *
16 * Note:
17 * Hopefully, cartographic style projection plotting will be added later.
18 *
19 * SPDX-FileCopyrightText: 2001-2008, 2013 GRASS Development Team
20 * SPDX-License-Identifier: GPL-2.0-or-later
21 *
22 * \author Original author CERL
23 */
24
25#include <stdlib.h>
26#include <math.h>
27#include <grass/gis.h>
28
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);
36
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);
42
43struct point {
44 double x;
45 int y;
46};
47
48#define POINT struct point
49
50static struct state {
51 struct Cell_head window;
52 double xconv, yconv;
53 double left, right, top, bottom;
54 int ymin, ymax;
55 int dotted_fill_gap;
56
57 POINT *P;
58 int np;
59 int npalloc;
60
61 void (*row_fill)(int, double, double);
62 int (*move)(int, int);
63 int (*cont)(int, int);
64} state;
65
66static struct state *st = &state;
67
68#define OK 0
69#define TOO_FEW_EDGES 2
70#define NO_MEMORY 1
71#define OUT_OF_SYNC -1
72
73/*!
74 * \brief Initialize plotting routines
75 *
76 * Initializes the plotting capability. This routine must be called
77 * once before calling the G_plot_*() routines described below. The
78 * parameters <i>t, b, l, r</i> are the top, bottom, left, and right
79 * of the output x,y coordinate space. They are not integers, but
80 * doubles to allow for subpixel registration of the input and output
81 * coordinate spaces. The input coordinate space is assumed to be the
82 * current GRASS region, and the routines supports both planimetric
83 * and latitude-longitude coordinate systems.
84
85 * <b>Move</b> and <b>Cont</b> are subroutines that will draw lines in x,y
86 * space. They will be called as follows:
87 * - Move(x, y) move to x,y (no draw)
88 * - Cont(x, y) draw from previous position to x,y. Cont(~) is responsible for
89 clipping
90 *
91 * \param t,b,l,r top, bottom, left, right
92 * \param move Move function
93 * \param Cont Cont function
94 */
95void G_setup_plot(double t, double b, double l, double r, int (*Move)(int, int),
96 int (*Cont)(int, int))
97{
98 G_get_set_window(&st->window);
99
100 st->left = l;
101 st->right = r;
102 st->top = t;
103 st->bottom = b;
104
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);
107
108 if (st->top < st->bottom) {
109 st->ymin = iceil(st->top);
110 st->ymax = ifloor(st->bottom);
111 }
112 else {
113 st->ymin = iceil(st->bottom);
114 st->ymax = ifloor(st->top);
115 }
116
117 st->move = Move;
118 st->cont = Cont;
119}
120
121/*!
122 * \brief Set row_fill routine to row_solid_fill or row_dotted_fill
123 *
124 * After calling this function, G_plot_polygon() and G_plot_area()
125 * fill shapes with solid or dotted lines. If gap is greater than
126 * zero, this value will be used for row_dotted_fill. Otherwise,
127 * row_solid_fill is used.
128 *
129 * \param gap
130 */
132{
133 if (gap > 0) {
134 st->row_fill = row_dotted_fill;
135 st->dotted_fill_gap = gap + 1;
136 }
137 else
138 st->row_fill = row_solid_fill;
139}
140
141#define X(e) (st->left + st->xconv * ((e) - st->window.west))
142#define Y(n) (st->top + st->yconv * (st->window.north - (n)))
143
144#define EAST(x) (st->window.west + ((x) - st->left) / st->xconv)
145#define NORTH(y) (st->window.north - ((y) - st->top) / st->yconv)
146
147/*!
148 * \brief Converts east,north to x,y
149 *
150 * The map coordinates <i>east,north</i> are converted
151 * to pixel coordinates <i>x,y</i>.
152 *
153 * \param east easting
154 * \param north nothing
155 * \param x x coordinate
156 * \param y y coordinate
157 */
158void G_plot_where_xy(double east, double north, int *x, int *y)
159{
160 *x = ifloor(X(G_adjust_easting(east, &st->window)) + 0.5);
161 *y = ifloor(Y(north) + 0.5);
162}
163
164/*!
165 * \brief Converts x,y to east,north
166 *
167 * The pixel coordinates <i>x,y</i> are converted to map
168 * coordinates <i>east,north</i>.
169 *
170 * \param x x coordinate
171 * \param y y coordinate
172 * \param east easting
173 * \param north northing
174 */
175void G_plot_where_en(int x, int y, double *east, double *north)
176{
177 *east = G_adjust_easting(EAST(x), &st->window);
178 *north = NORTH(y);
179}
180
181/*!
182 \brief Plot point
183
184 \param east easting
185 \param north northing
186 */
187void G_plot_point(double east, double north)
188{
189 int x, y;
190
191 G_plot_where_xy(east, north, &x, &y);
192 st->move(x, y);
193 st->cont(x, y);
194}
195
196/*!
197 * \brief Plot line between latlon coordinates (fastline)
198 *
199 * A line from <i>east1,north1</i> to <i>east2,north2</i> is plotted
200 * in output x,y coordinates (e.g. pixels for graphics.) This routine
201 * handles global wrap-around for latitude-longitude databases.
202 *
203 * \param east1, north1 first point (start line node)
204 * \param east2, north2 second point (end line node)
205 */
206void G_plot_line(double east1, double north1, double east2, double north2)
207{
208 plot_line(east1, north1, east2, north2, fastline);
209}
210
211/*!
212 * \brief Plot line between latlon coordinates (slowline)
213 *
214 * A line from <i>east1,north1</i> to <i>east2,north2</i> is plotted
215 * in output x,y coordinates (e.g. pixels for graphics.) This routine
216 * handles global wrap-around for latitude-longitude databases.
217 *
218 * \param east1, north1 first point (start line node)
219 * \param east2, north2 second point (end line node)
220 */
221void G_plot_line2(double east1, double north1, double east2, double north2)
222{
223 plot_line(east1, north1, east2, north2, slowline);
224}
225
226/* fastline converts double rows/cols to ints then plots
227 * this is ok for graphics, but not the best for vector to raster
228 */
229static void fastline(double x1, double y1, double x2, double y2)
230{
231 st->move(ifloor(x1 + 0.5), ifloor(y1 + 0.5));
232 st->cont(ifloor(x2 + 0.5), ifloor(y2 + 0.5));
233}
234
235/* NOTE (shapiro):
236 * I think the adding of 0.5 in slowline is not correct
237 * the output window (left, right, top, bottom) should already
238 * be adjusted for this: left=-0.5; right = window.cols-0.5;
239 */
240static void slowline(double x1, double y1, double x2, double y2)
241{
242 double dx, dy;
243 double m;
244 int xstart, xstop, ystart, ystop;
245
246 dx = x2 - x1;
247 dy = y2 - y1;
248
249 /* Zero-length segment: plot only one point. */
250 if (dx == 0.0 && dy == 0.0) {
251 xstart = ifloor(x1 + 0.5);
252 ystart = ifloor(y1 + 0.5);
253
254 st->move(xstart, ystart);
255 st->cont(xstart, ystart);
256 return;
257 }
258
259 if (fabs(dx) > fabs(dy)) {
260 /* Always go from smaller x to larger x for identical results
261 * independent of the direction. */
262 if (x1 > x2) {
263 double tmp;
264
265 tmp = x1;
266 x1 = x2;
267 x2 = tmp;
268
269 tmp = y1;
270 y1 = y2;
271 y2 = tmp;
272
273 dx = x2 - x1;
274 dy = y2 - y1;
275 }
276 m = dy / dx;
277 xstart = ifloor(x1 + 0.5);
278 xstop = ifloor(x2 + 0.5);
279
280 if (xstart <= xstop) {
281 /* Subtract the start point coordinate before multiplying
282 * to avoid numerical cancellation.
283 */
284 ystart = ifloor(y1 + m * (xstart - x1) + 0.5);
285 st->move(xstart, ystart);
286 while (xstart <= xstop) {
287 st->cont(xstart++, ystart);
288 ystart = ifloor(y1 + m * (xstart - x1) + 0.5);
289 }
290 }
291 }
292 else {
293 /* Always go from smaller y to larger y for identical results
294 * independent of the direction. */
295 if (y1 > y2) {
296 double tmp;
297
298 tmp = x1;
299 x1 = x2;
300 x2 = tmp;
301
302 tmp = y1;
303 y1 = y2;
304 y2 = tmp;
305
306 dx = x2 - x1;
307 dy = y2 - y1;
308 }
309 m = dx / dy;
310 ystart = ifloor(y1 + 0.5);
311 ystop = ifloor(y2 + 0.5);
312
313 if (ystart <= ystop) {
314 /* Subtract the start point coordinate before multiplying
315 * to avoid numerical cancellation.
316 */
317 xstart = ifloor(x1 + m * (ystart - y1) + 0.5);
318 st->move(xstart, ystart);
319 while (ystart <= ystop) {
320 st->cont(xstart, ystart++);
321 xstart = ifloor(x1 + m * (ystart - y1) + 0.5);
322 }
323 }
324 }
325}
326
327static void plot_line(double east1, double north1, double east2, double north2,
328 void (*line)(double, double, double, double))
329{
330 double x1, x2, y1, y2;
331
332 y1 = Y(north1);
333 y2 = Y(north2);
334
335 if (st->window.proj == PROJECTION_LL) {
336 if (east1 > east2)
337 while ((east1 - east2) > 180)
338 east2 += 360;
339 else if (east2 > east1)
340 while ((east2 - east1) > 180)
341 east1 += 360;
342 while (east1 > st->window.east) {
343 east1 -= 360.0;
344 east2 -= 360.0;
345 }
346 while (east1 < st->window.west) {
347 east1 += 360.0;
348 east2 += 360.0;
349 }
350 x1 = X(east1);
351 x2 = X(east2);
352
353 line(x1, y1, x2, y2);
354
355 if (east2 > st->window.east || east2 < st->window.west) {
356 while (east2 > st->window.east) {
357 east1 -= 360.0;
358 east2 -= 360.0;
359 }
360 while (east2 < st->window.west) {
361 east1 += 360.0;
362 east2 += 360.0;
363 }
364 x1 = X(east1);
365 x2 = X(east2);
366 line(x1, y1, x2, y2);
367 }
368 }
369 else {
370 x1 = X(east1);
371 x2 = X(east2);
372 line(x1, y1, x2, y2);
373 }
374}
375
376static double wrap_east(double e0, double e1)
377{
378 while (e0 - e1 > 180)
379 e1 += 360.0;
380 while (e1 - e0 > 180)
381 e1 -= 360.0;
382
383 return e1;
384}
385
386/*!
387 * \brief Plot filled polygon with n vertices
388 *
389 * The polygon, described by the <i>n</i> vertices
390 * <i>east,north</i>, is plotted in the output x,y space as a filled polygon.
391 *
392 * \param x coordinates of vertices
393 * \param y coordinates of vertices
394 * \param n number of vertices
395 *
396 * \return 0 on success
397 * \return 2 n < 3
398 * \return -1 weird internal error
399 * \return 1 no memory
400 */
401int G_plot_polygon(const double *x, const double *y, int n)
402{
403 int i;
404 int pole;
405 double x0, x1;
406 double y0, y1;
407 double shift, E, W = 0L;
408 double e0, e1;
409 int shift1, shift2;
410
411 if (!st->row_fill)
412 st->row_fill = row_solid_fill;
413
414 if (n < 3)
415 return TOO_FEW_EDGES;
416
417 /* traverse the perimeter */
418
419 st->np = 0;
420 shift1 = 0;
421
422 /* global wrap-around for lat-lon, part1 */
423 if (st->window.proj == PROJECTION_LL) {
424 /*
425 pole = G_pole_in_polygon(x,y,n);
426 */
427 pole = 0;
428
429 e0 = x[n - 1];
430 E = W = e0;
431
432 x0 = X(e0);
433 y0 = Y(y[n - 1]);
434
435 if (pole && !edge(x0, y0, x0, Y(90.0 * pole)))
436 return NO_MEMORY;
437
438 for (i = 0; i < n; i++) {
439 e1 = wrap_east(e0, x[i]);
440 if (e1 > E)
441 E = e1;
442 if (e1 < W)
443 W = e1;
444
445 x1 = X(e1);
446 y1 = Y(y[i]);
447
448 if (!edge(x0, y0, x1, y1))
449 return NO_MEMORY;
450
451 x0 = x1;
452 y0 = y1;
453 e0 = e1;
454 }
455 if (pole && !edge(x0, y0, x0, Y(90.0 * pole)))
456 return NO_MEMORY;
457
458 shift = 0; /* shift into window */
459 while (E + shift > st->window.east)
460 shift -= 360.0;
461 while (E + shift < st->window.west)
462 shift += 360.0;
463 shift1 = X(x[n - 1] + shift) - X(x[n - 1]);
464 }
465 else {
466 x0 = X(x[n - 1]);
467 y0 = Y(y[n - 1]);
468
469 for (i = 0; i < n; i++) {
470 x1 = X(x[i]);
471 y1 = Y(y[i]);
472 if (!edge(x0, y0, x1, y1))
473 return NO_MEMORY;
474 x0 = x1;
475 y0 = y1;
476 }
477 }
478
479 /* check if perimeter has odd number of points */
480 if (st->np & 1) {
481 G_warning("Weird internal error: perimeter has odd number of points");
482 return OUT_OF_SYNC;
483 }
484
485 /* sort the edge points by col(x) and then by row(y) */
486 qsort(st->P, st->np, sizeof(POINT), edge_order);
487
488 /* plot */
489 for (i = 1; i < st->np; i += 2) {
490 if (st->P[i].y != st->P[i - 1].y) {
491 G_warning("Weird internal error: edge leaves row");
492 return OUT_OF_SYNC;
493 }
494 st->row_fill(st->P[i].y, st->P[i - 1].x + shift1, st->P[i].x + shift1);
495 }
496 if (st->window.proj == PROJECTION_LL) { /* now do wrap-around, part 2 */
497 shift = 0;
498 while (W + shift < st->window.west)
499 shift += 360.0;
500 while (W + shift > st->window.east)
501 shift -= 360.0;
502 shift2 = X(x[n - 1] + shift) - X(x[n - 1]);
503 if (shift2 != shift1) {
504 for (i = 1; i < st->np; i += 2) {
505 st->row_fill(st->P[i].y, st->P[i - 1].x + shift2,
506 st->P[i].x + shift2);
507 }
508 }
509 }
510 return OK;
511}
512
513/*!
514 * \brief Plot multiple polygons
515 *
516 * Like G_plot_polygon(), except it takes a set of polygons, each with
517 * npts[<i>i</i>] vertices, where the number of polygons is specified
518 * with the <i>rings</i> argument. It is especially useful for
519 * plotting vector areas with interior islands.
520 *
521 * \param xs pointer to pointer for X's
522 * \param ys pointer to pointer for Y's
523 * \param rpnts array of ints w/ num points per ring
524 * \param rings number of rings
525 *
526 * \return 0 on success
527 * \return 2 n < 3
528 * \return -1 weird internal error
529 * \return 1 no memory
530 */
531int G_plot_area(double *const *xs, double *const *ys, int *rpnts, int rings)
532{
533 int i, j, n;
534 int pole;
535 double x0, x1, *x;
536 double y0, y1, *y;
537 double shift, E, W = 0L;
538 double e0, e1;
539 int *shift1 = NULL, shift2;
540
541 if (!st->row_fill)
542 st->row_fill = row_solid_fill;
543
544 /* traverse the perimeter */
545
546 st->np = 0;
547 shift1 = (int *)G_calloc(sizeof(int), rings);
548
549 for (j = 0; j < rings; j++) {
550 n = rpnts[j];
551
552 if (n < 3)
553 return TOO_FEW_EDGES;
554
555 x = xs[j];
556 y = ys[j];
557
558 /* global wrap-around for lat-lon, part1 */
559 if (st->window.proj == PROJECTION_LL) {
560 /*
561 pole = G_pole_in_polygon(x,y,n);
562 */
563 pole = 0;
564
565 e0 = x[n - 1];
566 E = W = e0;
567
568 x0 = X(e0);
569 y0 = Y(y[n - 1]);
570
571 if (pole && !edge(x0, y0, x0, Y(90.0 * pole)))
572 return NO_MEMORY;
573
574 for (i = 0; i < n; i++) {
575 e1 = wrap_east(e0, x[i]);
576 if (e1 > E)
577 E = e1;
578 if (e1 < W)
579 W = e1;
580
581 x1 = X(e1);
582 y1 = Y(y[i]);
583
584 if (!edge(x0, y0, x1, y1))
585 return NO_MEMORY;
586
587 x0 = x1;
588 y0 = y1;
589 e0 = e1;
590 }
591 if (pole && !edge(x0, y0, x0, Y(90.0 * pole)))
592 return NO_MEMORY;
593
594 shift = 0; /* shift into window */
595 while (E + shift > st->window.east)
596 shift -= 360.0;
597 while (E + shift < st->window.west)
598 shift += 360.0;
599 shift1[j] = X(x[n - 1] + shift) - X(x[n - 1]);
600 }
601 else {
602 x0 = X(x[n - 1]);
603 y0 = Y(y[n - 1]);
604
605 for (i = 0; i < n; i++) {
606 x1 = X(x[i]);
607 y1 = Y(y[i]);
608 if (!edge(x0, y0, x1, y1))
609 return NO_MEMORY;
610 x0 = x1;
611 y0 = y1;
612 }
613 }
614 } /* for() */
615
616 /* check if perimeter has odd number of points */
617 if (st->np & 1) {
618 G_warning("Weird internal error: perimeter has odd number of points");
619 return OUT_OF_SYNC;
620 }
621
622 /* sort the edge points by col(x) and then by row(y) */
623 qsort(st->P, st->np, sizeof(POINT), &edge_order);
624
625 /* plot */
626 for (j = 0; j < rings; j++) {
627 for (i = 1; i < st->np; i += 2) {
628 if (st->P[i].y != st->P[i - 1].y) {
629 G_warning("Weird internal error: edge leaves row");
630 return OUT_OF_SYNC;
631 }
632 st->row_fill(st->P[i].y, st->P[i - 1].x + shift1[j],
633 st->P[i].x + shift1[j]);
634 }
635 if (st->window.proj == PROJECTION_LL) { /* now do wrap-around, part 2 */
636 n = rpnts[j];
637 x = xs[j];
638 y = ys[j];
639
640 shift = 0;
641 while (W + shift < st->window.west)
642 shift += 360.0;
643 while (W + shift > st->window.east)
644 shift -= 360.0;
645 shift2 = X(x[n - 1] + shift) - X(x[n - 1]);
646 if (shift2 != shift1[j]) {
647 for (i = 1; i < st->np; i += 2) {
648 st->row_fill(st->P[i].y, st->P[i - 1].x + shift2,
649 st->P[i].x + shift2);
650 }
651 }
652 }
653 }
654 G_free(shift1);
655 return OK;
656}
657
658static int edge(double x0, double y0, double x1, double y1)
659{
660 double m, d;
661 double x;
662 int ystart, ystop;
663 int exp;
664
665 /* tolerance to avoid FPE */
666 d = GRASS_EPSILON;
667 if (y0 != y1) {
668 if (fabs(y0) > fabs(y1))
669 d = fabs(y0);
670 else
671 d = fabs(y1);
672
673 d = frexp(d, &exp);
674 exp -= 53;
675 d = ldexp(d, exp);
676 }
677
678 if (fabs(y0 - y1) < d)
679 return 1;
680
681 if (y0 < y1) {
682 ystart = iceil(y0);
683 ystop = ifloor(y1);
684 if (ystop == y1)
685 ystop--; /* if line stops at row center, don't include point */
686 }
687 else {
688 ystart = iceil(y1);
689 ystop = ifloor(y0);
690 if (ystop == y0)
691 ystop--; /* if line stops at row center, don't include point */
692 }
693
694 if (ystart > ystop)
695 return 1; /* does not cross center line of row */
696
697 m = (x0 - x1) / (y0 - y1);
698 x = m * (ystart - y0) + x0;
699 while (ystart <= ystop) {
700 if (!edge_point(x, ystart++))
701 return 0;
702 x += m;
703 }
704
705 return 1;
706}
707
708static int edge_point(double x, int y)
709{
710
711 if (y < st->ymin || y > st->ymax)
712 return 1;
713 if (st->np >= st->npalloc) {
714 if (st->npalloc > 0) {
715 st->npalloc *= 2;
716 st->P = (POINT *)G_realloc(st->P, st->npalloc * sizeof(POINT));
717 }
718 else {
719 st->npalloc = 32;
720 st->P = (POINT *)G_malloc(st->npalloc * sizeof(POINT));
721 }
722 if (st->P == NULL) {
723 st->npalloc = 0;
724 return 0;
725 }
726 }
727 st->P[st->np].x = x;
728 st->P[st->np++].y = y;
729 return 1;
730}
731
732static int edge_order(const void *aa, const void *bb)
733{
734 const struct point *a = aa, *b = bb;
735
736 if (a->y < b->y)
737 return (-1);
738 if (a->y > b->y)
739 return (1);
740
741 if (a->x < b->x)
742 return (-1);
743 if (a->x > b->x)
744 return (1);
745
746 return (0);
747}
748
749static void row_solid_fill(int y, double x1, double x2)
750{
751 int i1, i2;
752
753 i1 = iceil(x1);
754 i2 = ifloor(x2);
755 if (i1 <= i2) {
756 st->move(i1, y);
757 st->cont(i2, y);
758 }
759}
760
761static void row_dotted_fill(int y, double x1, double x2)
762{
763 int i1, i2, i;
764
765 if (y != iceil(y / st->dotted_fill_gap) * st->dotted_fill_gap)
766 return;
767
768 i1 = iceil(x1 / st->dotted_fill_gap) * st->dotted_fill_gap;
769 i2 = ifloor(x2);
770 if (i1 <= i2) {
771 for (i = i1; i <= i2; i += st->dotted_fill_gap) {
772 st->move(i, y);
773 st->cont(i, y);
774 }
775 }
776}
777
778static int ifloor(double x)
779{
780 int i;
781
782 i = (int)x;
783 if (i > x)
784 i--;
785 return i;
786}
787
788static int iceil(double x)
789{
790 int i;
791
792 i = (int)x;
793 if (i < x)
794 i++;
795 return i;
796}
797
798/*!
799 * \brief Plot f(east1) to f(east2)
800 *
801 * The function <i>f(east)</i> is plotted from <i>east1</i> to
802 * <i>east2</i>. The function <i>f(east)</i> must return the map
803 * northing coordinate associated with east.
804 *
805 * \param f plotting function
806 * \param east1 easting (first point)
807 * \param east2 easting (second point)
808 */
809void G_plot_fx(double (*f)(double), double east1, double east2)
810{
811 double east, north, north1;
812 double incr;
813
814 incr = fabs(1.0 / st->xconv);
815
816 east = east1;
817 north = f(east1);
818
819 if (east1 > east2) {
820 while ((east1 -= incr) > east2) {
821 north1 = f(east1);
822 G_plot_line(east, north, east1, north1);
823 north = north1;
824 east = east1;
825 }
826 }
827 else {
828 while ((east1 += incr) < east2) {
829 north1 = f(east1);
830 G_plot_line(east, north, east1, north1);
831 north = north1;
832 east = east1;
833 }
834 }
835
836 G_plot_line(east, north, east2, f(east2));
837}
#define NULL
Definition ccmath.h:32
void G_free(void *)
Free allocated memory.
Definition gis/alloc.c:145
#define G_realloc(p, n)
Definition defs/gis.h:138
#define G_calloc(m, n)
Definition defs/gis.h:137
void G_warning(const char *,...) __attribute__((format(printf
void G_get_set_window(struct Cell_head *)
Get the current working window (region)
#define G_malloc(n)
Definition defs/gis.h:136
double G_adjust_easting(double, const struct Cell_head *)
Returns east not smaller than west.
#define GRASS_EPSILON
Definition gis.h:177
#define PROJECTION_LL
Projection code - Latitude-Longitude.
Definition gis.h:128
#define W
Definition ogsf.h:149
struct state state
Definition parser.c:101
struct state * st
Definition parser.c:102
int G_plot_area(double *const *xs, double *const *ys, int *rpnts, int rings)
Plot multiple polygons.
Definition plot.c:531
void G_plot_line2(double east1, double north1, double east2, double north2)
Plot line between latlon coordinates (slowline)
Definition plot.c:221
int G_plot_polygon(const double *x, const double *y, int n)
Plot filled polygon with n vertices.
Definition plot.c:401
#define OUT_OF_SYNC
Definition plot.c:71
void G_plot_where_en(int x, int y, double *east, double *north)
Converts x,y to east,north.
Definition plot.c:175
#define X(e)
Definition plot.c:141
#define POINT
Definition plot.c:48
void G_plot_where_xy(double east, double north, int *x, int *y)
Converts east,north to x,y.
Definition plot.c:158
void G_setup_fill(int gap)
Set row_fill routine to row_solid_fill or row_dotted_fill.
Definition plot.c:131
void G_setup_plot(double t, double b, double l, double r, int(*Move)(int, int), int(*Cont)(int, int))
Initialize plotting routines.
Definition plot.c:95
#define NORTH(y)
Definition plot.c:145
void G_plot_fx(double(*f)(double), double east1, double east2)
Plot f(east1) to f(east2)
Definition plot.c:809
void G_plot_line(double east1, double north1, double east2, double north2)
Plot line between latlon coordinates (fastline)
Definition plot.c:206
#define Y(n)
Definition plot.c:142
#define NO_MEMORY
Definition plot.c:70
#define OK
Definition plot.c:68
void G_plot_point(double east, double north)
Plot point.
Definition plot.c:187
#define EAST(x)
Definition plot.c:144
#define TOO_FEW_EDGES
Definition plot.c:69
double b
Definition r_raster.c:37
double l
Definition r_raster.c:37
double t
Definition r_raster.c:37
double r
Definition r_raster.c:37
2D/3D raster map header (used also for region)
Definition gis.h:445
#define x