本文整理汇总了C++中OGRDataSource::ReleaseResultSet方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRDataSource::ReleaseResultSet方法的具体用法?C++ OGRDataSource::ReleaseResultSet怎么用?C++ OGRDataSource::ReleaseResultSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRDataSource
的用法示例。
在下文中一共展示了OGRDataSource::ReleaseResultSet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MyOGRHandler
MyOGRHandler(const std::string& filename) :
m_data_source(NULL),
m_layer_point(NULL),
m_filter(true),
m_tohstore() {
OGRRegisterAll();
OGRSFDriver* driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName("PostgreSQL");
if (driver == NULL) {
std::cerr << "PostgreSQL OGR driver not available.\n";
exit(1);
}
// using COPY is much faster than INSERT
CPLSetConfigOption("PG_USE_COPY", "YES");
const char* options[] = { NULL };
m_data_source = driver->CreateDataSource(filename.c_str(), const_cast<char**>(options));
if (m_data_source == NULL) {
std::cerr << "Database open failed.\n";
exit(1);
}
// OGR can't create a table with hstore column, so we do it ourselves here
OGRLayer* dummy = m_data_source->ExecuteSQL("CREATE TABLE nodes (id VARCHAR, tags hstore);", NULL, NULL);
if (dummy) {
m_data_source->ReleaseResultSet(dummy);
}
dummy = m_data_source->ExecuteSQL("SELECT AddGeometryColumn('nodes', 'geom', 4326, 'POINT', 2);", NULL, NULL);
if (dummy) {
m_data_source->ReleaseResultSet(dummy);
}
m_layer_point = m_data_source->GetLayerByName("nodes");
if (!m_layer_point) {
std::cerr << "Something went wrong setting up the 'nodes' layer.\n";
exit(1);
}
// using transactions makes this much faster than without
m_layer_point->StartTransaction();
m_filter.add(false, "created_by");
m_filter.add(false, "odbl");
}
示例2:
JNIEXPORT void JNICALL Java_es_gva_cit_jogr_OGRDataSource_releaseResultSetNat
(JNIEnv *env, jobject obj, jlong cPtr, jlong ptr_poResultsSet){
OGRDataSource *ds = (OGRDataSource *) 0 ;
OGRLayer *layer = (OGRLayer *) 0 ;
ds = *(OGRDataSource **)&cPtr;
layer = *(OGRLayer **)&ptr_poResultsSet;
if(ds!=NULL ){
ds->ReleaseResultSet(layer);
}
}
示例3: main
//.........这里部分代码省略.........
if( bVerbose )
printf( "INFO: Open of `%s'\n"
" using driver `%s' successful.\n",
pszDataSource, poDriver->GetName() );
if( bVerbose && !EQUAL(pszDataSource,poDS->GetName()) )
{
printf( "INFO: Internal data source name `%s'\n"
" different from user name `%s'.\n",
poDS->GetName(), pszDataSource );
}
/* -------------------------------------------------------------------- */
/* Special case for -sql clause. No source layers required. */
/* -------------------------------------------------------------------- */
if( pszSQLStatement != NULL )
{
OGRLayer *poResultSet = NULL;
nRepeatCount = 0; // skip layer reporting.
if( CSLCount(papszLayers) > 0 )
printf( "layer names ignored in combination with -sql.\n" );
poResultSet = poDS->ExecuteSQL( pszSQLStatement, poSpatialFilter,
pszDialect );
if( poResultSet != NULL )
{
if( pszWHERE != NULL )
poResultSet->SetAttributeFilter( pszWHERE );
ReportOnLayer( poResultSet, NULL, NULL );
poDS->ReleaseResultSet( poResultSet );
}
}
CPLDebug( "OGR", "GetLayerCount() = %d\n", poDS->GetLayerCount() );
for( int iRepeat = 0; iRepeat < nRepeatCount; iRepeat++ )
{
if ( CSLCount(papszLayers) == 0 )
{
/* -------------------------------------------------------------------- */
/* Process each data source layer. */
/* -------------------------------------------------------------------- */
for( int iLayer = 0; iLayer < poDS->GetLayerCount(); iLayer++ )
{
OGRLayer *poLayer = poDS->GetLayer(iLayer);
if( poLayer == NULL )
{
printf( "FAILURE: Couldn't fetch advertised layer %d!\n",
iLayer );
exit( 1 );
}
if (!bAllLayers)
{
printf( "%d: %s",
iLayer+1,
poLayer->GetLayerDefn()->GetName() );
if( poLayer->GetLayerDefn()->GetGeomType() != wkbUnknown )
printf( " (%s)",
OGRGeometryTypeToName(
示例4: LoadGeometry
static OGRGeometryCollection* LoadGeometry( const char* pszDS,
const char* pszSQL,
const char* pszLyr,
const char* pszWhere )
{
OGRDataSource *poDS;
OGRLayer *poLyr;
OGRFeature *poFeat;
OGRGeometryCollection *poGeom = NULL;
poDS = OGRSFDriverRegistrar::Open( pszDS, FALSE );
if ( poDS == NULL )
return NULL;
if ( pszSQL != NULL )
poLyr = poDS->ExecuteSQL( pszSQL, NULL, NULL );
else if ( pszLyr != NULL )
poLyr = poDS->GetLayerByName( pszLyr );
else
poLyr = poDS->GetLayer(0);
if ( poLyr == NULL )
{
fprintf( stderr,
"FAILURE: Failed to identify source layer from datasource.\n" );
OGRDataSource::DestroyDataSource( poDS );
return NULL;
}
if ( pszWhere )
poLyr->SetAttributeFilter( pszWhere );
while ( (poFeat = poLyr->GetNextFeature()) != NULL )
{
OGRGeometry* poSrcGeom = poFeat->GetGeometryRef();
if ( poSrcGeom )
{
OGRwkbGeometryType eType =
wkbFlatten( poSrcGeom->getGeometryType() );
if ( poGeom == NULL )
poGeom = new OGRMultiPolygon();
if ( eType == wkbPolygon )
poGeom->addGeometry( poSrcGeom );
else if ( eType == wkbMultiPolygon )
{
int iGeom;
int nGeomCount =
((OGRMultiPolygon *)poSrcGeom)->getNumGeometries();
for ( iGeom = 0; iGeom < nGeomCount; iGeom++ )
{
poGeom->addGeometry(
((OGRMultiPolygon *)poSrcGeom)->getGeometryRef(iGeom) );
}
}
else
{
fprintf( stderr, "FAILURE: Geometry not of polygon type.\n" );
OGRGeometryFactory::destroyGeometry( poGeom );
OGRFeature::DestroyFeature( poFeat );
if ( pszSQL != NULL )
poDS->ReleaseResultSet( poLyr );
OGRDataSource::DestroyDataSource( poDS );
return NULL;
}
}
OGRFeature::DestroyFeature( poFeat );
}
if( pszSQL != NULL )
poDS->ReleaseResultSet( poLyr );
OGRDataSource::DestroyDataSource( poDS );
return poGeom;
}
示例5:
void OGRDataSourceWithTransaction::ReleaseResultSet( OGRLayer * poResultsSet )
{
if( !m_poBaseDataSource ) return;
m_oSetExecuteSQLLayers.erase(poResultsSet);
m_poBaseDataSource->ReleaseResultSet(poResultsSet);
}
示例6: main
//.........这里部分代码省略.........
for( int iDriver = 0; iDriver < poR->GetDriverCount(); iDriver++ )
{
printf( " -> %s\n", poR->GetDriver(iDriver)->GetName() );
}
exit( 1 );
}
/* -------------------------------------------------------------------- */
/* Some information messages. */
/* -------------------------------------------------------------------- */
if( bVerbose )
printf( "INFO: Open of `%s' using driver `%s' successful.\n",
pszDataSource, poDriver->GetName() );
if( bVerbose && !EQUAL(pszDataSource,poDS->GetName()) )
{
printf( "INFO: Internal data source name `%s'\n"
" different from user name `%s'.\n",
poDS->GetName(), pszDataSource );
}
/* -------------------------------------------------------------------- */
/* Process optionnal SQL request. */
/* -------------------------------------------------------------------- */
if (pszSQLStatement != NULL)
{
OGRLayer *poResultSet = poDS->ExecuteSQL(pszSQLStatement, NULL, NULL);
if (poResultSet == NULL)
exit(1);
printf( "INFO: Testing layer %s.\n",
poResultSet->GetName() );
bRet = TestOGRLayer( poDS, poResultSet, TRUE );
poDS->ReleaseResultSet(poResultSet);
}
/* -------------------------------------------------------------------- */
/* Process each data source layer. */
/* -------------------------------------------------------------------- */
else if (papszLayers == NULL)
{
for( int iLayer = 0; iLayer < poDS->GetLayerCount(); iLayer++ )
{
OGRLayer *poLayer = poDS->GetLayer(iLayer);
if( poLayer == NULL )
{
printf( "FAILURE: Couldn't fetch advertised layer %d!\n",
iLayer );
exit( 1 );
}
printf( "INFO: Testing layer %s.\n",
poLayer->GetName() );
bRet &= TestOGRLayer( poDS, poLayer, FALSE );
}
}
else
{
/* -------------------------------------------------------------------- */
/* Or process layers specified by the user */
/* -------------------------------------------------------------------- */
char** papszLayerIter = papszLayers;
while (*papszLayerIter)
{
OGRLayer *poLayer = poDS->GetLayerByName(*papszLayerIter);
if( poLayer == NULL )
{
printf( "FAILURE: Couldn't fetch requested layer %s!\n",
*papszLayerIter );
exit( 1 );
}
printf( "INFO: Testing layer %s.\n",
poLayer->GetName() );
bRet &= TestOGRLayer( poDS, poLayer, FALSE );
papszLayerIter ++;
}
}
/* -------------------------------------------------------------------- */
/* Close down. */
/* -------------------------------------------------------------------- */
OGRDataSource::DestroyDataSource(poDS);
OGRCleanupAll();
CSLDestroy(papszLayers);
CSLDestroy(papszArgv);
#ifdef DBMALLOC
malloc_dump(1);
#endif
return (bRet) ? 0 : 1;
}