这篇教程C++ CSLAddString函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CSLAddString函数的典型用法代码示例。如果您正苦于以下问题:C++ CSLAddString函数的具体用法?C++ CSLAddString怎么用?C++ CSLAddString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CSLAddString函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: OGR2SQLITE_ogr_geocodestaticvoid OGR2SQLITE_ogr_geocode(sqlite3_context* pContext, int argc, sqlite3_value** argv){ OGRSQLiteExtensionData* poModule = (OGRSQLiteExtensionData*) sqlite3_user_data(pContext); if( argc < 1 || sqlite3_value_type (argv[0]) != SQLITE_TEXT ) { sqlite3_result_null (pContext); return; } const char* pszQuery = (const char*)sqlite3_value_text(argv[0]); CPLString osField = "geometry"; if( argc >= 2 && sqlite3_value_type (argv[1]) == SQLITE_TEXT ) { osField = (const char*)sqlite3_value_text(argv[1]); } int i; char** papszOptions = NULL; for(i = 2; i < argc; i++) { if( sqlite3_value_type (argv[i]) == SQLITE_TEXT ) { papszOptions = CSLAddString(papszOptions, (const char*)sqlite3_value_text(argv[i])); } } OGRGeocodingSessionH hSession = poModule->GetGeocodingSession(); if( hSession == NULL ) { hSession = OGRGeocodeCreateSession(papszOptions); if( hSession == NULL ) { sqlite3_result_null (pContext); CSLDestroy(papszOptions); return; } poModule->SetGeocodingSession(hSession); } if( osField == "raw" ) papszOptions = CSLAddString(papszOptions, "RAW_FEATURE=YES"); if( CSLFindString(papszOptions, "LIMIT") == -1 ) papszOptions = CSLAddString(papszOptions, "LIMIT=1"); OGRLayerH hLayer = OGRGeocode(hSession, pszQuery, NULL, papszOptions); OGR2SQLITE_ogr_geocode_set_result(pContext, hLayer, osField); CSLDestroy(papszOptions); return;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:58,
示例2: OGR2SQLITE_IgnoreAllFieldsExceptGeometrystaticvoid OGR2SQLITE_IgnoreAllFieldsExceptGeometry(OGRLayer* poLayer){ char** papszIgnored = NULL; papszIgnored = CSLAddString(papszIgnored, "OGR_STYLE"); OGRFeatureDefn* poFeatureDefn = poLayer->GetLayerDefn(); for(int i=0; i < poFeatureDefn->GetFieldCount(); i++) { papszIgnored = CSLAddString(papszIgnored, poFeatureDefn->GetFieldDefn(i)->GetNameRef()); } poLayer->SetIgnoredFields((const char**)papszIgnored); CSLDestroy(papszIgnored);}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:14,
示例3: wkt_to_p4sSEXP wkt_to_p4s(SEXP wkt, SEXP esri) { OGRSpatialReference hSRS = NULL; char *pszSRS_P4 = NULL; char **ppszInput = NULL; SEXP ans; ppszInput = CSLAddString(ppszInput, CHAR(STRING_ELT(wkt, 0))); installErrorHandler(); if (hSRS.importFromWkt(ppszInput) != OGRERR_NONE) { uninstallErrorHandlerAndTriggerError(); error("Can't parse WKT-style parameter string"); } uninstallErrorHandlerAndTriggerError(); installErrorHandler(); if (INTEGER_POINTER(esri)[0] == 1) hSRS.morphFromESRI(); hSRS.exportToProj4(&pszSRS_P4); uninstallErrorHandlerAndTriggerError(); PROTECT(ans=NEW_CHARACTER(1)); SET_STRING_ELT(ans, 0, COPY_TO_USER_STRING(pszSRS_P4)); UNPROTECT(1); return(ans);}
开发者ID:jeroenooms,项目名称:rgdal,代码行数:26,
示例4: CPLAssertvoid EIRDataset::ResetKeyValue( const char *pszKey, const char *pszValue ){ int i; char szNewLine[82]; if( strlen(pszValue) > 65 ) { CPLAssert( strlen(pszValue) <= 65 ); return; } sprintf( szNewLine, "%-15s%s", pszKey, pszValue ); for( i = CSLCount(papszHDR)-1; i >= 0; i-- ) { if( EQUALN(papszHDR[i],szNewLine,strlen(pszKey)+1 ) ) { if( strcmp(papszHDR[i],szNewLine) != 0 ) { CPLFree( papszHDR[i] ); papszHDR[i] = CPLStrdup( szNewLine ); bHDRDirty = TRUE; } return; } } bHDRDirty = TRUE; papszHDR = CSLAddString( papszHDR, szNewLine );}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:31,
示例5: CSLFindStringCPLErr GDALMultiDomainMetadata::SetMetadata( char **papszMetadata, const char *pszDomain ){ if( pszDomain == NULL ) pszDomain = ""; int iDomain = CSLFindString( papszDomainList, pszDomain ); if( iDomain == -1 ) { int nDomainCount; papszDomainList = CSLAddString( papszDomainList, pszDomain ); nDomainCount = CSLCount( papszDomainList ); papoMetadataLists = (CPLStringList **) CPLRealloc( papoMetadataLists, sizeof(void*)*(nDomainCount+1) ); papoMetadataLists[nDomainCount] = NULL; papoMetadataLists[nDomainCount-1] = new CPLStringList(); iDomain = nDomainCount-1; } papoMetadataLists[iDomain]->Assign( CSLDuplicate( papszMetadata ) ); // we want to mark name/value pair domains as being sorted for fast // access. if( !EQUALN(pszDomain,"xml:",4) && !EQUAL(pszDomain, "SUBDATASETS") ) papoMetadataLists[iDomain]->Sort(); return CE_None;}
开发者ID:drownedout,项目名称:datamap,代码行数:32,
示例6: CopyBandInfovoid CopyBandInfo( GDALRasterBand * poSrcBand, GDALRasterBand * poDstBand, int bCopyNoData ){ int bSuccess; double dfNoData; char** papszMetadata = poSrcBand->GetMetadata(); char** papszMetadataNew = NULL; for( int i = 0; papszMetadata != NULL && papszMetadata[i] != NULL; i++ ) { if (strncmp(papszMetadata[i], "STATISTICS_", 11) != 0) papszMetadataNew = CSLAddString(papszMetadataNew, papszMetadata[i]); } poDstBand->SetMetadata( papszMetadataNew ); CSLDestroy(papszMetadataNew); poDstBand->SetColorTable( poSrcBand->GetColorTable() ); poDstBand->SetColorInterpretation(poSrcBand->GetColorInterpretation()); if( strlen(poSrcBand->GetDescription()) > 0 ) poDstBand->SetDescription( poSrcBand->GetDescription() ); if (bCopyNoData) { dfNoData = poSrcBand->GetNoDataValue( &bSuccess ); if( bSuccess ) poDstBand->SetNoDataValue( dfNoData ); } poDstBand->SetCategoryNames( poSrcBand->GetCategoryNames() ); if( !EQUAL(poSrcBand->GetUnitType(),"") ) poDstBand->SetUnitType( poSrcBand->GetUnitType() );}
开发者ID:Mileslee,项目名称:wxgis,代码行数:32,
示例7: 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,
示例8: CPLPushFinderLocationvoid CPLPushFinderLocation( const char *pszLocation ){ CPLFinderInit(); papszFinderLocations = CSLAddString( papszFinderLocations, pszLocation );}
开发者ID:AluOne,项目名称:OpenCPN,代码行数:8,
示例9: 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,
示例10: CPLPushFinderLocationvoid CPLPushFinderLocation( const char *pszLocation ){ FindFileTLS* pTLSData = CPLFinderInit(); pTLSData->papszFinderLocations = CSLAddString( pTLSData->papszFinderLocations, pszLocation );}
开发者ID:0004c,项目名称:node-gdal,代码行数:8,
示例11: CSLAddStringvoid OGRTigerDataSource::AddModule( const char *pszModule ){ if( CheckModule( pszModule ) ) return; papszModules = CSLAddString( papszModules, pszModule ); nModules++;}
开发者ID:koordinates,项目名称:gdal,代码行数:9,
示例12: 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,
示例13: lockerbool wxGISDataset::Rename(const wxString &sNewName, ITrackCancel* const pTrackCancel){ wxCriticalSectionLocker locker(m_CritSect); Close(); CPLString szDirPath = CPLGetPath(m_sPath); CPLString szName = CPLGetBasename(m_sPath); CPLString szNewName(ClearExt(sNewName).mb_str(wxConvUTF8)); char** papszFileList = GetFileList(); papszFileList = CSLAddString( papszFileList, m_sPath ); if(!papszFileList) { if(pTrackCancel) pTrackCancel->PutMessage(_("No files to rename"), wxNOT_FOUND, enumGISMessageErr); return false; } char **papszNewFileList = NULL; for(int i = 0; papszFileList[i] != NULL; ++i ) { CPLString szNewPath(CPLFormFilename(szDirPath, szNewName, GetExtension(papszFileList[i], szName))); papszNewFileList = CSLAddString(papszNewFileList, szNewPath); if(!RenameFile(papszFileList[i], papszNewFileList[i], pTrackCancel)) { // Try to put the ones we moved back. for( --i; i >= 0; i-- ) RenameFile( papszNewFileList[i], papszFileList[i]); CSLDestroy( papszFileList ); CSLDestroy( papszNewFileList ); return false; } } m_sPath = CPLString(CPLFormFilename(szDirPath, szNewName, CPLGetExtension(m_sPath))); CSLDestroy( papszFileList ); CSLDestroy( papszNewFileList ); return true;}
开发者ID:Mileslee,项目名称:wxgis,代码行数:43,
示例14: CPLReadDirvoid wxGxArchiveFolder::LoadChildren(void){ if(m_bIsChildrenLoaded) return; char **papszItems = CPLReadDir(m_sPath); if(papszItems == NULL) return; char **papszFileList = NULL; //remove unused items for(int i = CSLCount(papszItems) - 1; i >= 0; i-- ) { if( wxGISEQUAL(papszItems[i],".") || wxGISEQUAL(papszItems[i],"..") ) continue; CPLString szFileName = m_sPath; szFileName += "/"; szFileName += papszItems[i]; VSIStatBufL BufL; int ret = VSIStatL(szFileName, &BufL); if(ret == 0) { if(VSI_ISDIR(BufL.st_mode)) { wxString sCharset(wxT("cp-866")); wxGISAppConfig oConfig = GetConfig(); if(oConfig.IsOk()) sCharset = oConfig.Read(enumGISHKCU, wxString(wxT("wxGISCommon/zip/charset")), sCharset); wxString sFileName(papszItems[i], wxCSConv(sCharset)); GetArchiveFolder(this, sFileName, szFileName); } else { papszFileList = CSLAddString( papszFileList, szFileName ); } } } CSLDestroy( papszItems ); //load names wxGxCatalog *pCatalog = wxDynamicCast(GetGxCatalog(), wxGxCatalog); if(pCatalog) { wxArrayLong ChildrenIds; pCatalog->CreateChildren(this, papszFileList, ChildrenIds); for(size_t i = 0; i < ChildrenIds.GetCount(); ++i) pCatalog->ObjectAdded(ChildrenIds[i]); } CSLDestroy( papszFileList ); m_bIsChildrenLoaded = true;}
开发者ID:Mileslee,项目名称:wxgis,代码行数:54,
示例15: WriteValueOGRErr OGRDXFWriterLayer::WriteCore( OGRFeature *poFeature ){/* -------------------------------------------------------------------- *//* Write out an entity id. I'm not sure why this is critical, *//* but it seems that VoloView will just quietly fail to open *//* dxf files without entity ids set on most/all entities. *//* Also, for reasons I don't understand these ids seem to have *//* to start somewhere around 0x50 hex (80 decimal). *//* -------------------------------------------------------------------- */ poFeature->SetFID( poDS->WriteEntityID(fp,(int)poFeature->GetFID()) );/* -------------------------------------------------------------------- *//* For now we assign everything to the default layer - layer *//* "0" - if there is no layer property on the source features. *//* -------------------------------------------------------------------- */ const char *pszLayer = poFeature->GetFieldAsString( "Layer" ); if( pszLayer == nullptr || strlen(pszLayer) == 0 ) { WriteValue( 8, "0" ); } else { CPLString osSanitizedLayer(pszLayer); // Replaced restricted characters with underscore // See http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%202010%20User%20Documentation/index.html?url=WS1a9193826455f5ffa23ce210c4a30acaf-7345.htm,topicNumber=d0e41665 const char achForbiddenChars[] = { '<', '>', '/', '//', '"', ':', ';', '?', '*', '|', '=', '/'' }; for( size_t i = 0; i < CPL_ARRAYSIZE(achForbiddenChars); ++i ) { osSanitizedLayer.replaceAll( achForbiddenChars[i], '_' ); } // also remove newline characters (#15067) osSanitizedLayer.replaceAll( "/r/n", "_" ); osSanitizedLayer.replaceAll( '/r', '_' ); osSanitizedLayer.replaceAll( '/n', '_' ); const char *pszExists = poDS->oHeaderDS.LookupLayerProperty( osSanitizedLayer, "Exists" ); if( (pszExists == nullptr || strlen(pszExists) == 0) && CSLFindString( poDS->papszLayersToCreate, osSanitizedLayer ) == -1 ) { poDS->papszLayersToCreate = CSLAddString( poDS->papszLayersToCreate, osSanitizedLayer ); } WriteValue( 8, osSanitizedLayer ); } return OGRERR_NONE;}
开发者ID:OSGeo,项目名称:gdal,代码行数:52,
示例16: whilevoid OGRPGDumpLayer::SetOverrideColumnTypes( const char* pszOverrideColumnTypes ){ if( pszOverrideColumnTypes == NULL ) return; const char* pszIter = pszOverrideColumnTypes; CPLString osCur; while(*pszIter != '/0') { if( *pszIter == '(' ) { /* Ignore commas inside ( ) pair */ while(*pszIter != '/0') { if( *pszIter == ')' ) { osCur += *pszIter; pszIter ++; break; } osCur += *pszIter; pszIter ++; } if( *pszIter == '/0') break; } if( *pszIter == ',' ) { papszOverrideColumnTypes = CSLAddString(papszOverrideColumnTypes, osCur); osCur = ""; } else osCur += *pszIter; pszIter ++; } if( osCur.size() ) papszOverrideColumnTypes = CSLAddString(papszOverrideColumnTypes, osCur);}
开发者ID:lydonchandra,项目名称:MapServer-SpeedUp,代码行数:39,
示例17: CPLFreeOGRGFTDataSource::~OGRGFTDataSource(){ for( int i = 0; i < nLayers; i++ ) delete papoLayers[i]; CPLFree( papoLayers ); if (bMustCleanPersistant) { char** papszOptions = CSLAddString(NULL, CPLSPrintf("CLOSE_PERSISTENT=GFT:%p", this)); CPLHTTPFetch( GetAPIURL(), papszOptions); CSLDestroy(papszOptions); } CPLFree( pszName );}
开发者ID:0004c,项目名称:node-gdal,代码行数:16,
示例18: RGDAL_SetCategoryNamesSEXPRGDAL_SetCategoryNames(SEXP sxpRasterBand, SEXP sxpNames) { GDALRasterBand *pRasterBand = getGDALRasterPtr(sxpRasterBand); char **nameList = NULL; int i; for (i = 0; i < length(sxpNames); ++i) nameList = CSLAddString(nameList, asString(sxpNames, i)); CPLErr err = pRasterBand->SetCategoryNames(nameList); if (err == CE_Failure) warning("Failed to set category names"); return(sxpRasterBand);}
开发者ID:jeroenooms,项目名称:rgdal,代码行数:18,
示例19: CPLFreeOGRAmigoCloudDataSource::~OGRAmigoCloudDataSource(){ for( int i = 0; i < nLayers; i++ ) delete papoLayers[i]; CPLFree( papoLayers ); if( bMustCleanPersistent ) { char** papszOptions = nullptr; papszOptions = CSLSetNameValue(papszOptions, "CLOSE_PERSISTENT", CPLSPrintf("AMIGOCLOUD:%p", this)); papszOptions = CSLAddString(papszOptions, GetUserAgentOption().c_str()); CPLHTTPDestroyResult( CPLHTTPFetch( GetAPIURL(), papszOptions) ); CSLDestroy(papszOptions); } CPLFree( pszName ); CPLFree(pszProjectId);}
开发者ID:ksshannon,项目名称:gdal,代码行数:19,
示例20: RGDAL_SetMetadataSEXPRGDAL_SetMetadata(SEXP sxpObj, SEXP sxpMetadataList) { void *pGDALObj = getGDALObjPtr(sxpObj); SEXP sxpNames = getAttrib(sxpMetadataList, R_NamesSymbol); char **metadata = (char **) CPLCalloc(1, sizeof(char *)); const char *name, *value; if (isNull(sxpNames)) { int i; for (i = 0; i < length(sxpMetadataList); ++i) { value = asString(VECTOR_ELT(sxpMetadataList, i)); CSLAddString(metadata, value); } } else { int i; for (i = 0; i < length(sxpMetadataList); ++i) { name = asString(sxpNames, i); value = asString(VECTOR_ELT(sxpMetadataList, i)); CSLAddNameValue(metadata, name, value); } } CPLErr err = ((GDALMajorObject *)pGDALObj)->SetMetadata(metadata, NULL); if (err == CE_Failure) warning("Failed to set metadata/n"); return(sxpObj);}
开发者ID:jeroenooms,项目名称:rgdal,代码行数:41,
示例21: WriteValueOGRErr OGRDXFWriterLayer::WriteCore( OGRFeature *poFeature ){/* -------------------------------------------------------------------- *//* Write out an entity id. I'm not sure why this is critical, *//* but it seems that VoloView will just quietly fail to open *//* dxf files without entity ids set on most/all entities. *//* Also, for reasons I don't understand these ids seem to have *//* to start somewhere around 0x50 hex (80 decimal). *//* -------------------------------------------------------------------- */ poFeature->SetFID( poDS->WriteEntityID(fp,(int)poFeature->GetFID()) );/* -------------------------------------------------------------------- *//* For now we assign everything to the default layer - layer *//* "0" - if there is no layer property on the source features. *//* -------------------------------------------------------------------- */ const char *pszLayer = poFeature->GetFieldAsString( "Layer" ); if( pszLayer == NULL || strlen(pszLayer) == 0 ) { WriteValue( 8, "0" ); } else { const char *pszExists = poDS->oHeaderDS.LookupLayerProperty( pszLayer, "Exists" ); if( (pszExists == NULL || strlen(pszExists) == 0) && CSLFindString( poDS->papszLayersToCreate, pszLayer ) == -1 ) { poDS->papszLayersToCreate = CSLAddString( poDS->papszLayersToCreate, pszLayer ); } WriteValue( 8, pszLayer ); } return OGRERR_NONE;}
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:37,
示例22: CPLAssertint OGRPGeoDataSource::Open( const char * pszNewName, int bUpdate, CPL_UNUSED int bTestOpen ){ CPLAssert( nLayers == 0 );/* -------------------------------------------------------------------- *//* If this is the name of an MDB file, then construct the *//* appropriate connection string. Otherwise clip of PGEO: to *//* get the DSN. *//* *//* -------------------------------------------------------------------- */ char *pszDSN; const char* pszOptionName = ""; const char* pszDSNStringTemplate = NULL; if( EQUALN(pszNewName,"PGEO:",5) ) pszDSN = CPLStrdup( pszNewName + 5 ); else { pszOptionName = "PGEO_DRIVER_TEMPLATE"; pszDSNStringTemplate = CPLGetConfigOption( pszOptionName, NULL ); if( pszDSNStringTemplate == NULL ) { pszOptionName = ""; pszDSNStringTemplate = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=%s"; } if (!CheckDSNStringTemplate(pszDSNStringTemplate)) { CPLError( CE_Failure, CPLE_AppDefined, "Illegal value for PGEO_DRIVER_TEMPLATE option"); return FALSE; } pszDSN = (char *) CPLMalloc(strlen(pszNewName)+strlen(pszDSNStringTemplate)+100); sprintf( pszDSN, pszDSNStringTemplate, pszNewName ); }/* -------------------------------------------------------------------- *//* Initialize based on the DSN. *//* -------------------------------------------------------------------- */ CPLDebug( "PGeo", "EstablishSession(%s)", pszDSN ); if( !oSession.EstablishSession( pszDSN, NULL, NULL ) ) { int bError = TRUE; if( !EQUALN(pszNewName,"PGEO:",5) ) { // Trying with another template (#5594) pszDSNStringTemplate = "DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=%s"; CPLFree( pszDSN ); pszDSN = (char *) CPLMalloc(strlen(pszNewName)+strlen(pszDSNStringTemplate)+100); sprintf( pszDSN, pszDSNStringTemplate, pszNewName ); CPLDebug( "PGeo", "EstablishSession(%s)", pszDSN ); if( oSession.EstablishSession( pszDSN, NULL, NULL ) ) { bError = FALSE; } } if( bError ) { CPLError( CE_Failure, CPLE_AppDefined, "Unable to initialize ODBC connection to DSN for %s,/n" "%s", pszDSN, oSession.GetLastError() ); CPLFree( pszDSN ); return FALSE; } } CPLFree( pszDSN ); pszName = CPLStrdup( pszNewName ); bDSUpdate = bUpdate;/* -------------------------------------------------------------------- *//* Collect list of tables and their supporting info from *//* GDB_GeomColumns. *//* -------------------------------------------------------------------- */ std::vector<char **> apapszGeomColumns; CPLODBCStatement oStmt( &oSession ); oStmt.Append( "SELECT TableName, FieldName, ShapeType, ExtentLeft, ExtentRight, ExtentBottom, ExtentTop, SRID, HasZ FROM GDB_GeomColumns" ); if( !oStmt.ExecuteSQL() ) { CPLDebug( "PGEO", "SELECT on GDB_GeomColumns fails, perhaps not a personal geodatabase?/n%s", oSession.GetLastError() ); return FALSE; } while( oStmt.Fetch() ) { int i, iNew = apapszGeomColumns.size(); char **papszRecord = NULL; for( i = 0; i < 9; i++ ) papszRecord = CSLAddString( papszRecord, oStmt.GetColData(i) ); apapszGeomColumns.resize(iNew+1); apapszGeomColumns[iNew] = papszRecord; } //.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例23: 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,
示例24: CPLAssert//.........这里部分代码省略......... char **papszGeomColumnNames=NULL; char **papszCoordDimensions=NULL; char **papszSRIds=NULL; /* Determine if the connection string contains the TABLES portion */ if( pszTableSpec != NULL ) { char **papszTableList; int i; papszTableList = CSLTokenizeString2( pszTableSpec, ",", 0 ); for( i = 0; i < CSLCount(papszTableList); i++ ) { char **papszQualifiedParts; // Get schema and table name papszQualifiedParts = CSLTokenizeString2( papszTableList[i], ".", 0 ); /* Find the geometry column name if specified */ if( CSLCount( papszQualifiedParts ) >= 1 ) { char* pszGeomColumnName = NULL; char* pos = strchr(papszQualifiedParts[CSLCount( papszQualifiedParts ) - 1], '('); if (pos != NULL) { *pos = '/0'; pszGeomColumnName = pos+1; int len = strlen(pszGeomColumnName); if (len > 0) pszGeomColumnName[len - 1] = '/0'; } papszGeomColumnNames = CSLAddString( papszGeomColumnNames, pszGeomColumnName ? pszGeomColumnName : ""); } if( CSLCount( papszQualifiedParts ) == 2 ) { papszSchemaNames = CSLAddString( papszSchemaNames, papszQualifiedParts[0] ); papszTableNames = CSLAddString( papszTableNames, papszQualifiedParts[1] ); } else if( CSLCount( papszQualifiedParts ) == 1 ) { papszSchemaNames = CSLAddString( papszSchemaNames, "dbo"); papszTableNames = CSLAddString( papszTableNames, papszQualifiedParts[0] ); } CSLDestroy(papszQualifiedParts); } CSLDestroy(papszTableList); } CPLFree(pszTableSpec); /* Initialize the SQL Server connection. */ CPLDebug( "OGR_MSSQLSpatial", "EstablishSession(Connection:/"%s/")", pszConnectionName); if( !oSession.EstablishSession( CPLSPrintf("DRIVER=SQL Server;%s", pszConnectionName), "", "" ) ) { CPLError( CE_Failure, CPLE_AppDefined, "Unable to initialize connection to the server for %s,/n"
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:67,
示例25: osURLjson_object* OGRAmigoCloudDataSource::RunDELETE(const char*pszURL){ CPLString osURL(pszURL); /* -------------------------------------------------------------------- */ /* Provide the API Key */ /* -------------------------------------------------------------------- */ if( osAPIKey.size() > 0 ) { osURL += "?token="; osURL += osAPIKey; } char** papszOptions=NULL; CPLString osPOSTFIELDS("CUSTOMREQUEST=DELETE"); papszOptions = CSLAddString(papszOptions, osPOSTFIELDS); CPLHTTPResult * psResult = CPLHTTPFetch( osURL.c_str(), papszOptions); CSLDestroy(papszOptions); if( psResult == NULL ) return NULL; 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 NULL; } if (psResult->pszErrBuf != NULL) { CPLDebug( "AMIGOCLOUD", "RunDELETE Error Message:%s", psResult->pszErrBuf ); } else if ( psResult->nStatus != 0) { CPLDebug( "AMIGOCLOUD", "RunDELETE Error Status:%d", psResult->nStatus ); } if( psResult->pabyData == NULL ) { CPLHTTPDestroyResult(psResult); return NULL; } CPLDebug( "AMIGOCLOUD", "RunDELETE 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,代码行数:92,
示例26: CPLAssert//.........这里部分代码省略......... CPLError( CE_Failure, CPLE_AppDefined, "mysql_init() failed." ); }/* -------------------------------------------------------------------- *//* Set desired options on the connection: charset and timeout. *//* -------------------------------------------------------------------- */ if( hConn ) { const char *pszTimeoutLength = CPLGetConfigOption( "MYSQL_TIMEOUT", "0" ); unsigned int timeout = atoi(pszTimeoutLength); mysql_options(hConn, MYSQL_OPT_CONNECT_TIMEOUT, (char*)&timeout); mysql_options(hConn, MYSQL_SET_CHARSET_NAME, "utf8" ); } /* -------------------------------------------------------------------- *//* Perform connection. *//* -------------------------------------------------------------------- */ if( hConn && mysql_real_connect( hConn, oHost.length() ? oHost.c_str() : NULL, oUser.length() ? oUser.c_str() : NULL, oPassword.length() ? oPassword.c_str() : NULL, oDB.length() ? oDB.c_str() : NULL, nPort, NULL, CLIENT_INTERACTIVE ) == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "MySQL connect failed for: %s/n%s", pszNewName + 6, mysql_error( hConn ) ); mysql_close( hConn ); hConn = NULL; } if( hConn == NULL ) { CSLDestroy( papszTableNames ); return FALSE; } pszName = CPLStrdup( pszNewName ); bDSUpdate = bUpdate;/* -------------------------------------------------------------------- *//* Get a list of available tables. *//* -------------------------------------------------------------------- */ if( papszTableNames == NULL ) { MYSQL_RES *hResultSet; MYSQL_ROW papszRow; if( mysql_query( hConn, "SHOW TABLES" ) ) { ReportError( "SHOW TABLES Failed" ); return FALSE; } hResultSet = mysql_store_result( hConn ); if( hResultSet == NULL ) { ReportError( "mysql_store_result() failed on SHOW TABLES result."); return FALSE; } while( (papszRow = mysql_fetch_row( hResultSet )) != NULL ) { if( papszRow[0] == NULL ) continue; if( EQUAL(papszRow[0],"spatial_ref_sys") || EQUAL(papszRow[0],"geometry_columns") ) continue; papszTableNames = CSLAddString(papszTableNames, papszRow[0] ); } mysql_free_result( hResultSet ); }/* -------------------------------------------------------------------- *//* Get the schema of the available tables. *//* -------------------------------------------------------------------- */ int iRecord; for( iRecord = 0; papszTableNames != NULL && papszTableNames[iRecord] != NULL; iRecord++ ) { // FIXME: This should be fixed to deal with tables // for which we can't open because the name is bad/ OpenTable( papszTableNames[iRecord], bUpdate, FALSE ); } CSLDestroy( papszTableNames ); return nLayers > 0 || bUpdate;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例27: mainint main( int argc, char ** argv ){ GDALDatasetH hDataset, hOutDS; int i; const char *pszSource=NULL, *pszDest=NULL, *pszFormat = "GTiff"; GDALDriverH hDriver; GDALDataType eOutputType = GDT_Unknown; char **papszCreateOptions = NULL; GDALProgressFunc pfnProgress = GDALTermProgress; int nLUTBins = 256; const char *pszMethod = "minmax";// double dfStdDevMult = 0.0; double *padfScaleMin = NULL; double *padfScaleMax = NULL; int **papanLUTs = NULL; int iBand; const char *pszConfigFile = NULL; /* Check strict compilation and runtime library version as we use C++ API */ if (! GDAL_CHECK_VERSION(argv[0])) exit(1);/* -------------------------------------------------------------------- *//* Register standard GDAL drivers, and process generic GDAL *//* command options. *//* -------------------------------------------------------------------- */ GDALAllRegister(); argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 ); if( argc < 1 ) exit( -argc );/* -------------------------------------------------------------------- *//* Handle command line arguments. *//* -------------------------------------------------------------------- */ for( i = 1; i < argc; i++ ) { if( EQUAL(argv[i], "--utility_version") ) { printf("%s was compiled against GDAL %s and is running against GDAL %s/n", argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME")); return 0; } else if( EQUAL(argv[i],"-of") && i < argc-1 ) pszFormat = argv[++i]; else if( EQUAL(argv[i],"-ot") && i < argc-1 ) { int iType; for( iType = 1; iType < GDT_TypeCount; iType++ ) { if( GDALGetDataTypeName((GDALDataType)iType) != NULL && EQUAL(GDALGetDataTypeName((GDALDataType)iType), argv[i+1]) ) { eOutputType = (GDALDataType) iType; } } if( eOutputType == GDT_Unknown ) { printf( "Unknown output pixel type: %s/n", argv[i+1] ); Usage(); GDALDestroyDriverManager(); exit( 2 ); } i++; } else if( EQUALN(argv[i],"-s_nodata",9) ) { // TODO i += 1; } else if( EQUAL(argv[i],"-co") && i < argc-1 ) { papszCreateOptions = CSLAddString( papszCreateOptions, argv[++i] ); } else if( EQUALN(argv[i],"-src_scale",10) && i < argc-2) { // TODO i += 2; } else if( EQUALN(argv[i],"-dst_scale",10) && i < argc-2 ) { // TODO i += 2; } else if( EQUAL(argv[i],"-config") && i < argc-1 ) { pszConfigFile = argv[++i]; } else if( EQUAL(argv[i],"-equalize") ) { pszMethod = "equalize";//.........这里部分代码省略.........
开发者ID:brunosimoes,项目名称:WorldWind,代码行数:101,
注:本文中的CSLAddString函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CSLDestroy函数代码示例 C++ CSL函数代码示例 |