这篇教程C++ CSLDestroy函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CSLDestroy函数的典型用法代码示例。如果您正苦于以下问题:C++ CSLDestroy函数的具体用法?C++ CSLDestroy怎么用?C++ CSLDestroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CSLDestroy函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CPLStrdup//.........这里部分代码省略......... EQUALN(osBaseFilename, "AllStatesFedCodes_", 18) || EQUALN(osBaseFilename, "ANTARCTICA_", 11) || (strlen(osBaseFilename) > 2 && EQUALN(osBaseFilename+2, "_FedCodes_", 10))) { OpenTable( osFilename, NULL, "PRIMARY"); } else if (EQUALN(osBaseFilename, "GOVT_UNITS_", 11) || EQUALN(osBaseFilename, "Feature_Description_History_", 28)) { OpenTable( osFilename, NULL, ""); } else { OpenTable( osFilename, NULL, "PRIM"); OpenTable( osFilename, NULL, "SOURCE"); } return nLayers != 0; } return OpenTable( osFilename ); }/* -------------------------------------------------------------------- *//* Is this a single a ZIP file with only a CSV file inside ? *//* -------------------------------------------------------------------- */ if( strncmp(osFilename, "/vsizip/", 8) == 0 && EQUAL(osExt, "zip") && VSI_ISREG(sStatBuf.st_mode) ) { char** papszFiles = VSIReadDir(osFilename); if (CSLCount(papszFiles) != 1 || !EQUAL(CPLGetExtension(papszFiles[0]), "CSV")) { CSLDestroy(papszFiles); return FALSE; } osFilename = CPLFormFilename(osFilename, papszFiles[0], NULL); CSLDestroy(papszFiles); return OpenTable( osFilename ); }/* -------------------------------------------------------------------- *//* Otherwise it has to be a directory. *//* -------------------------------------------------------------------- */ if( !VSI_ISDIR(sStatBuf.st_mode) ) return FALSE;/* -------------------------------------------------------------------- *//* Scan through for entries ending in .csv. *//* -------------------------------------------------------------------- */ int nNotCSVCount = 0, i; char **papszNames = CPLReadDir( osFilename ); for( i = 0; papszNames != NULL && papszNames[i] != NULL; i++ ) { CPLString oSubFilename = CPLFormFilename( osFilename, papszNames[i], NULL ); if( EQUAL(papszNames[i],".") || EQUAL(papszNames[i],"..") ) continue; if (EQUAL(CPLGetExtension(oSubFilename),"csvt")) continue; if( VSIStatL( oSubFilename, &sStatBuf ) != 0 || !VSI_ISREG(sStatBuf.st_mode) )
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:67,
示例2: OGR2SQLITE_ogr_geocode_reversestaticvoid OGR2SQLITE_ogr_geocode_reverse(sqlite3_context* pContext, int argc, sqlite3_value** argv){ OGRSQLiteExtensionData* poModule = (OGRSQLiteExtensionData*) sqlite3_user_data(pContext); double dfLon = 0.0, dfLat = 0.0; int iAfterGeomIdx = 0; int bGotLon = FALSE, bGotLat = FALSE; if( argc >= 2 ) { dfLon = OGR2SQLITE_GetValAsDouble(argv[0], &bGotLon); dfLat = OGR2SQLITE_GetValAsDouble(argv[1], &bGotLat); } if( argc >= 3 && bGotLon && bGotLat && sqlite3_value_type (argv[2]) == SQLITE_TEXT ) { iAfterGeomIdx = 2; } else if( argc >= 2 && sqlite3_value_type (argv[0]) == SQLITE_BLOB && sqlite3_value_type (argv[1]) == SQLITE_TEXT ) { OGRGeometry* poGeom = OGR2SQLITE_GetGeom(pContext, argc, argv, NULL); if( poGeom != NULL && wkbFlatten(poGeom->getGeometryType()) == wkbPoint ) { OGRPoint* poPoint = (OGRPoint*) poGeom; dfLon = poPoint->getX(); dfLat = poPoint->getY(); delete poGeom; } else { delete poGeom; sqlite3_result_null (pContext); return; } iAfterGeomIdx = 1; } else { sqlite3_result_null (pContext); return; } const char* pszField = (const char*)sqlite3_value_text(argv[iAfterGeomIdx]); int i; char** papszOptions = NULL; for(i = iAfterGeomIdx + 1; 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( strcmp(pszField, "raw") == 0 ) papszOptions = CSLAddString(papszOptions, "RAW_FEATURE=YES"); OGRLayerH hLayer = OGRGeocodeReverse(hSession, dfLon, dfLat, papszOptions); OGR2SQLITE_ogr_geocode_set_result(pContext, hLayer, pszField); CSLDestroy(papszOptions); return;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:85,
示例3: CPLGetXMLNodevoid *GDALDeserializeRPCTransformer( CPLXMLNode *psTree ){ void *pResult; char **papszOptions = NULL;/* -------------------------------------------------------------------- *//* Collect metadata. *//* -------------------------------------------------------------------- */ char **papszMD = NULL; CPLXMLNode *psMDI, *psMetadata; GDALRPCInfo sRPC; psMetadata = CPLGetXMLNode( psTree, "Metadata" ); if( psMetadata == NULL || psMetadata->eType != CXT_Element || !EQUAL(psMetadata->pszValue,"Metadata") ) return NULL; for( psMDI = psMetadata->psChild; psMDI != NULL; psMDI = psMDI->psNext ) { if( !EQUAL(psMDI->pszValue,"MDI") || psMDI->eType != CXT_Element || psMDI->psChild == NULL || psMDI->psChild->psNext == NULL || psMDI->psChild->eType != CXT_Attribute || psMDI->psChild->psChild == NULL ) continue; papszMD = CSLSetNameValue( papszMD, psMDI->psChild->psChild->pszValue, psMDI->psChild->psNext->pszValue ); } if( !GDALExtractRPCInfo( papszMD, &sRPC ) ) { CPLError( CE_Failure, CPLE_AppDefined, "Failed to reconstitute RPC transformer." ); CSLDestroy( papszMD ); return NULL; } CSLDestroy( papszMD );/* -------------------------------------------------------------------- *//* Get other flags. *//* -------------------------------------------------------------------- */ double dfPixErrThreshold; int bReversed; bReversed = atoi(CPLGetXMLValue(psTree,"Reversed","0")); dfPixErrThreshold = CPLAtof(CPLGetXMLValue(psTree,"PixErrThreshold","0.25")); papszOptions = CSLSetNameValue( papszOptions, "RPC_HEIGHT", CPLGetXMLValue(psTree,"HeightOffset","0")); papszOptions = CSLSetNameValue( papszOptions, "RPC_HEIGHT_SCALE", CPLGetXMLValue(psTree,"HeightScale","1")); const char* pszDEMPath = CPLGetXMLValue(psTree,"DEMPath",NULL); if (pszDEMPath != NULL) papszOptions = CSLSetNameValue( papszOptions, "RPC_DEM", pszDEMPath); const char* pszDEMInterpolation = CPLGetXMLValue(psTree,"DEMInterpolation", "bilinear"); if (pszDEMInterpolation != NULL) papszOptions = CSLSetNameValue( papszOptions, "RPC_DEMINTERPOLATION", pszDEMInterpolation);/* -------------------------------------------------------------------- *//* Generate transformation. *//* -------------------------------------------------------------------- */ pResult = GDALCreateRPCTransformer( &sRPC, bReversed, dfPixErrThreshold, papszOptions ); CSLDestroy( papszOptions ); return pResult;}
开发者ID:afarnham,项目名称:gdal,代码行数:82,
示例4: CSLTokenizeString2static GDALDataset *OGRCADDriverOpen( GDALOpenInfo* poOpenInfo ){ long nSubRasterLayer = -1; long nSubRasterFID = -1; CADFileIO* pFileIO; if ( STARTS_WITH_CI(poOpenInfo->pszFilename, "CAD:") ) { char** papszTokens = CSLTokenizeString2( poOpenInfo->pszFilename, ":", 0 ); int nTokens = CSLCount( papszTokens ); if( nTokens < 4 ) { CSLDestroy(papszTokens); return NULL; } CPLString osFilename; for( int i = 1; i < nTokens - 2; ++i ) { if( osFilename.empty() ) osFilename += ":"; osFilename += papszTokens[i]; } pFileIO = new VSILFileIO( osFilename ); nSubRasterLayer = atol( papszTokens[nTokens - 2] ); nSubRasterFID = atol( papszTokens[nTokens - 1] ); CSLDestroy( papszTokens ); } else { pFileIO = new VSILFileIO( poOpenInfo->pszFilename ); } if ( IdentifyCADFile( pFileIO, false ) == FALSE ) { delete pFileIO; return NULL; }/* -------------------------------------------------------------------- *//* Confirm the requested access is supported. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_Update ) { CPLError( CE_Failure, CPLE_NotSupported, "The CAD driver does not support update access to existing" " datasets./n" ); delete pFileIO; return NULL; } GDALCADDataset *poDS = new GDALCADDataset(); if( !poDS->Open( poOpenInfo, pFileIO, nSubRasterLayer, nSubRasterFID ) ) { delete poDS; return NULL; } else return poDS;}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:63,
示例5: main//.........这里部分代码省略......... if( i < nArgc - 5 && (atof(papszArgv[i+5]) > 0.0 || papszArgv[i+5][0] == '0') ) { z_orig = z = atof(papszArgv[i+5]); nArgsUsed++; } else z_orig = z = 0; if( poCT == NULL || !poCT->Transform( 1, &x, &y, &z ) ) printf( "Transformation failed./n" ); else printf( "(%f,%f,%f) -> (%f,%f,%f)/n", atof( papszArgv[i+3] ), atof( papszArgv[i+4] ), z_orig, x, y, z ); i += nArgsUsed; } else { if( oSRS.SetFromUserInput(papszArgv[i]) != OGRERR_NONE ) CPLError( CE_Failure, CPLE_AppDefined, "Error occured translating %s./n", papszArgv[i] ); else { char *pszWKT = NULL; if( oSRS.Validate() != OGRERR_NONE ) printf( "Validate Fails./n" ); else printf( "Validate Succeeds./n" ); oSRS.exportToPrettyWkt( &pszWKT, FALSE ); printf( "WKT[%s] =/n%s/n", papszArgv[i], pszWKT ); CPLFree( pszWKT ); printf( "/n" ); oSRS.exportToPrettyWkt( &pszWKT, TRUE ); printf( "Simplified WKT[%s] =/n%s/n", papszArgv[i], pszWKT ); CPLFree( pszWKT ); printf( "/n" ); OGRSpatialReference *poSRS2; poSRS2 = oSRS.Clone(); poSRS2->StripCTParms(); poSRS2->exportToWkt( &pszWKT ); printf( "Old Style WKT[%s] = %s/n", papszArgv[i], pszWKT ); CPLFree( pszWKT ); OGRSpatialReference::DestroySpatialReference( poSRS2 ); poSRS2 = oSRS.Clone(); poSRS2->morphToESRI(); poSRS2->exportToPrettyWkt( &pszWKT, FALSE ); printf( "ESRI'ified WKT[%s] = /n%s/n", papszArgv[i], pszWKT ); CPLFree( pszWKT ); OGRSpatialReference::DestroySpatialReference( poSRS2 ); oSRS.exportToProj4( &pszWKT ); printf( "PROJ.4 rendering of [%s] = %s/n", papszArgv[i], pszWKT ); CPLFree( pszWKT ); if( bReportXML ) { char *pszRawXML; if( oSRS.exportToXML(&pszRawXML) == OGRERR_NONE ) { printf( "XML[%s] =/n%s/n", papszArgv[i], pszRawXML ); CPLFree( pszRawXML ); } else { printf( "XML translation failed/n" ); } } printf( "/n" ); } } } CSLDestroy( papszArgv ); OSRCleanup(); CPLFinderClean(); CPLCleanupTLS(); return 0;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例6: FindSRSint FindSRS( const char *pszInput, OGRSpatialReference &oSRS ){ int bGotSRS = FALSE; VSILFILE *fp = NULL; GDALDataset *poGDALDS = NULL; OGRLayer *poLayer = NULL; const char *pszProjection = NULL; CPLErrorHandler oErrorHandler = NULL; int bIsFile = FALSE; OGRErr eErr = OGRERR_NONE; int bDebug = FALSE; /* temporarily suppress error messages we may get from xOpen() */ bDebug = CSLTestBoolean(CPLGetConfigOption("CPL_DEBUG", "OFF")); if ( ! bDebug ) oErrorHandler = CPLSetErrorHandler ( CPLQuietErrorHandler ); /* Test if argument is a file */ fp = VSIFOpenL( pszInput, "r" ); if ( fp ) { bIsFile = TRUE; VSIFCloseL( fp ); CPLDebug( "gdalsrsinfo", "argument is a file" ); } /* try to open with GDAL */ if( strncmp(pszInput, "http://spatialreference.org/", strlen("http://spatialreference.org/")) != 0 ) { CPLDebug( "gdalsrsinfo", "trying to open with GDAL" ); poGDALDS = (GDALDataset *) GDALOpenEx( pszInput, 0, NULL, NULL, NULL ); } if ( poGDALDS != NULL ) { pszProjection = poGDALDS->GetProjectionRef( ); if( pszProjection != NULL && pszProjection[0] != '/0' ) { char* pszProjectionTmp = (char*) pszProjection; if( oSRS.importFromWkt( &pszProjectionTmp ) == OGRERR_NONE ) { CPLDebug( "gdalsrsinfo", "got SRS from GDAL" ); bGotSRS = TRUE; } } else if( poGDALDS->GetLayerCount() > 0 ) { poLayer = poGDALDS->GetLayer( 0 ); if ( poLayer != NULL ) { OGRSpatialReference *poSRS = poLayer->GetSpatialRef( ); if ( poSRS != NULL ) { CPLDebug( "gdalsrsinfo", "got SRS from OGR" ); bGotSRS = TRUE; OGRSpatialReference* poSRSClone = poSRS->Clone(); oSRS = *poSRSClone; OGRSpatialReference::DestroySpatialReference( poSRSClone ); } } } GDALClose( (GDALDatasetH) poGDALDS ); if ( ! bGotSRS ) CPLDebug( "gdalsrsinfo", "did not open with GDAL" ); } /* Try ESRI file */ if ( ! bGotSRS && bIsFile && (strstr(pszInput,".prj") != NULL) ) { CPLDebug( "gdalsrsinfo", "trying to get SRS from ESRI .prj file [%s]", pszInput ); char **pszTemp; if ( strstr(pszInput,"ESRI::") != NULL ) pszTemp = CSLLoad( pszInput+6 ); else pszTemp = CSLLoad( pszInput ); if( pszTemp ) { eErr = oSRS.importFromESRI( pszTemp ); CSLDestroy( pszTemp ); } else eErr = OGRERR_UNSUPPORTED_SRS; if( eErr != OGRERR_NONE ) { CPLDebug( "gdalsrsinfo", "did not get SRS from ESRI .prj file" ); } else { CPLDebug( "gdalsrsinfo", "got SRS from ESRI .prj file" ); bGotSRS = TRUE; } } /* Last resort, try OSRSetFromUserInput() */ if ( ! bGotSRS ) { CPLDebug( "gdalsrsinfo", "trying to get SRS from user input [%s]", pszInput ); eErr = oSRS.SetFromUserInput( pszInput ); if( eErr != OGRERR_NONE ) { CPLDebug( "gdalsrsinfo", "did not get SRS from user input" ); } else {//.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,
示例7: Clear//.........这里部分代码省略......... papszDatum[0] ); goto other_error; } int nDatumCode = atoi( CSVGetField( pszOziDatum, "NAME", papszDatum[0], CC_ApproxString, "EPSG_DATUM_CODE" ) ); if ( nDatumCode > 0 ) // There is a matching EPSG code { OGRSpatialReference oGCS; oGCS.importFromEPSG( nDatumCode ); CopyGeogCSFrom( &oGCS ); } else // We use the parameters from the CSV files { CPLString osEllipseCode = CSVGetField( pszOziDatum, "NAME", papszDatum[0], CC_ApproxString, "ELLIPSOID_CODE" ); double dfDeltaX = CPLAtof(CSVGetField( pszOziDatum, "NAME", papszDatum[0], CC_ApproxString, "DELTAX" ) ); double dfDeltaY = CPLAtof(CSVGetField( pszOziDatum, "NAME", papszDatum[0], CC_ApproxString, "DELTAY" ) ); double dfDeltaZ = CPLAtof(CSVGetField( pszOziDatum, "NAME", papszDatum[0], CC_ApproxString, "DELTAZ" ) ); /* -------------------------------------------------------------------- */ /* Verify that we can find the CSV file containing the ellipsoids */ /* -------------------------------------------------------------------- */ if( CSVScanFileByName( CSVFilename( "ozi_ellips.csv" ), "ELLIPSOID_CODE", "20", CC_Integer ) == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to open OZI support file %s./n" "Try setting the GDAL_DATA environment variable to point/n" "to the directory containing OZI csv files.", CSVFilename( "ozi_ellips.csv" ) ); goto other_error; } /* -------------------------------------------------------------------- */ /* Lookup the ellipse code. */ /* -------------------------------------------------------------------- */ const char *pszOziEllipse = CSVFilename( "ozi_ellips.csv" ); CPLString osEName = CSVGetField( pszOziEllipse, "ELLIPSOID_CODE", osEllipseCode, CC_ApproxString, "NAME" ); if( strlen(osEName) == 0 ) { CPLError( CE_Failure, CPLE_AppDefined, "Failed to find ellipsoid %s in ozi_ellips.csv.", osEllipseCode.c_str() ); goto other_error; } double dfA = CPLAtof(CSVGetField( pszOziEllipse, "ELLIPSOID_CODE", osEllipseCode, CC_ApproxString, "A" )); double dfInvF = CPLAtof(CSVGetField( pszOziEllipse, "ELLIPSOID_CODE", osEllipseCode, CC_ApproxString, "INVF" )); /* -------------------------------------------------------------------- */ /* Create geographic coordinate system. */ /* -------------------------------------------------------------------- */ SetGeogCS( osDName, osDName, osEName, dfA, dfInvF ); SetTOWGS84( dfDeltaX, dfDeltaY, dfDeltaZ ); } }/* -------------------------------------------------------------------- *//* Grid units translation *//* -------------------------------------------------------------------- */ if( IsLocal() || IsProjected() ) SetLinearUnits( SRS_UL_METER, 1.0 ); FixupOrdering(); CSLDestroy(papszProj); CSLDestroy(papszProjParms); CSLDestroy(papszDatum); return OGRERR_NONE;not_enough_data: CSLDestroy(papszProj); CSLDestroy(papszProjParms); CSLDestroy(papszDatum); return OGRERR_NOT_ENOUGH_DATA;other_error: CSLDestroy(papszProj); CSLDestroy(papszProjParms); CSLDestroy(papszDatum); return OGRERR_FAILURE;}
开发者ID:afarnham,项目名称:gdal,代码行数:101,
示例8: CSLTestBooleanint OGRCARTODBDataSource::Open( const char * pszFilename, char** papszOpenOptions, int bUpdateIn ){ bReadWrite = bUpdateIn; bBatchInsert = CSLTestBoolean(CSLFetchNameValueDef(papszOpenOptions, "BATCH_INSERT", "YES")); pszName = CPLStrdup( pszFilename ); if( CSLFetchNameValue(papszOpenOptions, "ACCOUNT") ) pszAccount = CPLStrdup(CSLFetchNameValue(papszOpenOptions, "ACCOUNT")); else { pszAccount = CPLStrdup(pszFilename + strlen("CARTODB:")); char* pchSpace = strchr(pszAccount, ' '); if( pchSpace ) *pchSpace = '/0'; if( pszAccount[0] == 0 ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing account name"); return FALSE; } } osAPIKey = CSLFetchNameValueDef(papszOpenOptions, "API_KEY", CPLGetConfigOption("CARTODB_API_KEY", "")); CPLString osTables = OGRCARTODBGetOptionValue(pszFilename, "tables"); /*if( osTables.size() == 0 && osAPIKey.size() == 0 ) { CPLError(CE_Failure, CPLE_AppDefined, "When not specifying tables option, CARTODB_API_KEY must be defined"); return FALSE; }*/ bUseHTTPS = CSLTestBoolean(CPLGetConfigOption("CARTODB_HTTPS", "YES")); OGRLayer* poSchemaLayer = ExecuteSQLInternal("SELECT current_schema()"); if( poSchemaLayer ) { OGRFeature* poFeat = poSchemaLayer->GetNextFeature(); if( poFeat ) { if( poFeat->GetFieldCount() == 1 ) { osCurrentSchema = poFeat->GetFieldAsString(0); } delete poFeat; } ReleaseResultSet(poSchemaLayer); } if( osCurrentSchema.size() == 0 ) return FALSE; if( osAPIKey.size() && bUpdateIn ) { ExecuteSQLInternal( "DROP FUNCTION IF EXISTS ogr_table_metadata(TEXT,TEXT); " "CREATE OR REPLACE FUNCTION ogr_table_metadata(schema_name TEXT, table_name TEXT) RETURNS TABLE " "(attname TEXT, typname TEXT, attlen INT, format_type TEXT, " "attnum INT, attnotnull BOOLEAN, indisprimary BOOLEAN, " "defaultexpr TEXT, dim INT, srid INT, geomtyp TEXT, srtext TEXT) AS $$ " "SELECT a.attname::text, t.typname::text, a.attlen::int, " "format_type(a.atttypid,a.atttypmod)::text, " "a.attnum::int, " "a.attnotnull::boolean, " "i.indisprimary::boolean, " "pg_get_expr(def.adbin, c.oid)::text AS defaultexpr, " "(CASE WHEN t.typname = 'geometry' THEN postgis_typmod_dims(a.atttypmod) ELSE NULL END)::int dim, " "(CASE WHEN t.typname = 'geometry' THEN postgis_typmod_srid(a.atttypmod) ELSE NULL END)::int srid, " "(CASE WHEN t.typname = 'geometry' THEN postgis_typmod_type(a.atttypmod) ELSE NULL END)::text geomtyp, " "srtext " "FROM pg_class c " "JOIN pg_attribute a ON a.attnum > 0 AND " "a.attrelid = c.oid AND c.relname = $2 " "AND c.relname IN (SELECT CDB_UserTables())" "JOIN pg_type t ON a.atttypid = t.oid " "JOIN pg_namespace n ON c.relnamespace=n.oid AND n.nspname = $1 " "LEFT JOIN pg_index i ON c.oid = i.indrelid AND " "i.indisprimary = 't' AND a.attnum = ANY(i.indkey) " "LEFT JOIN pg_attrdef def ON def.adrelid = c.oid AND " "def.adnum = a.attnum " "LEFT JOIN spatial_ref_sys srs ON srs.srid = postgis_typmod_srid(a.atttypmod) " "ORDER BY a.attnum " "$$ LANGUAGE SQL"); } if (osTables.size() != 0) { char** papszTables = CSLTokenizeString2(osTables, ",", 0); for(int i=0;papszTables && papszTables[i];i++) { papoLayers = (OGRCARTODBTableLayer**) CPLRealloc( papoLayers, (nLayers + 1) * sizeof(OGRCARTODBTableLayer*)); papoLayers[nLayers ++] = new OGRCARTODBTableLayer(this, papszTables[i]); } CSLDestroy(papszTables); return TRUE; }//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例9: osSQLjson_object* OGRCARTODBDataSource::RunSQL(const char* pszUnescapedSQL){ CPLString osSQL("POSTFIELDS=q="); /* 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 *//* -------------------------------------------------------------------- */ if( osAPIKey.size() ) { osSQL += "&api_key="; osSQL += osAPIKey; }/* -------------------------------------------------------------------- *//* Collection the header options and execute request. *//* -------------------------------------------------------------------- */ const char* pszAPIURL = GetAPIURL(); char** papszOptions = CSLAddString( strncmp(pszAPIURL, "/vsimem/", strlen("/vsimem/")) != 0 ? AddHTTPOptions(): NULL, 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( "CARTODB", "RunSQL HTML Response:%s", psResult->pabyData ); CPLError(CE_Failure, CPLE_AppDefined, "HTML error page returned by server"); CPLHTTPDestroyResult(psResult); return NULL; } if (psResult && psResult->pszErrBuf != NULL) { CPLDebug( "CARTODB", "RunSQL Error Message:%s", psResult->pszErrBuf ); } else if (psResult && psResult->nStatus != 0) { CPLDebug( "CARTODB", "RunSQL Error Status:%d", psResult->nStatus ); } if( psResult->pabyData == NULL ) { CPLHTTPDestroyResult(psResult); return NULL; } if( strlen((const char*)psResult->pabyData) < 1000 ) CPLDebug( "CARTODB", "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 = 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 {//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例10: while//.........这里部分代码省略......... { CPLError( CE_Warning, CPLE_AppDefined, "No matching definition for field '%s' of " "table %s found", geomfldname.c_str(), featureDef->GetName() ); } } else { geomIdx = -1; } if (geomIdx >= 0) { if (featureDef->GetGeomFieldDefn(geomIdx)->GetType() == wkbPoint) { // Add Point geometry. OGRPoint *ogrPoint = new OGRPoint( CPLAtof(tokens[fIndex-1]), CPLAtof(tokens[fIndex])); feature->SetGeomFieldDirectly(geomIdx, ogrPoint); } else if (featureDef->GetGeomFieldDefn(geomIdx)->GetType() == wkbPoint25D && fieldno > 1 && featureDef->GetFieldDefn(fieldno-2)->GetType() == OFTReal) { // Add 3D Point geometry. OGRPoint *ogrPoint = new OGRPoint( CPLAtof(tokens[fIndex-2]), CPLAtof(tokens[fIndex-1]), CPLAtof(tokens[fIndex]) ); feature->SetGeomFieldDirectly(geomIdx, ogrPoint); } } } } } if (!warned && featureDef->GetFieldCount() != CSLCount(tokens)-1) { CPLError( CE_Warning, CPLE_AppDefined, "Field count of table %s doesn't match. %d declared, " "%d found (e.g. ignored LINEATTR)", featureDef->GetName(), featureDef->GetFieldCount(), CSLCount(tokens) - 1 ); warned = TRUE; } if (feature->GetFieldCount() > 0) { // USE _TID as FID. TODO: respect IDENT field from model. feature->SetFID(feature->GetFieldAsInteger64(0)); } curLayer->AddFeature(feature); bFeatureAdded = true; geomIdx = -1; //Reset } else if (EQUAL(firsttok, "STPT") && feature != NULL) { //Find next non-Point geometry if (geomIdx < 0) geomIdx = 0; while (geomIdx < featureDef->GetGeomFieldCount() && featureDef->GetGeomFieldDefn(geomIdx)->GetType() == wkbPoint) { geomIdx++; } OGRwkbGeometryType geomType = (geomIdx < featureDef->GetGeomFieldCount()) ? featureDef->GetGeomFieldDefn(geomIdx)->GetType() : wkbNone; ReadGeom(tokens, geomIdx, geomType, feature); } else if (EQUAL(firsttok, "ELIN")) { // Empty geom. } else if (EQUAL(firsttok, "EDGE") && feature != NULL) { CSLDestroy(tokens); tokens = ReadParseLine(); //STPT //Find next non-Point geometry do { geomIdx++; } while (geomIdx < featureDef->GetGeomFieldCount() && featureDef->GetGeomFieldDefn(geomIdx)->GetType() == wkbPoint); ReadGeom(tokens, geomIdx, wkbMultiLineString, feature); } else if (EQUAL(firsttok, "PERI")) { } else if (EQUAL(firsttok, "ETAB")) { CPLDebug( "OGR_ILI", "Total features: " CPL_FRMT_GIB, curLayer->GetFeatureCount() ); CSLDestroy(tokens); if( !bFeatureAdded ) delete feature; return TRUE; } else { CPLError( CE_Warning, CPLE_AppDefined, "Unexpected token: %s", firsttok ); } CSLDestroy(tokens); } if( !bFeatureAdded ) delete feature; return ret;}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例11: CPLDebug//.........这里部分代码省略......... { //Finish line and start arc if (ogrLine->getNumPoints() > 1) { OGRErr error = ogrCurve->addCurveDirectly(ogrLine); if (error != OGRERR_NONE) { CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrLine->exportToJson() ); } ogrLine = new OGRLineString(); } else { ogrLine->empty(); } arc = new OGRCircularString(); arc->addPoint(&ogrPoint); ogrPoint.setX(CPLAtof(tokens[1])); ogrPoint.setY(CPLAtof(tokens[2])); arc->addPoint(&ogrPoint); } else if (EQUAL(firsttok, "ELIN")) { if (ogrLine->getNumPoints() > 1) { // Ignore single LIPT after ARCP OGRErr error = ogrCurve->addCurveDirectly(ogrLine); if (error != OGRERR_NONE) { CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrLine->exportToJson() ); } ogrLine = NULL; } if (!ogrCurve->IsEmpty()) { if (ogrMultiLine) { OGRErr error = ogrMultiLine->addGeometryDirectly(ogrCurve); if (error != OGRERR_NONE) { CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrCurve->exportToJson() ); } ogrCurve = NULL; } if (ogrPoly) { OGRErr error = ogrPoly->addRingDirectly(ogrCurve); if (error != OGRERR_NONE) { CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrCurve->exportToJson() ); } ogrCurve = NULL; } } end = true; } else if (EQUAL(firsttok, "EEDG")) { end = true; } else if (EQUAL(firsttok, "LATT")) { //Line Attributes (ignored) } else if (EQUAL(firsttok, "EFLA")) { end = true; } else if (EQUAL(firsttok, "ETAB")) { end = true; } else { CPLError( CE_Warning, CPLE_AppDefined, "Unexpected token: %s", firsttok ); } CSLDestroy(tokens); } delete ogrLine; //Set feature geometry if (eType == wkbMultiCurve) { feature->SetGeomFieldDirectly(geomIdx, ogrMultiLine); delete ogrCurve; } else if (eType == wkbMultiLineString) { feature->SetGeomFieldDirectly(geomIdx, ogrMultiLine->getLinearGeometry()); delete ogrMultiLine; delete ogrCurve; } else if (eType == wkbCurvePolygon) { feature->SetGeomFieldDirectly(geomIdx, ogrPoly); delete ogrCurve; } else if (eType == wkbPolygon) { feature->SetGeomFieldDirectly(geomIdx, ogrPoly->getLinearGeometry()); delete ogrPoly; delete ogrCurve; } else { feature->SetGeomFieldDirectly(geomIdx, ogrCurve); }}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例12: CPLStrdupint ILI1Reader::ReadFeatures() { char **tokens = NULL; const char *pszLine = NULL; char *topic = CPLStrdup("(null)"); int ret = TRUE; while (ret && (tokens = ReadParseLine()) != NULL) { const char *firsttok = tokens[0]; if (EQUAL(firsttok, "SCNT")) { //read description do { pszLine = CPLReadLine( fpItf ); } while (pszLine && !STARTS_WITH_CI(pszLine, "////")); ret = (pszLine != NULL); } else if (EQUAL(firsttok, "MOTR")) { //read model do { pszLine = CPLReadLine( fpItf ); } while (pszLine && !STARTS_WITH_CI(pszLine, "////")); ret = (pszLine != NULL); } else if (EQUAL(firsttok, "MTID")) { } else if (EQUAL(firsttok, "MODL")) { } else if (EQUAL(firsttok, "TOPI") && CSLCount(tokens) >= 2) { CPLFree(topic); topic = CPLStrdup(CSLGetField(tokens, 1)); } else if (EQUAL(firsttok, "TABL") && CSLCount(tokens) >= 2) { const char *layername = GetLayerNameString(topic, CSLGetField(tokens, 1)); CPLDebug( "OGR_ILI", "Reading table '%s'", layername ); curLayer = GetLayerByName(layername); if (curLayer == NULL) { //create one CPLError( CE_Warning, CPLE_AppDefined, "No model definition for table '%s' found, " "using default field names.", layername ); OGRFeatureDefn* poFeatureDefn = new OGRFeatureDefn( GetLayerNameString(topic, CSLGetField(tokens, 1))); poFeatureDefn->SetGeomType( wkbUnknown ); GeomFieldInfos oGeomFieldInfos; curLayer = new OGRILI1Layer(poFeatureDefn, oGeomFieldInfos, NULL); AddLayer(curLayer); } if(curLayer != NULL) { for (int i=0; i < curLayer->GetLayerDefn()->GetFieldCount(); i++) { CPLDebug( "OGR_ILI", "Field %d: %s", i, curLayer->GetLayerDefn()->GetFieldDefn(i)->GetNameRef()); } } ret = ReadTable(layername); } else if (EQUAL(firsttok, "ETOP")) { } else if (EQUAL(firsttok, "EMOD")) { } else if (EQUAL(firsttok, "ENDE")) { CSLDestroy(tokens); CPLFree(topic); return TRUE; } else { CPLError( CE_Warning, CPLE_AppDefined, "Unexpected token: %s", firsttok ); } CSLDestroy(tokens); tokens = NULL; } CSLDestroy(tokens); CPLFree(topic); return ret;}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:94,
示例13: mainint main( int argc, char ** argv ){ int i, b3D = FALSE; int bInverse = FALSE; const char *pszSrcFilename = NULL; const char *pszDstFilename = NULL; char **papszLayers = NULL; const char *pszSQL = NULL; const char *pszBurnAttribute = NULL; const char *pszWHERE = NULL; std::vector<int> anBandList; std::vector<double> adfBurnValues; char **papszRasterizeOptions = NULL; double dfXRes = 0, dfYRes = 0; int bCreateOutput = FALSE; const char* pszFormat = "GTiff"; int bFormatExplicitelySet = FALSE; char **papszCreateOptions = NULL; GDALDriverH hDriver = NULL; GDALDataType eOutputType = GDT_Float64; std::vector<double> adfInitVals; int bNoDataSet = FALSE; double dfNoData = 0; OGREnvelope sEnvelop; int bGotBounds = FALSE; int nXSize = 0, nYSize = 0; int bQuiet = FALSE; GDALProgressFunc pfnProgress = GDALTermProgress; OGRSpatialReferenceH hSRS = NULL; int bTargetAlignedPixels = FALSE; /* Check that we are running against at least GDAL 1.4 */ /* Note to developers : if we use newer API, please change the requirement */ if (atoi(GDALVersionInfo("VERSION_NUM")) < 1400) { fprintf(stderr, "At least, GDAL >= 1.4.0 is required for this version of %s, " "which was compiled against GDAL %s/n", argv[0], GDAL_RELEASE_NAME); exit(1); } GDALAllRegister(); OGRRegisterAll(); argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 ); if( argc < 1 ) exit( -argc );/* -------------------------------------------------------------------- *//* Parse 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],"-q") || EQUAL(argv[i],"-quiet") ) { bQuiet = TRUE; pfnProgress = GDALDummyProgress; } else if( EQUAL(argv[i],"-a") && i < argc-1 ) { pszBurnAttribute = argv[++i]; } else if( EQUAL(argv[i],"-b") && i < argc-1 ) { if (strchr(argv[i+1], ' ')) { char** papszTokens = CSLTokenizeString( argv[i+1] ); char** papszIter = papszTokens; while(papszIter && *papszIter) { anBandList.push_back(atoi(*papszIter)); papszIter ++; } CSLDestroy(papszTokens); i += 1; } else { while(i < argc-1 && ArgIsNumeric(argv[i+1])) { anBandList.push_back(atoi(argv[i+1])); i += 1; } } } else if( EQUAL(argv[i],"-3d") ) { b3D = TRUE; papszRasterizeOptions = CSLSetNameValue( papszRasterizeOptions, "BURN_VALUE_FROM", "Z"); } else if( EQUAL(argv[i],"-i") ) {//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,
示例14: VSIFOpenLint OGRCSVDataSource::OpenTable( const char * pszFilename, const char* pszNfdcRunwaysGeomField, const char* pszGeonamesGeomFieldPrefix){/* -------------------------------------------------------------------- *//* Open the file. *//* -------------------------------------------------------------------- */ VSILFILE * fp; if( bUpdate ) fp = VSIFOpenL( pszFilename, "rb+" ); else fp = VSIFOpenL( pszFilename, "rb" ); if( fp == NULL ) { CPLError( CE_Warning, CPLE_OpenFailed, "Failed to open %s, %s.", pszFilename, VSIStrerror( errno ) ); return FALSE; } if( !bUpdate && strstr(pszFilename, "/vsigzip/") == NULL && strstr(pszFilename, "/vsizip/") == NULL ) fp = (VSILFILE*) VSICreateBufferedReaderHandle((VSIVirtualHandle*)fp); CPLString osLayerName = CPLGetBasename(pszFilename); CPLString osExt = CPLGetExtension(pszFilename); if( strncmp(pszFilename, "/vsigzip/", 9) == 0 && EQUAL(osExt, "gz") ) { if( strlen(pszFilename) > 7 && EQUAL(pszFilename + strlen(pszFilename) - 7, ".csv.gz") ) { osLayerName = osLayerName.substr(0, osLayerName.size() - 4); osExt = "csv"; } else if( strlen(pszFilename) > 7 && EQUAL(pszFilename + strlen(pszFilename) - 7, ".tsv.gz") ) { osLayerName = osLayerName.substr(0, osLayerName.size() - 4); osExt = "tsv"; } }/* -------------------------------------------------------------------- *//* Read and parse a line. Did we get multiple fields? *//* -------------------------------------------------------------------- */ const char* pszLine = CPLReadLineL( fp ); if (pszLine == NULL) { VSIFCloseL( fp ); return FALSE; } char chDelimiter = CSVDetectSeperator(pszLine); /* Force the delimiter to be TAB for a .tsv file that has a tabulation */ /* in its first line */ if( EQUAL(osExt, "tsv") && chDelimiter != '/t' && strchr(pszLine, '/t') != NULL ) { chDelimiter = '/t'; } VSIRewindL( fp ); /* GNIS specific */ if (pszGeonamesGeomFieldPrefix != NULL && strchr(pszLine, '|') != NULL) chDelimiter = '|'; char **papszFields = OGRCSVReadParseLineL( fp, chDelimiter, FALSE ); if( CSLCount(papszFields) < 2 ) { VSIFCloseL( fp ); CSLDestroy( papszFields ); return FALSE; } VSIRewindL( fp ); CSLDestroy( papszFields );/* -------------------------------------------------------------------- *//* Create a layer. *//* -------------------------------------------------------------------- */ nLayers++; papoLayers = (OGRCSVLayer **) CPLRealloc(papoLayers, sizeof(void*) * nLayers); if (pszNfdcRunwaysGeomField != NULL) { osLayerName += "_"; osLayerName += pszNfdcRunwaysGeomField; } else if (pszGeonamesGeomFieldPrefix != NULL && !EQUAL(pszGeonamesGeomFieldPrefix, "")) { osLayerName += "_"; osLayerName += pszGeonamesGeomFieldPrefix; } if (EQUAL(pszFilename, "/vsistdin/"))//.........这里部分代码省略.........
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:101,
示例15: CSLDestroyNASAKeywordHandler::~NASAKeywordHandler(){ CSLDestroy( papszKeywordList ); papszKeywordList = NULL;}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:6,
示例16: osFilenameGDALDataset *XYZDataset::Open( GDALOpenInfo * poOpenInfo ){ int i; int bHasHeaderLine; int nCommentLineCount = 0; if (!IdentifyEx(poOpenInfo, bHasHeaderLine, nCommentLineCount)) return NULL; CPLString osFilename(poOpenInfo->pszFilename); /* GZipped .xyz files are common, so automagically open them */ /* if the /vsigzip/ has not been explicitely passed */ if (strlen(poOpenInfo->pszFilename) > 6 && EQUAL(poOpenInfo->pszFilename + strlen(poOpenInfo->pszFilename) - 6, "xyz.gz") && !EQUALN(poOpenInfo->pszFilename, "/vsigzip/", 9)) { osFilename = "/vsigzip/"; osFilename += poOpenInfo->pszFilename; }/* -------------------------------------------------------------------- *//* Find dataset characteristics *//* -------------------------------------------------------------------- */ VSILFILE* fp = VSIFOpenL(osFilename.c_str(), "rb"); if (fp == NULL) return NULL; /* For better performance of CPLReadLine2L() we create a buffered reader */ /* (except for /vsigzip/ since it has one internally) */ if (!EQUALN(poOpenInfo->pszFilename, "/vsigzip/", 9)) fp = (VSILFILE*) VSICreateBufferedReaderHandle((VSIVirtualHandle*)fp); const char* pszLine; int nXIndex = -1, nYIndex = -1, nZIndex = -1; int nMinTokens = 0; for(i=0;i<nCommentLineCount;i++) CPLReadLine2L(fp, 100, NULL);/* -------------------------------------------------------------------- *//* Parse header line *//* -------------------------------------------------------------------- */ if (bHasHeaderLine) { pszLine = CPLReadLine2L(fp, 100, NULL); if (pszLine == NULL) { VSIFCloseL(fp); return NULL; } char** papszTokens = CSLTokenizeString2( pszLine, " ,/t;", CSLT_HONOURSTRINGS ); int nTokens = CSLCount(papszTokens); if (nTokens < 3) { CPLError(CE_Failure, CPLE_AppDefined, "At line %d, found %d tokens. Expected 3 at least", 1, nTokens); CSLDestroy(papszTokens); VSIFCloseL(fp); return NULL; } int i; for(i=0;i<nTokens;i++) { if (EQUAL(papszTokens[i], "x") || EQUALN(papszTokens[i], "lon", 3) || EQUALN(papszTokens[i], "east", 4)) nXIndex = i; else if (EQUAL(papszTokens[i], "y") || EQUALN(papszTokens[i], "lat", 3) || EQUALN(papszTokens[i], "north", 5)) nYIndex = i; else if (EQUAL(papszTokens[i], "z") || EQUALN(papszTokens[i], "alt", 3) || EQUAL(papszTokens[i], "height")) nZIndex = i; } CSLDestroy(papszTokens); papszTokens = NULL; if (nXIndex < 0 || nYIndex < 0 || nZIndex < 0) { CPLError(CE_Warning, CPLE_AppDefined, "Could not find one of the X, Y or Z column names in header line. Defaulting to the first 3 columns"); nXIndex = 0; nYIndex = 1; nZIndex = 2; } nMinTokens = 1 + MAX(MAX(nXIndex, nYIndex), nZIndex); } else { nXIndex = 0; nYIndex = 1; nZIndex = 2; nMinTokens = 3; } //.........这里部分代码省略.........
开发者ID:samalone,项目名称:gdal-ios,代码行数:101,
示例17: strstr//.........这里部分代码省略......... } /* -------------------------------------------------------------------- *//* Create band information objects. *//* -------------------------------------------------------------------- */ int i; poDS->nBands = nBands;; for( i = 0; i < poDS->nBands; i++ ) { RawRasterBand *poBand; poBand = new RawRasterBand( poDS, i+1, poDS->fpImage, nSkipBytes + nBandOffset * i, nPixelOffset, nLineOffset, eDataType,#ifdef CPL_LSB chByteOrder == 'I' || chByteOrder == 'L',#else chByteOrder == 'M',#endif TRUE ); if( bNoDataSet ) poBand->SetNoDataValue( dfNoData ); poDS->SetBand( i+1, poBand ); // Set offset/scale values at the PAM level. poBand->SetOffset( CPLAtofM(poDS->GetKeyword("QUBE.CORE_BASE","0.0"))); poBand->SetScale( CPLAtofM(poDS->GetKeyword("QUBE.CORE_MULTIPLIER","1.0"))); }/* -------------------------------------------------------------------- *//* Check for a .prj file. For isis2 I would like to keep this in *//* -------------------------------------------------------------------- */ CPLString osPath, osName; osPath = CPLGetPath( poOpenInfo->pszFilename ); osName = CPLGetBasename(poOpenInfo->pszFilename); const char *pszPrjFile = CPLFormCIFilename( osPath, osName, "prj" ); fp = VSIFOpen( pszPrjFile, "r" ); if( fp != NULL ) { char **papszLines; OGRSpatialReference oSRS; VSIFClose( fp ); papszLines = CSLLoad( pszPrjFile ); if( oSRS.importFromESRI( papszLines ) == OGRERR_NONE ) { char *pszResult = NULL; oSRS.exportToWkt( &pszResult ); poDS->osProjection = pszResult; CPLFree( pszResult ); } CSLDestroy( papszLines ); } if( dfULYMap != 0.5 || dfULYMap != 0.5 || dfXDim != 1.0 || dfYDim != 1.0 ) { poDS->bGotTransform = TRUE; poDS->adfGeoTransform[0] = dfULXMap; poDS->adfGeoTransform[1] = dfXDim; poDS->adfGeoTransform[2] = 0.0; poDS->adfGeoTransform[3] = dfULYMap; poDS->adfGeoTransform[4] = 0.0; poDS->adfGeoTransform[5] = dfYDim; } if( !poDS->bGotTransform ) poDS->bGotTransform = GDALReadWorldFile( poOpenInfo->pszFilename, "cbw", poDS->adfGeoTransform ); if( !poDS->bGotTransform ) poDS->bGotTransform = GDALReadWorldFile( poOpenInfo->pszFilename, "wld", poDS->adfGeoTransform );/* -------------------------------------------------------------------- */ /* Initialize any PAM information. */ /* -------------------------------------------------------------------- */ poDS->SetDescription( poOpenInfo->pszFilename ); poDS->TryLoadXML(); /* -------------------------------------------------------------------- *//* Check for overviews. *//* -------------------------------------------------------------------- */ poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); return( poDS );}
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,
示例18: ProxyMain//.........这里部分代码省略......... && GDALGetRasterCount(hDataset) == 0) { fprintf(stderr, "Input file contains subdatasets. Please, select one of them for reading./n"); GDALClose(hDataset); GDALDestroyDriverManager(); exit(1); } if (CSLCount(GDALGetMetadata(hDataset, "SUBDATASETS")) > 0 && bCopySubDatasets) { char **papszSubdatasets = GDALGetMetadata(hDataset, "SUBDATASETS"); char *pszSubDest = (char*) CPLMalloc(strlen(pszDest) + 32); int i; int bOldSubCall = bSubCall; char **papszDupArgv = CSLDuplicate(argv); int nRet = 0; CPLFree(papszDupArgv[iDstFileArg]); papszDupArgv[iDstFileArg] = pszSubDest; bSubCall = TRUE; for (i = 0; papszSubdatasets[i] != NULL; i += 2) { CPLFree(papszDupArgv[iSrcFileArg]); papszDupArgv[iSrcFileArg] = CPLStrdup(strstr(papszSubdatasets[i], "=") + 1); sprintf(pszSubDest, "%s%d", pszDest, i / 2 + 1); nRet = ProxyMain(argc, papszDupArgv); if (nRet != 0) break; } CSLDestroy(papszDupArgv); bSubCall = bOldSubCall; CSLDestroy(argv); GDALClose(hDataset); if (!bSubCall) { GDALDumpOpenDatasets(stderr); GDALDestroyDriverManager(); } return nRet; }/* -------------------------------------------------------------------- *//* Collect some information from the source file. *//* -------------------------------------------------------------------- */ nRasterXSize = GDALGetRasterXSize(hDataset); nRasterYSize = GDALGetRasterYSize(hDataset); if (!bQuiet) printf("Input file size is %d, %d/n", nRasterXSize, nRasterYSize); if (anSrcWin[2] == 0 && anSrcWin[3] == 0) { anSrcWin[2] = nRasterXSize; anSrcWin[3] = nRasterYSize; }/* -------------------------------------------------------------------- *//* Build band list to translate */
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:67,
示例19: mainint main( int argc, char ** argv ) { int i; int bGotSRS = FALSE; int bPretty = FALSE; int bValidate = FALSE; int bFindEPSG = FALSE; int nEPSGCode = -1; const char *pszInput = NULL; const char *pszOutputType = "default"; OGRSpatialReference oSRS; /* Check strict compilation and runtime library version as we use C++ API */ if (! GDAL_CHECK_VERSION(argv[0])) exit(1); EarlySetConfigOptions(argc, argv);/* -------------------------------------------------------------------- *//* Register standard GDAL and OGR drivers. *//* -------------------------------------------------------------------- */ GDALAllRegister();#ifdef OGR_ENABLED OGRRegisterAll();#endif/* -------------------------------------------------------------------- *//* Register standard GDAL drivers, and process generic GDAL *//* command options. *//* -------------------------------------------------------------------- */ argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 ); if( argc < 1 ) exit( -argc );/* -------------------------------------------------------------------- *//* Parse arguments. *//* -------------------------------------------------------------------- */ for( i = 1; i < argc; i++ ) { CPLDebug( "gdalsrsinfo", "got arg #%d : [%s]", i, argv[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], "-h") || EQUAL(argv[i], "--help") ) Usage(); else if( EQUAL(argv[i], "-e") ) bFindEPSG = TRUE; else if( EQUAL(argv[i], "-o") ) { CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1); pszOutputType = argv[++i]; } else if( EQUAL(argv[i], "-p") ) bPretty = TRUE; else if( EQUAL(argv[i], "-V") ) bValidate = TRUE; else if( argv[i][0] == '-' ) { Usage(CPLSPrintf("Unknown option name '%s'", argv[i])); } else pszInput = argv[i]; } if ( pszInput == NULL ) { CSLDestroy( argv ); Usage("No input specified."); } /* Search for SRS */ bGotSRS = FindSRS( pszInput, oSRS ); CPLDebug( "gdalsrsinfo", "bGotSRS: %d bValidate: %d pszOutputType: %s bPretty: %d", bGotSRS, bValidate, pszOutputType, bPretty ); /* Make sure we got a SRS */ if ( ! bGotSRS ) { CPLError( CE_Failure, CPLE_AppDefined, "ERROR - failed to load SRS definition from %s", pszInput ); } else { /* Find EPSG code - experimental */ if ( EQUAL(pszOutputType,"epsg") ) bFindEPSG = TRUE; if ( bFindEPSG ) { CPLError( CE_Warning, CPLE_AppDefined, "EPSG detection is experimental and requires new data files (see bug #4345)" ); nEPSGCode = FindEPSG( oSRS ); /* If found, replace oSRS based on EPSG code */ if(nEPSGCode != -1) {//.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,
示例20: CPLSerializeXMLTree//.........这里部分代码省略......... } } // UserPwd const char *pszUserPwd = CPLGetXMLValue(config, "UserPwd", ""); if (pszUserPwd[0] != '/0') m_osUserPwd = pszUserPwd; const char *pszUserAgent = CPLGetXMLValue(config, "UserAgent", ""); if (pszUserAgent[0] != '/0') m_osUserAgent = pszUserAgent; const char *pszReferer = CPLGetXMLValue(config, "Referer", ""); if (pszReferer[0] != '/0') m_osReferer = pszReferer; if (ret == CE_None) { const char *pszHttpZeroBlockCodes = CPLGetXMLValue(config, "ZeroBlockHttpCodes", ""); if(pszHttpZeroBlockCodes == '/0') { m_http_zeroblock_codes.push_back(204); } else { char **kv = CSLTokenizeString2(pszHttpZeroBlockCodes,",",CSLT_HONOURSTRINGS); int nCount = CSLCount(kv); for(int i=0; i<nCount; i++) { int code = atoi(kv[i]); if(code <= 0) { CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS: Invalid value of ZeroBlockHttpCodes /"%s/", comma separated HTTP response codes expected.", kv[i]); ret = CE_Failure; break; } m_http_zeroblock_codes.push_back(code); } CSLDestroy(kv); } } if (ret == CE_None) { const char *pszZeroExceptions = CPLGetXMLValue(config, "ZeroBlockOnServerException", ""); if(pszZeroExceptions[0] != '/0') { m_zeroblock_on_serverexceptions = StrToBool(pszZeroExceptions); if (m_zeroblock_on_serverexceptions == -1) { CPLError(CE_Failure, CPLE_AppDefined, "GDALWMS: Invalid value of ZeroBlockOnServerException /"%s/", true/false expected.", pszZeroExceptions); ret = CE_Failure; } } } if (ret == CE_None) { const char *max_conn = CPLGetXMLValue(config, "MaxConnections", ""); if (max_conn[0] != '/0') { m_http_max_conn = atoi(max_conn); } else { m_http_max_conn = 2; } } if (ret == CE_None) { const char *timeout = CPLGetXMLValue(config, "Timeout", ""); if (timeout[0] != '/0') { m_http_timeout = atoi(timeout); } else { m_http_timeout = 300; } } if (ret == CE_None) {
开发者ID:imincik,项目名称:pkg-gdal,代码行数:67,
示例21: main//.........这里部分代码省略......... if (pszWkt && pszWkt[0]) { hSRS = OSRNewSpatialReference(pszWkt); } if (pszLayerName == NULL) pszLayerName = CPLStrdup(CPLGetBasename(pszDstFilename)); hOGRLayer = OGR_DS_CreateLayer( hOGRDS, pszLayerName, hSRS, eType, NULL); if (hSRS) OSRDestroySpatialReference(hSRS); if (hOGRLayer == NULL) { fprintf(stderr, "Can't create layer %s/n", pszLayerName); exit(1); } if (eType != wkbPoint25D) { OGRFieldDefnH hFieldDefn = OGR_Fld_Create( "z", OFTReal ); OGR_L_CreateField(hOGRLayer, hFieldDefn, 0); OGR_Fld_Destroy( hFieldDefn ); } } padfBuffer = (double*)CPLMalloc(nXSize * sizeof(double));#define GET_X(j, i) adfGeotransform[0] + (j) * adfGeotransform[1] + (i) * adfGeotransform[2]#define GET_Y(j, i) adfGeotransform[3] + (j) * adfGeotransform[4] + (i) * adfGeotransform[5]#define GET_XY(j, i) GET_X(j, i), GET_Y(j, i)/* -------------------------------------------------------------------- *//* "Translate" the source dataset *//* -------------------------------------------------------------------- */ for(i=0;i<nYSize;i+=yStep) { GDALRasterIO( hBand, GF_Read, 0, i, nXSize, 1, padfBuffer, nXSize, 1, GDT_Float64, 0, 0); for(j=0;j<nXSize;j+=xStep) { if (fOut) { fprintf(fOut, "%f,%f,%f/n", GET_XY(j + .5, i + .5), padfBuffer[j]); } else { OGRFeatureH hFeature = OGR_F_Create(OGR_L_GetLayerDefn(hOGRLayer)); OGRGeometryH hGeometry = OGR_G_CreateGeometry(eType); if (eType == wkbPoint25D) { OGR_G_SetPoint(hGeometry, 0, GET_XY(j + .5, i + .5), padfBuffer[j]); } else if (eType == wkbPoint) { OGR_G_SetPoint_2D(hGeometry, 0, GET_XY(j + .5, i + .5)); OGR_F_SetFieldDouble(hFeature, 0, padfBuffer[j]); } else { OGRGeometryH hLinearRing = OGR_G_CreateGeometry(wkbLinearRing); OGR_G_SetPoint_2D(hLinearRing, 0, GET_XY(j + 0, i + 0)); OGR_G_SetPoint_2D(hLinearRing, 1, GET_XY(j + 1, i + 0)); OGR_G_SetPoint_2D(hLinearRing, 2, GET_XY(j + 1, i + 1)); OGR_G_SetPoint_2D(hLinearRing, 3, GET_XY(j + 0, i + 1)); OGR_G_SetPoint_2D(hLinearRing, 4, GET_XY(j + 0, i + 0)); OGR_G_AddGeometryDirectly(hGeometry, hLinearRing); OGR_F_SetFieldDouble(hFeature, 0, padfBuffer[j]); } OGR_F_SetGeometryDirectly(hFeature, hGeometry); OGR_L_CreateFeature(hOGRLayer, hFeature); OGR_F_Destroy(hFeature); } } }/* -------------------------------------------------------------------- *//* Cleanup *//* -------------------------------------------------------------------- */ if (fOut) fclose(fOut); else OGR_DS_Destroy(hOGRDS); GDALClose(hDS); CPLFree(padfBuffer); CPLFree(pszLayerName); GDALDumpOpenDatasets( stderr ); GDALDestroyDriverManager(); OGRCleanupAll(); CSLDestroy( argv ); return 0;}
开发者ID:MattLatt,项目名称:GDAL_2.0.x_VC,代码行数:101,
示例22: MAIN_STARTMAIN_START(argc, argv){ /* Check strict compilation and runtime library version as we use C++ API */ if (! GDAL_CHECK_VERSION(argv[0])) exit(1); EarlySetConfigOptions(argc, argv);/* -------------------------------------------------------------------- *//* Register standard GDAL drivers, and process generic GDAL *//* command options. *//* -------------------------------------------------------------------- */ GDALAllRegister(); argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 ); if( argc < 1 ) exit( -argc ); for( int i = 0; argv != nullptr && argv[i] != nullptr; 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")); CSLDestroy( argv ); return 0; } else if( EQUAL(argv[i],"--help") ) { Usage(nullptr); } else if ( EQUAL(argv[i], "--long-usage") ) { Usage(nullptr, FALSE); } }/* -------------------------------------------------------------------- *//* Set optimal setting for best performance with huge input VRT. *//* The rationale for 450 is that typical Linux process allow *//* only 1024 file descriptors per process and we need to keep some *//* spare for shared libraries, etc. so let's go down to 900. *//* And some datasets may need 2 file descriptors, so divide by 2 *//* for security. *//* -------------------------------------------------------------------- */ if( CPLGetConfigOption("GDAL_MAX_DATASET_POOL_SIZE", nullptr) == nullptr ) {#if defined(__MACH__) && defined(__APPLE__) // On Mach, the default limit is 256 files per process // TODO We should eventually dynamically query the limit for all OS CPLSetConfigOption("GDAL_MAX_DATASET_POOL_SIZE", "100");#else CPLSetConfigOption("GDAL_MAX_DATASET_POOL_SIZE", "450");#endif } GDALTranslateOptionsForBinary* psOptionsForBinary = GDALTranslateOptionsForBinaryNew(); GDALTranslateOptions *psOptions = GDALTranslateOptionsNew(argv + 1, psOptionsForBinary); CSLDestroy( argv ); if( psOptions == nullptr ) { Usage(nullptr); } if( psOptionsForBinary->pszSource == nullptr ) { Usage("No source dataset specified."); } if( psOptionsForBinary->pszDest == nullptr ) { Usage("No target dataset specified."); } if( strcmp(psOptionsForBinary->pszDest, "/vsistdout/") == 0 ) { psOptionsForBinary->bQuiet = TRUE; } if( !(psOptionsForBinary->bQuiet) ) { GDALTranslateOptionsSetProgress(psOptions, GDALTermProgress, nullptr); } if( psOptionsForBinary->pszFormat ) { GDALDriverH hDriver = GDALGetDriverByName( psOptionsForBinary->pszFormat ); if( hDriver == nullptr ) { fprintf(stderr, "Output driver `%s' not recognised./n", psOptionsForBinary->pszFormat); fprintf(stderr, "The following format drivers are configured and support output:/n" ); for( int iDr = 0; iDr < GDALGetDriverCount(); iDr++ ) { hDriver = GDALGetDriver(iDr); if( GDALGetMetadataItem( hDriver, GDAL_DCAP_RASTER, nullptr) != nullptr && (GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATE, nullptr ) != nullptr || GDALGetMetadataItem( hDriver, GDAL_DCAP_CREATECOPY, nullptr ) != nullptr) )//.........这里部分代码省略.........
开发者ID:AsgerPetersen,项目名称:gdal,代码行数:101,
示例23: CPLGetConfigOption//.........这里部分代码省略......... } if( fp == NULL ) return;/* -------------------------------------------------------------------- *//* Skip first line, with the column titles. *//* -------------------------------------------------------------------- */ CPLReadLine( fp );/* -------------------------------------------------------------------- *//* Create a RAT to populate. *//* -------------------------------------------------------------------- */ GDALRasterAttributeTable *poRAT = new GDALDefaultRasterAttributeTable(); poRAT->CreateColumn( "FROM", GFT_Integer, GFU_Min ); poRAT->CreateColumn( "TO", GFT_Integer, GFU_Max ); poRAT->CreateColumn( "RED", GFT_Integer, GFU_Red ); poRAT->CreateColumn( "GREEN", GFT_Integer, GFU_Green ); poRAT->CreateColumn( "BLUE", GFT_Integer, GFU_Blue ); poRAT->CreateColumn( "LEGEND", GFT_String, GFU_Name );/* -------------------------------------------------------------------- *//* Apply lines. *//* -------------------------------------------------------------------- */ const char *pszLine = CPLReadLine( fp ); int iRow = 0; while( pszLine != NULL ) { char **papszTokens = CSLTokenizeStringComplex( pszLine, " /t", FALSE, FALSE ); if( CSLCount( papszTokens ) >= 5 ) { poRAT->SetValue( iRow, 0, atoi(papszTokens[0]) ); poRAT->SetValue( iRow, 1, atoi(papszTokens[1]) ); poRAT->SetValue( iRow, 2, atoi(papszTokens[2]) ); poRAT->SetValue( iRow, 3, atoi(papszTokens[3]) ); poRAT->SetValue( iRow, 4, atoi(papszTokens[4]) ); // find name, first nonspace after 5th token. const char *pszName = pszLine; // skip from while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip to while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip red while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip green while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip blue while( *pszName == ' ' || *pszName == '/t' ) pszName++; while( *pszName != ' ' && *pszName != '/t' && *pszName != '/0' ) pszName++; // skip pre-name white space while( *pszName == ' ' || *pszName == '/t' ) pszName++; poRAT->SetValue( iRow, 5, pszName ); iRow++; } CSLDestroy( papszTokens ); pszLine = CPLReadLine( fp ); } VSIFClose( fp );/* -------------------------------------------------------------------- *//* Attach RAT to band. *//* -------------------------------------------------------------------- */ ((IDARasterBand *) GetRasterBand( 1 ))->poRAT = poRAT;/* -------------------------------------------------------------------- *//* Build a conventional color table from this. *//* -------------------------------------------------------------------- */ ((IDARasterBand *) GetRasterBand( 1 ))->poColorTable = poRAT->TranslateToColorTable();}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,
示例24: TABAdjustCaseSensitiveFilename// Unix case.static bool TABAdjustCaseSensitiveFilename(char *pszFname){ VSIStatBufL sStatBuf; // First check if the filename is OK as is. if (VSIStatL(pszFname, &sStatBuf) == 0) { return true; } // File either does not exist or has the wrong cases. // Go backwards until we find a portion of the path that is valid. char *pszTmpPath = CPLStrdup(pszFname); const int nTotalLen = static_cast<int>(strlen(pszTmpPath)); int iTmpPtr = nTotalLen; GBool bValidPath = false; while(iTmpPtr > 0 && !bValidPath) { // Move back to the previous '/' separator. pszTmpPath[--iTmpPtr] = '/0'; while( iTmpPtr > 0 && pszTmpPath[iTmpPtr-1] != '/' ) { pszTmpPath[--iTmpPtr] = '/0'; } if (iTmpPtr > 0 && VSIStatL(pszTmpPath, &sStatBuf) == 0) bValidPath = true; } CPLAssert(iTmpPtr >= 0); // Assume that CWD is valid. Therefor an empty path is a valid. if (iTmpPtr == 0) bValidPath = true; // Now that we have a valid base, reconstruct the whole path // by scanning all the sub-directories. // If we get to a point where a path component does not exist then // we simply return the rest of the path as is. while(bValidPath && (int)strlen(pszTmpPath) < nTotalLen) { int iLastPartStart = iTmpPtr; char **papszDir = VSIReadDir(pszTmpPath); // Add one component to the current path. pszTmpPath[iTmpPtr] = pszFname[iTmpPtr]; iTmpPtr++; for( ; pszFname[iTmpPtr] != '/0' && pszFname[iTmpPtr]!='/'; iTmpPtr++) { pszTmpPath[iTmpPtr] = pszFname[iTmpPtr]; } while(iLastPartStart < iTmpPtr && pszTmpPath[iLastPartStart] == '/') iLastPartStart++; // And do a case insensitive search in the current dir. for(int iEntry = 0; papszDir && papszDir[iEntry]; iEntry++) { if (EQUAL(pszTmpPath + iLastPartStart, papszDir[iEntry])) { // Fount it. strcpy(pszTmpPath+iLastPartStart, papszDir[iEntry]); break; } } if (iTmpPtr > 0 && VSIStatL(pszTmpPath, &sStatBuf) != 0) bValidPath = false; CSLDestroy(papszDir); } // We reached the last valid path component... just copy the rest // of the path as is. if (iTmpPtr < nTotalLen-1) { strncpy(pszTmpPath+iTmpPtr, pszFname+iTmpPtr, nTotalLen-iTmpPtr); } // Update the source buffer and return. strcpy(pszFname, pszTmpPath); CPLFree(pszTmpPath); return bValidPath;}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:87,
示例25: CPLGetConfigOptionint VSICurlStreamingHandle::Exists(){ if (eExists == EXIST_UNKNOWN) { /* Consider that only the files whose extension ends up with one that is */ /* listed in CPL_VSIL_CURL_ALLOWED_EXTENSIONS exist on the server */ /* This can speeds up dramatically open experience, in case the server */ /* cannot return a file list */ /* For example : */ /* gdalinfo --config CPL_VSIL_CURL_ALLOWED_EXTENSIONS ".tif" /vsicurl_streaming/http://igskmncngs506.cr.usgs.gov/gmted/Global_tiles_GMTED/075darcsec/bln/W030/30N030W_20101117_gmted_bln075.tif */ const char* pszAllowedExtensions = CPLGetConfigOption("CPL_VSIL_CURL_ALLOWED_EXTENSIONS", NULL); if (pszAllowedExtensions) { char** papszExtensions = CSLTokenizeString2( pszAllowedExtensions, ", ", 0 ); int nURLLen = strlen(pszURL); int bFound = FALSE; for(int i=0;papszExtensions[i] != NULL;i++) { int nExtensionLen = strlen(papszExtensions[i]); if (nURLLen > nExtensionLen && EQUAL(pszURL + nURLLen - nExtensionLen, papszExtensions[i])) { bFound = TRUE; break; } } if (!bFound) { eExists = EXIST_NO; fileSize = 0; poFS->AcquireMutex(); CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(pszURL); cachedFileProp->bHastComputedFileSize = TRUE; cachedFileProp->fileSize = fileSize; cachedFileProp->eExists = eExists; poFS->ReleaseMutex(); CSLDestroy(papszExtensions); return 0; } CSLDestroy(papszExtensions); } char chFirstByte; int bExists = (Read(&chFirstByte, 1, 1) == 1); AcquireMutex(); poFS->AcquireMutex(); CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(pszURL); cachedFileProp->eExists = eExists = bExists ? EXIST_YES : EXIST_NO; poFS->ReleaseMutex(); ReleaseMutex(); Seek(0, SEEK_SET); } return eExists == EXIST_YES;}
开发者ID:0004c,项目名称:node-gdal,代码行数:63,
示例26: CSLDestroyCPLKeywordParser::~CPLKeywordParser(){ CSLDestroy( papszKeywordList ); papszKeywordList = NULL;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:6,
示例27: CPLStrdupint OGRGFTDataSource::Open( const char * pszFilename, int bUpdateIn){ bReadWrite = bUpdateIn; pszName = CPLStrdup( pszFilename ); osAuth = OGRGFTGetOptionValue(pszFilename, "auth"); if (osAuth.empty()) osAuth = CPLGetConfigOption("GFT_AUTH", ""); osRefreshToken = OGRGFTGetOptionValue(pszFilename, "refresh"); if (osRefreshToken.empty()) osRefreshToken = CPLGetConfigOption("GFT_REFRESH_TOKEN", ""); osAPIKey = CPLGetConfigOption("GFT_APIKEY", GDAL_API_KEY); CPLString osTables = OGRGFTGetOptionValue(pszFilename, "tables"); bUseHTTPS = TRUE; osAccessToken = OGRGFTGetOptionValue(pszFilename, "access"); if (osAccessToken.empty()) osAccessToken = CPLGetConfigOption("GFT_ACCESS_TOKEN",""); if (osAccessToken.empty() && !osRefreshToken.empty()) { osAccessToken.Seize(GOA2GetAccessToken(osRefreshToken, FUSION_TABLE_SCOPE)); if (osAccessToken.empty()) return FALSE; } /* coverity[copy_paste_error] */ if (osAccessToken.empty() && !osAuth.empty()) { osRefreshToken.Seize(GOA2GetRefreshToken(osAuth, FUSION_TABLE_SCOPE)); if (osRefreshToken.empty()) return FALSE; } if (osAccessToken.empty()) { if (osTables.empty()) { CPLError(CE_Failure, CPLE_AppDefined, "Unauthenticated access requires explicit tables= parameter"); return FALSE; } } if (!osTables.empty()) { char** papszTables = CSLTokenizeString2(osTables, ",", 0); for(int i=0;papszTables && papszTables[i];i++) { papoLayers = (OGRLayer**) CPLRealloc(papoLayers, (nLayers + 1) * sizeof(OGRLayer*)); papoLayers[nLayers ++] = new OGRGFTTableLayer(this, papszTables[i], papszTables[i]); } CSLDestroy(papszTables); return TRUE; } /* Get list of tables */ CPLHTTPResult * psResult = RunSQL("SHOW TABLES"); if (psResult == nullptr) return FALSE; char* pszLine = (char*) psResult->pabyData; if (pszLine == nullptr || psResult->pszErrBuf != nullptr || !STARTS_WITH(pszLine, "table id,name")) { CPLHTTPDestroyResult(psResult); return FALSE; } pszLine = OGRGFTGotoNextLine(pszLine); while(pszLine != nullptr && *pszLine != 0) { char* pszNextLine = OGRGFTGotoNextLine(pszLine); if (pszNextLine) pszNextLine[-1] = 0; char** papszTokens = CSLTokenizeString2(pszLine, ",", 0); if (CSLCount(papszTokens) == 2) { CPLString osTableId(papszTokens[0]); CPLString osLayerName(papszTokens[1]); for(int i=0;i<nLayers;i++) { if (strcmp(papoLayers[i]->GetName(), osLayerName) == 0) { osLayerName += " ("; osLayerName += osTableId; osLayerName += ")"; break; } } papoLayers = (OGRLayer**) CPLRealloc(papoLayers, (nLayers + 1) * sizeof(OGRLayer*)); papoLayers[nLayers ++] = new OGRGFTTableLayer(this, osLayerName, osTableId);//.........这里部分代码省略.........
开发者ID:OSGeo,项目名称:gdal,代码行数:101,
示例28: strlenGDALDataset *HDF5ImageDataset::Open( GDALOpenInfo * poOpenInfo ){ int i; HDF5ImageDataset *poDS; char szFilename[2048]; if(!EQUALN( poOpenInfo->pszFilename, "HDF5:", 5 ) || strlen(poOpenInfo->pszFilename) > sizeof(szFilename) - 3 ) return NULL;/* -------------------------------------------------------------------- *//* Confirm the requested access is supported. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_Update ) { CPLError( CE_Failure, CPLE_NotSupported, "The HDF5ImageDataset driver does not support update access to existing" " datasets./n" ); return NULL; } poDS = new HDF5ImageDataset(); /* -------------------------------------------------------------------- */ /* Create a corresponding GDALDataset. */ /* -------------------------------------------------------------------- */ /* printf("poOpenInfo->pszFilename %s/n",poOpenInfo->pszFilename); */ char **papszName = CSLTokenizeString2( poOpenInfo->pszFilename, ":", CSLT_HONOURSTRINGS|CSLT_PRESERVEESCAPES ); if( !((CSLCount(papszName) == 3) || (CSLCount(papszName) == 4)) ) { CSLDestroy(papszName); delete poDS; return NULL; } poDS->SetDescription( poOpenInfo->pszFilename ); /* -------------------------------------------------------------------- */ /* Check for drive name in windows HDF5:"D:/... */ /* -------------------------------------------------------------------- */ strcpy(szFilename, papszName[1]); if( strlen(papszName[1]) == 1 && papszName[3] != NULL ) { strcat(szFilename, ":"); strcat(szFilename, papszName[2]); poDS->SetSubdatasetName( papszName[3] ); } else poDS->SetSubdatasetName( papszName[2] ); CSLDestroy(papszName); papszName = NULL; if( !H5Fis_hdf5(szFilename) ) { delete poDS; return NULL; } poDS->SetPhysicalFilename( szFilename ); /* -------------------------------------------------------------------- */ /* Try opening the dataset. */ /* -------------------------------------------------------------------- */ poDS->hHDF5 = H5Fopen(szFilename, H5F_ACC_RDONLY, H5P_DEFAULT ); if( poDS->hHDF5 < 0 ) { delete poDS; return NULL; } poDS->hGroupID = H5Gopen( poDS->hHDF5, "/" ); if( poDS->hGroupID < 0 ) { poDS->bIsHDFEOS=false; delete poDS; return NULL; }/* -------------------------------------------------------------------- *//* THIS IS AN HDF5 FILE *//* -------------------------------------------------------------------- */ poDS->bIsHDFEOS=TRUE; poDS->ReadGlobalAttributes( FALSE );/* -------------------------------------------------------------------- *//* Create HDF5 Data Hierarchy in a link list *//* -------------------------------------------------------------------- */ poDS->poH5Objects = poDS->HDF5FindDatasetObjectsbyPath( poDS->poH5RootGroup, (char *)poDS->GetSubdatasetName() ); if( poDS->poH5Objects == NULL ) {//.........这里部分代码省略.........
开发者ID:TUW-GEO,项目名称:OGRSpatialRef3D,代码行数:101,
示例29: VALIDATE_POINTER1CPLXMLNode *GDALSerializeRPCTransformer( void *pTransformArg ){ VALIDATE_POINTER1( pTransformArg, "GDALSerializeRPCTransformer", NULL ); CPLXMLNode *psTree; GDALRPCTransformInfo *psInfo = (GDALRPCTransformInfo *)(pTransformArg); psTree = CPLCreateXMLNode( NULL, CXT_Element, "RPCTransformer" );/* -------------------------------------------------------------------- *//* Serialize bReversed. *//* -------------------------------------------------------------------- */ CPLCreateXMLElementAndValue( psTree, "Reversed", CPLString().Printf( "%d", psInfo->bReversed ) );/* -------------------------------------------------------------------- *//* Serialize Height Offset. *//* -------------------------------------------------------------------- */ CPLCreateXMLElementAndValue( psTree, "HeightOffset", CPLString().Printf( "%.15g", psInfo->dfHeightOffset ) );/* -------------------------------------------------------------------- *//* Serialize Height Scale. *//* -------------------------------------------------------------------- */ if (psInfo->dfHeightScale != 1.0) CPLCreateXMLElementAndValue( psTree, "HeightScale", CPLString().Printf( "%.15g", psInfo->dfHeightScale ) );/* -------------------------------------------------------------------- *//* Serialize DEM path. *//* -------------------------------------------------------------------- */ if (psInfo->pszDEMPath != NULL) CPLCreateXMLElementAndValue( psTree, "DEMPath", CPLString().Printf( "%s", psInfo->pszDEMPath ) );/* -------------------------------------------------------------------- *//* Serialize DEM interpolation *//* -------------------------------------------------------------------- */ CPLString soDEMInterpolation; switch(psInfo->eResampleAlg) { case DRA_NearestNeighbour: soDEMInterpolation = "near"; break; case DRA_Cubic: soDEMInterpolation = "cubic"; break; default: case DRA_Bilinear: soDEMInterpolation = "bilinear"; } CPLCreateXMLElementAndValue( psTree, "DEMInterpolation", soDEMInterpolation );/* -------------------------------------------------------------------- *//* Serialize pixel error threshold. *//* -------------------------------------------------------------------- */ CPLCreateXMLElementAndValue( psTree, "PixErrThreshold", CPLString().Printf( "%.15g", psInfo->dfPixErrThreshold ) );/* -------------------------------------------------------------------- *//* RPC metadata. *//* -------------------------------------------------------------------- */ char **papszMD = RPCInfoToMD( &(psInfo->sRPC) ); CPLXMLNode *psMD= CPLCreateXMLNode( psTree, CXT_Element, "Metadata" ); for( int i = 0; papszMD != NULL && papszMD[i] != NULL; i++ ) { const char *pszRawValue; char *pszKey; CPLXMLNode *psMDI; pszRawValue = CPLParseNameValue( papszMD[i], &pszKey ); psMDI = CPLCreateXMLNode( psMD, CXT_Element, "MDI" ); CPLSetXMLValue( psMDI, "#key", pszKey ); CPLCreateXMLNode( psMDI, CXT_Text, pszRawValue ); CPLFree( pszKey ); } CSLDestroy( papszMD ); return psTree;}
开发者ID:afarnham,项目名称:gdal,代码行数:93,
示例30: GDALComputeProximity//.........这里部分代码省略......... fNoDataValue = (float) GDALGetRasterNoDataValue( hProximityBand, &bSuccess ); if( !bSuccess ) fNoDataValue = 65535.0; } /* -------------------------------------------------------------------- *//* Is there a fixed value we wish to force the buffer area to? *//* -------------------------------------------------------------------- */ pszOpt = CSLFetchNameValue( papszOptions, "FIXED_BUF_VAL" ); if( pszOpt ) { dfFixedBufVal = CPLAtof(pszOpt); bFixedBufVal = TRUE; }/* -------------------------------------------------------------------- *//* Get the target value(s). *//* -------------------------------------------------------------------- */ int *panTargetValues = NULL; int nTargetValues = 0; pszOpt = CSLFetchNameValue( papszOptions, "VALUES" ); if( pszOpt != NULL ) { char **papszValuesTokens; papszValuesTokens = CSLTokenizeStringComplex( pszOpt, ",", FALSE,FALSE); nTargetValues = CSLCount(papszValuesTokens); panTargetValues = (int *) CPLCalloc(sizeof(int),nTargetValues); for( i = 0; i < nTargetValues; i++ ) panTargetValues[i] = atoi(papszValuesTokens[i]); CSLDestroy( papszValuesTokens ); }/* -------------------------------------------------------------------- *//* Initialize progress counter. *//* -------------------------------------------------------------------- */ if( !pfnProgress( 0.0, "", pProgressArg ) ) { CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" ); CPLFree(panTargetValues); return CE_Failure; }/* -------------------------------------------------------------------- *//* We need a signed type for the working proximity values kept *//* on disk. If our proximity band is not signed, then create a *//* temporary file for this purpose. *//* -------------------------------------------------------------------- */ GDALRasterBandH hWorkProximityBand = hProximityBand; GDALDatasetH hWorkProximityDS = NULL; GDALDataType eProxType = GDALGetRasterDataType( hProximityBand ); int *panNearX = NULL, *panNearY = NULL; float *pafProximity = NULL; GInt32 *panSrcScanline = NULL; int iLine; CPLErr eErr = CE_None; if( eProxType == GDT_Byte || eProxType == GDT_UInt16 || eProxType == GDT_UInt32 ) { GDALDriverH hDriver = GDALGetDriverByName("GTiff"); if (hDriver == NULL)
开发者ID:drownedout,项目名称:datamap,代码行数:67,
注:本文中的CSLDestroy函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CSLDuplicate函数代码示例 C++ CSLAddString函数代码示例 |