⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mitab_priv.h

📁 用于读取TAB、MIF、SHP文件的类
💻 H
📖 第 1 页 / 共 4 页
字号:
    void        GetCoordFilter(TABVertex &sMin, TABVertex &sMax);    void        ResetCoordFilter();    int         SetCoordsysBounds(double dXMin, double dYMin,                                   double dXMax, double dYMax);    GInt32      GetMaxObjId();    int         MoveToObjId(int nObjId);    void        UpdateMapHeaderInfo(GByte nObjType);    int         PrepareNewObj(int nObjId, GByte nObjType);    void        ResetReading();    int         GetNextFeatureId( int nPrevId );    int         GetCurObjType();    int         GetCurObjId();    TABMAPObjectBlock *GetCurObjBlock();    TABMAPCoordBlock  *GetCurCoordBlock();    TABMAPCoordBlock  *GetCoordBlock(int nFileOffset);    TABMAPHeaderBlock *GetHeaderBlock();    TABIDFile         *GetIDFileRef();    TABRawBinBlock    *GetIndexObjectBlock(int nFileOffset);    int         ReadPenDef(int nPenIndex, TABPenDef *psDef);    int         ReadBrushDef(int nBrushIndex, TABBrushDef *psDef);    int         ReadFontDef(int nFontIndex, TABFontDef *psDef);    int         ReadSymbolDef(int nSymbolIndex, TABSymbolDef *psDef);    int         WritePenDef(TABPenDef *psDef);    int         WriteBrushDef(TABBrushDef *psDef);    int         WriteFontDef(TABFontDef *psDef);    int         WriteSymbolDef(TABSymbolDef *psDef);    int         GetMinTABFileVersion();#ifdef DEBUG    void Dump(FILE *fpOut = NULL);#endif};/*--------------------------------------------------------------------- *                      class TABINDNode * * An index node in a .IND file. * * This class takes care of reading child nodes as necessary when looking * for a given key value in the index tree. *--------------------------------------------------------------------*/class CPL_DLL TABINDNode{  private:    FILE        *m_fp;    TABAccess   m_eAccessMode;    TABINDNode *m_poCurChildNode;    TABINDNode *m_poParentNodeRef;    TABBinBlockManager *m_poBlockManagerRef;    int         m_nSubTreeDepth;    int         m_nKeyLength;    TABFieldType m_eFieldType;    GBool       m_bUnique;    GInt32      m_nCurDataBlockPtr;    int         m_nCurIndexEntry;    TABRawBinBlock *m_poDataBlock;    int         m_numEntriesInNode;    GInt32      m_nPrevNodePtr;    GInt32      m_nNextNodePtr;    int         GotoNodePtr(GInt32 nNewNodePtr);    GInt32      ReadIndexEntry(int nEntryNo, GByte *pKeyValue);    int         IndexKeyCmp(GByte *pKeyValue, int nEntryNo);    int         InsertEntry(GByte *pKeyValue, GInt32 nRecordNo,                            GBool bInsertAfterCurChild=FALSE,                            GBool bMakeNewEntryCurChild=FALSE);    int         SetNodeBufferDirectly(int numEntries, GByte *pBuf,                                      int nCurIndexEntry=0,                                       TABINDNode *poCurChild=NULL);   public:    TABINDNode(TABAccess eAccessMode = TABRead);    ~TABINDNode();    int         InitNode(FILE *fp, int nBlockPtr,                          int nKeyLength, int nSubTreeDepth, GBool bUnique,                         TABBinBlockManager *poBlockMgr=NULL,                         TABINDNode *poParentNode=NULL,                         int nPrevNodePtr=0, int nNextNodePtr=0);    int         SetFieldType(TABFieldType eType);    TABFieldType GetFieldType()         {return m_eFieldType;};    void        SetUnique(GBool bUnique){m_bUnique = bUnique;};    GBool       IsUnique()              {return m_bUnique;};    int         GetKeyLength()          {return m_nKeyLength;};    int         GetSubTreeDepth()       {return m_nSubTreeDepth;};    GInt32      GetNodeBlockPtr()       {return m_nCurDataBlockPtr;};    int         GetNumEntries()         {return m_numEntriesInNode;};    int         GetMaxNumEntries()      {return (512-12)/(m_nKeyLength+4);};    GInt32      FindFirst(GByte *pKeyValue);    GInt32      FindNext(GByte *pKeyValue);    int         CommitToFile();    int         AddEntry(GByte *pKeyValue, GInt32 nRecordNo,                         GBool bAddInThisNodeOnly=FALSE,                         GBool bInsertAfterCurChild=FALSE,                         GBool bMakeNewEntryCurChild=FALSE);    int         SplitNode();    int         SplitRootNode();    GByte*      GetNodeKey();    int         UpdateCurChildEntry(GByte *pKeyValue, GInt32 nRecordNo);    int         UpdateSplitChild(GByte *pKeyValue1, GInt32 nRecordNo1,                                 GByte *pKeyValue2, GInt32 nRecordNo2,                                 int nNewCurChildNo /* 1 or 2 */);    int         SetNodeBlockPtr(GInt32 nThisNodePtr);    int         SetPrevNodePtr(GInt32 nPrevNodePtr);    int         SetNextNodePtr(GInt32 nNextNodePtr);#ifdef DEBUG    void Dump(FILE *fpOut = NULL);#endif};/*--------------------------------------------------------------------- *                      class TABINDFile * * Class to handle table field index (.IND) files... we use this * class as the main entry point to open and search the table field indexes. * Note that .IND files are supported for read access only. *--------------------------------------------------------------------*/class CPL_DLL TABINDFile{  private:    char        *m_pszFname;    FILE        *m_fp;    TABAccess   m_eAccessMode;    TABBinBlockManager m_oBlockManager;    int         m_numIndexes;    TABINDNode  **m_papoIndexRootNodes;    GByte       **m_papbyKeyBuffers;    int         ValidateIndexNo(int nIndexNumber);    int         ReadHeader();    int         WriteHeader();   public:    TABINDFile();    ~TABINDFile();    int         Open(const char *pszFname, const char *pszAccess,                      GBool bTestOpenNoError=FALSE);    int         Close();    int         GetNumIndexes() {return m_numIndexes;};    int         SetIndexFieldType(int nIndexNumber, TABFieldType eType);    int         SetIndexUnique(int nIndexNumber, GBool bUnique=TRUE);    GByte      *BuildKey(int nIndexNumber, GInt32 nValue);    GByte      *BuildKey(int nIndexNumber, const char *pszStr);    GByte      *BuildKey(int nIndexNumber, double dValue);    GInt32      FindFirst(int nIndexNumber, GByte *pKeyValue);    GInt32      FindNext(int nIndexNumber, GByte *pKeyValue);    int         CreateIndex(TABFieldType eType, int nFieldSize);    int         AddEntry(int nIndexNumber, GByte *pKeyValue, GInt32 nRecordNo);#ifdef DEBUG    void Dump(FILE *fpOut = NULL);#endif};/*--------------------------------------------------------------------- *                      class TABDATFile * * Class to handle Read/Write operation on .DAT files... the .DAT file * contains the table of attribute field values. *--------------------------------------------------------------------*/class CPL_DLL TABDATFile{  private:    char        *m_pszFname;    FILE        *m_fp;    TABAccess   m_eAccessMode;    TABTableType m_eTableType;    TABRawBinBlock *m_poHeaderBlock;    int         m_numFields;    TABDATFieldDef *m_pasFieldDef;    TABRawBinBlock *m_poRecordBlock;    int         m_nBlockSize;    int         m_nRecordSize;    int         m_nCurRecordId;    GBool       m_bCurRecordDeletedFlag;    GInt32      m_numRecords;    GInt32      m_nFirstRecordPtr;    GBool       m_bWriteHeaderInitialized;    int         InitWriteHeader();    int         WriteHeader();   public:    TABDATFile();    ~TABDATFile();    int         Open(const char *pszFname, const char *pszAccess,                     TABTableType eTableType =TABTableNative);    int         Close();    int         GetNumFields();    TABFieldType GetFieldType(int nFieldId);    int         GetFieldWidth(int nFieldId);    int         GetFieldPrecision(int nFieldId);    int         ValidateFieldInfoFromTAB(int iField, const char *pszName,                                         TABFieldType eType,                                         int nWidth, int nPrecision);    int         AddField(const char *pszName, TABFieldType eType,                         int nWidth, int nPrecision=0);    GInt32      GetNumRecords();    TABRawBinBlock *GetRecordBlock(int nRecordId);    GBool       IsCurrentRecordDeleted() { return m_bCurRecordDeletedFlag;};    int         CommitRecordToFile();    const char  *ReadCharField(int nWidth);    GInt32      ReadIntegerField(int nWidth);    GInt16      ReadSmallIntField(int nWidth);    double      ReadFloatField(int nWidth);    double      ReadDecimalField(int nWidth);    const char  *ReadLogicalField(int nWidth);    const char  *ReadDateField(int nWidth);    int         WriteCharField(const char *pszValue, int nWidth,                               TABINDFile *poINDFile, int nIndexNo);    int         WriteIntegerField(GInt32 nValue,                                  TABINDFile *poINDFile, int nIndexNo);    int         WriteSmallIntField(GInt16 nValue,                                   TABINDFile *poINDFile, int nIndexNo);    int         WriteFloatField(double dValue,                                TABINDFile *poINDFile, int nIndexNo);    int         WriteDecimalField(double dValue, int nWidth, int nPrecision,                                  TABINDFile *poINDFile, int nIndexNo);    int         WriteLogicalField(const char *pszValue,                                  TABINDFile *poINDFile, int nIndexNo);    int         WriteDateField(const char *pszValue,                               TABINDFile *poINDFile, int nIndexNo);#ifdef DEBUG    void Dump(FILE *fpOut = NULL);#endif};/*--------------------------------------------------------------------- *                      class TABRelation * * Class that maintains a relation between 2 tables through a field * in each table (the SQL "where table1.field1=table2.field2" found in  * TABView datasets). * * An instance of this class is used to read data records from the * combined tables as if they were a single one. *--------------------------------------------------------------------*/class CPL_DLL TABRelation{  private:    /* Information about the main table.     */    TABFile     *m_poMainTable;    char        *m_pszMainFieldName;    int         m_nMainFieldNo;    /* Information about the related table.       * NOTE: The related field MUST be indexed.     */    TABFile     *m_poRelTable;    char        *m_pszRelFieldName;    int         m_nRelFieldNo;    TABINDFile  *m_poRelINDFileRef;    int         m_nRelFieldIndexNo;    int         m_nUniqueRecordNo;    /* Main and Rel table field map:     * For each field in the source tables, -1 means that the field is not     * selected, and a value >=0 is the index of this field in the combined     * FeatureDefn     */    int         *m_panMainTableFieldMap;    int         *m_panRelTableFieldMap;    OGRFeatureDefn *m_poDefn;    void        ResetAllMembers();    GByte       *BuildFieldKey(TABFeature *poFeature, int nFieldNo,                                  TABFieldType eType, int nIndexNo);   public:    TABRelation();    ~TABRelation();    int         Init(const char *pszViewName,                     TABFile *poMainTable, TABFile *poRelTable,                     const char *pszMainFieldName,                     const char *pszRelFieldName,                     char **papszSelectedFields);    int         CreateRelFields();    OGRFeatureDefn *GetFeatureDefn()  {return m_poDefn;};    TABFieldType    GetNativeFieldType(int nFieldId);    TABFeature     *GetFeature(int nFeatureId);    int         SetFeature(TABFeature *poFeature, int nFeatureId=-1);    int         SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,                           TABFieldType *paeMapInfoNativeFieldTypes=NULL);    int         AddFieldNative(const char *pszName, TABFieldType eMapInfoType,                               int nWidth=0, int nPrecision=0,                               GBool bIndexed=FALSE, GBool bUnique=FALSE);    int         SetFieldIndexed(int nFieldId);    GBool       IsFieldIndexed(int nFieldId);    GBool       IsFieldUnique(int nFieldId);    const char *GetMainFieldName()      {return m_pszMainFieldName;};    const char *GetRelFieldName()       {return m_pszRelFieldName;};};/*--------------------------------------------------------------------- *                      class MIDDATAFile * * Class to handle a file pointer with a copy of the latest readed line * *--------------------------------------------------------------------*/class CPL_DLL MIDDATAFile{   public:      MIDDATAFile();     ~MIDDATAFile();     int         Open(const char *pszFname, const char *pszAccess);     int         Close();     const char *GetLine();     const char *GetLastLine();     int Rewind();     void SaveLine(const char *pszLine);     const char *GetSavedLine();     void WriteLine(const char*, ...);     GBool IsValidFeature(const char *pszString);//  Translation information     void SetTranslation(double, double, double, double);     double GetXTrans(double);     double GetYTrans(double);     double GetXMultiplier(){return m_dfXMultiplier;}     const char *GetDelimiter(){return m_pszDelimiter;}     void SetDelimiter(const char *pszDelimiter){m_pszDelimiter=pszDelimiter;}     void SetEof(GBool bEof);     GBool GetEof();     private:       FILE *m_fp;       const char *m_pszDelimiter;       // Set limit for the length of a line#define MIDMAXCHAR 10000       char m_szLastRead[MIDMAXCHAR];       char m_szSavedLine[MIDMAXCHAR];       char        *m_pszFname;       TABAccess   m_eAccessMode;       double      m_dfXMultiplier;       double      m_dfYMultiplier;       double      m_dfXDisplacement;       double      m_dfYDisplacement;       GBool       m_bEof;};/*=====================================================================                        Function prototypes =====================================================================*/CPL_DLL TABRawBinBlock *TABCreateMAPBlockFromFile(FILE *fpSrc, int nOffset,                                           int nSize = 512,                                           GBool bHardBlockSize = TRUE,                                          TABAccess eAccessMode = TABRead);#endif /* _MITAB_PRIV_H_INCLUDED_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -