diff --git a/src/contour_creator.hh b/src/contour_creator.hh index 64c9beb..84dc926 100644 --- a/src/contour_creator.hh +++ b/src/contour_creator.hh @@ -43,15 +43,10 @@ class Point int x; int y; int mscase; - Point * next; - Point * previous; - bool endpoint = false; bool allocated = false; Point(int x, int y, int mscase){ this -> x = x; this -> y = y; this -> mscase = mscase; - this -> next = nullptr; - this -> previous = nullptr; }; }; diff --git a/src/main.cpp b/src/main.cpp index 9aa9fae..408592f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,16 +5,13 @@ #include #include #include -#include #include -#include #include #include #include #include "gdal/gdal_priv.h" #include #include -#include std::vector produce_cellmap(HeightMap* heightmap, float z) { @@ -30,22 +27,15 @@ std::vector produce_cellmap(HeightMap* heightmap, float z) (heightmap->get_pixel(x,y+1)>z)*8; if (result != 0 and result != 15 ) { points.push_back(Point(x, y, result)); - }; } - return points; - - } - - -std::vector> vector_cellmap(HeightMap* heightmap, int interval) +std::vector> create_lines(HeightMap* heightmap, int interval) { int num_contours = (heightmap->max - heightmap->min)/interval; std::vector> vector_contours; - omp_set_num_threads(12); #pragma omp parallel { @@ -117,11 +107,7 @@ std::vector> vector_cellmap(HeightMap* heightmap, int interva } } } - } - //vec_private.push_back(points); - //vector_contours.push_back(points); - //std::cout << vector_contours.size(); } #pragma omp critical @@ -213,31 +199,15 @@ void write_output_file(std::vector> all_points, const char *f feature = OGRFeature::CreateFeature( poLayer->GetLayerDefn() ); feature->SetField( "Name", j ); - std::vector points = all_points[j]; for (int k = 0; k < points.size(); k++) { - //int x_raw = i%width; - //int y_raw = i/height; int x_raw = points[k].x; int y_raw = points[k].y; - /* - if (x_raw > 500 || y_raw > 400) - { - std::cout << "🤯";std::cout.flush(); - continue; - } - */ auto [x, y] = local_to_projected(heightmap->geotransform, x_raw, y_raw); //auto [x_bl, y_bl, x_tr, y_tr] = marching_squares_lookup(*(cellmap->cells + i) ); - //std::cout << x_raw << ", " << y_raw << " ";std::cout.flush(); - //geometry->setPoint( geometry->getNumPoints(), x+x_tr*0.25, y+y_tr*0.25 ); - //geometry->setPoint( geometry->getNumPoints(), x+x_bl*0.25, y+y_bl*0.25 ); geometry->setPoint(geometry->getNumPoints(),x ,y ); - - //current sometimes becomes random pointer????? - } if ( feature->SetGeometry(geometry) != OGRERR_NONE) @@ -253,7 +223,6 @@ void write_output_file(std::vector> all_points, const char *f } OGRFeature::DestroyFeature( feature ); } - GDALClose( poDS ); } @@ -267,8 +236,6 @@ int main(int argc, const char* argv[]) map.blur(0.8); - auto cellmap = produce_cellmap(&map, 40); - - auto cellmaps = vector_cellmap(&map, 5); - write_output_file(cellmaps, "out.geojson", &map); + auto lines = create_lines(&map, 5); + write_output_file(lines, "out.geojson", &map); } \ No newline at end of file