PDFWritableVectorDataset::~PDFWritableVectorDataset() { SyncToDisk(); CSLDestroy(papszOptions); for(int i=0;i<nLayers;i++) delete papoLayers[i]; CPLFree( papoLayers ); }
OGRErr OGRShapeLayer::CreateSpatialIndex( int nMaxDepth ) { /* -------------------------------------------------------------------- */ /* If we have an existing spatial index, blow it away first. */ /* -------------------------------------------------------------------- */ if( CheckForQIX() ) DropSpatialIndex(); bCheckedForQIX = FALSE; /* -------------------------------------------------------------------- */ /* Build a quadtree structure for this file. */ /* -------------------------------------------------------------------- */ SHPTree *psTree; SyncToDisk(); psTree = SHPCreateTree( hSHP, 2, nMaxDepth, NULL, NULL ); if( NULL == psTree ) { // TODO - mloskot: Is it better to return OGRERR_NOT_ENOUGH_MEMORY? CPLDebug( "SHAPE", "Index creation failure. Likely, memory allocation error." ); return OGRERR_FAILURE; } /* -------------------------------------------------------------------- */ /* Trim unused nodes from the tree. */ /* -------------------------------------------------------------------- */ SHPTreeTrimExtraNodes( psTree ); /* -------------------------------------------------------------------- */ /* Dump tree to .qix file. */ /* -------------------------------------------------------------------- */ char *pszQIXFilename; pszQIXFilename = CPLStrdup(CPLResetExtension( pszFullName, "qix" )); CPLDebug( "SHAPE", "Creating index file %s", pszQIXFilename ); SHPWriteTree( psTree, pszQIXFilename ); CPLFree( pszQIXFilename ); /* -------------------------------------------------------------------- */ /* cleanup */ /* -------------------------------------------------------------------- */ SHPDestroyTree( psTree ); CheckForQIX(); return OGRERR_NONE; }
OGRGMELayer::~OGRGMELayer() { SyncToDisk(); ResetReading(); if( poSRS ) poSRS->Release(); if( poFeatureDefn ) poFeatureDefn->Release(); }
OGRErr OGRGMELayer::CommitTransaction() { if (!bInTransaction) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot commit, not in transaction"); return OGRERR_FAILURE; } bInTransaction = FALSE; return SyncToDisk(); }
void OGRShapeLayer::ResetReading() { /* -------------------------------------------------------------------- */ /* Clear previous index search result, if any. */ /* -------------------------------------------------------------------- */ CPLFree( panMatchingFIDs ); panMatchingFIDs = NULL; iMatchingFID = 0; iNextShapeId = 0; if( bHeaderDirty && bUpdateAccess ) SyncToDisk(); }
/********************************************************************** * TABIDFile::Close() * * Close current file, and release all memory used. * * Returns 0 on success, -1 on error. **********************************************************************/ int TABIDFile::Close() { if (m_fp == NULL) return 0; /*---------------------------------------------------------------- * Write access: commit latest changes to the file. *---------------------------------------------------------------*/ if (m_eAccessMode != TABRead) SyncToDisk(); // Delete all structures delete m_poIDBlock; m_poIDBlock = NULL; // Close file VSIFCloseL(m_fp); m_fp = NULL; CPLFree(m_pszFname); m_pszFname = NULL; return 0; }
OGRLayer * OGROCIDataSource::ExecuteSQL( const char *pszSQLCommand, OGRGeometry *poSpatialFilter, const char *pszDialect ) { /* -------------------------------------------------------------------- */ /* Use generic implementation for OGRSQL dialect. */ /* -------------------------------------------------------------------- */ if( pszDialect != NULL && EQUAL(pszDialect,"OGRSQL") ) return OGRDataSource::ExecuteSQL( pszSQLCommand, poSpatialFilter, pszDialect ); /* -------------------------------------------------------------------- */ /* Ensure any pending stuff is flushed to the database. */ /* -------------------------------------------------------------------- */ SyncToDisk(); CPLDebug( "OCI", "ExecuteSQL(%s)", pszSQLCommand ); /* -------------------------------------------------------------------- */ /* Special case DELLAYER: command. */ /* -------------------------------------------------------------------- */ if( EQUALN(pszSQLCommand,"DELLAYER:",9) ) { const char *pszLayerName = pszSQLCommand + 9; while( *pszLayerName == ' ' ) pszLayerName++; DeleteLayer( pszLayerName ); return NULL; } /* -------------------------------------------------------------------- */ /* Special case VALLAYER: command. */ /* -------------------------------------------------------------------- */ if( EQUALN(pszSQLCommand,"VALLAYER:",9) ) { const char *pszLayerName = pszSQLCommand + 9; while( *pszLayerName == ' ' ) pszLayerName++; ValidateLayer( pszLayerName ); return NULL; } /* -------------------------------------------------------------------- */ /* Just execute simple command. */ /* -------------------------------------------------------------------- */ if( !EQUALN(pszSQLCommand,"SELECT",6) ) { OGROCIStatement oCommand( poSession ); oCommand.Execute( pszSQLCommand, OCI_COMMIT_ON_SUCCESS ); return NULL; } /* -------------------------------------------------------------------- */ /* Otherwise instantiate a layer. */ /* -------------------------------------------------------------------- */ else { OGROCIStatement oCommand( poSession ); if( oCommand.Execute( pszSQLCommand, OCI_DESCRIBE_ONLY ) == CE_None ) return new OGROCISelectLayer( this, pszSQLCommand, &oCommand ); else return NULL; } }