Skip to content

Commit

Permalink
GDALDEM: clean up fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Aug 11, 2024
1 parent e809557 commit 97a0016
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/osgEarth/GDALDEM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ GDALDEMLayer::openImplementation()
Status
GDALDEMLayer::closeImplementation()
{
getElevationLayer()->close();
options().elevationLayer().close();
return STATUS_OK;
}

Expand Down Expand Up @@ -415,7 +415,15 @@ GeoImage
GDALDEMLayer::createImageImplementation(const TileKey& key, ProgressCallback* progress) const
{
#ifdef HAS_GDALDEM

ElevationLayer* layer = getElevationLayer();
if (layer->isOpen() == false)
{
OE_WARN << LC << "Elevation layer is not open!" << key.str() << std::endl;
return {};
}


GeoHeightField heightField = layer->createHeightField(key, progress);
if (heightField.valid())
{
Expand All @@ -425,7 +433,6 @@ GDALDEMLayer::createImageImplementation(const TileKey& key, ProgressCallback* pr
GDALDataset* srcDS = createDataSetFromHeightField(hf, key.getExtent().xMin(), key.getExtent().yMin(), key.getExtent().xMax(), key.getExtent().yMax(), key.getExtent().getSRS()->getWKT());
int error = 0;
std::string processing = options().processing().get();
std::string color_filename = options().color_filename()->full();
char** papsz = NULL;
papsz = CSLAddString(papsz, "-compute_edges");

Expand Down Expand Up @@ -464,7 +471,9 @@ GDALDEMLayer::createImageImplementation(const TileKey& key, ProgressCallback* pr
static std::atomic_int s_tempNameGen = { 0 };
std::string tmpPath = Stringify() << "/vsimem/" << std::this_thread::get_id() << std::to_string(s_tempNameGen++) << ".tif";

GDALDatasetH outputDS = GDALDEMProcessing(tmpPath.c_str(), srcDS, processing.c_str(), _colorRampFilename.c_str(), psOptions, &error);
const char* color_filename = processing == "color-relief" ? _colorRampFilename.c_str() : nullptr;

GDALDatasetH outputDS = GDALDEMProcessing(tmpPath.c_str(), srcDS, processing.c_str(), color_filename, psOptions, &error);
if (outputDS)
{
image = createImageFromDataset((GDALDataset*)outputDS);
Expand Down

0 comments on commit 97a0016

Please sign in to comment.