mirror of
https://gitlab.com/Trygve/contour-creator.git
synced 2024-11-21 23:00:18 +00:00
Tried fixing gdal bullshit in steepnes method
This commit is contained in:
parent
c47565eabb
commit
97c52ecef3
@ -33,6 +33,7 @@ HeightMap::HeightMap(const char* filepath)
|
|||||||
//https://gdal.org/api/gdaldataset_cpp.html#_CPPv4N11GDALDataset15GetGeoTransformEPd
|
//https://gdal.org/api/gdaldataset_cpp.html#_CPPv4N11GDALDataset15GetGeoTransformEPd
|
||||||
this->geotransform = (double *) CPLMalloc(sizeof(double)*6);
|
this->geotransform = (double *) CPLMalloc(sizeof(double)*6);
|
||||||
this->reference_system = *(file->GetSpatialRef());
|
this->reference_system = *(file->GetSpatialRef());
|
||||||
|
this->filepath = filepath;
|
||||||
|
|
||||||
file->GetGeoTransform(this->geotransform);
|
file->GetGeoTransform(this->geotransform);
|
||||||
|
|
||||||
@ -175,11 +176,13 @@ void HeightMap::calculate_steepness()
|
|||||||
steepness[i] = max - min;
|
steepness[i] = max - min;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GDALAllRegister();
|
||||||
|
GDALDataset *original_file = (GDALDataset *) GDALOpen( filepath, GA_ReadOnly );
|
||||||
|
|
||||||
const char * filename = "steepness.tif";
|
const char * filename = "steepness.tif";
|
||||||
auto driver = GetGDALDriverManager()->GetDriverByName("GeoRaster");
|
auto driver = GetGDALDriverManager()->GetDriverByName("GeoRaster");
|
||||||
GDALDataset *file;
|
GDALDataset *file;
|
||||||
file = driver->Create("steepness.tif", this->width, this->height, 1, GDT_Float32, NULL);
|
file = driver->CreateCopy("steepness.tif", original_file, FALSE, NULL, NULL, NULL);
|
||||||
GDALRegister_GTiff();
|
|
||||||
|
|
||||||
file->AddBand(GDT_Float32, NULL);
|
file->AddBand(GDT_Float32, NULL);
|
||||||
GDALRasterBand *band = file->GetRasterBand(0);
|
GDALRasterBand *band = file->GetRasterBand(0);
|
||||||
@ -187,15 +190,4 @@ void HeightMap::calculate_steepness()
|
|||||||
steepness, this->width, this->height, GDT_Float32,
|
steepness, this->width, this->height, GDT_Float32,
|
||||||
0, 0 );
|
0, 0 );
|
||||||
GDALClose(file);
|
GDALClose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//namespace plt = matplotlibcpp;
|
|
||||||
|
|
||||||
//matplotlibcpp::plot(x, y);
|
|
||||||
//plt::loglog(x, y);
|
|
||||||
/*
|
|
||||||
int main() {
|
|
||||||
|
|
||||||
|
|
||||||
}*/
|
|
@ -16,8 +16,8 @@ class HeightMap
|
|||||||
float min; //!< Minimum value in image
|
float min; //!< Minimum value in image
|
||||||
float max; //!< Maximum value in image
|
float max; //!< Maximum value in image
|
||||||
OGRSpatialReference reference_system;
|
OGRSpatialReference reference_system;
|
||||||
|
|
||||||
HeightMap(const char* filepath);
|
HeightMap(const char* filepath);
|
||||||
|
const char* filepath;
|
||||||
float get_pixel(int x,int y);
|
float get_pixel(int x,int y);
|
||||||
void blur(float standard_deviation);
|
void blur(float standard_deviation);
|
||||||
void statistics();
|
void statistics();
|
||||||
|
Loading…
Reference in New Issue
Block a user