From f962a40adea52b1072369a5cab00d1a1ee9bbc8f Mon Sep 17 00:00:00 2001 From: Trygve Date: Sat, 27 Apr 2024 17:15:37 +0200 Subject: [PATCH] Fixed segfault --- src/main.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 486af9e..9383f98 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -66,7 +66,7 @@ std::tuple local_to_projected(double* geotransform, int x, int y void write_output_file(std::vector cellmaps, const char *filepath) { - const char *pszDriverName = "ESRI Shapefile"; + const char *pszDriverName = "GeoJSON"; GDALDriver *poDriver; GDALAllRegister(); @@ -109,7 +109,7 @@ void write_output_file(std::vector cellmaps, const char *filepath) { CellMap* cellmap = &cellmaps[j]; OGRFeature *feature; - OGRLineString *geometry; + OGRLineString *geometry = new OGRLineString(); feature = OGRFeature::CreateFeature( poLayer->GetLayerDefn() ); feature->SetField( "Name", j ); for (int i = 0; i < cellmap->height*cellmap->width; i++) @@ -118,15 +118,9 @@ void write_output_file(std::vector cellmaps, const char *filepath) { int x_raw = i%cellmap->width; int y_raw = i/cellmap->width; - - std::cout << "🤬"; std::cout.flush(); - - auto [x, y] = local_to_projected(cellmap->geotransform, x_raw, y_raw); - - - geometry->setPoint( i, x, y ); - + //std::cout << x << ", " << y << " "; + geometry->setPoint( geometry->getNumPoints(), x, y ); } } @@ -180,5 +174,5 @@ int main(int argc, const char* argv[]) */ auto cellmaps = vector_cellmap(&map, 5); - write_output_file(cellmaps, "out.shp"); + write_output_file(cellmaps, "out.geojson"); } \ No newline at end of file