Compare commits

..

3 Commits

Author SHA1 Message Date
esther
d046e18c43 changed to create a vector 2024-04-29 15:02:50 +02:00
esther
33dd409c43 changed contour creator 2024-04-29 14:56:06 +02:00
esther
5cd5627bb7 introduced class Point and changed cell map to create lines 2024-04-29 14:54:44 +02:00
2 changed files with 26 additions and 8 deletions

View File

@ -36,3 +36,17 @@ class CellMap
CellMap(int width, int height, uint8_t* cells, OGRSpatialReference reference_system, double* geotransform);
int get_cell(int x,int y);
};
class Point
{
public:
int x;
int y;
int mscase;
Point(int x, int y, int mscase){
this -> x = x;
this -> y = y;
this -> mscase = mscase;
};
};

View File

@ -13,10 +13,11 @@
#include <gdal/gdal_frmts.h>
#include <omp.h>
CellMap produce_cellmap(HeightMap* heightmap, float z)
std::vector<Point> produce_cellmap(HeightMap* heightmap, float z)
{
int length = (heightmap->width-1)*(heightmap->height-1);
uint8_t *cells = (uint8_t *) CPLMalloc(sizeof(uint8_t)*length);
std::vector<Point> points;
for (int i = 0; i<length; i++) {
int y = i/(heightmap->width-1);
int x = i%(heightmap->width-1);
@ -24,23 +25,26 @@ CellMap produce_cellmap(HeightMap* heightmap, float z)
(heightmap->get_pixel(x+1,y)>z)*2 +
(heightmap->get_pixel(x+1,y+1)>z)*4 +
(heightmap->get_pixel(x,y+1)>z)*8;
*(cells + i) = result;
if (result != 0 and result != 15 ) {
points.push_back(Point(x, y, result));
};
}
return CellMap(heightmap->width-1, heightmap->height-1, cells, heightmap->reference_system, heightmap->geotransform);
return points;
}
std::vector<CellMap> vector_cellmap(HeightMap* heightmap, int interval)
std::vector<std::vector<Point>> vector_cellmap(HeightMap* heightmap, int interval)
{
int num_contours = (heightmap->max - heightmap->min)/interval;
std::vector<CellMap> vector_contours;
std::vector<std::vector<Point>> vector_contours;
omp_set_num_threads(12);
#pragma omp parallel
{
std::vector<CellMap> vec_private;
std::vector<std::vector<Point>> vec_private;
#pragma omp for
for (int i = 1; i <= num_contours; i++)
{
@ -180,5 +184,5 @@ int main(int argc, const char* argv[])
auto cellmap = produce_cellmap(&map, 40);
auto cellmaps = vector_cellmap(&map, 5);
write_output_file(cellmaps, "out.geojson");
//write_output_file(cellmaps, "out.geojson");
}