本文整理汇总了C++中CPLGetLastErrorMsg函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLGetLastErrorMsg函数的具体用法?C++ CPLGetLastErrorMsg怎么用?C++ CPLGetLastErrorMsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CPLGetLastErrorMsg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDatasetFast
bool wxGxOpenFileGDB::Rename(const wxString &sNewName)
{
wxGISDataset* pDSet = GetDatasetFast();
if (NULL != pDSet)
{
pDSet->Close();
wsDELETE(pDSet);
}
wxFileName PathName(wxString(m_sPath, wxConvUTF8));
PathName.SetName(ClearExt(sNewName));
wxString sNewPath = PathName.GetFullPath();
CPLString szNewPath(sNewPath.mb_str(wxConvUTF8));
if (RenameFile(m_sPath, szNewPath))
{
if (m_bIsChildrenLoaded)
Refresh();
return true;
}
else
{
const char* err = CPLGetLastErrorMsg();
wxLogError(_("Operation '%s' failed! GDAL error: %s, file '%s'"), _("Rename"), wxString(err, wxConvUTF8).c_str(), wxString(m_sPath, wxConvUTF8).c_str());
return false;
}
return false;
}
示例2: simplet_set_error
// Add a bit of debugging information to the error.
int
simplet_set_error(simplet_errorable_t *error, simplet_status_t status, const char *msg){
int res = 1;
switch(status){
case SIMPLET_ERR:
error->status = SIMPLET_ERR;
res = asprintf(&error->error_msg, "simple tiles error: %s", msg);
break;
case SIMPLET_OOM:
error->status = SIMPLET_OOM;
res = asprintf(&error->error_msg, "out of memory for allocation, %s", msg);
break;
case SIMPLET_CAIRO_ERR:
error->status = SIMPLET_CAIRO_ERR;
res = asprintf(&error->error_msg, "cairo error: %s", msg);
break;
case SIMPLET_OGR_ERR:
error->status = SIMPLET_OGR_ERR;
res = asprintf(&error->error_msg, "OGR error: %s, %s", CPLGetLastErrorMsg(), msg);
break;
case SIMPLET_OK:
error->status = SIMPLET_OK;
res = asprintf(&error->error_msg, "%s", msg);
}
return res;
}
示例3: srs
void SpatialReference::setFromUserInput(std::string const& v)
{
if (v.empty())
{
m_wkt.clear();
return;
}
OGRSpatialReference srs(NULL);
CPLErrorReset();
const char* input = v.c_str();
OGRErr err = srs.SetFromUserInput(const_cast<char *>(input));
if (err != OGRERR_NONE)
{
std::ostringstream oss;
std::string msg = CPLGetLastErrorMsg();
if (msg.empty())
msg = "(unknown reason)";
oss << "Could not import coordinate system '" << input << "': " <<
msg << ".";
throw pdal_error(oss.str());
}
char *poWKT = 0;
srs.exportToWkt(&poWKT);
std::string tmp(poWKT);
CPLFree(poWKT);
setWKT(tmp);
}
示例4: while
shared_ptr<OGRDataSource> OgrUtilities::createDataSource(QString url)
{
const char* driverName = NULL;
int i = 0;
while (extensions[i][0] != NULL)
{
if (url.endsWith(extensions[i][0]))
{
driverName = extensions[i][1];
}
i++;
}
i = 0;
while (beginName[i][0] != NULL)
{
if (url.startsWith(beginName[i][0]))
{
driverName = beginName[i][1];
}
i++;
}
if (driverName == NULL)
{
throw HootException("No driver found for: " + url);
}
OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driverName);
if (driver == 0)
{
throw HootException("Error getting driver by name: " + QString(driverName));
}
// if the user specifies a shapefile then crop off the .shp and create a directory.
if (url.toLower().endsWith(".shp"))
{
url = url.mid(0, url.length() - 4);
}
shared_ptr<OGRDataSource> result(driver->CreateDataSource(url.toAscii()));
if (result == NULL)
{
throw HootException("Unable to create data source: " + url +
" (" + QString(CPLGetLastErrorMsg()) + ")");
}
result->SetDriver(driver);
if (QString(driverName) == "FileGDB")
{
long v = GDAL_VERSION_MAJOR * 1000000 + GDAL_VERSION_MINOR * 1000 + GDAL_VERSION_REV;
long lowest = 1 * 1000000 + 10 * 1000 + 1;
if (v < lowest)
{
LOG_WARN("Writing to FileGDB with GDAL v" << GDAL_RELEASE_NAME << ". FileGDB with a GDAL "
"v1.9.0 is known to create files that can't be read by ArcMap 10.2. "
"GDAL v1.10.1 is known to work.");
}
}
return result;
}
示例5: WCTSEmitServiceException
CPLXMLNode *WCTSCollectRequest()
{
if( getenv("REQUEST_METHOD") == NULL )
WCTSEmitServiceException( "REQUEST_METHOD not set." );
if( EQUAL(getenv("REQUEST_METHOD"),"GET") )
return WCTSCollectKVPRequest();
/* -------------------------------------------------------------------- */
/* Read the body of the POST message into a buffer. */
/* -------------------------------------------------------------------- */
int nContentLength = 0;
char *pszXML = NULL;
if( getenv("CONTENT_LENGTH") != NULL )
{
nContentLength = atoi(getenv("CONTENT_LENGTH"));
pszXML = (char *) CPLMalloc(nContentLength+1);
if( (int) fread(pszXML, 1, nContentLength, stdin) < nContentLength )
WCTSEmitServiceException( "POST body is short." );
pszXML[nContentLength] = '\0';
}
else
{
int nXMLMax, nXMLLen=0;
nXMLMax = 100;
pszXML = (char *) CPLMalloc(nXMLMax);
while( !feof(stdin) )
{
pszXML[nXMLLen++] = fgetc(stdin);
if( nXMLLen == nXMLMax )
{
nXMLMax = nXMLMax * 2;
pszXML = (char *) CPLRealloc(pszXML, nXMLMax);
}
}
pszXML[nXMLLen] = '\0';
}
/* -------------------------------------------------------------------- */
/* Convert into an XML document. */
/* -------------------------------------------------------------------- */
CPLErrorReset();
CPLXMLNode *psTree = CPLParseXMLString( pszXML );
CPLFree( pszXML );
if( CPLGetLastErrorType() == CE_Failure )
WCTSEmitServiceException( CPLGetLastErrorMsg() );
return psTree;
}
示例6: Init
/*
* Initializes the object, assuming that filename, origin, size, etc are already set on the
* member variables. Makes sure the raster can be opened, sets the block size, NODATA value,
* pixel size, and the extent of the raster. If not using the full image then makes sure that
* the subset chosen (based on origin and size) is valid. If using the full image then sets the
* size and origin is assumed to be 0,0 and is set in the constructor.
* @param fullImage True if using the full image, False if using a subset.
*/
void Raster::Init(bool bFullImage)
{
Init();
GDALDataset * ds = (GDALDataset*) GDALOpen(m_sFilePath, GA_ReadOnly);
if (ds == NULL)
throw RasterManagerException(INPUT_FILE_NOT_VALID, CPLGetLastErrorMsg());
GDALRasterBand * band = ds->GetRasterBand(1);
double dRMin, dRMax, dRMean, dRStdDev;
// Get some easy stats that GDAL gives us
band->GetStatistics( 0 , true, &dRMin, &dRMax, &dRMean, &dRStdDev );
m_dRasterMax = dRMax;
m_dRasterMin = dRMin;
m_dRasterMean = dRMean;
m_dRasterStdDev = dRStdDev;
OGRLinearRing ring = OGRLinearRing();
if (bFullImage)
{
SetCols( band->GetXSize() );
SetRows( band->GetYSize() );
ring.addPoint(GetLeft(), GetTop());
ring.addPoint(GetLeft(), GetTop() + (GetCellHeight() * GetRows()));
ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop() + (GetCellHeight() * GetRows()));
ring.addPoint(GetLeft() + (GetCellWidth() * GetCols()), GetTop());
ring.closeRings();
}
else
{
if ((GetLeft() + GetCols() > band->GetXSize()) || (GetTop() + GetRows() > band->GetYSize()))
{
QString sErr = QString("Invalid origin ( %1, %2 ) and size ( %5, %6 ) for file: %7")
.arg(GetLeft())
.arg(GetTop())
.arg(GetCols())
.arg(GetRows())
.arg(FilePath());
throw RasterManagerException(INPUT_FILE_NOT_VALID, sErr);
}
double xMapOrigin = GetLeft() + (GetLeft() * GetCellWidth());
double yMapOrigin = GetTop() + (GetTop() * GetCellHeight());
ring.addPoint(xMapOrigin, yMapOrigin);
ring.addPoint(xMapOrigin, yMapOrigin + (GetCellHeight() * GetRows()));
ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin + (GetCellHeight() * GetRows()));
ring.addPoint(xMapOrigin + (GetCellWidth() * GetCols()), yMapOrigin);
ring.closeRings();
}
GDALClose(ds);
}
示例7: OCTTransform
void ReprojectionFilter::transform(double& x, double& y, double& z)
{
int ret = OCTTransform(m_transform_ptr, 1, &x, &y, &z);
if (ret == 0)
{
std::ostringstream msg;
msg << "Could not project point for ReprojectionTransform::" <<
CPLGetLastErrorMsg() << ret;
throw pdal_error(msg.str());
}
}
示例8: CPLGetLastErrorMsg
bool wxGxFile::Delete(void)
{
if(DeleteFile(m_sPath))
{
return true;
}
else
{
const char* err = CPLGetLastErrorMsg();
wxLogError(_("Operation '%s' failed! GDAL error: %s, file '%s'"), _("Delete"), wxString(err, wxConvUTF8).c_str(), wxString(m_sPath, wxConvUTF8).c_str());
return false;
}
}
示例9: RGDAL_OpenDataset
SEXP
RGDAL_OpenDataset(SEXP filename, SEXP read_only, SEXP silent) {
const char *fn = asString(filename);
GDALAccess RWFlag;
if (asLogical(read_only))
RWFlag = GA_ReadOnly;
else
RWFlag = GA_Update;
/* Modification suggested by Even Rouault, 2009-08-08: */
CPLErrorReset();
if (asLogical(silent))
CPLPushErrorHandler(CPLQuietErrorHandler);
else
installErrorHandler();
GDALDataset *pDataset = (GDALDataset *) GDALOpen(fn, RWFlag);
if (pDataset == NULL)
error("%s\n", CPLGetLastErrorMsg());
if (asLogical(silent))
CPLPopErrorHandler();
else
uninstallErrorHandlerAndTriggerError();
/* Similarly to SWIG bindings, the following lines will cause
RGDAL_OpenDataset() to fail on - uncleared - errors even if pDataset is not
NULL. They could also be just removed. While pDataset != NULL, there's some
hope ;-) */
/* CPLErr eclass = CPLGetLastErrorType();
if (pDataset != NULL && eclass == CE_Failure) {
GDALClose(pDataset);
pDataset = NULL;
__errorHandler(eclass, CPLGetLastErrorNo(), CPLGetLastErrorMsg());
}*/
SEXP sxpHandle = R_MakeExternalPtr((void *) pDataset,
mkChar("GDAL Dataset"),
R_NilValue);
return(sxpHandle);
}
示例10: CPLGetLastErrorMsg
void GeoRasterValue::tryToOpenSource()
{
// GDALOpenShared to allow copy then close of this raster in virtual format (see http://www.gdal.org/gdal_vrttut.html)
mp_Data = static_cast<GDALDataset*>(GDALOpenShared(m_AbsolutePath.c_str(),
GA_ReadOnly));
if (!mp_Data)
{
throw openfluid::base::FrameworkException(OPENFLUID_CODE_LOCATION,
"Error while trying to open file " + m_AbsolutePath +
" (" + CPLGetLastErrorMsg() + ")");
}
}
示例11: t
void MapReprojector::reproject(const shared_ptr<Geometry>& g,
const shared_ptr<OGRSpatialReference>& srs1, const shared_ptr<OGRSpatialReference>& srs2)
{
OGRCoordinateTransformation* t(OGRCreateCoordinateTransformation(srs1.get(), srs2.get()));
if (t == 0)
{
throw HootException(QString("Error creating transformation object: ") + CPLGetLastErrorMsg());
}
ReprojectCoordinateFilter filter(t);
g->apply_rw(&filter);
OGRCoordinateTransformation::DestroyCT(t);
}
示例12: debug_print_last_error
void debug_print_last_error()
{
if (! is_valid_)
{
const std::string err = CPLGetLastErrorMsg();
if (err.size() == 0)
{
MAPNIK_LOG_DEBUG(ogr) << "ogr_layer_ptr: Error getting layer";
}
else
{
MAPNIK_LOG_DEBUG(ogr) << "ogr_layer_ptr: " << err;
}
}
}
示例13: CPLGetLastErrorMsg
ERMsg COGRDataSource::Open(const char * pszName, int bUpdate)
{
ERMsg msg;
m_poDS = OGRSFDriverRegistrar::Open(pszName, bUpdate);
if (m_poDS == NULL)
{
const char* pError = CPLGetLastErrorMsg();
if (pError && *pError)
msg.ajoute(pError);
else msg.ajoute("File doesn't exist");
return msg;
}
return msg;
}
示例14: PathName
bool wxGxFile::Rename(const wxString &sNewName)
{
wxFileName PathName(wxString(m_sPath, wxConvUTF8));
PathName.SetName(ClearExt(sNewName));
wxString sNewPath = PathName.GetFullPath();
CPLString szNewPath(sNewPath.mb_str(wxConvUTF8));
if(RenameFile(m_sPath, szNewPath))
{
return true;
}
else
{
const char* err = CPLGetLastErrorMsg();
wxLogError(_("Operation '%s' failed! GDAL error: %s, file '%s'"), _("Rename"), wxString(err, wxConvUTF8).c_str(), wxString(m_sPath, wxConvUTF8).c_str());
return false;
}
return false;
}
示例15: Geometry
Geometry(const std::string& wkt, const SpatialRef& srs)
{
OGRGeometryH geom;
char *p_wkt = const_cast<char *>(wkt.data());
OGRSpatialReferenceH ref = srs.get();
if (srs.empty())
{
ref = NULL;
}
bool isJson = wkt.find("{") != wkt.npos ||
wkt.find("}") != wkt.npos;
if (!isJson)
{
OGRErr err = OGR_G_CreateFromWkt(&p_wkt, ref, &geom);
if (err != OGRERR_NONE)
{
std::cout << "wkt: " << wkt << std::endl;
std::ostringstream oss;
oss << "unable to construct OGR Geometry";
oss << " '" << CPLGetLastErrorMsg() << "'";
throw pdal::pdal_error(oss.str());
}
}
else
{
// Assume it is GeoJSON and try constructing from that
geom = OGR_G_CreateGeometryFromJson(p_wkt);
if (!geom)
throw pdal_error("Unable to create geometry from "
"input GeoJSON");
OGR_G_AssignSpatialReference(geom, ref);
}
newRef(geom);
}