diff --git a/src/HeightMap.cpp b/src/HeightMap.cpp index b3d374b..537c1bf 100644 --- a/src/HeightMap.cpp +++ b/src/HeightMap.cpp @@ -132,7 +132,7 @@ void HeightMap::statistics() }; -void HeightMap::calculate_steepness() +void HeightMap::calculate_steepness(const char* filepath) { int kernel_height = 5; int kernel_width = 5; @@ -176,12 +176,11 @@ void HeightMap::calculate_steepness() } } GDALAllRegister(); - GDALDataset *original_file = (GDALDataset *) GDALOpen( filepath, GA_ReadOnly ); + GDALDataset *original_file = (GDALDataset *) GDALOpen( this->filepath, GA_ReadOnly ); - const char * filename = "steepness.tif"; auto driver = GetGDALDriverManager()->GetDriverByName("GeoRaster"); GDALDataset *file; - file = driver->CreateCopy("steepness.tif", original_file, FALSE, NULL, NULL, NULL); + file = driver->CreateCopy(filepath, original_file, FALSE, NULL, NULL, NULL); file->AddBand(GDT_Float32, NULL); GDALRasterBand *band = file->GetRasterBand(0); diff --git a/src/contour_creator.hh b/src/contour_creator.hh index c697b6e..59c3b63 100644 --- a/src/contour_creator.hh +++ b/src/contour_creator.hh @@ -26,7 +26,7 @@ class HeightMap float get_pixel(int x,int y); void blur(float standard_deviation); void statistics(); - void calculate_steepness(); + void calculate_steepness(const char*); }; /** diff --git a/src/main.cpp b/src/main.cpp index 2185237..2a195d7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -295,13 +295,16 @@ int main(int argc, const char* argv[]) if (cmdl[{ "-h", "--help" }]) { std::cout << "Usage:\n" - << "contour_creator [OPTIONS] \n" + << "contour_creator [OPTIONS] \n\n" + << "Arguments in the form --=:" << "-o; --output - File to write output to (Default: contours.geojson)\n" << "-i; --interval - Set the interval between contours (Default: 5)\n" << "-b; --blur - Blur the image\n" - << "--stats - Print statistical information about the heightmap\n"; + << "--stats - Print statistical information about the heightmap\n" + << "--steepness - Create steepness map\n"; exit(0); } + int interval; cmdl({"-i", "--interval"}, 5) >> interval; if (interval <= 0) @@ -320,6 +323,10 @@ int main(int argc, const char* argv[]) if (cmdl[{"--stats"}]) map.statistics(); + std::string steepness_output_file; + if (cmdl({"--steepness"}, "steepness.tif") >> steepness_output_file) + map.calculate_steepness(output_file.c_str()); + auto lines = create_lines(&map, interval); write_output_file(lines, output_file.c_str(), &map); std::cout << "Contours written to " << output_file << " 🗺️\n";