Elegantly handle missing LIDAR tiles

This commit is contained in:
Gareth Evans
2017-02-22 12:08:21 +00:00
parent b2008590e7
commit 3de2bf8f97
2 changed files with 92 additions and 100 deletions

View File

@@ -234,9 +234,8 @@ int loadLIDAR(char *filenames)
} }
while (indx < fc) { while (indx < fc) {
fd = fopen(files[indx], "rb"); if( (fd = fopen(files[indx], "rb")) == NULL )
return errno;
if (fd != NULL) {
if (fgets(line, 255, fd) != NULL) { if (fgets(line, 255, fd) != NULL) {
pch = strtok (line," "); pch = strtok (line," ");
@@ -332,9 +331,6 @@ int loadLIDAR(char *filenames)
fclose(fd); fclose(fd);
if (debug) if (debug)
fprintf(stderr, "LIDAR LOADED %d x %d\n", width, height); fprintf(stderr, "LIDAR LOADED %d x %d\n", width, height);
} else {
return -1;
}
indx++; indx++;
} // filename(s) } // filename(s)
IPPD=width; IPPD=width;

View File

@@ -1665,17 +1665,13 @@ int main(int argc, char *argv[])
/* Load the required tiles */ /* Load the required tiles */
if(lidar){ if(lidar){
int err; if( (result = loadLIDAR(lidar_tiles)) != 0 ){
err = loadLIDAR(lidar_tiles);
if (err) {
fprintf(stderr, "Couldn't find one or more of the " fprintf(stderr, "Couldn't find one or more of the "
"lidar files. Please ensure their paths are " "lidar files. Please ensure their paths are "
"correct and try again.\n"); "correct and try again.\n");
exit(EXIT_FAILURE); exit(result);
} }
if(debug){ if(debug){
fprintf(stderr,"%.4f,%.4f,%.4f,%.4f,%d x %d\n",max_north,min_west,min_north,max_west,width,height); fprintf(stderr,"%.4f,%.4f,%.4f,%.4f,%d x %d\n",max_north,min_west,min_north,max_west,width,height);
} }