in src/apps/testapps/testCellToBoundary.c [41:93]
int readBoundary(FILE *f, CellBoundary *b) {
char buff[BUFF_SIZE];
// get the first line, which should be a "{"
if (!fgets(buff, BUFF_SIZE, f)) {
if (feof(stdin)) {
return EOF;
} else {
printf("reading CellBoundary from input");
return -1;
}
}
if (buff[0] != '{') {
printf("missing CellBoundary {");
return -2;
}
// now read the verts
b->numVerts = 0;
while (1) {
if (!fgets(buff, BUFF_SIZE, f)) {
printf("reading CellBoundary from input");
return -3;
}
if (buff[0] == '}') {
if (b->numVerts == 0) {
printf("reading empty cell boundary");
return -4;
} else {
break;
}
}
if (b->numVerts == MAX_CELL_BNDRY_VERTS) {
printf("too many vertices in CellBoundary from input");
return -5;
}
double latDegs, lngDegs;
if (sscanf(buff, "%lf %lf", &latDegs, &lngDegs) != 2) {
printf("parsing CellBoundary from input");
return -6;
}
setGeoDegs(&b->verts[b->numVerts], latDegs, lngDegs);
b->numVerts++;
}
return 0;
}