2.72 More LIDAR tiles

This commit is contained in:
root
2016-02-07 20:40:16 +00:00
parent 3c0bcb97d1
commit 1216e66121
11 changed files with 305 additions and 11629 deletions

4
1200.h
View File

@@ -1,4 +0,0 @@
#define MAXPAGES 64
#define ARRAYSIZE 76810
#define IPPD 1200

4
3600.h
View File

@@ -1,4 +0,0 @@
#define MAXPAGES 4
#define ARRAYSIZE 14844
#define IPPD 3600

View File

@@ -1,5 +1,10 @@
SIGNAL SERVER CHANGELOG
2.7.1 - 14 Jan 2016
2.72 - 07 Feb 2016
Expanded LIDAR coverage to read in 4 adjacent ASCII tiles in a 2x2 grid
Removed requirement to specify -res in LIDAR mode as it's in the file header
2.71 - 14 Jan 2016
LIDAR longitude bugfix for Greenwich meridian tiles
Adjusted ITM parameters warnings

View File

@@ -25,11 +25,11 @@ Additional programs/scripts will be required to prepare inputs such as .sdf tile
$ make
```
## Parameters
-- Signal Server 2.70 --
-- Signal Server 2.72 --
Set for 64 tiles at 1200 pixels/degree
-sdf Directory containing .sdf tiles
-lid LIDAR ASCII tile with WGS84 bounds
-lid LIDAR ASCII tile with WGS84 bounds (Dimensions defined in file metadata)
-lat Tx Latitude (decimal degrees) -70/+70
-lon Tx Longitude (decimal degrees) -180/+180
-txh Tx Height (above ground)
@@ -50,7 +50,7 @@ $ make
-cl Climate code 1-6 (optional)
-o Filename. Required.
-R Radius (miles/kilometers)
-res Pixels per tile. 300/600/1200/3600/5000/10000 (optional)
-res Pixels per tile. 300/600/1200/3600 (Optional. LIDAR res is defined within the tile)
-t Terrain background
-pm Prop model. 1: ITM, 2: LOS, 3: Hata, 4: ECC33,
5: SUI, 6: COST-Hata, 7: FSPL, 8: ITWOM, 9: Ericsson
@@ -61,20 +61,19 @@ $ make
-nothreads Turn off threaded processing (optional)
## Examples
### 90m resolution
- INPUTS: 900MHz tower at 25m AGL with 5W ERP
- INPUTS: 900MHz tower at 25m AGL with 5W ERP, 30km radius
- OUTPUTS: 1200 resolution, 30km radius, -90dBm receiver threshold, Longley Rice model
- ./signalserver -sdf /data/SRTM3 -lat 51.849 -lon -2.2299 -txh 25 -f 900 -erp 5 -rxh 2 -rt -90 -dbm -m -o test1 -R 30 -res 1200 -pm 1
### 30m resolution
- INPUTS: 450MHz tower at 25f AGL with 20W ERP
- INPUTS: 450MHz tower at 25f AGL with 20W ERP, 10km radius
- OUTPUTS: 3600 resolution, 30km radius, 10dBuV receiver threshold, Hata model
- ./signalserverHD -sdf /data/SRTM1 -lat 51.849 -lon -2.2299 -txh 25 -f 450 -erp 20 -rxh 2 -rt 10 -o test2 -R 30 -res 3600 -pm 3
- ./signalserverHD -sdf /data/SRTM1 -lat 51.849 -lon -2.2299 -txh 25 -f 450 -erp 20 -rxh 2 -rt 10 -o test2 -R 10 -res 3600 -pm 3
### 2m resolution (LIDAR)
- INPUTS: 1800MHz tower at 15m AGL with 1W ERP
- INPUTS: 1800MHz tower at 15m AGL with 1W ERP, 1 km radius
- OUTPUTS: 2m LIDAR resolution, 5km radius, -90dBm receiver threshold, Longley Rice model
- ./signalserverLIDAR -lid /data/LIDAR2m/Gloucester_2m.asc -lat 51.849 -lon -2.2299 -txh 15 -f 1800 -erp 1 -rxh 2 -rt -90 -dbm -m -o test3 -R 30 -res 5000 -pm 1
- ./signalserverLIDAR -lid /data/LIDAR/Gloucester_2m.asc -lat 51.849 -lon -2.2299 -txh 15 -f 1800 -erp 1 -rxh 2 -rt -90 -dbm -m -o test3 -R 1 -pm 1

View File

@@ -78,6 +78,7 @@ extern double max_north;
extern double min_west;
extern double max_west;
extern int ippd;
extern int MAXRAD;
extern int mpi;
extern int max_elevation;
extern int min_elevation;

246
inputs.cc
View File

@@ -6,9 +6,117 @@
#include "common.h"
#include "main.hh"
int loadLIDAR(char *filename)
void readLIDAR(FILE *fd, int hoffset, int voffset, int h, int w, int indx, double n, double e, double s, double west)
{
/* This function reads a single LIDAR tile of n rows and n columns in ASCII grid format.
int x=0,y=0,reads=0;
char line[150000];
char * pch;
// use offsets to determine middle lat/lon for 5 x 10k tiles
// TALL
if(voffset==0 && h==10000){
s = (s+n)/2;
h=5000;
}
if(voffset==5000 && h==10000){
n = (s+n)/2;
}
// WIDE
if(hoffset==0 && w==10000){
e = (e+west)/2;
w=5000;
}
if(hoffset==5000 && w==10000){
west = (e+west)/2;
w=5000;
}
dem[indx].max_north=n;
dem[indx].min_west=e;
dem[indx].min_north=s;
dem[indx].max_west=west;
if (dem[indx].max_west > max_west)
max_west = dem[indx].max_west;
if (dem[indx].min_west < min_west)
min_west = dem[indx].min_west;
if (max_west == -1)
max_west = dem[indx].max_west;
else {
if (abs(dem[indx].max_west - max_west) < 180) {
if (dem[indx].max_west > max_west)
max_west = dem[indx].max_west;
}
else {
if (dem[indx].max_west < max_west)
max_west = dem[indx].max_west;
}
}
if (min_west == 360)
min_west = dem[indx].min_west;
else {
if (fabs(dem[indx].min_west - min_west) < 180.0) {
if (dem[indx].min_west < min_west)
min_west = dem[indx].min_west;
}
else {
if (dem[indx].min_west > min_west)
min_west = dem[indx].min_west;
}
}
for (y = h-1; y > -1; y--) {
x=w-1;
if (fgets(line, 150000, fd) != NULL) {
// do nothing until n rows have passed
if(y<voffset || voffset==0){
pch = strtok (line, " ");
//dummy reads until we reach offset
// for 5000 offset, width must be 10e3
for(n=0;n<hoffset;n++){
pch = strtok(NULL, " ");
}
while(pch != NULL && x > -1){
if(atoi(pch)<-999){
pch="0";
}
dem[indx].data[y][x]=atoi(pch);
dem[indx].signal[x][y] = 0;
dem[indx].mask[x][y] = 0;
if (atoi(pch) > dem[indx].max_el){
dem[indx].max_el = atoi(pch);
max_elevation = atoi(pch);
}
if (atoi(pch) < dem[indx].min_el){
dem[indx].min_el = atoi(pch);
min_elevation = dem[indx].min_el;
}
//}
x--;
pch = strtok (NULL, " ");
} //while
} //voffset
}else{
fprintf(stdout,"LIDAR error @ x %d y %d indx %d\n",x,y,indx);
}//if
}//for
}
int loadLIDAR(char *filenames)
{
/* This function reads either 9 LIDAR tiles of n rows and n columns in ASCII grid format OR a single super tile composed of 2 or more tiles.
The tile must have WGS84 bounds in the header in the order: WEST,SOUTH,EAST,NORTH
ncols 5000
nrows 5000
@@ -19,27 +127,42 @@ int loadLIDAR(char *filename)
cellsize 2
NODATA_value -9999
Tiles must be entered in the format -lid tile1.asc,tile2.asc,tile3.asc
*/
int x, y, width, height, cellsize;
char *filename;
char *files[4]; // 4 tiles
int x, y, cellsize,indx=0,fc=0,hoffset=0,voffset=0,pos;
double xll, yll, xur, yur;
char found, free_page = 0, line[50000], jline[20], lid_file[255],
char found, free_page = 0, jline[20], lid_file[255],
path_plus_name[255], *junk = NULL;
FILE *fd;
char line[50000];
char * pch;
fd = fopen(filename, "rb");
FILE *fd;
// test for multiple files
filename = strtok(filenames, " ,");
while (filename != NULL)
{
files[fc] = filename;
filename = strtok(NULL, " ,");
fc++;
}
while (indx<fc) {
fd = fopen(files[indx], "rb");
if (fd != NULL) {
if (debug) {
fprintf(stdout,"Loading \"%s\"...\n", filename);
fprintf(stdout,"Loading \"%s\" into page %d...\n",files[indx], indx);
fflush(stdout);
}
if (fgets(line, 20, fd) != NULL) {
if (fgets(line, 18, fd) != NULL) {
pch = strtok (line," ");
pch = strtok (NULL, " ");
width=atoi(pch);
}
if (fgets(line, 20, fd) != NULL) {
if (fgets(line, 18, fd) != NULL) {
height=atoi(pch);
}
fgets(line, 24, fd); //
@@ -48,9 +171,7 @@ int loadLIDAR(char *filename)
//xll=atof(pch);
sscanf(pch, "%lf", &xll);
}
fgets(line, 24, fd); //
if (fgets(line, 24, fd) != NULL) {
//yll=atof(pch);
sscanf(pch, "%lf", &yll);
@@ -70,13 +191,25 @@ int loadLIDAR(char *filename)
sscanf(pch, "%lf", &yur);
}
fgets(line, 21, fd); //
fgets(line, 15, fd); //
if (fgets(line, 21, fd) != NULL) {
if (fgets(line, 15, fd) != NULL) {
cellsize=atoi(pch);
}
// LIDAR 2m @ 54000 PPD
if(cellsize==2){
ippd=5000;
MAXRAD=15;
}
// LIDAR 1m @ 108000 PPD!
if(cellsize==1){
ippd=10000;
MAXRAD=10;
}
if(xur<eastoffset)
eastoffset=xur;
if(xll>westoffset)
westoffset=xll;
// Greenwich straddling hack
@@ -106,61 +239,64 @@ int loadLIDAR(char *filename)
if(debug){
fprintf(stdout,"yll %.7f yur %.7f xur %.7f xll %.7f delta %.6f\n",yll,yur,xur,xll,delta);
}
dem[0].min_north=yll;
if (yll < min_north)
min_north=yll;
dem[0].max_north=yur;
if (yur > max_north)
max_north=yur;
dem[0].min_west=xur;
min_west=xur;
dem[0].max_west=xll;
max_west=xll;
if(width!=height){
fprintf(stdout,"LIDAR tile is not a square. Rows != Columns\n");
return 0;
}
fgets(line, 30, fd); // NODATA
for (y = height-1; y > -1; y--) {
x=width-1;
if (fgets(line, 50000,fd) != NULL) {
pch = strtok (line, " "); // 500
while(pch != NULL){
if(atoi(pch)<-999){
pch="0";
pos=ftell(fd);
// tile 0 [x| ]
if(debug){
fprintf(stdout,"readLIDAR(fd,%d,%d,%d,%d,%d,%.4f,%.4f,%.4f,%.4f)\n",0,0,height,width,indx,yur,xur,yll,xll);
}
readLIDAR(fd,0,0,height,width,indx,yur,xur,yll,xll);
//rewind
fseek(fd,pos,SEEK_SET);
// tile 1 [ |x]
if(width==10000){
indx++;
if(debug){
fprintf(stdout,"readLIDAR(fd,%d,%d,%d,%d,%d,%.4f,%.4f,%.4f,%.4f)\n",5000,0,height,width,indx,yur,xur,yll,xll);
}
readLIDAR(fd,5000,0,height,width,indx,yur,xur,yll,xll);
}
dem[0].data[y][x]=atoi(pch);
dem[0].signal[x][y] = 0;
dem[0].mask[x][y] = 0;
//rewind
fseek(fd,pos,SEEK_SET);
if (atoi(pch) > dem[0].max_el){
dem[0].max_el = atoi(pch);
max_elevation = atoi(pch);
// tile 2 [x | ]
if(height==10000){
indx++;
if(debug){
fprintf(stdout,"readLIDAR(fd,%d,%d,%d,%d,%d,%.4f,%.4f,%.4f,%.4f)\n",0,5000,height,width,indx,yur,xur,yll,xll);
}
readLIDAR(fd,0,5000,height,width,indx,yur,xur,yll,xll);
}
if (atoi(pch) < dem[0].min_el){
dem[0].min_el = atoi(pch);
min_elevation = dem[0].min_el;
}
//rewind
fseek(fd,pos,SEEK_SET);
x--;
pch = strtok (NULL, " "); // 500
// tile 3 [ |x]
if(width==10000 && height==10000){
indx++;
if(debug){
fprintf(stdout,"readLIDAR(fd,%d,%d,%d,%d,%d,%.4f,%.4f,%.4f,%.4f)\n",5000,5000,height,width,indx,yur,xur,yll,xll);
}
}else{
fprintf(stdout,"LIDAR error @ line %d\n",x);
return 0;
readLIDAR(fd,5000,5000,height,width,indx,yur,xur,yll,xll);
}
}
fclose(fd);
return 0;
}
fprintf(stdout,"LIDAR LOADED %d x %d\n",width,height);
} // if (fd != NULL)
else
return -1;
indx++;
} // filename(s)
}
int LoadSDF_SDF(char *name)

112
main.cc
View File

@@ -1,4 +1,4 @@
double version = 2.7.1;
double version = 2.72;
/****************************************************************************\
* Signal Server: Server optimised SPLAT! by Alex Farrant, M6ZUJ *
******************************************************************************
@@ -44,7 +44,7 @@ char string[255], sdf_path[255], udt_file[255], opened = 0, gpsav =
double earthradius, max_range = 0.0, forced_erp, dpp, ppd, yppd,
fzone_clearance = 0.6, forced_freq, clutter, lat, lon, txh, tercon, terdic,
north, east, south, west, dBm, loss, field_strength,
min_north = 90, max_north = -90, min_west = 360, max_west = -1, westoffset=0, eastoffset=0, delta=0;
min_north = 90, max_north = -90, min_west = 360, max_west = -1, westoffset=-180, eastoffset=180, delta=0;
int ippd, mpi,
max_elevation = -32768, min_elevation = 32768, bzerror, contour_threshold,
@@ -993,7 +993,7 @@ int main(int argc, char *argv[])
unsigned char LRmap = 0, txsites = 0, topomap = 0, geo = 0, kml =
0, area_mode = 0, max_txsites, ngs = 0;
char mapfile[255], udt_file[255], ano_filename[255], lidar_tile[255];
char mapfile[255], udt_file[255], ano_filename[255], lidar_tiles[512];
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;
@@ -1005,9 +1005,9 @@ int main(int argc, char *argv[])
}
if (strstr(argv[0], "signalserverLIDAR")) {
MAXPAGES = 1; // 10km2 for now :)
IPPD = 5000; // // 2m resolution
ARRAYSIZE = 5010;
MAXPAGES = 4;
IPPD = 5000; // // 2m resolution default
ARRAYSIZE = 20010;
ppd=IPPD;
}
@@ -1020,7 +1020,7 @@ int main(int argc, char *argv[])
"\tSet for %d tiles at %d pixels/degree\n\n",
MAXPAGES, IPPD);
fprintf(stdout, " -sdf Directory containing .sdf tiles\n");
fprintf(stdout, " -lid LIDAR ASCII tile with WGS84 bounds\n");
fprintf(stdout, " -lid LIDAR ASCII tile with WGS84 bounds (Dimensions defined in file metadata)\n");
fprintf(stdout,
" -lat Tx Latitude (decimal degrees) -70/+70\n");
fprintf(stdout,
@@ -1053,7 +1053,7 @@ int main(int argc, char *argv[])
fprintf(stdout, " -o Filename. Required. \n");
fprintf(stdout, " -R Radius (miles/kilometers)\n");
fprintf(stdout,
" -res Pixels per tile. 300/600/1200/3600/5000/10000 (optional)\n");
" -res Pixels per tile. 300/600/1200/3600 (Optional. LIDAR res is defined within the tile)\n");
fprintf(stdout, " -t Terrain background\n");
fprintf(stdout,
" -pm Prop model. 1: ITM, 2: LOS, 3: Hata, 4: ECC33,\n");
@@ -1142,44 +1142,7 @@ int main(int argc, char *argv[])
for (x = 1; x <= y; x++) {
if (strcmp(argv[x], "-res") == 0) {
z = x + 1;
if (z <= y && argv[z][0] && argv[z][0] != '-') {
sscanf(argv[z], "%d", &ippd);
switch (ippd) {
case 300:
MAXRAD = 500;
jgets = 3; // 3 dummy reads
break;
case 600:
MAXRAD = 500;
jgets = 1;
break;
case 1200:
MAXRAD = 200;
ippd = 1200;
break;
case 3600:
MAXRAD = 100;
ippd = 3600;
break;
case 5000: // LIDAR 2m
MAXRAD = 10;
ippd = 5000;
break;
case 10000: // LIDAR 1m
MAXRAD = 5;
ippd = 10000;
break;
default:
MAXRAD = 200;
ippd = 1200;
break;
}
}
}
if (strcmp(argv[x], "-R") == 0) {
z = x + 1;
@@ -1242,7 +1205,38 @@ int main(int argc, char *argv[])
z = x + 1;
lidar=1;
if (z <= y && argv[z][0] && argv[z][0] != '-')
strncpy(lidar_tile, argv[z], 253);
strncpy(lidar_tiles, argv[z], 253);
}
if (strcmp(argv[x], "-res") == 0) {
z = x + 1;
if (z <= y && argv[z][0] && argv[z][0] != '-') {
sscanf(argv[z], "%d", &ippd);
switch (ippd) {
case 300:
MAXRAD = 500;
jgets = 3; // 3 dummy reads
break;
case 600:
MAXRAD = 500;
jgets = 1;
break;
case 1200:
MAXRAD = 200;
ippd = 1200;
break;
case 3600:
MAXRAD = 100;
ippd = 3600;
break;
default:
MAXRAD = 200;
ippd = 1200;
break;
}
}
}
if (strcmp(argv[x], "-lat") == 0) {
@@ -1497,10 +1491,14 @@ int main(int argc, char *argv[])
"ERROR: Rx altitude above ground was too high!");
exit(0);
}
if(!lidar){
if (ippd < 300 || ippd > 10000) {
fprintf(stdout, "ERROR: resolution out of range!");
exit(0);
}
}
if (contour_threshold < -200 || contour_threshold > 200) {
fprintf(stdout,
"ERROR: Receiver threshold out of range (-200 / +200)");
@@ -1576,14 +1574,17 @@ int main(int argc, char *argv[])
/* Load the required tiles */
if(lidar){
loadLIDAR(lidar_tile);
ppd=rint(ippd / (max_north-min_north));
yppd=rint(ippd / (max_west-min_west));
height=ippd;
width=ippd;
loadLIDAR(lidar_tiles);
if(debug){
fprintf(stdout,"%.4f,%.4f,%.4f,%.4f\n",max_north,min_west,min_north,max_west);
}
ppd=rint(height / (max_north-min_north));
yppd=rint(width / (max_west-min_west));
if(delta>0){
tx_site[0].lon+=delta;
}
}else{
LoadTopoData(max_lon, min_lon, max_lat, min_lat);
if (area_mode || topomap) {
@@ -1718,12 +1719,15 @@ int main(int argc, char *argv[])
txsites);
}
if(lidar){
east=eastoffset;
west=westoffset;
}
// Print WGS84 bounds
fprintf(stdout, "|%.6f", north);
fprintf(stdout, "|%.6f", eastoffset);
fprintf(stdout, "|%.6f", east);
fprintf(stdout, "|%.6f", south);
fprintf(stdout, "|%.6f|", westoffset);
fprintf(stdout, "|%.6f|", west);
} else {
strncpy(tx_site[0].name, "Tx", 3);

5984
mainHD.cc

File diff suppressed because it is too large Load Diff

5464
mainHD.cpp

File diff suppressed because it is too large Load Diff

View File

@@ -1,37 +0,0 @@
from math import sin, cos, asin, sqrt, degrees, radians
import os, sys
Earth_radius_km = 6371.0
RADIUS = Earth_radius_km
def dist2degs(lat, lon, km):
dlat = km / RADIUS
dlon = asin(sin(dlat) / cos(radians(lat)))
return degrees(dlon)
lat=50
lon=10
pm=sys.argv[1]
pe=sys.argv[2]
erp=sys.argv[3]
f=int(sys.argv[4])
rad=int(sys.argv[5])
for km in range(1,31):
rlo = lon+dist2degs(lat,lon,rad);
cmd = "./signalserver -m -lat "+str(lat)+" -lon "+str(lon)+" -rla "+str(lat)+" -rlo "+str(rlo)+" -txh 30 -rxh 2 -f "+str(f)+" -pm "+pm+" -pe "+pe+" -res 1200"
out = os.popen(cmd).read().split("\n")
#print out
try:
db = out[1]
dbm = out[2]
dbuv = out[3]
except:
db = 0
dbm = 0
dbuv = 0
#print str(rad)+"km, "+str(f)+"MHz = "+str(db)
print str(db)+",",
f=f+200

View File

@@ -101,6 +101,13 @@ void DoPathLoss(char *filename, unsigned char geo, unsigned char kml,
(LonDiff
((double)dem[indx].max_west,
lon)));
// fix for multi-tile lidar
if(width==10000 && (indx==1 || indx==3)){
if(y0 >= 3510){ //3535
y0=y0-3510;
}
}
if (x0 >= 0 && x0 <= mpi && y0 >= 0
&& y0 <= mpi)
@@ -322,6 +329,14 @@ void DoSigStr(char *filename, unsigned char geo, unsigned char kml,
((double)dem[indx].max_west,
lon)));
// fix for multi-tile lidar
if(width==10000 && (indx==1 || indx==3)){
if(y0 >= 3510){ //3535
y0=y0-3510;
}
}
if (x0 >= 0 && x0 <= mpi && y0 >= 0
&& y0 <= mpi)
found = 1;
@@ -488,7 +503,6 @@ void DoRxdPwr(char *filename, unsigned char geo, unsigned char kml,
double conversion, one_over_gamma, lat, lon, minwest;
FILE *fd;
one_over_gamma = 1.0 / GAMMA;
conversion =
255.0 / pow((double)(max_elevation - min_elevation),
@@ -535,7 +549,7 @@ void DoRxdPwr(char *filename, unsigned char geo, unsigned char kml,
fprintf(fd, "P6\n%u %u\n255\n", width, (kml ? height : height));
if (debug) {
fprintf(stdout, "\nWriting \"%s\" (%ux%u pixmap image)... ",
fprintf(stdout, "\nWriting \"%s\" (%ux%u pixmap image)...\n",
mapfile, width, (kml ? height : height));
fflush(stdout);
}
@@ -550,6 +564,7 @@ void DoRxdPwr(char *filename, unsigned char geo, unsigned char kml,
for (indx = 0, found = 0;
indx < MAXPAGES && found == 0;) {
x0 = (int)rint((ppd *
(lat -
(double)dem[indx].min_north))); // +4549 fix
@@ -558,11 +573,20 @@ void DoRxdPwr(char *filename, unsigned char geo, unsigned char kml,
(LonDiff
((double)dem[indx].max_west,lon)));
// fix for multi-tile lidar
if(width==10000 && (indx==1 || indx==3)){
if(y0 >= 3510){ //3535
y0=y0-3510;
}
}
if (x0 >= 0 && x0 <= mpi && y0 >= 0
&& y0 <= mpi)
found = 1;
else
indx++;
}
if (found) {