• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ CPLGetLastErrorMsg函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中CPLGetLastErrorMsg函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLGetLastErrorMsg函数的具体用法?C++ CPLGetLastErrorMsg怎么用?C++ CPLGetLastErrorMsg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了CPLGetLastErrorMsg函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:30,代码来源:gxlocaldb.cpp


示例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;
}
开发者ID:ashaw,项目名称:simple-tiles,代码行数:27,代码来源:error.c


示例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);
}
开发者ID:FeodorFitsner,项目名称:PDAL,代码行数:30,代码来源:SpatialReference.cpp


示例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;
}
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:60,代码来源:OgrUtilities.cpp


示例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;
}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:60,代码来源:ogrwcts.cpp


示例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);

}
开发者ID:JamesSLC,项目名称:rasterman,代码行数:63,代码来源:raster.cpp


示例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());
    }
}
开发者ID:adam-erickson,项目名称:PDAL,代码行数:11,代码来源:ReprojectionFilter.cpp


示例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;
    }
}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:13,代码来源:gxfile.cpp


示例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);

}
开发者ID:jeroenooms,项目名称:rgdal,代码行数:51,代码来源:gdal-bindings.cpp


示例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() + ")");
  }

}
开发者ID:OpenFLUID,项目名称:openfluid,代码行数:14,代码来源:GeoRasterValue.cpp


示例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);
}
开发者ID:giserh,项目名称:hootenanny,代码行数:15,代码来源:MapReprojector.cpp


示例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;
         }
     }
 }
开发者ID:cquest,项目名称:mapnik,代码行数:15,代码来源:ogr_layer_ptr.hpp


示例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;
	}
开发者ID:RNCan,项目名称:WeatherBasedSimulationFramework,代码行数:17,代码来源:OGRBasic.cpp


示例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;
}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:19,代码来源:gxfile.cpp


示例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);
    }
开发者ID:pblottiere,项目名称:PDAL,代码行数:39,代码来源:GDALUtils.hpp


示例16: wxDynamicCast

wxGISDataset* const wxGxMLDatasetUI::GetDataset(bool bCache, ITrackCancel* const pTrackCancel)
{
    wxGISFeatureDataset* pwxGISFeatureDataset = wxDynamicCast(GetDatasetFast(), wxGISFeatureDataset);

    if(pwxGISFeatureDataset && !pwxGISFeatureDataset->IsOpened())
    {
        if (!pwxGISFeatureDataset->Open(0, TRUE, bCache, pTrackCancel))
        {
            const char* err = CPLGetLastErrorMsg();
            wxString sErr = wxString::Format(_("Operation '%s' failed! GDAL error: %s"), _("Open"), wxString(err, wxConvUTF8).c_str());
            wxLogError(sErr);
            if (pTrackCancel)
            {
                pTrackCancel->PutMessage(sErr, wxNOT_FOUND, enumGISMessageErr);
            }
            wsDELETE(pwxGISFeatureDataset);
            return NULL;
        }
        wxGIS_GXCATALOG_EVENT(ObjectChanged);
    }

    wsGET( m_pwxGISDataset );
}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:23,代码来源:gxmldatasetui.cpp


示例17: wxDynamicCast

wxGISDataset* const wxGxOpenFileGDB::GetDataset(bool bCached, ITrackCancel* const pTrackCancel)
{
    wxGISDataSource* pwxGISDataSource = wxDynamicCast(GetDatasetFast(), wxGISDataSource);

    if (NULL != pwxGISDataSource && !pwxGISDataSource->IsOpened())
    {
        if (!pwxGISDataSource->Open(TRUE))
        {
            wsDELETE(pwxGISDataSource);
            const char* err = CPLGetLastErrorMsg();
            wxString sErr = wxString::Format(_("Operation '%s' failed! GDAL error: %s"), _("Open"), wxString(err, wxConvUTF8).c_str());
            wxLogError(sErr);
            if (pTrackCancel)
                pTrackCancel->PutMessage(sErr, wxNOT_FOUND, enumGISMessageErr);
            return NULL;
        }
        wxGIS_GXCATALOG_EVENT(ObjectChanged);
        wsDELETE(pwxGISDataSource);
    }

    wsGET(m_pwxGISDataset);

}
开发者ID:GimpoByte,项目名称:nextgismanager,代码行数:23,代码来源:gxlocaldb.cpp


示例18: CPLGetLastErrorMsg

bool wxGxArchive::Delete(void)
{
	int nCount = 0;
    for(size_t i = 1; i < m_sPath.length(); ++i)
    {
        nCount++;
        if(m_sPath[i] == '/')
            break;
    }

    m_sPath.erase(0, nCount + 1);

    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;
    }
    return false;
}
开发者ID:Mileslee,项目名称:wxgis,代码行数:24,代码来源:gxarchfolder.cpp


示例19: simplet_set_error

// Add a bit of debugging information to the error.
void
simplet_set_error(simplet_error_t *error, simplet_status_t status, const char *msg){
  switch(status){
    case SIMPLET_ERR:
      error->status = SIMPLET_ERR;
      snprintf(error->msg, SIMPLET_MAX_ERROR, "simple tiles error: %s", msg);
      break;
    case SIMPLET_OOM:
      error->status = SIMPLET_OOM;
      snprintf(error->msg, SIMPLET_MAX_ERROR, "out of memory for allocation, %s", msg);
      break;
    case SIMPLET_CAIRO_ERR:
      error->status = SIMPLET_CAIRO_ERR;
      snprintf(error->msg, SIMPLET_MAX_ERROR, "cairo error: %s", msg);
      break;
    case SIMPLET_OGR_ERR:
      error->status = SIMPLET_OGR_ERR;
      snprintf(error->msg, SIMPLET_MAX_ERROR, "OGR error: %s, %s", CPLGetLastErrorMsg(), msg);
      break;
    case SIMPLET_OK:
      error->status = SIMPLET_OK;
      snprintf(error->msg, SIMPLET_MAX_ERROR, "%s", msg);
  }
}
开发者ID:coleGillespie,项目名称:simple-tiles,代码行数:25,代码来源:error.c


示例20: OGRRegisterAll

shared_ptr<OgrFeatureProvider> OgrFeatureProvider::openDataSource(const QString& ds)
{
    static bool first = true;
    if (first == true)
    {
        OGRRegisterAll();
        first = false;
    }

    OGRDataSource* dataSource(OGRSFDriverRegistrar::Open(ds.toAscii(), FALSE));

    QString errorMsg = CPLGetLastErrorMsg();
    qDebug() << errorMsg;
    if (dataSource->GetLayerCount() != 1)
    {
        throw Exception("Invalid layer count.");
    }

    shared_ptr<OgrFeatureProvider> result(
            new OgrFeatureProvider(dataSource->GetLayer(0)));
    result->_dataSource = dataSource;

    return result;
}
开发者ID:Nanonid,项目名称:hootenanny,代码行数:24,代码来源:OgrFeatureProvider.cpp



注:本文中的CPLGetLastErrorMsg函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CPLGetPath函数代码示例发布时间:2022-05-30
下一篇:
C++ CPLGetFilename函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap