Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport GDAL #8788 #43

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ubuntu:22.04

# Needed in case tzdata gets upgraded
ENV TZ=Australia/Brisbane
ARG DEBIAN_FRONTEND=noninteractive

# Use Aussie mirrors
RUN sed -i 's/http:\/\/archive./http:\/\/au.archive./g' /etc/apt/sources.list

# Update Ubuntu software stack and install base GDAL stack
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y wget g++ cmake libhdf5-dev libgdal-dev gdal-bin

RUN apt-get autoremove -y && apt-get clean && rm -rf /var/lib/apt/lists/*

COPY . /tmp/kealib
RUN cd /tmp/kealib \
&& mkdir build \
&& cd build \
&& cmake -D LIBKEA_WITH_GDAL=ON .. \
&& make \
&& make install \
&& cd ../.. \
&& rm -rf kealib

ENV LD_LIBRARY_PATH=/usr/local/lib
ENV GDAL_DRIVER_PATH=/usr/local/lib/gdalplugins

RUN gdal_translate --formats | grep KEA
30 changes: 30 additions & 0 deletions gdal/keadataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "keacopy.h"

#include "libkea/KEACommon.h"
#include "cpl_vsi_virtual.h"

// Function for converting a libkea type into a GDAL type
GDALDataType KEA_to_GDAL_Type( kealib::KEADataType ekeaType )
Expand Down Expand Up @@ -166,6 +167,14 @@ GDALDataset *KEADataset::Open( GDALOpenInfo * poOpenInfo )
poOpenInfo->pszFilename, e.what() );
return nullptr;
}
catch (...)
{
// was a problem - can't be a valid file
CPLError(CE_Failure, CPLE_OpenFailed,
"Attempt to open file `%s' failed. Error: unknown\n",
poOpenInfo->pszFilename);
return nullptr;
}
}
else
{
Expand Down Expand Up @@ -208,6 +217,20 @@ GDALDataset *KEADataset::Create( const char * pszFilename,
"Attempt to create file `%s' failed. Invalid creation option(s)\n", pszFilename);
return nullptr;
}

// This helps avoiding issues with H5File handles in a bad state, that
// may cause crashes at process termination
// Cf https://github.com/OSGeo/gdal/issues/8743
if (VSIFileManager::GetHandler(pszFilename) !=
VSIFileManager::GetHandler(""))
{
CPLError(CE_Failure, CPLE_OpenFailed,
"Attempt to create file `%s' failed. /vsi file systems not "
"supported\n",
pszFilename);
return nullptr;
}

// process any creation options in papszParmList
// default value
unsigned int nimageblockSize = kealib::KEA_IMAGE_CHUNK_SIZE;
Expand Down Expand Up @@ -296,6 +319,13 @@ GDALDataset *KEADataset::Create( const char * pszFilename,
pszFilename, e.what() );
return nullptr;
}
catch (...)
{
CPLError(CE_Failure, CPLE_OpenFailed,
"Attempt to create file `%s' failed. Error: unknown\n",
pszFilename);
return nullptr;
}
}

GDALDataset *KEADataset::CreateCopy( const char * pszFilename, GDALDataset *pSrcDs,
Expand Down
Loading