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);
char * G_mapset(void)
current mapset name
int I_new_control_point(struct Control_Points *cp, double e1, double n1, double e2, double n2, int status)
add new control point
int I_put_control_points(const char *group, const struct Control_Points *cp)
write group control points
int G_getl2(char *buf, int n, FILE *fd)
gets a line of text from a file of any pedigree
int I_get_control_points(const char *group, struct Control_Points *cp)
read group control points
int G_strip(char *buf)
Removes all leading and trailing white space from string.
FILE * I_fopen_group_file_old(const char *group, const char *file)
FILE * I_fopen_group_file_new(const char *group, const char *file)
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)