Correctly detect missing clutter file

This commit is contained in:
Gareth Evans
2017-02-22 11:54:23 +00:00
parent e68a6c4221
commit b2008590e7
2 changed files with 97 additions and 94 deletions

View File

@@ -3,6 +3,7 @@
#include <string.h>
#include <unistd.h>
#include <math.h>
#include <errno.h>
#include "common.h"
#include "main.hh"
@@ -22,9 +23,8 @@ int loadClutter(char *filename, double radius, struct site tx)
char * pch;
FILE *fd;
fd = fopen(filename, "rb");
if (fd != NULL) {
if( (fd = fopen(filename, "rb")) == NULL)
return errno;
if (fgets(line, 19, fd) != NULL) {
pch = strtok (line," ");
@@ -120,7 +120,7 @@ int loadClutter(char *filename, double radius, struct site tx)
fprintf(stderr, "Clutter error @ x %d y %d\n", x, y);
}//if
}//for
}
fclose(fd);
return 0;
}

View File

@@ -1042,7 +1042,7 @@ int main(int argc, char *argv[])
int x, y, z = 0, min_lat, min_lon, max_lat, max_lon,
rxlat, rxlon, txlat, txlon, west_min, west_max,
nortRxHin, nortRxHax, propmodel, knifeedge = 0, ppa =
0, normalise = 0, haf = 0, pmenv = 1, lidar=0, cropped;
0, normalise = 0, haf = 0, pmenv = 1, lidar=0, cropped, result;
bool use_threads = true;
@@ -1797,7 +1797,10 @@ int main(int argc, char *argv[])
Clutter tiles cover 16 x 12 degs but we only need a fraction of that area.
Limit by max_range / miles per degree (at equator)
*/
loadClutter(clutter_file,max_range/45,tx_site[0]);
if( (result = loadClutter(clutter_file,max_range/45,tx_site[0])) != 0 ){
fprintf(stderr, "Error, invalid or clutter file not found\n");
return result;
}
}
if (ppa == 0) {