Detect and handle errors in topo data

This commit is contained in:
Gareth Evans
2017-03-04 19:35:03 +00:00
parent af13a8d4ba
commit f3029bb3cf
3 changed files with 27 additions and 13 deletions

View File

@@ -364,8 +364,8 @@ int LoadSDF_SDF(char *name)
/* Parse filename for minimum latitude and longitude values */
sscanf(sdf_file, "%d:%d:%d:%d", &minlat, &maxlat, &minlon,
&maxlon);
sscanf(sdf_file, "%d:%d:%d:%d", &minlat, &maxlat, &minlon,
&maxlon);
sdf_file[x] = '.';
@@ -533,7 +533,7 @@ int LoadSDF_SDF(char *name)
return 0;
}
char LoadSDF(char *name)
int LoadSDF(char *name)
{
/* This function loads the requested SDF file from the filesystem.
It first tries to invoke the LoadSDF_SDF() function to load an
@@ -555,8 +555,8 @@ char LoadSDF(char *name)
if ( return_value == 0 || return_value < 0 ) {
sscanf(name, "%d:%d:%d:%d", &minlat, &maxlat, &minlon,
&maxlon);
sscanf(name, "%d:%d:%d:%d", &minlat, &maxlat, &minlon,
&maxlon);
/* Is it already in memory? */
@@ -1458,12 +1458,13 @@ int LoadDBMColors(struct site xmtr)
return 0;
}
void LoadTopoData(int max_lon, int min_lon, int max_lat, int min_lat)
int LoadTopoData(int max_lon, int min_lon, int max_lat, int min_lat)
{
/* This function loads the SDF files required
to cover the limits of the region specified. */
int x, y, width, ymin, ymax;
int success;
width = ReduceAngle(max_lon - min_lon);
@@ -1495,7 +1496,9 @@ void LoadTopoData(int max_lon, int min_lon, int max_lat, int min_lat)
snprintf(string, 16,
"%d:%d:%d:%d", x,
x + 1, ymin, ymax);
LoadSDF(string);
if( (success = LoadSDF(string)) < 0 ){
return -success;
}
}
}
@@ -1526,9 +1529,12 @@ void LoadTopoData(int max_lon, int min_lon, int max_lat, int min_lat)
snprintf(string, 16,
"%d:%d:%d:%d", x,
x + 1, ymin, ymax);
LoadSDF(string);
if( (success = LoadSDF(string)) < 0 ){
return -success;
}
}
}
return 0;
}
void LoadUDT(char *filename)

View File

@@ -4,12 +4,12 @@
#include "common.h"
int LoadSDF_SDF(char *name, int winfiles);
char LoadSDF(char *name, int winfiles);
int LoadSDF(char *name, int winfiles);
int LoadPAT(char *az_filename, char *el_filename);
int LoadSignalColors(struct site xmtr);
int LoadLossColors(struct site xmtr);
int LoadDBMColors(struct site xmtr);
void LoadTopoData(int max_lon, int min_lon, int max_lat, int min_lat);
int LoadTopoData(int max_lon, int min_lon, int max_lat, int min_lat);
void LoadUDT(char *filename);
int loadLIDAR(char *filename);
int loadClutter(char *filename, double radius, struct site tx);

14
main.cc
View File

@@ -1708,9 +1708,13 @@ int main(int argc, char *argv[])
}else{
// DEM first
LoadTopoData(max_lon, min_lon, max_lat, min_lat);
if( (result = LoadTopoData(max_lon, min_lon, max_lat, min_lat)) != 0 ){
// This only fails on errors loading SDF tiles
fprintf(stderr, "Error loading topo data\n");
return result;
}
if (area_mode || topomap) {
if (area_mode || topomap) {
for (z = 0; z < txsites && z < max_txsites; z++) {
/* "Ball park" estimates used to load any additional
SDF files required to conduct this analysis. */
@@ -1793,7 +1797,11 @@ int main(int argc, char *argv[])
/* Load any additional SDF files, if required */
LoadTopoData(max_lon, min_lon, max_lat, min_lat);
if( (result = LoadTopoData(max_lon, min_lon, max_lat, min_lat)) != 0 ){
// This only fails on errors loading SDF tiles
fprintf(stderr, "Error loading topo data\n");
return result;
}
}
ppd=(double)ippd;
yppd=ppd;