mirror of
https://gitlab.com/Trygve/contour-creator.git
synced 2024-11-21 23:00:18 +00:00
Fixed segfault
This commit is contained in:
parent
ee0b87c2b3
commit
f962a40ade
16
src/main.cpp
16
src/main.cpp
@ -66,7 +66,7 @@ std::tuple<double, double> local_to_projected(double* geotransform, int x, int y
|
||||
void write_output_file(std::vector<CellMap> 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<CellMap> 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<CellMap> 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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user