diff --git a/src/CellMap.cpp b/src/CellMap.cpp deleted file mode 100644 index b1f5112..0000000 --- a/src/CellMap.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include -#include -#include "contour_creator.hh" - - -CellMap::CellMap(int width, int height, uint8_t* cells, OGRSpatialReference reference_system, double* geotransform) -{ - this->width = width; - this->height = height; - this->cells = cells; - this->reference_system = reference_system; - this->geotransform = geotransform; -} -int CellMap::get_cell(int x, int y) -{ - // all the cells are in an array of ints from left to right, top to bottom - int offset = ((this->width * y) + x); - return *(this->cells + offset); -} \ No newline at end of file diff --git a/src/contour_creator.hh b/src/contour_creator.hh index 59c3b63..8d43372 100644 --- a/src/contour_creator.hh +++ b/src/contour_creator.hh @@ -22,26 +22,11 @@ class HeightMap delete[] data; delete[] geotransform; } - const char* filepath; + const char* filepath; //!< Where the heightmap was read from float get_pixel(int x,int y); void blur(float standard_deviation); - void statistics(); - void calculate_steepness(const char*); -}; - -/** - @brief stores the cells from marching squars for one elevation level - */ -class CellMap -{ - public: - uint8_t* cells; //!< pointer to the first cell in the array. uint8_t is a 8 bit unsigned integer - double* geotransform; //!< Six double buffer for storing the affine transformations - int width; //!< width of image in cells - int height; //!< height of image in cells - OGRSpatialReference reference_system; - CellMap(int width, int height, uint8_t* cells, OGRSpatialReference reference_system, double* geotransform); - int get_cell(int x,int y); + void statistics(); //!< Print statistical information about the heightmap + void calculate_steepness(const char*); //!< Output a raster file with the steepness of each pixel }; class Point @@ -49,8 +34,8 @@ class Point public: int x; int y; - int mscase; - bool allocated = false; + uint8_t mscase; //!< The case outputted by the algorithm. A number between 0 and 15 + bool allocated = false; //!< Used when sorting the points to see if it has been sorted Point(int x, int y, int mscase){ this -> x = x; this -> y = y; diff --git a/src/main.cpp b/src/main.cpp index 591d141..e239662 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -250,8 +250,8 @@ void write_output_file(std::vector> all_points, const char *f if ((points[k].x - points[k-1].x) < 0) left_to_right = false; bool top_to_bottom = true; - if ((points[k].y - points[k-1].y) <= 0) - left_to_right = false; + if ((points[k].y - points[k-1].y) < 0) + top_to_bottom = false; @@ -261,7 +261,7 @@ void write_output_file(std::vector> all_points, const char *f auto [x1, y1, x2, y2] = marching_squares_lookup(points[k].mscase); - if (left_to_right or !top_to_bottom) + if (left_to_right or top_to_bottom) { geometry->setPoint(geometry->getNumPoints(),x + (x1/4) ,y + (y1/4)); geometry->setPoint(geometry->getNumPoints(),x + (x2/4) ,y + (y2/4));