这篇教程C++ CPLHTTPDestroyResult函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CPLHTTPDestroyResult函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLHTTPDestroyResult函数的具体用法?C++ CPLHTTPDestroyResult怎么用?C++ CPLHTTPDestroyResult使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CPLHTTPDestroyResult函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: GetLayerDefnOGRErr OGRGFTTableLayer::CommitTransaction(){ GetLayerDefn(); if (!bInTransaction) { CPLError(CE_Failure, CPLE_AppDefined, "Should be in transaction"); return OGRERR_FAILURE; } bInTransaction = FALSE; if (nFeaturesInTransaction > 0) { if (nFeaturesInTransaction > 1) osTransaction += ";"; CPLHTTPResult * psResult = poDS->RunSQL(osTransaction); osTransaction.resize(0); nFeaturesInTransaction = 0; if (psResult == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "CommitTransaction failed"); return OGRERR_FAILURE; } char* pszLine = (char*) psResult->pabyData; if (pszLine == NULL || strncmp(pszLine, "rowid", 5) != 0 || psResult->pszErrBuf != NULL) { CPLError(CE_Failure, CPLE_AppDefined, "CommitTransaction failed : %s", pszLine ? pszLine : psResult->pszErrBuf); CPLHTTPDestroyResult(psResult); return OGRERR_FAILURE; } pszLine = OGRGFTGotoNextLine(pszLine); while(pszLine && *pszLine != 0) { char* pszNextLine = OGRGFTGotoNextLine(pszLine); if (pszNextLine) pszNextLine[-1] = 0; //CPLDebug("GFT", "Feature id = %s", pszLine); pszLine = pszNextLine; } CPLHTTPDestroyResult(psResult); } return OGRERR_NONE;}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:54,
示例2: osChangedSQLint OGRGFTResultLayer::FetchNextRows(){ if (!EQUALN(osSQL.c_str(), "SELECT", 6)) return FALSE; aosRows.resize(0); CPLString osChangedSQL(osSQL); if (osSQL.ifind(" OFFSET ") == std::string::npos && osSQL.ifind(" LIMIT ") == std::string::npos) { osChangedSQL += CPLSPrintf(" OFFSET %d LIMIT %d", nOffset, GetFeaturesToFetch()); } CPLPushErrorHandler(CPLQuietErrorHandler); CPLHTTPResult * psResult = poDS->RunSQL(osChangedSQL); CPLPopErrorHandler(); if (psResult == NULL) { bEOF = TRUE; return FALSE; } char* pszLine = (char*) psResult->pabyData; if (pszLine == NULL || psResult->pszErrBuf != NULL) { CPLError(CE_Failure, CPLE_AppDefined, "RunSQL() failed"); CPLHTTPDestroyResult(psResult); bEOF = TRUE; return FALSE; } pszLine = OGRGFTGotoNextLine(pszLine); if (pszLine == NULL) { CPLHTTPDestroyResult(psResult); bEOF = TRUE; return FALSE; } ParseCSVResponse(pszLine, aosRows); CPLHTTPDestroyResult(psResult); bEOF = (int)aosRows.size() < GetFeaturesToFetch(); return TRUE;}
开发者ID:0004c,项目名称:node-gdal,代码行数:51,
示例3: CPLURLAddKVPGIntBig OGRESRIFeatureServiceLayer::GetFeatureCount( int bForce ){ GIntBig nFeatureCount = -1; if( m_poAttrQuery == NULL && m_poFilterGeom == NULL ) { CPLString osNewURL = CPLURLAddKVP(poDS->GetURL(), "returnCountOnly", "true"); CPLHTTPResult* pResult = NULL; CPLErrorReset(); pResult = CPLHTTPFetch( osNewURL, NULL ); if( pResult != NULL && pResult->nDataLen != 0 && CPLGetLastErrorNo() == 0 && pResult->nStatus == 0 ) { const char* pszCount = strstr((const char*)pResult->pabyData, "/"count/""); if( pszCount ) { pszCount = strchr(pszCount, ':'); if( pszCount ) { pszCount++; nFeatureCount = CPLAtoGIntBig(pszCount); } } } CPLHTTPDestroyResult( pResult ); } if( nFeatureCount < 0 ) nFeatureCount = OGRLayer::GetFeatureCount(bForce); return nFeatureCount;}
开发者ID:drownedout,项目名称:datamap,代码行数:29,
示例4: CPLURLAddKVPOGRErr OGRESRIFeatureServiceLayer::GetExtent(OGREnvelope *psExtent, int bForce){ OGRErr eErr = OGRERR_FAILURE; CPLString osNewURL = CPLURLAddKVP(poDS->GetURL(), "returnExtentOnly", "true"); osNewURL = CPLURLAddKVP(osNewURL, "f", "geojson"); CPLErrorReset(); CPLHTTPResult* pResult = CPLHTTPFetch( osNewURL, NULL ); if( pResult != NULL && pResult->nDataLen != 0 && CPLGetLastErrorNo() == 0 && pResult->nStatus == 0 ) { const char* pszBBox = strstr((const char*)pResult->pabyData, "/"bbox/""); if( pszBBox ) { pszBBox = strstr(pszBBox, ":["); if( pszBBox ) { pszBBox+=2; char** papszTokens = CSLTokenizeString2(pszBBox, ",", 0); if( CSLCount(papszTokens) >= 4 ) { psExtent->MinX = CPLAtof(papszTokens[0]); psExtent->MinY = CPLAtof(papszTokens[1]); psExtent->MaxX = CPLAtof(papszTokens[2]); psExtent->MaxY = CPLAtof(papszTokens[3]); eErr = OGRERR_NONE; } CSLDestroy(papszTokens); } } } CPLHTTPDestroyResult( pResult ); if( eErr == OGRERR_FAILURE ) eErr = OGRLayer::GetExtent(psExtent, bForce); return eErr;}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:35,
示例5: osURLbool OGRAmigoCloudDataSource::RunDELETE(const char*pszURL){ CPLString osURL(pszURL); /* -------------------------------------------------------------------- */ /* Provide the API Key */ /* -------------------------------------------------------------------- */ if( !osAPIKey.empty() ) { if(osURL.find("?") == std::string::npos) osURL += "?token="; else osURL += "&token="; osURL += osAPIKey; } char** papszOptions=nullptr; CPLString osPOSTFIELDS("CUSTOMREQUEST=DELETE"); papszOptions = CSLAddString(papszOptions, osPOSTFIELDS); papszOptions = CSLAddString(papszOptions, GetUserAgentOption().c_str()); CPLHTTPResult * psResult = CPLHTTPFetch( osURL.c_str(), papszOptions); CSLDestroy(papszOptions); if( psResult == nullptr ) return false; if (psResult->pszContentType && strncmp(psResult->pszContentType, "text/html", 9) == 0) { CPLDebug( "AMIGOCLOUD", "RunDELETE HTML Response:%s", psResult->pabyData ); CPLError(CE_Failure, CPLE_AppDefined, "HTML error page returned by server:%s", psResult->pabyData); CPLHTTPDestroyResult(psResult); return false; } if (psResult->pszErrBuf != nullptr && psResult->pabyData != nullptr ) { CPLError( CE_Failure, CPLE_AppDefined, "DELETE Response: %s", psResult->pabyData ); } else if ( psResult->nStatus != 0) { CPLDebug( "AMIGOCLOUD", "DELETE Error Status:%d", psResult->nStatus ); } CPLHTTPDestroyResult(psResult); return true;}
开发者ID:ksshannon,项目名称:gdal,代码行数:47,
示例6: HTTPFetchint OGRElasticDataSource::GetLayerCount(){ if( m_bAllLayersListed ) { return static_cast<int>(m_apoLayers.size()); } m_bAllLayersListed = true; CPLHTTPResult* psResult = HTTPFetch((m_osURL + "/_cat/indices?h=i").c_str(), nullptr); if( psResult == nullptr || psResult->pszErrBuf != nullptr || psResult->pabyData == nullptr ) { CPLHTTPDestroyResult(psResult); return 0; } char* pszCur = (char*)psResult->pabyData; char* pszNextEOL = strchr(pszCur, '/n'); while( pszNextEOL && pszNextEOL > pszCur ) { *pszNextEOL = '/0'; char* pszBeforeEOL = pszNextEOL - 1; while( *pszBeforeEOL == ' ' ) { *pszBeforeEOL = '/0'; pszBeforeEOL --; } const char* pszIndexName = pszCur; pszCur = pszNextEOL + 1; pszNextEOL = strchr(pszCur, '/n'); if( STARTS_WITH(pszIndexName, ".security") || STARTS_WITH(pszIndexName, ".monitoring") ) { continue; } FetchMapping(pszIndexName); } CPLHTTPDestroyResult(psResult); return static_cast<int>(m_apoLayers.size());}
开发者ID:tbonfort,项目名称:gdal,代码行数:46,
示例7: GetLayerDefnGIntBig OGRGFTTableLayer::GetFeatureCount(CPL_UNUSED int bForce){ GetLayerDefn(); CPLString osSQL("SELECT COUNT() FROM "); osSQL += osTableId; if (osWHERE.size()) { osSQL += " "; osSQL += osWHERE; } CPLHTTPResult * psResult = poDS->RunSQL(osSQL); if (psResult == NULL) return 0; char* pszLine = (char*) psResult->pabyData; if (pszLine == NULL || strncmp(pszLine, "count()", 7) != 0 || psResult->pszErrBuf != NULL) { CPLError(CE_Failure, CPLE_AppDefined, "GetFeatureCount() failed"); CPLHTTPDestroyResult(psResult); return 0; } pszLine = OGRGFTGotoNextLine(pszLine); if (pszLine == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "GetFeatureCount() failed"); CPLHTTPDestroyResult(psResult); return 0; } char* pszNextLine = OGRGFTGotoNextLine(pszLine); if (pszNextLine) pszNextLine[-1] = 0; int nFeatureCount = atoi(pszLine); CPLHTTPDestroyResult(psResult); return nFeatureCount;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:45,
示例8: CSLAddNameValuevoid OGRElasticDataSource::DeleteIndex(const CPLString &url) { char** papszOptions = NULL; papszOptions = CSLAddNameValue(papszOptions, "CUSTOMREQUEST", "DELETE"); CPLHTTPResult* psResult = CPLHTTPFetch(url, papszOptions); CSLDestroy(papszOptions); if (psResult) { CPLHTTPDestroyResult(psResult); }}
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:9,
示例9: osSQLCPLHTTPResult * OGRGFTDataSource::RunSQL(const char* pszUnescapedSQL){ CPLString osSQL("POSTFIELDS=sql="); /* Do post escaping */ for(int i=0;pszUnescapedSQL[i] != 0;i++) { const int ch = ((unsigned char*)pszUnescapedSQL)[i]; if (ch != '&' && ch >= 32 && ch < 128) osSQL += (char)ch; else osSQL += CPLSPrintf("%%%02X", ch); }/* -------------------------------------------------------------------- *//* Provide the API Key - used to rate limit access (see *//* GFT_APIKEY config) *//* -------------------------------------------------------------------- */ osSQL += "&key="; osSQL += osAPIKey;/* -------------------------------------------------------------------- *//* Force old style CSV output from calls - maybe we want to *//* migrate to JSON output at some point? *//* -------------------------------------------------------------------- */ osSQL += "&alt=csv";/* -------------------------------------------------------------------- *//* Collection the header options and execute request. *//* -------------------------------------------------------------------- */ char** papszOptions = CSLAddString(AddHTTPOptions(), osSQL); CPLHTTPResult * psResult = CPLHTTPFetch( GetAPIURL(), papszOptions); CSLDestroy(papszOptions);/* -------------------------------------------------------------------- *//* Check for some error conditions and report. HTML Messages *//* are transformed info failure. *//* -------------------------------------------------------------------- */ if (psResult && psResult->pszContentType && strncmp(psResult->pszContentType, "text/html", 9) == 0) { CPLDebug( "GFT", "RunSQL HTML Response:%s", psResult->pabyData ); CPLError(CE_Failure, CPLE_AppDefined, "HTML error page returned by server"); CPLHTTPDestroyResult(psResult); psResult = NULL; } if (psResult && psResult->pszErrBuf != NULL) { CPLDebug( "GFT", "RunSQL Error Message:%s", psResult->pszErrBuf ); } else if (psResult && psResult->nStatus != 0) { CPLDebug( "GFT", "RunSQL Error Status:%d", psResult->nStatus ); } return psResult;}
开发者ID:0004c,项目名称:node-gdal,代码行数:57,
示例10: CPLStrdupint OGRElasticDataSource::Create(const char *pszFilename, CPL_UNUSED char **papszOptions) { this->pszName = CPLStrdup(pszFilename); const char* pszMetaFile = CPLGetConfigOption("ES_META", NULL); const char* pszWriteMap = CPLGetConfigOption("ES_WRITEMAP", NULL);; this->bOverwrite = CSLTestBoolean(CPLGetConfigOption("ES_OVERWRITE", "0")); this->nBulkUpload = (int) CPLAtof(CPLGetConfigOption("ES_BULK", "0")); if (pszWriteMap != NULL) { this->pszWriteMap = CPLStrdup(pszWriteMap); } // Read in the meta file from disk if (pszMetaFile != NULL) { int fsize; char *fdata; FILE *fp; fp = fopen(pszMetaFile, "rb"); if (fp != NULL) { fseek(fp, 0, SEEK_END); fsize = (int) ftell(fp); fdata = (char *) malloc(fsize + 1); fseek(fp, 0, SEEK_SET); if (0 == fread(fdata, fsize, 1, fp)) { CPLError(CE_Failure, CPLE_FileIO, "OGRElasticDataSource::Create read failed."); } fdata[fsize] = 0; this->pszMapping = fdata; fclose(fp); } } // Do a status check to ensure that the server is valid CPLHTTPResult* psResult = CPLHTTPFetch(CPLSPrintf("%s/_status", pszFilename), NULL); int bOK = (psResult != NULL && psResult->pszErrBuf == NULL); if (!bOK) { CPLError(CE_Failure, CPLE_NoWriteAccess, "Could not connect to server"); } CPLHTTPDestroyResult(psResult); return bOK;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:51,
示例11: CPLFreeOGRPLScenesDataV1Dataset::~OGRPLScenesDataV1Dataset(){ for( int i = 0; i < m_nLayers; i++ ) delete m_papoLayers[i]; CPLFree(m_papoLayers); if( m_bMustCleanPersistent ) { char **papszOptions = CSLSetNameValue( nullptr, "CLOSE_PERSISTENT", CPLSPrintf("PLSCENES:%p", this)); CPLHTTPDestroyResult(CPLHTTPFetch(m_osBaseURL, papszOptions)); CSLDestroy(papszOptions); }}
开发者ID:OSGeo,项目名称:gdal,代码行数:15,
示例12: CPLFreeOGRCouchDBDataSource::~OGRCouchDBDataSource(){ for( int i = 0; i < nLayers; i++ ) delete papoLayers[i]; CPLFree( papoLayers ); if( bMustCleanPersistent ) { char** papszOptions = NULL; papszOptions = CSLSetNameValue(papszOptions, "CLOSE_PERSISTENT", CPLSPrintf("CouchDB:%p", this)); CPLHTTPDestroyResult( CPLHTTPFetch( osURL, papszOptions ) ); CSLDestroy(papszOptions); } CPLFree( pszName );}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:17,
示例13: CSLAddStringchar* OGRCouchDBDataSource::GetETag(const char* pszURI){ // make a head request and only return the etag response header char* pszEtag = NULL; char **papszTokens; char** papszOptions = NULL; bMustCleanPersistant = TRUE; papszOptions = CSLAddString(papszOptions, CPLSPrintf("PERSISTENT=CouchDB:%p", this)); papszOptions = CSLAddString(papszOptions, "HEADERS=Content-Type: application/json"); papszOptions = CSLAddString(papszOptions, "NO_BODY=1"); if (osUserPwd.size()) { CPLString osUserPwdOption("USERPWD="); osUserPwdOption += osUserPwd; papszOptions = CSLAddString(papszOptions, osUserPwdOption); } CPLDebug("CouchDB", "HEAD %s", pszURI); CPLString osFullURL(osURL); osFullURL += pszURI; CPLPushErrorHandler(CPLQuietErrorHandler); CPLHTTPResult * psResult = CPLHTTPFetch( osFullURL, papszOptions); CPLPopErrorHandler(); CSLDestroy(papszOptions); if (psResult == NULL) return NULL; if (CSLFetchNameValue(psResult->papszHeaders, "Etag") != NULL) { papszTokens = CSLTokenizeString2( CSLFetchNameValue(psResult->papszHeaders, "Etag"), "/"/r/n", 0 ); pszEtag = CPLStrdup(papszTokens[0]); CSLDestroy( papszTokens ); } CPLHTTPDestroyResult(psResult); return pszEtag;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:46,
示例14: CPLFreeOGRGFTDataSource::~OGRGFTDataSource(){ for( int i = 0; i < nLayers; i++ ) delete papoLayers[i]; CPLFree( papoLayers ); if (bMustCleanPersistent) { char** papszOptions = nullptr; papszOptions = CSLSetNameValue(papszOptions, "CLOSE_PERSISTENT", CPLSPrintf("GFT:%p", this)); CPLHTTPDestroyResult( CPLHTTPFetch( GetAPIURL(), papszOptions) ); CSLDestroy(papszOptions); } CPLFree( pszName );}
开发者ID:koordinates,项目名称:gdal,代码行数:17,
示例15: CPLFreeOGRAmigoCloudDataSource::~OGRAmigoCloudDataSource(){ for( int i = 0; i < nLayers; i++ ) delete papoLayers[i]; CPLFree( papoLayers ); if( bMustCleanPersistent ) { char** papszOptions = NULL; papszOptions = CSLSetNameValue(papszOptions, "CLOSE_PERSISTENT", CPLSPrintf("AMIGOCLOUD:%p", this)); CPLHTTPDestroyResult( CPLHTTPFetch( GetAPIURL(), papszOptions) ); CSLDestroy(papszOptions); } CPLFree( pszName ); CPLFree(pszProjetctId);}
开发者ID:ryandavid,项目名称:rotobox,代码行数:18,
示例16: atoibool CPLJSONDocument::LoadUrl(const std::string & /*osUrl*/, char ** /*papszOptions*/, GDALProgressFunc /*pfnProgress*/, void * /*pProgressArg*/)#endif // HAVE_CURL{#ifdef HAVE_CURL int nDepth = atoi( CSLFetchNameValueDef( papszOptions, "JSON_DEPTH", "10") ); JsonContext ctx = { nullptr, json_tokener_new_ex(nDepth), 0 }; CPLHTTPFetchWriteFunc pWriteFunc = CPLJSONWriteFunction; CPLHTTPResult *psResult = CPLHTTPFetchEx( osUrl.c_str(), papszOptions, pfnProgress, pProgressArg, pWriteFunc, &ctx ); bool bResult = true; if( psResult->nStatus != 0 /*CURLE_OK*/ ) { bResult = false; } CPLHTTPDestroyResult( psResult ); enum json_tokener_error jerr; if ((jerr = json_tokener_get_error(ctx.pTokener)) != json_tokener_success) { CPLError(CE_Failure, CPLE_AppDefined, "JSON error: %s/n", json_tokener_error_desc(jerr)); bResult = false; } else { if( m_poRootJsonObject ) json_object_put( TO_JSONOBJ(m_poRootJsonObject) ); m_poRootJsonObject = ctx.pObject; } json_tokener_free(ctx.pTokener); return bResult;#else return false;#endif}
开发者ID:ksshannon,项目名称:gdal,代码行数:41,
示例17: GMLParseXMLFilestaticCPLXMLNode* GMLParseXMLFile(const char* pszFilename){ if( STARTS_WITH(pszFilename, "http://") || STARTS_WITH(pszFilename, "https://") ) { CPLXMLNode* psRet = NULL; CPLHTTPResult* psResult = CPLHTTPFetch( pszFilename, NULL ); if( psResult != NULL ) { if( psResult->pabyData != NULL ) { psRet = CPLParseXMLString( (const char*) psResult->pabyData ); } CPLHTTPDestroyResult(psResult); } return psRet; } else { return CPLParseXMLFile(pszFilename); }}
开发者ID:ryandavid,项目名称:rotobox,代码行数:23,
示例18: CSLAddStringjson_object* OGRCouchDBDataSource::REQUEST(const char* pszVerb, const char* pszURI, const char* pszData){ bMustCleanPersistent = true; char** papszOptions = NULL; papszOptions = CSLAddString(papszOptions, CPLSPrintf("PERSISTENT=CouchDB:%p", this)); CPLString osCustomRequest("CUSTOMREQUEST="); osCustomRequest += pszVerb; papszOptions = CSLAddString(papszOptions, osCustomRequest); CPLString osPOSTFIELDS("POSTFIELDS="); if (pszData) osPOSTFIELDS += pszData; papszOptions = CSLAddString(papszOptions, osPOSTFIELDS); papszOptions = CSLAddString(papszOptions, "HEADERS=Content-Type: application/json"); if (!osUserPwd.empty() ) { CPLString osUserPwdOption("USERPWD="); osUserPwdOption += osUserPwd; papszOptions = CSLAddString(papszOptions, osUserPwdOption); } CPLDebug("CouchDB", "%s %s", pszVerb, pszURI); CPLString osFullURL(osURL); osFullURL += pszURI; CPLPushErrorHandler(CPLQuietErrorHandler); CPLHTTPResult * psResult = CPLHTTPFetch( osFullURL, papszOptions); CPLPopErrorHandler(); CSLDestroy(papszOptions); if (psResult == NULL) return NULL; const char* pszServer = CSLFetchNameValue(psResult->papszHeaders, "Server"); if (pszServer == NULL || !STARTS_WITH_CI(pszServer, "CouchDB")) { CPLHTTPDestroyResult(psResult); return NULL; } if (psResult->nDataLen == 0) { CPLHTTPDestroyResult(psResult); return NULL; } json_object* jsobj = NULL; const char* pszText = reinterpret_cast<const char*>(psResult->pabyData); if( !OGRJSonParse(pszText, &jsobj, true) ) { CPLHTTPDestroyResult(psResult); return NULL; } CPLHTTPDestroyResult(psResult); return jsobj;}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:62,
示例19: CPLStringjson_object* OGRAmigoCloudDataSource::RunSQL(const char* pszUnescapedSQL){ CPLString osSQL; osSQL = "/users/0/projects/" + CPLString(pszProjectId) + "/sql"; /* -------------------------------------------------------------------- */ /* Provide the API Key */ /* -------------------------------------------------------------------- */ if( !osAPIKey.empty() ) { osSQL += "?token=" + osAPIKey; } osSQL += "&query="; char * pszEscaped = CPLEscapeString( pszUnescapedSQL, -1, CPLES_URL ); std::string escaped = pszEscaped; CPLFree( pszEscaped ); osSQL += escaped;/* -------------------------------------------------------------------- *//* Collection the header options and execute request. *//* -------------------------------------------------------------------- */ std::string pszAPIURL = GetAPIURL(); char** papszOptions = nullptr; papszOptions = CSLAddString(papszOptions, GetUserAgentOption().c_str()); pszAPIURL += osSQL; CPLHTTPResult * psResult = CPLHTTPFetch( pszAPIURL.c_str(), papszOptions); CSLDestroy(papszOptions); if( psResult == nullptr ) return nullptr;/* -------------------------------------------------------------------- *//* Check for some error conditions and report. HTML Messages *//* are transformed info failure. *//* -------------------------------------------------------------------- */ if (psResult->pszContentType && strncmp(psResult->pszContentType, "text/html", 9) == 0) { CPLDebug( "AMIGOCLOUD", "RunSQL HTML Response:%s", psResult->pabyData ); CPLError(CE_Failure, CPLE_AppDefined, "HTML error page returned by server"); CPLHTTPDestroyResult(psResult); return nullptr; } if (psResult->pszErrBuf != nullptr && psResult->pabyData != nullptr ) { CPLError( CE_Failure, CPLE_AppDefined, "GET Response: %s", psResult->pabyData ); } else if (psResult->nStatus != 0) { CPLDebug( "AMIGOCLOUD", "RunGET Error Status:%d", psResult->nStatus ); } if( psResult->pabyData == nullptr ) { CPLHTTPDestroyResult(psResult); return nullptr; } CPLDebug( "AMIGOCLOUD", "RunSQL Response:%s", psResult->pabyData ); json_object* poObj = nullptr; const char* pszText = reinterpret_cast<const char*>(psResult->pabyData); if( !OGRJSonParse(pszText, &poObj, true) ) { CPLHTTPDestroyResult(psResult); return nullptr; } CPLHTTPDestroyResult(psResult); if( poObj != nullptr ) { if( json_object_get_type(poObj) == json_type_object ) { json_object* poError = CPL_json_object_object_get(poObj, "error"); if( poError != nullptr && json_object_get_type(poError) == json_type_array && json_object_array_length(poError) > 0 ) { poError = json_object_array_get_idx(poError, 0); if( poError != nullptr && json_object_get_type(poError) == json_type_string ) { CPLError(CE_Failure, CPLE_AppDefined, "Error returned by server : %s", json_object_get_string(poError)); json_object_put(poObj); return nullptr; } } } else { json_object_put(poObj); return nullptr; } }//.........这里部分代码省略.........
开发者ID:ksshannon,项目名称:gdal,代码行数:101,
示例20: osURLjson_object* OGRAmigoCloudDataSource::RunGET(const char*pszURL){ CPLString osURL(pszURL); /* -------------------------------------------------------------------- */ /* Provide the API Key */ /* -------------------------------------------------------------------- */ if( osAPIKey.size() > 0 ) { osURL += "?token="; osURL += osAPIKey; } CPLHTTPResult * psResult = CPLHTTPFetch( osURL.c_str(), NULL); if( psResult == NULL ) return NULL; if (psResult->pszContentType && strncmp(psResult->pszContentType, "text/html", 9) == 0) { CPLDebug( "AMIGOCLOUD", "RunGET HTML Response:%s", psResult->pabyData ); CPLError(CE_Failure, CPLE_AppDefined, "HTML error page returned by server:%s", psResult->pabyData); CPLHTTPDestroyResult(psResult); return NULL; } if ( psResult->pszErrBuf != NULL) { CPLDebug( "AMIGOCLOUD", "RunGET Error Message:%s", psResult->pszErrBuf ); } else if (psResult->nStatus != 0) { CPLDebug( "AMIGOCLOUD", "RunGET Error Status:%d", psResult->nStatus ); } if( psResult->pabyData == NULL ) { CPLHTTPDestroyResult(psResult); return NULL; } CPLDebug( "AMIGOCLOUD", "RunGET Response:%s", psResult->pabyData ); json_tokener* jstok = NULL; json_object* poObj = NULL; jstok = json_tokener_new(); poObj = json_tokener_parse_ex(jstok, (const char*) psResult->pabyData, -1); if( jstok->err != json_tokener_success) { CPLError( CE_Failure, CPLE_AppDefined, "JSON parsing error: %s (at offset %d)", json_tokener_error_desc(jstok->err), jstok->char_offset); json_tokener_free(jstok); CPLHTTPDestroyResult(psResult); return NULL; } json_tokener_free(jstok); CPLHTTPDestroyResult(psResult); if( poObj != NULL ) { if( json_object_get_type(poObj) == json_type_object ) { json_object* poError = CPL_json_object_object_get(poObj, "error"); if( poError != NULL && json_object_get_type(poError) == json_type_array && json_object_array_length(poError) > 0 ) { poError = json_object_array_get_idx(poError, 0); if( poError != NULL && json_object_get_type(poError) == json_type_string ) { CPLError(CE_Failure, CPLE_AppDefined, "Error returned by server : %s", json_object_get_string(poError)); json_object_put(poObj); return NULL; } } } else { json_object_put(poObj); return NULL; } } return poObj;}
开发者ID:ryandavid,项目名称:rotobox,代码行数:88,
示例21: CPLStringjson_object* OGRAmigoCloudDataSource::RunSQL(const char* pszUnescapedSQL){ CPLString osSQL; osSQL = "/users/0/projects/" + CPLString(pszProjetctId) + "/sql"; /* -------------------------------------------------------------------- */ /* Provide the API Key */ /* -------------------------------------------------------------------- */ if( osAPIKey.size() > 0 ) { osSQL += "?token="; osSQL += osAPIKey; } osSQL += "&query="; char * pszEscaped = CPLEscapeString( pszUnescapedSQL, -1, CPLES_URL ); std::string escaped = pszEscaped; CPLFree( pszEscaped ); osSQL += escaped;/* -------------------------------------------------------------------- *//* Collection the header options and execute request. *//* -------------------------------------------------------------------- */ std::string pszAPIURL = GetAPIURL(); char** papszOptions = NULL; pszAPIURL += osSQL; CPLHTTPResult * psResult = CPLHTTPFetch( pszAPIURL.c_str(), papszOptions); CSLDestroy(papszOptions); if( psResult == NULL ) return NULL;/* -------------------------------------------------------------------- *//* Check for some error conditions and report. HTML Messages *//* are transformed info failure. *//* -------------------------------------------------------------------- */ if (psResult->pszContentType && strncmp(psResult->pszContentType, "text/html", 9) == 0) { CPLDebug( "AMIGOCLOUD", "RunSQL HTML Response:%s", psResult->pabyData ); CPLError(CE_Failure, CPLE_AppDefined, "HTML error page returned by server"); CPLHTTPDestroyResult(psResult); return NULL; } if (psResult->pszErrBuf != NULL) { CPLDebug( "AMIGOCLOUD", "RunSQL Error Message:%s", psResult->pszErrBuf ); } else if (psResult->nStatus != 0) { CPLDebug( "AMIGOCLOUD", "RunSQL Error Status:%d", psResult->nStatus ); } if( psResult->pabyData == NULL ) { CPLHTTPDestroyResult(psResult); return NULL; } CPLDebug( "AMIGOCLOUD", "RunSQL Response:%s", psResult->pabyData ); json_tokener* jstok = NULL; json_object* poObj = NULL; jstok = json_tokener_new(); poObj = json_tokener_parse_ex(jstok, (const char*) psResult->pabyData, -1); if( jstok->err != json_tokener_success) { CPLError( CE_Failure, CPLE_AppDefined, "JSON parsing error: %s (at offset %d)", json_tokener_error_desc(jstok->err), jstok->char_offset); json_tokener_free(jstok); CPLHTTPDestroyResult(psResult); return NULL; } json_tokener_free(jstok); CPLHTTPDestroyResult(psResult); if( poObj != NULL ) { if( json_object_get_type(poObj) == json_type_object ) { json_object* poError = CPL_json_object_object_get(poObj, "error"); if( poError != NULL && json_object_get_type(poError) == json_type_array && json_object_array_length(poError) > 0 ) { poError = json_object_array_get_idx(poError, 0); if( poError != NULL && json_object_get_type(poError) == json_type_string ) { CPLError(CE_Failure, CPLE_AppDefined, "Error returned by server : %s", json_object_get_string(poError)); json_object_put(poObj); return NULL; } }//.........这里部分代码省略.........
开发者ID:ryandavid,项目名称:rotobox,代码行数:101,
示例22: OGRFeatureDefnint OGRGFTTableLayer::FetchDescribe(){ poFeatureDefn = new OGRFeatureDefn( osTableName ); poFeatureDefn->Reference(); poFeatureDefn->GetGeomFieldDefn(0)->SetSpatialRef(poSRS); const CPLString& osAuth = poDS->GetAccessToken(); std::vector<CPLString> aosHeaderAndFirstDataLine; if (osAuth.size()) { CPLString osSQL("DESCRIBE "); osSQL += osTableId; CPLHTTPResult * psResult = poDS->RunSQL(osSQL); if (psResult == NULL) return FALSE; char* pszLine = (char*) psResult->pabyData; if (pszLine == NULL || psResult->pszErrBuf != NULL || strncmp(pszLine, "column id,name,type", strlen("column id,name,type")) != 0) { CPLHTTPDestroyResult(psResult); return FALSE; } pszLine = OGRGFTGotoNextLine(pszLine); std::vector<CPLString> aosLines; ParseCSVResponse(pszLine, aosLines); for(int i=0;i<(int)aosLines.size();i++) { char** papszTokens = OGRGFTCSVSplitLine(aosLines[i], ','); if (CSLCount(papszTokens) == 3) { aosColumnInternalName.push_back(papszTokens[0]); //CPLDebug("GFT", "%s %s %s", papszTokens[0], papszTokens[1], papszTokens[2]); OGRFieldType eType = OFTString; if (EQUAL(papszTokens[2], "number")) eType = OFTReal; else if (EQUAL(papszTokens[2], "datetime")) eType = OFTDateTime; if (EQUAL(papszTokens[2], "location") && osGeomColumnName.size() == 0) { if (iGeometryField < 0) iGeometryField = poFeatureDefn->GetFieldCount(); else CPLDebug("GFT", "Multiple geometry fields detected. " "Only first encountered one is handled"); } CPLString osLaunderedColName(LaunderColName(papszTokens[1])); OGRFieldDefn oFieldDefn(osLaunderedColName, eType); poFeatureDefn->AddFieldDefn(&oFieldDefn); } CSLDestroy(papszTokens); } CPLHTTPDestroyResult(psResult); } else { /* http://code.google.com/intl/fr/apis/fusiontables/docs/developers_guide.html#Exploring states */ /* that DESCRIBE should work on public tables without authentication, but it is not true... */ CPLString osSQL("SELECT * FROM "); osSQL += osTableId; osSQL += " OFFSET 0 LIMIT 1"; CPLHTTPResult * psResult = poDS->RunSQL(osSQL); if (psResult == NULL) return FALSE; char* pszLine = (char*) psResult->pabyData; if (pszLine == NULL || psResult->pszErrBuf != NULL) { CPLHTTPDestroyResult(psResult); return FALSE; } ParseCSVResponse(pszLine, aosHeaderAndFirstDataLine); if (aosHeaderAndFirstDataLine.size() > 0) { char** papszTokens = OGRGFTCSVSplitLine(aosHeaderAndFirstDataLine[0], ','); for(int i=0;papszTokens && papszTokens[i];i++) { CPLString osLaunderedColName(LaunderColName(papszTokens[i])); OGRFieldDefn oFieldDefn(osLaunderedColName, OFTString); poFeatureDefn->AddFieldDefn(&oFieldDefn); } CSLDestroy(papszTokens); } CPLHTTPDestroyResult(psResult); } if (osGeomColumnName.size() > 0)//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,
示例23: CPLError//.........这里部分代码省略......... osCommand += "'"; osCommand += pszKML; osCommand += "'"; CPLFree(pszKML); } continue; } if( !poFeature->IsFieldSet( iField ) ) { osCommand += "''"; } else { OGRFieldType eType = poFeatureDefn->GetFieldDefn(iField)->GetType(); if (eType != OFTInteger && eType != OFTReal) { CPLString osTmp; const char* pszVal = poFeature->GetFieldAsString(iField); if (!CPLIsUTF8(pszVal, -1)) { static int bFirstTime = TRUE; if (bFirstTime) { bFirstTime = FALSE; CPLError(CE_Warning, CPLE_AppDefined, "%s is not a valid UTF-8 string. Forcing it to ASCII./n" "This warning won't be issued anymore", pszVal); } else { CPLDebug("OGR", "%s is not a valid UTF-8 string. Forcing it to ASCII", pszVal); } char* pszEscaped = CPLForceToASCII(pszVal, -1, '?'); osTmp = pszEscaped; CPLFree(pszEscaped); pszVal = osTmp.c_str(); } osCommand += EscapeAndQuote(pszVal); } else osCommand += poFeature->GetFieldAsString(iField); } } osCommand += ")"; //CPLDebug("GFT", "%s", osCommand.c_str()); if (bInTransaction) { nFeaturesInTransaction ++; if (nFeaturesInTransaction > 1) osTransaction += "; "; osTransaction += osCommand; return OGRERR_NONE; } CPLHTTPResult * psResult = poDS->RunSQL(osCommand); if (psResult == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Feature creation failed"); return OGRERR_FAILURE; } char* pszLine = (char*) psResult->pabyData; if (pszLine == NULL || strncmp(pszLine, "rowid", 5) != 0 || psResult->pszErrBuf != NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Feature creation failed"); CPLHTTPDestroyResult(psResult); return OGRERR_FAILURE; } pszLine = OGRGFTGotoNextLine(pszLine); if (pszLine == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Feature creation failed"); CPLHTTPDestroyResult(psResult); return OGRERR_FAILURE; } char* pszNextLine = OGRGFTGotoNextLine(pszLine); if (pszNextLine) pszNextLine[-1] = 0; CPLDebug("GFT", "Feature id = %s", pszLine); int nFID = atoi(pszLine); if (strcmp(CPLSPrintf("%d", nFID), pszLine) == 0) poFeature->SetFID(nFID); CPLHTTPDestroyResult(psResult); return OGRERR_NONE;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,
示例24: osSQL//.........这里部分代码省略......... if (iLatitudeField >= 0 && iLongitudeField >= 0) { iGeometryField = iLatitudeField; poFeatureDefn->SetGeomType( wkbPoint ); } /* If no longitude/latitude field exist, let's look at a column */ /* named 'geometry' and use it as the LOCATION column if the layer */ /* hasn't been created with a none geometry type */ else if (iGeometryField < 0 && eGTypeForCreation != wkbNone) { iGeometryField = poFeatureDefn->GetFieldIndex(GetDefaultGeometryColumnName()); poFeatureDefn->SetGeomType( eGTypeForCreation ); } /* The user doesn't want geometries, so don't create one */ else if (eGTypeForCreation == wkbNone) { poFeatureDefn->SetGeomType( eGTypeForCreation ); } for(i=0;i<poFeatureDefn->GetFieldCount();i++) { if (i > 0) osSQL += ", "; const char* pszFieldName = poFeatureDefn->GetFieldDefn(i)->GetNameRef(); osSQL += EscapeAndQuote(pszFieldName); osSQL += ": "; if (iGeometryField == i) { osSQL += "LOCATION"; } else { switch(poFeatureDefn->GetFieldDefn(i)->GetType()) { case OFTInteger: case OFTReal: osSQL += "NUMBER"; break; default: osSQL += "STRING"; } } } /* If there's not yet a geometry field and the user didn't forbid */ /* the creation of one, then let's add it to the CREATE TABLE, but */ /* DO NOT add it to the feature defn as a feature might already have */ /* been created with it, so it is not safe to alter it at that point. */ /* So we set the bHiddenGeometryField flag to be able to fetch/set this */ /* column but not try to get/set a related feature field */ if (iGeometryField < 0 && eGTypeForCreation != wkbNone) { if (i > 0) osSQL += ", "; osSQL += EscapeAndQuote(GetDefaultGeometryColumnName()); osSQL += ": LOCATION"; iGeometryField = poFeatureDefn->GetFieldCount(); bHiddenGeometryField = TRUE; } osSQL += ")"; CPLHTTPResult * psResult = poDS->RunSQL(osSQL); if (psResult == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Table creation failed"); return; } char* pszLine = (char*) psResult->pabyData; if (pszLine == NULL || strncmp(pszLine, "tableid", 7) != 0 || psResult->pszErrBuf != NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Table creation failed"); CPLHTTPDestroyResult(psResult); return; } pszLine = OGRGFTGotoNextLine(pszLine); if (pszLine == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Table creation failed"); CPLHTTPDestroyResult(psResult); return; } char* pszNextLine = OGRGFTGotoNextLine(pszLine); if (pszNextLine) pszNextLine[-1] = 0; osTableId = pszLine; CPLDebug("GFT", "Table %s --> id = %s", osTableName.c_str(), osTableId.c_str()); CPLHTTPDestroyResult(psResult);}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,
注:本文中的CPLHTTPDestroyResult函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CPLMalloc函数代码示例 C++ CPLGetXMLValue函数代码示例 |