📄 tabview.cpp
字号:
return NULL; } if(m_poCurFeature) { delete m_poCurFeature; m_poCurFeature = NULL; } m_poCurFeature = m_poRelation->GetFeature(nFeatureId); m_nCurFeatureId = nFeatureId; m_poCurFeature->SetFID(m_nCurFeatureId); return m_poCurFeature;}/********************************************************************** * TABView::SetFeature() * * Write a feature to this dataset. * * For now only sequential writes are supported (i.e. with nFeatureId=-1) * but eventually we should be able to do random access by specifying * a value through nFeatureId. * * Returns the new featureId (> 0) on success, or -1 if an * error happened in which case, CPLError() will have been called to * report the reason of the failure. **********************************************************************/int TABView::SetFeature(TABFeature *poFeature, int nFeatureId /*=-1*/){ if (m_eAccessMode != TABWrite) { UGKError(ET_Failure, UGKErr_NotSupported, "SetFeature() can be used only with Write access."); return -1; } if (nFeatureId != -1) { UGKError(ET_Failure, UGKErr_NotSupported, "SetFeature(): random access not implemented yet."); return -1; } if (m_poRelation == NULL) { UGKError(ET_Failure, UGKErr_IllegalArg, "SetFeature() failed: file is not opened!"); return -1; } /*----------------------------------------------------------------- * If we're about to write the first feature, then we must finish * the initialization of the view first by creating the MI_refnum fields *----------------------------------------------------------------*/ if (!m_bRelFieldsCreated) { if (m_poRelation->CreateRelFields() != 0) return -1; m_bRelFieldsCreated = TRUE; } return m_poRelation->SetFeature(poFeature, nFeatureId);}/********************************************************************** * TABView::GetLayerDefn() * * Returns a reference to the UGKFeatureDefn that will be used to create * features in this dataset. * * Returns a reference to an object that is maintained by this TABView * object (and thus should not be modified or freed by the caller) or * NULL if the UGKFeatureDefn has not been initialized yet (i.e. no file * opened yet) **********************************************************************/UGKFeatureDefn *TABView::GetLayerDefn(){ if (m_poRelation) return m_poRelation->GetFeatureDefn(); return NULL;}/********************************************************************** * TABView::SetFeatureDefn() * * Set the FeatureDefn for this dataset. * * For now, fields passed through SetFeatureDefn will not be mapped * properly, so this function can be used only with an empty feature defn. **********************************************************************/int TABView::SetFeatureDefn(UGKFeatureDefn *poFeatureDefn, TABFieldType *paeMapInfoNativeFieldTypes /* =NULL */){ if (m_poRelation) return m_poRelation->SetFeatureDefn(poFeatureDefn); return -1;}/********************************************************************** * TABView::GetNativeFieldType() * * Returns the native MapInfo field type for the specified field. * * Returns TABFUnknown if file is not opened, or if specified field index is * invalid. * * Note that field ids are positive and start at 0. **********************************************************************/TABFieldType TABView::GetNativeFieldType(int nFieldId){ if (m_poRelation) return m_poRelation->GetNativeFieldType(nFieldId); return TABFUnknown;}/********************************************************************** * TABView::AddFieldNative() * * Create a new field using a native mapinfo data type... this is an * alternative to defining fields through the UGK interface. * This function should be called after creating a new dataset, but before * writing the first feature. * * This function will build/update the UGKFeatureDefn that will have to be * used when writing features to this dataset. * * A reference to the UGKFeatureDefn can be obtained using GetLayerDefn(). * * Returns 0 on success, -1 on error. **********************************************************************/int TABView::AddFieldNative(const char *pszName, TABFieldType eMapInfoType, int nWidth /*=0*/, int nPrecision /*=0*/, UGKBool bIndexed /*=FALSE*/, UGKBool bUnique/*=FALSE*/){ if (m_poRelation) return m_poRelation->AddFieldNative(pszName, eMapInfoType, nWidth, nPrecision, bIndexed, bUnique); return -1;}/********************************************************************** * TABView::SetFieldIndexed() * * Request that a field be indexed. This will create the .IND file if * necessary, etc. * * Note that field ids are positive and start at 0. * * Returns 0 on success, -1 on error. **********************************************************************/int TABView::SetFieldIndexed(int nFieldId){ if (m_poRelation) return m_poRelation->SetFieldIndexed(nFieldId); return -1;}/********************************************************************** * TABView::IsFieldIndexed() * * Returns TRUE if field is indexed, or FALSE otherwise. **********************************************************************/UGKBool TABView::IsFieldIndexed(int nFieldId){ if (m_poRelation) return m_poRelation->IsFieldIndexed(nFieldId); return FALSE;}/********************************************************************** * TABView::IsFieldUnique() * * Returns TRUE if field is in the Unique table, or FALSE otherwise. **********************************************************************/UGKBool TABView::IsFieldUnique(int nFieldId){ if (m_poRelation) return m_poRelation->IsFieldUnique(nFieldId); return FALSE;}/********************************************************************** * TABView::GetBounds() * * Fetch projection coordinates bounds of a dataset. * * The bForce flag has no effect on TAB files since the bounds are * always in the header. * * Returns 0 on success, -1 on error. **********************************************************************/int TABView::GetBounds(double &dXMin, double &dYMin, double &dXMax, double &dYMax, UGKBool bForce /*= TRUE*/){ if (m_nMainTableIndex == -1) { UGKError(ET_Failure, UGKErr_AppDefined, "GetBounds() can be called only after dataset has been opened."); return -1; } return m_papoTABFiles[m_nMainTableIndex]->GetBounds(dXMin, dYMin, dXMax, dYMax, bForce);}/********************************************************************** * TABView::GetExtent() * * Fetch extent of the data currently stored in the dataset. * * The bForce flag has no effect on TAB files since that value is * always in the header. * * Returns UGKERR_NONE/UGKRERR_FAILURE. **********************************************************************/UGKErr TABView::GetExtent (UGKEnvelope *psExtent, int bForce){ if (m_nMainTableIndex == -1) { UGKError(ET_Failure, UGKErr_AppDefined, "GetExtent() can be called only after dataset has been opened."); return -1; } return m_papoTABFiles[m_nMainTableIndex]->GetExtent(psExtent, bForce);}/********************************************************************** * TABView::GetFeatureCountByType() * * Return number of features of each type. * * Note that the sum of the 4 returned values may be different from * the total number of features since features with NONE geometry * are not taken into account here. * * Note: the bForce flag has nmo effect on .TAB files since the info * is always in the header. * * Returns 0 on success, or silently returns -1 (with no error) if this * information is not available. **********************************************************************/int TABView::GetFeatureCountByType(int &numPoints, int &numLines, int &numRegions, int &numTexts, UGKBool bForce /*= TRUE*/){ if (m_nMainTableIndex == -1) return -1; return m_papoTABFiles[m_nMainTableIndex]->GetFeatureCountByType(numPoints, numLines, numRegions, numTexts, bForce);}/********************************************************************** * TABView::SetBounds() **********************************************************************/int TABView::SetBounds(double dXMin, double dYMin, double dXMax, double dYMax){ if (m_nMainTableIndex == -1) { UGKError(ET_Failure, UGKErr_AssertionFailed, "SetBounds() failed: file has not been opened yet."); return -1; } return m_papoTABFiles[m_nMainTableIndex]->SetBounds(dXMin, dYMin, dXMax, dYMax);}/************************************************************************//* TestCapability() *//************************************************************************/int TABView::TestCapability( const char * pszCap ){ if( EQUAL(pszCap,OLCRandomRead) ) return TRUE; else if( EQUAL(pszCap,OLCSequentialWrite)) return TRUE; else if( EQUAL(pszCap,OLCRandomWrite)) return FALSE; else if( EQUAL(pszCap,OLCFastFeatureCount) ) return m_poFilterGeom == NULL; else if( EQUAL(pszCap,OLCFastSpatialFilter) ) return FALSE; else if( EQUAL(pszCap,OLCFastGetExtent) ) return TRUE; else return FALSE;}/********************************************************************** * TABView::Dump() * * Dump block contents... available only in DEBUG mode. **********************************************************************/void TABView::Dump(FILE *fpOut /*=NULL*/){ if (fpOut == NULL) fpOut = stdout; fprintf(fpOut, "----- TABView::Dump() -----\n"); if (m_numTABFiles > 0) { fprintf(fpOut, "File is not opened.\n"); } else { fprintf(fpOut, "File is opened: %s\n", m_pszFname); fprintf(fpOut, "View contains %d tables\n", m_numTABFiles); } fflush(fpOut);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -