forked from ExternalVendorCode/Signal-Server
Improve PAT loading logic
This commit is contained in:
35
inputs.cc
35
inputs.cc
@@ -659,14 +659,14 @@ char LoadSDF(char *name)
|
|||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadPAT(char *filename)
|
int LoadPAT(char *az_filename, char *el_filename)
|
||||||
{
|
{
|
||||||
/* This function reads and processes antenna pattern (.az
|
/* This function reads and processes antenna pattern (.az
|
||||||
and .el) files that correspond in name to previously
|
and .el) files that correspond in name to previously
|
||||||
loaded ss .lrp files. */
|
loaded ss .lrp files. */
|
||||||
|
|
||||||
int a, b, w, x, y, z, last_index, next_index, span;
|
int a, b, w, x, y, z, last_index, next_index, span;
|
||||||
char string[255], azfile[255], elfile[255], *pointer = NULL;
|
char string[255], *pointer = NULL;
|
||||||
float az, xx, elevation, amplitude, rotation, valid1, valid2,
|
float az, xx, elevation, amplitude, rotation, valid1, valid2,
|
||||||
delta, azimuth[361], azimuth_pattern[361], el_pattern[10001],
|
delta, azimuth[361], azimuth_pattern[361], el_pattern[10001],
|
||||||
elevation_pattern[361][1001], slant_angle[361], tilt,
|
elevation_pattern[361][1001], slant_angle[361], tilt,
|
||||||
@@ -674,21 +674,6 @@ int LoadPAT(char *filename)
|
|||||||
FILE *fd = NULL;
|
FILE *fd = NULL;
|
||||||
unsigned char read_count[10001];
|
unsigned char read_count[10001];
|
||||||
|
|
||||||
for (x = 0; filename[x] != '.' && filename[x] != 0 && x < 250; x++) {
|
|
||||||
azfile[x] = filename[x];
|
|
||||||
elfile[x] = filename[x];
|
|
||||||
}
|
|
||||||
|
|
||||||
azfile[x] = '.';
|
|
||||||
azfile[x + 1] = 'a';
|
|
||||||
azfile[x + 2] = 'z';
|
|
||||||
azfile[x + 3] = 0;
|
|
||||||
|
|
||||||
elfile[x] = '.';
|
|
||||||
elfile[x + 1] = 'e';
|
|
||||||
elfile[x + 2] = 'l';
|
|
||||||
elfile[x + 3] = 0;
|
|
||||||
|
|
||||||
rotation = 0.0;
|
rotation = 0.0;
|
||||||
|
|
||||||
got_azimuth_pattern = 0;
|
got_azimuth_pattern = 0;
|
||||||
@@ -696,8 +681,11 @@ int LoadPAT(char *filename)
|
|||||||
|
|
||||||
/* Load .az antenna pattern file */
|
/* Load .az antenna pattern file */
|
||||||
|
|
||||||
if( (fd = fopen(azfile, "r")) != NULL ){
|
if( az_filename != NULL && (fd = fopen(az_filename, "r")) == NULL && errno != ENOENT )
|
||||||
|
/* Any error other than file not existing is an error */
|
||||||
|
return errno;
|
||||||
|
|
||||||
|
if( fd != NULL ){
|
||||||
/* Clear azimuth pattern array */
|
/* Clear azimuth pattern array */
|
||||||
|
|
||||||
for (x = 0; x <= 360; x++) {
|
for (x = 0; x <= 360; x++) {
|
||||||
@@ -757,6 +745,7 @@ int LoadPAT(char *filename)
|
|||||||
} while (feof(fd) == 0);
|
} while (feof(fd) == 0);
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
fd = NULL;
|
||||||
|
|
||||||
/* Handle 0=360 degree ambiguity */
|
/* Handle 0=360 degree ambiguity */
|
||||||
|
|
||||||
@@ -823,13 +812,15 @@ int LoadPAT(char *filename)
|
|||||||
azimuth_pattern[360] = azimuth_pattern[0];
|
azimuth_pattern[360] = azimuth_pattern[0];
|
||||||
|
|
||||||
got_azimuth_pattern = 255;
|
got_azimuth_pattern = 255;
|
||||||
}else if( errno == EACCES ){
|
|
||||||
return errno;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read and process .el file */
|
/* Read and process .el file */
|
||||||
|
|
||||||
if( (fd = fopen(elfile, "r")) != NULL ){
|
if( el_filename != NULL && (fd = fopen(el_filename, "r")) == NULL && errno != ENOENT )
|
||||||
|
/* Any error other than file not existing is an error */
|
||||||
|
return errno;
|
||||||
|
|
||||||
|
if( fd != NULL ){
|
||||||
|
|
||||||
for (x = 0; x <= 10000; x++) {
|
for (x = 0; x <= 10000; x++) {
|
||||||
el_pattern[x] = 0.0;
|
el_pattern[x] = 0.0;
|
||||||
@@ -1009,8 +1000,6 @@ int LoadPAT(char *filename)
|
|||||||
LR.antenna_pattern[x][y] = az * elevation;
|
LR.antenna_pattern[x][y] = az * elevation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else if( errno == EACCES ){
|
|
||||||
return errno;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
int LoadSDF_SDF(char *name, int winfiles);
|
int LoadSDF_SDF(char *name, int winfiles);
|
||||||
char LoadSDF(char *name, int winfiles);
|
char LoadSDF(char *name, int winfiles);
|
||||||
int LoadPAT(char *filename);
|
int LoadPAT(char *az_filename, char *el_filename);
|
||||||
int LoadSignalColors(struct site xmtr);
|
int LoadSignalColors(struct site xmtr);
|
||||||
void LoadLossColors(struct site xmtr);
|
void LoadLossColors(struct site xmtr);
|
||||||
void LoadDBMColors(struct site xmtr);
|
void LoadDBMColors(struct site xmtr);
|
||||||
@@ -14,4 +14,7 @@ void LoadUDT(char *filename);
|
|||||||
int loadLIDAR(char *filename);
|
int loadLIDAR(char *filename);
|
||||||
int loadClutter(char *filename, double radius, struct site tx);
|
int loadClutter(char *filename, double radius, struct site tx);
|
||||||
|
|
||||||
|
static const char AZ_FILE_SUFFIX[] = ".az";
|
||||||
|
static const char EL_FILE_SUFFIX[] = ".el";
|
||||||
|
|
||||||
#endif /* _INPUTS_HH_ */
|
#endif /* _INPUTS_HH_ */
|
||||||
|
21
main.cc
21
main.cc
@@ -1050,6 +1050,7 @@ int main(int argc, char *argv[])
|
|||||||
0, area_mode = 0, max_txsites, ngs = 0;
|
0, area_mode = 0, max_txsites, ngs = 0;
|
||||||
|
|
||||||
char mapfile[255], udt_file[255], ano_filename[255], lidar_tiles[4096], clutter_file[255];
|
char mapfile[255], udt_file[255], ano_filename[255], lidar_tiles[4096], clutter_file[255];
|
||||||
|
char *az_filename, *el_filename;
|
||||||
|
|
||||||
double altitude = 0.0, altitudeLR = 0.0, tx_range = 0.0,
|
double altitude = 0.0, altitudeLR = 0.0, tx_range = 0.0,
|
||||||
rx_range = 0.0, deg_range = 0.0, deg_limit = 0.0, deg_range_lon;
|
rx_range = 0.0, deg_range = 0.0, deg_limit = 0.0, deg_range_lon;
|
||||||
@@ -1218,10 +1219,26 @@ int main(int argc, char *argv[])
|
|||||||
strncpy(mapfile, argv[z], 253);
|
strncpy(mapfile, argv[z], 253);
|
||||||
strncpy(tx_site[0].name, "Tx", 2);
|
strncpy(tx_site[0].name, "Tx", 2);
|
||||||
strncpy(tx_site[0].filename, argv[z], 253);
|
strncpy(tx_site[0].filename, argv[z], 253);
|
||||||
if( (result = LoadPAT(argv[z])) != 0 ){
|
/* Antenna pattern files have the same basic name as the output file
|
||||||
fprintf(stderr,"Error reading antenna pattern file\n");
|
* but with a different extension. If they exist, load them now */
|
||||||
|
if( (az_filename = (char*) calloc(strlen(argv[z]) + strlen(AZ_FILE_SUFFIX) + 1, sizeof(char))) == NULL )
|
||||||
|
return ENOMEM;
|
||||||
|
strcpy(az_filename, argv[z]);
|
||||||
|
strcat(az_filename, AZ_FILE_SUFFIX);
|
||||||
|
if( (el_filename = (char*) calloc(strlen(argv[z]) + strlen(EL_FILE_SUFFIX) + 1, sizeof(char))) == NULL ){
|
||||||
|
free(az_filename);
|
||||||
|
return ENOMEM;
|
||||||
|
}
|
||||||
|
strcpy(el_filename, argv[z]);
|
||||||
|
strcat(el_filename, EL_FILE_SUFFIX);
|
||||||
|
if( (result = LoadPAT(az_filename,el_filename)) != 0 ){
|
||||||
|
fprintf(stderr,"Permissions error reading antenna pattern file\n");
|
||||||
|
free(az_filename);
|
||||||
|
free(el_filename);
|
||||||
exit(result);
|
exit(result);
|
||||||
}
|
}
|
||||||
|
free(az_filename);
|
||||||
|
free(el_filename);
|
||||||
} else if (z <= y && argv[z][0] && argv[z][0] == '-' && argv[z][1] == '\0' ) {
|
} else if (z <= y && argv[z][0] && argv[z][0] == '-' && argv[z][1] == '\0' ) {
|
||||||
/* Handle writing image data to stdout */
|
/* Handle writing image data to stdout */
|
||||||
to_stdout = true;
|
to_stdout = true;
|
||||||
|
Reference in New Issue
Block a user