Skip to content

Commit

Permalink
store copy of geojson raster in local file system
Browse files Browse the repository at this point in the history
  • Loading branch information
elidwa committed Aug 21, 2024
1 parent c671179 commit 78d35f8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions packages/geo/GeoJsonRaster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ GeoJsonRaster::GeoJsonRaster(lua_State* L, GeoParms* _parms, const char* _geojst
CHECK_GDALERR(cplerr);
mlog(DEBUG, "Rasterized geojson into raster %s", rasterFileName.c_str());

#if 0
/* For debugging, save raster to local file */
GDALDriver* localDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
if(localDriver)
{
const char* localFileName = "/tmp/local_raster.tif";
remove(localFileName);
GDALDataset* dsetcopy = localDriver->CreateCopy(localFileName, rasterDset, FALSE, NULL, NULL, NULL);
GDALClose(reinterpret_cast<GDALDatasetH>(dsetcopy));
mlog(INFO, "Raster saved to local file: %s", localFileName);
}
else mlog(ERROR, "Failed to get GDAL driver for local file");
#endif

/* Must close raster to flush it into file in vsimem */
GDALClose((GDALDatasetH)rasterDset);
rasterDset = NULL;
Expand All @@ -255,8 +269,8 @@ GeoJsonRaster::GeoJsonRaster(lua_State* L, GeoParms* _parms, const char* _geojst

/* Cleanup */
VSIUnlink(jsonFile.c_str());
if(jsonDset) GDALClose(reinterpret_cast<GDALDatasetH>(jsonDset));
if(rasterDset) GDALClose(reinterpret_cast<GDALDatasetH>(rasterDset));
if(jsonDset) GDALClose(reinterpret_cast<GDALDatasetH>(jsonDset));
if(rasterDset) GDALClose(reinterpret_cast<GDALDatasetH>(rasterDset));

if(!rasterCreated)
throw RunTimeException(CRITICAL, RTE_ERROR, "GeoJsonRaster failed");
Expand Down

0 comments on commit 78d35f8

Please sign in to comment.