Fixed some errors

This commit is contained in:
Trygve 2024-04-11 15:37:33 +02:00
parent 25354cc115
commit 1a10f0df33
4 changed files with 11 additions and 14 deletions

View File

@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 3.0)
find_package(GDAL CONFIG REQUIRED) find_package(GDAL CONFIG REQUIRED)
add_executable(${PROJECT_NAME} add_executable(${PROJECT_NAME}
src/HeightMap.cpp src/main.cpp src/HeightMap.cpp src/CaseMap.cpp src/main.cpp
) )

View File

@ -1,11 +1,4 @@
#include <gdal/gdal.h>
#include "gdal/gdal_priv.h"
#include <iostream>
#include <stdfloat>
#include "CaseMap.hh" #include "CaseMap.hh"
#include "HeightMap.hh"
CaseMap::CaseMap(int width, int height, int* cases) CaseMap::CaseMap(int width, int height, int* cases)
{ {

View File

@ -4,10 +4,10 @@
class CaseMap class CaseMap
{ {
public: public:
float* data; int* cases;
int width; //!< width of image in cases int width; //!< width of image in cases
int height; //!< height of image in cases int height; //!< height of image in cases
CaseMap(int width, int height, int* cases); CaseMap(int width, int height, int* cases);
float get_case(int x,int y); int get_case(int x,int y);
}; };

View File

@ -4,14 +4,17 @@
#include <ostream> #include <ostream>
#include <vector> #include <vector>
#include <gdal/gdal.h> #include <gdal/gdal.h>
#include "gdal/gdal_priv.h"
#include <gdal/gdal_frmts.h>
std::vector<CaseMap> produce_casemap(HeightMap* heightmap) std::vector<CaseMap> produce_casemap(HeightMap* heightmap)
{ {
std::vector<CaseMap> output; std::vector<CaseMap> output;
int* test = (int *) CPLMalloc(sizeof(int)*heightmap->width*heightmap->height); int* test = (int *) CPLMalloc(sizeof(int)*heightmap->width*heightmap->height);
*(test + 4) = 13;
CaseMap casemap1(heightmap->width-1, heightmap->height-1, test); CaseMap casemap1(heightmap->width-1, heightmap->height-1, test);
output.push_back(casemap1); output.push_back(casemap1);
return output return output;
} }
//(int a, int b, ) //(int a, int b, )
@ -23,7 +26,7 @@ int main(int argc, const char* argv[])
std::cout << "x: " << map.width << " y: " << map.height << "\n"; std::cout << "x: " << map.width << " y: " << map.height << "\n";
std::cout << "max: " << map.max << " min: " << map.min << "\n"; std::cout << "max: " << map.max << " min: " << map.min << "\n";
/*
for (int y = 0; y < map.height; y++) for (int y = 0; y < map.height; y++)
{ {
for (int x = 0; x < map.width; x++) for (int x = 0; x < map.width; x++)
@ -32,7 +35,8 @@ int main(int argc, const char* argv[])
} }
std::cout << "\n"; std::cout << "\n";
} }
*/
std::cout << "\nend🤡\n"; std::cout << "\nend🤡\n";
casemap = produce_casemap(map); auto casemap = produce_casemap(&map);
std::cout << casemap.get_case( 2, 2) std::cout << casemap[0].get_case( 4, 0);
} }