commit
10e03b6e01
|
@ -136,8 +136,17 @@ createAccessor_C(PyObject* self, PyObject* args)
|
|||
}
|
||||
if (casterCh[0] == '\0')
|
||||
{
|
||||
ptDataAccessor = (uint64_t) AF->createAccessor(filename, filemode, size,
|
||||
bands, width, scheme);
|
||||
try
|
||||
{
|
||||
ptDataAccessor = (uint64_t) AF->createAccessor(filename, filemode, size,
|
||||
bands, width, scheme);
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
{
|
||||
PyErr_SetString(PyExc_OSError, e.what());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
else if (casterCh[0] != '\0' && PyDict_Size(dict) == 0)
|
||||
{
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
|
|
@ -69,21 +69,21 @@ GDALAccessor::openFile (string filename, string accessMode, GDALDataset ** fd)
|
|||
if (accessMode == "read" || accessMode == "READ")
|
||||
{
|
||||
std::cout << "GDAL open (R): " << filename << std::endl;
|
||||
(*fd) = (GDALDataset *) GDALOpenShared (filename.c_str (), GA_ReadOnly);
|
||||
if ((*fd) == NULL)
|
||||
{
|
||||
cout << "Error. Cannot open the file " << filename << " in "
|
||||
<< accessMode << " mode." << endl;
|
||||
ERR_MESSAGE
|
||||
;
|
||||
}
|
||||
(*fd) = (GDALDataset *) GDALOpenShared (filename.c_str (), GA_ReadOnly);
|
||||
if ((*fd) == NULL)
|
||||
{
|
||||
string errMsg = "Cannot open the file " + filename + " in "
|
||||
+ accessMode + " mode.";
|
||||
throw runtime_error(errMsg);
|
||||
// ERR_MESSAGE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << "Error. Only read mode is available and not " << accessMode
|
||||
<< " mode." << endl;
|
||||
ERR_MESSAGE
|
||||
;
|
||||
string errMsg = "Error. Only read mode is available and not " + accessMode + " mode.";
|
||||
throw runtime_error(errMsg);
|
||||
// ERR_MESSAGE
|
||||
// ;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -112,8 +112,8 @@ void InterleavedAccessor::openFile(string filename, string accessMode, fstream
|
|||
fd.open(filename.c_str(), ios_base::in);
|
||||
if(fd.fail())
|
||||
{
|
||||
cout << "Error. Cannot open the file " << filename << " in " << accessMode << " mode." <<endl;
|
||||
ERR_MESSAGE;
|
||||
string errMsg = "Cannot open the file " + filename + " in " + accessMode + " mode.";
|
||||
throw runtime_error(errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -139,13 +139,13 @@ void InterleavedAccessor::openFile(string filename, string accessMode, fstream
|
|||
}
|
||||
else
|
||||
{
|
||||
cout << "Error. Unrecognized open mode " << accessMode << " for file " << filename << endl;
|
||||
ERR_MESSAGE;
|
||||
string errMsg = "Unrecognized open mode " + accessMode + " for file " + filename;
|
||||
throw runtime_error(errMsg);
|
||||
}
|
||||
if(!fd.good())
|
||||
{
|
||||
cout << "Cannot open file " << filename << endl;
|
||||
ERR_MESSAGE;
|
||||
string errMsg = "Cannot open file " + filename;
|
||||
throw runtime_error(errMsg);
|
||||
}
|
||||
}
|
||||
void InterleavedAccessor::getStream(char * dataLine, int & numEl)
|
||||
|
|
Loading…
Reference in New Issue