1 #include <grass/imagery.h>
2 #include <grass/glocale.h>
4 #define POINT_FILE "POINTS"
6 static int I_read_control_points(FILE * fd,
struct Control_Points *cp)
23 while (
G_getl2(buf,
sizeof buf, fd)) {
25 if (*buf ==
'#' || *buf == 0)
27 if (sscanf(buf,
"%lf%lf%lf%lf%d", &e1, &n1, &e2, &n2, &status) == 5)
58 double e1,
double n1,
double e2,
double n2,
67 size = cp->count *
sizeof(double);
68 cp->e1 = (
double *)G_realloc(cp->e1, size);
69 cp->e2 = (
double *)G_realloc(cp->e2, size);
70 cp->n1 = (
double *)G_realloc(cp->n1, size);
71 cp->n2 = (
double *)G_realloc(cp->n2, size);
72 size = cp->count *
sizeof(int);
73 cp->status = (
int *)G_realloc(cp->status, size);
79 cp->status[i] = status;
84 static int I_write_control_points(FILE * fd,
const struct Control_Points *cp)
88 fprintf(fd,
"# %7s %15s %15s %15s %9s status\n",
"",
"image",
"",
90 fprintf(fd,
"# %15s %15s %15s %15s (1=ok)\n",
"east",
"north",
"east",
93 for (i = 0; i < cp->count; i++)
94 if (cp->status[i] >= 0)
95 fprintf(fd,
" %15f %15f %15f %15f %4d\n",
96 cp->e1[i], cp->n1[i], cp->e2[i], cp->n2[i],
124 G_warning(_(
"Unable to open control point file for group [%s in %s]"),
129 stat = I_read_control_points(fd, cp);
132 G_warning(_(
"Bad format in control point file for group [%s in %s]"),
159 G_warning(_(
"Unable to create control point file for group [%s in %s]"),
164 I_write_control_points(fd, cp);