From dded0219cf54e38e6fc8b1ce7c9fa62b1f42c061 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 16 Feb 2017 23:40:53 +0000 Subject: [PATCH] 3.01 Image crop, SUI bugfix, txelev replaced --- common.h | 2 ++ inputs.cc | 2 +- main.cc | 70 ++++++++++++++++++++++++++++++++++++++++----------- models/los.cc | 39 +++++++++++++++++----------- models/sui.cc | 8 +++--- 5 files changed, 86 insertions(+), 35 deletions(-) diff --git a/common.h b/common.h index 268f802..7abd1ad 100644 --- a/common.h +++ b/common.h @@ -106,6 +106,8 @@ extern __thread double *elev; extern double westoffset; extern double eastoffset; extern double delta; +extern double cropLat; +extern double cropLon; extern char string[]; extern char sdf_path[]; diff --git a/inputs.cc b/inputs.cc index d870cf6..c3561af 100644 --- a/inputs.cc +++ b/inputs.cc @@ -261,7 +261,7 @@ int loadLIDAR(char *filenames) } // add fudge as reprojected tiles sometimes vary by a pixel or ten IPPD+=50; - ARRAYSIZE = (MAXPAGES * IPPD) + 50; + ARRAYSIZE = (MAXPAGES * IPPD)+50; do_allocs(); dem_alloced = 1; } diff --git a/main.cc b/main.cc index 4614bfe..9e7a4f2 100644 --- a/main.cc +++ b/main.cc @@ -1,4 +1,4 @@ -double version = 3.00; +double version = 3.01; /****************************************************************************\ * Signal Server: Radio propagation simulator by Alex Farrant QCVS, 2E0TDW * ****************************************************************************** @@ -47,7 +47,8 @@ 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=180, eastoffset=-180, delta=0, rxGain=0; + min_north = 90, max_north = -90, min_west = 360, max_west = -1, westoffset=180, eastoffset=-180, delta=0, rxGain=0, + cropLat=-70, cropLon=0; int ippd, mpi, max_elevation = -32768, min_elevation = 32768, bzerror, contour_threshold, @@ -351,6 +352,23 @@ int AddElevation(double lat, double lon, double height, int size) return found; } +double dist(double lat1, double lon1, double lat2, double lon2) +{ + //ENHANCED HAVERSINE FORMULA WITH RADIUS SLIDER + double dx, dy, dz; + int polarRadius=6357; + int equatorRadius=6378; + int delta = equatorRadius-polarRadius; // 21km + float earthRadius = equatorRadius - ((lat1/100) * delta); + lon1 -= lon2; + lon1 *= DEG2RAD, lat1 *= DEG2RAD, lat2 *= DEG2RAD; + + dz = sin(lat1) - sin(lat2); + dx = cos(lon1) * cos(lat1) - cos(lat2); + dy = sin(lon1) * cos(lat1); + return asin(sqrt(dx * dx + dy * dy + dz * dz) / 2) * 2 * earthRadius; +} + double Distance(struct site site1, struct site site2) { /* This function returns the great circle distance @@ -1024,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; + 0, normalise = 0, haf = 0, pmenv = 1, lidar=0, cropped; bool use_threads = true; @@ -1799,18 +1817,25 @@ int main(int argc, char *argv[]) hottest=9; // 9dB nearfield // nearfield bugfix - for (lat = tx_site[0].lat - 0.001; - lat <= tx_site[0].lat + 0.001; - lat = lat + 0.0001) { - for (lon = tx_site[0].lon - 0.001; - lon <= tx_site[0].lon + 0.001; - lon = lon + 0.0001) { + for (lat = tx_site[0].lat - 0.0005; + lat <= tx_site[0].lat + 0.0005; + lat = lat + 0.0005) { + for (lon = tx_site[0].lon - 0.0005; + lon <= tx_site[0].lon + 0.0005; + lon = lon + 0.0005) { PutSignal(lat, lon, hottest); } } - } + // CROPPING. croplat assigned in propPathLoss() + max_north=cropLat; // MAX(path.lat[y]) + max_west=cropLon; // MAX(path.lon[y]) + cropLat-=tx_site[0].lat; // angle from tx to edge + cropLon-=tx_site[0].lon; + width=(int)((cropLon*ppd)*2); + height=(int)((cropLat*ppd)*2); + // Write bitmap if (LR.erp == 0.0) DoPathLoss(mapfile, geo, kml, ngs, tx_site, @@ -1827,12 +1852,27 @@ int main(int argc, char *argv[]) west=westoffset; } - // Print WGS84 bounds - fprintf(stderr, "|%.6f", north); - fprintf(stderr, "|%.6f", east); - fprintf(stderr, "|%.6f", south); - fprintf(stderr, "|%.6f|", west); + if (tx_site[0].lon > 0.0){ + tx_site[0].lon *= -1; + } + if (tx_site[0].lon < -180.0){ + tx_site[0].lon += 360; + } + if (propmodel == 2) { + // No croppping because this is LOS + fprintf(stderr, "|%.6f", max_north); + fprintf(stderr, "|%.6f", east); + fprintf(stderr, "|%.6f", min_north); + fprintf(stderr, "|%.6f|",west); + }else{ + // Cropped EPSG4326 coordinates + fprintf(stderr, "|%.6f", tx_site[0].lat+cropLat); + fprintf(stderr, "|%.6f", tx_site[0].lon+cropLon); + fprintf(stderr, "|%.6f", tx_site[0].lat-cropLat); + fprintf(stderr, "|%.6f|",tx_site[0].lon-cropLon); + } fprintf(stderr, "\n"); + } else { strncpy(tx_site[0].name, "Tx", 3); diff --git a/models/los.cc b/models/los.cc index 778e017..f07f624 100644 --- a/models/los.cc +++ b/models/los.cc @@ -304,7 +304,7 @@ void PlotPropPath(struct site source, struct site destination, xmtr_alt, dest_alt, xmtr_alt2, dest_alt2, cos_rcvr_angle, cos_test_angle = 0.0, test_alt, elevation = 0.0, distance = 0.0, four_thirds_earth, - field_strength = 0.0, rxp, dBm, txelev, dkm, diffloss; + field_strength = 0.0, rxp, dBm, dkm, diffloss; struct site temp; ReadPath(source, destination); @@ -323,7 +323,6 @@ void PlotPropPath(struct site source, struct site destination, /* Copy ending points without clutter */ elev[2] = path.elevation[0] * METERS_PER_FOOT; - txelev = elev[2] + (source.alt * METERS_PER_FOOT); elev[path.length + 1] = path.elevation[path.length - 1] * METERS_PER_FOOT; @@ -446,6 +445,8 @@ void PlotPropPath(struct site source, struct site destination, dkm = (elev[1] * elev[0]) / 1000; // km + + switch (propmodel) { case 1: // Longley Rice ITM @@ -462,16 +463,15 @@ void PlotPropPath(struct site source, struct site destination, case 3: //HATA 1, 2 & 3 loss = - HATApathLoss(LR.frq_mhz, txelev, - path.elevation[y] + - (destination.alt * - METERS_PER_FOOT), dkm, pmenv); + HATApathLoss(LR.frq_mhz, source.alt * METERS_PER_FOOT, + (path.elevation[y] * METERS_PER_FOOT) + (destination.alt * METERS_PER_FOOT), dkm, pmenv); break; case 4: // ECC33 loss = - ECC33pathLoss(LR.frq_mhz, txelev, - path.elevation[y] + + ECC33pathLoss(LR.frq_mhz, source.alt * METERS_PER_FOOT, + (path.elevation[y] * + METERS_PER_FOOT) + (destination.alt * METERS_PER_FOOT), dkm, pmenv); @@ -479,16 +479,18 @@ void PlotPropPath(struct site source, struct site destination, case 5: // SUI loss = - SUIpathLoss(LR.frq_mhz, txelev, - path.elevation[y] + + SUIpathLoss(LR.frq_mhz, source.alt * METERS_PER_FOOT, + (path.elevation[y] * + METERS_PER_FOOT) + (destination.alt * METERS_PER_FOOT), dkm, pmenv); break; case 6: // COST231-Hata loss = - COST231pathLoss(LR.frq_mhz, txelev, - path.elevation[y] + + COST231pathLoss(LR.frq_mhz, source.alt * METERS_PER_FOOT, + (path.elevation[y] * + METERS_PER_FOOT) + (destination.alt * METERS_PER_FOOT), dkm, pmenv); @@ -512,8 +514,9 @@ void PlotPropPath(struct site source, struct site destination, case 9: // Ericsson loss = - EricssonpathLoss(LR.frq_mhz, txelev, - path.elevation[y] + + EricssonpathLoss(LR.frq_mhz, source.alt * METERS_PER_FOOT, + (path.elevation[y] * + METERS_PER_FOOT) + (destination.alt * METERS_PER_FOOT), dkm, pmenv); @@ -521,7 +524,7 @@ void PlotPropPath(struct site source, struct site destination, case 10: // Plane earth - loss = PlaneEarthLoss(dkm, txelev, path.elevation[y] + (destination.alt * METERS_PER_FOOT)); + loss = PlaneEarthLoss(dkm, source.alt * METERS_PER_FOOT, (path.elevation[y] * METERS_PER_FOOT) + (destination.alt * METERS_PER_FOOT)); break; default: @@ -537,6 +540,7 @@ void PlotPropPath(struct site source, struct site destination, } + if (knifeedge == 1) { diffloss = ked(LR.frq_mhz, @@ -677,6 +681,11 @@ void PlotPropPath(struct site source, struct site destination, } } + if(path.lat[y]>cropLat) + cropLat=path.lat[y]; + + if(path.lon[y]>cropLon) + cropLon=path.lon[y]; } void PlotLOSMap(struct site source, double altitude, char *plo_filename, diff --git a/models/sui.cc b/models/sui.cc index 03549c9..6ad7657 100644 --- a/models/sui.cc +++ b/models/sui.cc @@ -9,9 +9,9 @@ double SUIpathLoss(float f, float TxH, float RxH, float d, int mode) TxH = Transmitter height (m) RxH = Receiver height (m) d = distance (km) - mode 1 = Hilly + trees - mode 2 = Flat + trees OR hilly + light foliage - mode 3 = Flat + light foliage + mode A1 = Hilly + trees + mode B2 = Flat + trees OR hilly + light foliage + mode C3 = Flat + light foliage http://www.cl.cam.ac.uk/research/dtg/lce-pub/public/vsa23/VTC05_Empirical.pdf */ d = d * 1000; // km to m @@ -45,5 +45,5 @@ double SUIpathLoss(float f, float TxH, float RxH, float d, int mode) double Xf = 6 * log10(f / 2000); double Xh = XhCF * log10(RxH / 2000); - return A + (10 * y) * (log10(d / d0)) + Xf + Xh + s; + return A + (10 * y * log10(d / d0)) + Xf + Xh + s; }