in src/apps/applib/lib/utility.c [126:178]
int readBoundary(FILE* f, GeoBoundary* 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 GeoBoundary from input");
return -1;
}
}
if (buff[0] != '{') {
printf("missing GeoBoundary {");
return -2;
}
// now read the verts
b->numVerts = 0;
while (1) {
if (!fgets(buff, BUFF_SIZE, f)) {
printf("reading GeoBoundary 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 GeoBoundary from input");
return -5;
}
double latDegs, lonDegs;
if (sscanf(buff, "%lf %lf", &latDegs, &lonDegs) != 2) {
printf("parsing GeoBoundary from input");
return -6;
}
setGeoDegs(&b->verts[b->numVerts], latDegs, lonDegs);
b->numVerts++;
}
return 0;
}