diff --git a/src/elevation_map.cpp b/src/elevation_map.cpp index 0dd30a6..8518ad6 100644 --- a/src/elevation_map.cpp +++ b/src/elevation_map.cpp @@ -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"); @@ -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, diff --git a/src/imagewriter.h b/src/imagewriter.h index 7f20790..ed086ad 100644 --- a/src/imagewriter.h +++ b/src/imagewriter.h @@ -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 diff --git a/src/main.cpp b/src/main.cpp index 502dca1..58efebf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 city_file; vector boundary_file; @@ -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; @@ -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 = "_"; @@ -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; @@ -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; @@ -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) */ diff --git a/src/report.cpp b/src/report.cpp index 79ed9ae..fae8d64 100644 --- a/src/report.cpp +++ b/src/report.cpp @@ -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, @@ -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, @@ -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", @@ -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); } @@ -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)", diff --git a/src/splat_run.h b/src/splat_run.h index d40e61e..410dcb1 100644 --- a/src/splat_run.h +++ b/src/splat_run.h @@ -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; @@ -96,6 +101,7 @@ class SplatRun { bool multithread; std::string sdf_delimiter; ImageType imagetype; + ProjectionType projection; }; #endif /* splat_run_h */