本文整理汇总了C++中CSLDestroy函数的典型用法代码示例。如果您正苦于以下问题:C++ CSLDestroy函数的具体用法?C++ CSLDestroy怎么用?C++ CSLDestroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CSLDestroy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:ogrcsvdatasource.cpp
示例2: OGR2SQLITE_ogr_geocode_reverse
static
void 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,代码来源:ogrsqlitesqlfunctions.cpp
示例3: CPLGetXMLNode
void *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,代码来源:gdal_rpc.cpp
示例4: CSLTokenizeString2
static 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,代码来源:ogrcaddriver.cpp
示例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,代码来源:testepsg.cpp
示例6: FindSRS
int 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,代码来源:gdalsrsinfo.cpp
示例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,代码来源:ogr_srs_ozi.cpp
示例8: CSLTestBoolean
int 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,代码来源:ogrcartodbdatasource.cpp
示例9: osSQL
json_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,代码来源:ogrcartodbdatasource.cpp
示例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,代码来源:ili1reader.cpp
示例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,代码来源:ili1reader.cpp
示例12: CPLStrdup
int 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,代码来源:ili1reader.cpp
示例13: main
int 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,代码来源:gdal_rasterize.cpp
-
六六分期app的软件客服如何联系?不知道吗?加qq群【895510560】即可!标题:六六分期
阅读:19157|2023-10-27
-
今天小编告诉大家如何处理win10系统火狐flash插件总是崩溃的问题,可能很多用户都不知
阅读:9981|2022-11-06
-
今天小编告诉大家如何对win10系统删除桌面回收站图标进行设置,可能很多用户都不知道
阅读:8320|2022-11-06
-
今天小编告诉大家如何对win10系统电脑设置节能降温的设置方法,想必大家都遇到过需要
阅读:8690|2022-11-06
-
我们在使用xp系统的过程中,经常需要对xp系统无线网络安装向导设置进行设置,可能很多
阅读:8632|2022-11-06
-
今天小编告诉大家如何处理win7系统玩cf老是与主机连接不稳定的问题,可能很多用户都不
阅读:9649|2022-11-06
-
电脑对日常生活的重要性小编就不多说了,可是一旦碰到win7系统设置cf烟雾头的问题,很
阅读:8615|2022-11-06
-
我们在日常使用电脑的时候,有的小伙伴们可能在打开应用的时候会遇见提示应用程序无法
阅读:7994|2022-11-06
-
今天小编告诉大家如何对win7系统打开vcf文件进行设置,可能很多用户都不知道怎么对win
阅读:8647|2022-11-06
-
今天小编告诉大家如何对win10系统s4开启USB调试模式进行设置,可能很多用户都不知道怎
阅读:7530|2022-11-06
|
请发表评论