Skip to content

Commit

Permalink
clarify propagation model and add output projection
Browse files Browse the repository at this point in the history
- see #23 for clarification of propagation model
- see #9 for output projection. Still needs to call the gdal warp function
  • Loading branch information
der-stefan committed Aug 14, 2020
1 parent bae7dcb commit 73ec7ea
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/elevation_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,10 +901,10 @@ void ElevationMap::PlotLRMap(const Site &source, double altitude,

count = 0;

if (sr.olditm)
fprintf(stdout, "\nComputing ITWOM ");
else
if(sr.propagation_model == PROP_ITM)
fprintf(stdout, "\nComputing ITM ");
else
fprintf(stdout, "\nComputing ITWOM ");

if (lrp.erp == 0.0)
fprintf(stdout, "path loss");
Expand Down Expand Up @@ -1269,7 +1269,7 @@ void ElevationMap::PlotLRPath(const Site &source, const Site &destination,
elev[1] = (elev_t)(METERS_PER_MILE *
(path.distance[y] - path.distance[y - 1]));

if (!sr.olditm)
if (sr.propagation_model == PROP_ITM)
point_to_point(elev, source.alt * METERS_PER_FOOT,
destination.alt * METERS_PER_FOOT,
lrp.eps_dielect, lrp.sgm_conductivity,
Expand Down
7 changes: 7 additions & 0 deletions src/imagewriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ typedef enum ImageType {
#endif
} ImageType;

typedef enum ProjectionType {
PROJ_EPSG_4326 = 0,
#ifdef HAVE_LIBGDAL
PROJ_EPSG_3857
#endif
} ProjectionType;

class ImageWriter {
private:
ImageWriter(); // private constructor
Expand Down
28 changes: 24 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc, const char *argv[]) {

char *env = NULL;
string mapfile, elevation_file, height_file, longley_file, terrain_file,
udt_file, ani_filename, ano_filename, logfile, maxpages_str;
udt_file, ani_filename, ano_filename, logfile, maxpages_str, proj;

vector<std::string> city_file;
vector<std::string> boundary_file;
Expand All @@ -66,7 +66,7 @@ int main(int argc, const char *argv[]) {
sr.maxpages = 16;
sr.arraysize = -1;

sr.olditm = true;
sr.propagation_model = PROP_ITM;
sr.hd_mode = false;
sr.coverage = false;
sr.LRmap = false;
Expand Down Expand Up @@ -113,6 +113,7 @@ int main(int argc, const char *argv[]) {
#else
sr.imagetype = IMAGETYPE_PPM;
#endif
sr.projection = PROJ_EPSG_4326;
sr.multithread = true;
sr.verbose = 1;
sr.sdf_delimiter = "_";
Expand Down Expand Up @@ -373,6 +374,25 @@ int main(int argc, const char *argv[]) {
}
#endif

#ifdef HAVE_LIBGDAL
if (strcmp(argv[x], "-proj") == 0) {
if (sr.imagetype == IMAGETYPE_GEOTIFF || sr.imagetype == IMAGETYPE_PNG || sr.imagetype == IMAGETYPE_JPG) {
z = x + 1;
if (z <= y && argv[z][0] && argv[z][0] != '-') {
if(strcmp(argv[z], "epsg:3857") == 0) {
sr.projection = PROJ_EPSG_3857;
} else if(strcmp(argv[z], "epsg:4326") == 0) {
sr.projection = PROJ_EPSG_4326;
} else {
cerr << "Ignoring unknown projection " << argv[z] << " and taking epsg:4326 instead.\n";
}
}
} else {
cerr << "-proj supports only gdal output formats. Please use -png, -tif or -jpg.\n";
}
}
#endif

if (strcmp(argv[x], "-metric") == 0)
sr.metric = true;

Expand Down Expand Up @@ -407,7 +427,7 @@ int main(int argc, const char *argv[]) {
sr.multithread = false;

if (strcmp(argv[x], "-itwom") == 0)
sr.olditm = false;
sr.propagation_model = PROP_ITWOM;

if (strcmp(argv[x], "-N") == 0) {
sr.nolospath = true;
Expand Down Expand Up @@ -657,7 +677,7 @@ int main(int argc, const char *argv[]) {
int degrees = (int)sqrt((int)sr.maxpages);

cout << "This invocation of " << SplatRun::splat_name
<< " supports analysis over a region of " << degrees << " square " << ((degrees == 1) ? "degree" : "degrees")
<< " supports analysis over a region of " << degrees << " square \n" << ((degrees == 1) ? "degree" : "degrees")
<< " of terrain, and computes signal levels using ITWOM Version " << ITWOMVersion() << ".\n\n";

sr.ppd = (double)sr.ippd; /* pixels per degree (double) */
Expand Down
10 changes: 5 additions & 5 deletions src/report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void Report::PathReport(const Site &source, const Site &destination,
fprintf(fd2, "\n%s\n\n", dashes.c_str());

if (lrp.frq_mhz > 0.0) {
if (sr.olditm)
if (sr.propagation_model == PROP_ITM)
fprintf(fd2, "Longley-Rice Parameters Used In This Analysis:\n\n");
else
fprintf(fd2,
Expand Down Expand Up @@ -432,7 +432,7 @@ void Report::PathReport(const Site &source, const Site &destination,
elev[1] =
METERS_PER_MILE * (path.distance[y] - path.distance[y - 1]);

if (sr.olditm)
if (sr.propagation_model == PROP_ITM)
point_to_point_ITM(elev, source.alt * METERS_PER_FOOT,
destination.alt * METERS_PER_FOOT,
lrp.eps_dielect, lrp.sgm_conductivity,
Expand Down Expand Up @@ -494,7 +494,7 @@ void Report::PathReport(const Site &source, const Site &destination,
fprintf(fd2, "Free space path loss: %.2f dB\n", free_space_loss);
}

if (sr.olditm)
if (sr.propagation_model == PROP_ITM)
fprintf(fd2, "Longley-Rice path loss: %.2f dB\n", loss);
else
fprintf(fd2, "ITWOM Version %.1f path loss: %.2f dB\n",
Expand Down Expand Up @@ -549,7 +549,7 @@ void Report::PathReport(const Site &source, const Site &destination,

fprintf(fd2, "Mode of propagation: ");

if (sr.olditm) {
if (sr.propagation_model == PROP_ITM) {
fprintf(fd2, "%s\n", strmode);
fprintf(fd2, "Longley-Rice model error number: %d", errnum);
}
Expand Down Expand Up @@ -701,7 +701,7 @@ void Report::PathReport(const Site &source, const Site &destination,
fprintf(fd, "set ylabel \"Total Path Loss (including TX antenna "
"pattern) (dB)");
else {
if (sr.olditm)
if (sr.propagation_model == PROP_ITM)
fprintf(fd, "set ylabel \"Longley-Rice Path Loss (dB)");
else
fprintf(fd, "set ylabel \"ITWOM Version %.1f Path Loss (dB)",
Expand Down
8 changes: 7 additions & 1 deletion src/splat_run.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ const size_t SPLAT_NAME_SIZE = 10;
const size_t DASHES_SIZE = 80;
const size_t SDF_PATH_SIZE = 255;

typedef enum PropagationModel {
PROP_ITM = 0,
PROP_ITWOM
} PropagationModel;

class SplatRun {
public:
static const std::string splat_name;
static const std::string splat_version;

bool olditm;
PropagationModel propagation_model;

std::string sdf_path;

Expand Down Expand Up @@ -96,6 +101,7 @@ class SplatRun {
bool multithread;
std::string sdf_delimiter;
ImageType imagetype;
ProjectionType projection;
};

#endif /* splat_run_h */

0 comments on commit 73ec7ea

Please sign in to comment.