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

View File

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