introduced class Point and changed cell map to create lines

This commit is contained in:
esther 2024-04-29 14:54:44 +02:00
parent 29a7ddb083
commit 5cd5627bb7

View File

@ -17,6 +17,7 @@ CellMap produce_cellmap(HeightMap* heightmap, float z)
{ {
int length = (heightmap->width-1)*(heightmap->height-1); int length = (heightmap->width-1)*(heightmap->height-1);
uint8_t *cells = (uint8_t *) CPLMalloc(sizeof(uint8_t)*length); uint8_t *cells = (uint8_t *) CPLMalloc(sizeof(uint8_t)*length);
std::vector<Point> points;
for (int i = 0; i<length; i++) { for (int i = 0; i<length; i++) {
int y = i/(heightmap->width-1); int y = i/(heightmap->width-1);
int x = i%(heightmap->width-1); int x = i%(heightmap->width-1);
@ -24,7 +25,10 @@ CellMap produce_cellmap(HeightMap* heightmap, float z)
(heightmap->get_pixel(x+1,y)>z)*2 + (heightmap->get_pixel(x+1,y)>z)*2 +
(heightmap->get_pixel(x+1,y+1)>z)*4 + (heightmap->get_pixel(x+1,y+1)>z)*4 +
(heightmap->get_pixel(x,y+1)>z)*8; (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 CellMap(heightmap->width-1, heightmap->height-1, cells, heightmap->reference_system, heightmap->geotransform);
@ -180,5 +184,5 @@ int main(int argc, const char* argv[])
auto cellmap = produce_cellmap(&map, 40); auto cellmap = produce_cellmap(&map, 40);
auto cellmaps = vector_cellmap(&map, 5); auto cellmaps = vector_cellmap(&map, 5);
write_output_file(cellmaps, "out.geojson"); //write_output_file(cellmaps, "out.geojson");
} }