mirror of
https://gitlab.com/Trygve/contour-creator.git
synced 2024-11-21 14:50:18 +00:00
Added steepness cli arg
This commit is contained in:
parent
9ab5aac40f
commit
b4b89c2282
@ -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);
|
||||
|
@ -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*);
|
||||
};
|
||||
|
||||
/**
|
||||
|
11
src/main.cpp
11
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] <input_file>\n"
|
||||
<< "contour_creator [OPTIONS] <input_file>\n\n"
|
||||
<< "Arguments in the form --<name>=<value>:"
|
||||
<< "-o; --output <FILENAME.geojson> - File to write output to (Default: contours.geojson)\n"
|
||||
<< "-i; --interval <int> - 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 <filename> - 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";
|
||||
|
Loading…
Reference in New Issue
Block a user