Compare commits

..

No commits in common. "d046e18c43d883eb7d60cf77aac60a8782044a6c" and "29a7ddb0837856df1796c39b0379979156e6f3bc" have entirely different histories.

2 changed files with 8 additions and 26 deletions

View File

@ -35,18 +35,4 @@ class CellMap
OGRSpatialReference reference_system;
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,11 +13,10 @@
#include <gdal/gdal_frmts.h>
#include <omp.h>
std::vector<Point> produce_cellmap(HeightMap* heightmap, float z)
CellMap 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);
@ -25,26 +24,23 @@ std::vector<Point> 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;
if (result != 0 and result != 15 ) {
points.push_back(Point(x, y, result));
};
*(cells + i) = result;
}
return points;
return CellMap(heightmap->width-1, heightmap->height-1, cells, heightmap->reference_system, heightmap->geotransform);
}
std::vector<std::vector<Point>> vector_cellmap(HeightMap* heightmap, int interval)
std::vector<CellMap> vector_cellmap(HeightMap* heightmap, int interval)
{
int num_contours = (heightmap->max - heightmap->min)/interval;
std::vector<std::vector<Point>> vector_contours;
std::vector<CellMap> vector_contours;
omp_set_num_threads(12);
#pragma omp parallel
{
std::vector<std::vector<Point>> vec_private;
std::vector<CellMap> vec_private;
#pragma omp for
for (int i = 1; i <= num_contours; i++)
{
@ -184,5 +180,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");
}