📄 mitab_priv.h
字号:
GInt16 m_nBlockSize; double m_dCoordsys2DistUnits; GInt32 m_nXMin; GInt32 m_nYMin; GInt32 m_nXMax; GInt32 m_nYMax; GBool m_bIntBoundsOverflow; // Set to TRUE if coordinates // outside of bounds were written GInt32 m_nFirstIndexBlock; GInt32 m_nFirstGarbageBlock; GInt32 m_nFirstToolBlock; GInt32 m_numPointObjects; GInt32 m_numLineObjects; GInt32 m_numRegionObjects; GInt32 m_numTextObjects; GInt32 m_nMaxCoordBufSize; GByte m_nDistUnitsCode; // See Appendix F GByte m_nMaxSpIndexDepth; GByte m_nCoordPrecision; // Num. decimal places on coord. GByte m_nCoordOriginQuadrant; GByte m_nReflectXAxisCoord; GByte m_nMaxObjLenArrayId; // See gabyObjLenArray[] GByte m_numPenDefs; GByte m_numBrushDefs; GByte m_numSymbolDefs; GByte m_numFontDefs; GInt16 m_numMapToolBlocks; double m_XScale; double m_YScale; double m_XDispl; double m_YDispl; };/*--------------------------------------------------------------------- * class TABMAPIndexBlock * * Class to handle Read/Write operation on .MAP Index Blocks (Type 01) *--------------------------------------------------------------------*/class CPL_DLL TABMAPIndexBlock: public TABRawBinBlock{ protected: int m_numEntries; TABMAPIndexEntry m_asEntries[TAB_MAX_ENTRIES_INDEX_BLOCK]; int ReadNextEntry(TABMAPIndexEntry *psEntry); int WriteNextEntry(TABMAPIndexEntry *psEntry); // Use these to keep track of current block's MBR GInt32 m_nMinX; GInt32 m_nMinY; GInt32 m_nMaxX; GInt32 m_nMaxY; TABBinBlockManager *m_poBlockManagerRef; // Info about child currently loaded TABMAPIndexBlock *m_poCurChild; int m_nCurChildIndex; // Also need to know about its parent TABMAPIndexBlock *m_poParentRef; int ReadAllEntries(); public: TABMAPIndexBlock(TABAccess eAccessMode = TABRead); ~TABMAPIndexBlock(); virtual int InitBlockFromData(GByte *pabyBuf, int nSize, GBool bMakeCopy = TRUE, FILE *fpSrc = NULL, int nOffset = 0); virtual int InitNewBlock(FILE *fpSrc, int nBlockSize, int nFileOffset=0); virtual int CommitToFile(); virtual int GetBlockClass() { return TABMAP_INDEX_BLOCK; }; int GetNumFreeEntries(); int GetNumEntries() {return m_numEntries;}; TABMAPIndexEntry *GetEntry( int iIndex ); int AddEntry(GInt32 XMin, GInt32 YMin, GInt32 XMax, GInt32 YMax, GInt32 nBlockPtr, GBool bAddInThisNodeOnly=FALSE); int GetCurMaxDepth(); void GetMBR(GInt32 &nXMin, GInt32 &nYMin, GInt32 &nXMax, GInt32 &nYMax); GInt32 GetNodeBlockPtr() { return GetStartAddress();}; void SetMAPBlockManagerRef(TABBinBlockManager *poBlockMgr); void SetParentRef(TABMAPIndexBlock *poParent); void SetCurChildRef(TABMAPIndexBlock *poChild, int nChildIndex); int GetCurChildIndex() { return m_nCurChildIndex; } TABMAPIndexBlock *GetCurChild() { return m_poCurChild; } TABMAPIndexBlock *GetParentRef() { return m_poParentRef; } int SplitNode(int nNewEntryX, int nNewEntryY); int SplitRootNode(int nNewEntryX, int nNewEntryY); void UpdateCurChildMBR(GInt32 nXMin, GInt32 nYMin, GInt32 nXMax, GInt32 nYMax, GInt32 nBlockPtr); void RecomputeMBR(); int InsertEntry(GInt32 XMin, GInt32 YMin, GInt32 XMax, GInt32 YMax, GInt32 nBlockPtr);#ifdef DEBUG virtual void Dump(FILE *fpOut = NULL);#endif};/*--------------------------------------------------------------------- * class TABMAPObjectBlock * * Class to handle Read/Write operation on .MAP Object data Blocks (Type 02) *--------------------------------------------------------------------*/class CPL_DLL TABMAPObjectBlock: public TABRawBinBlock{ protected: int m_numDataBytes; /* Excluding first 4 bytes header */ GInt32 m_nFirstCoordBlock; GInt32 m_nLastCoordBlock; GInt32 m_nCenterX; GInt32 m_nCenterY; // In order to compute block center, we need to keep track of MBR GInt32 m_nMinX; GInt32 m_nMinY; GInt32 m_nMaxX; GInt32 m_nMaxY; int m_nCurObjectOffset; // -1 if there is no current object. int m_nCurObjectId; // -1 if there is no current object. int m_nCurObjectType; // -1 if there is no current object. // Array of object headers held in memory until CommitToFile() is called TABMAPObjHdr **m_papoObjHdr; int m_numObjects; void FreeObjectArray(); public: TABMAPObjectBlock(TABAccess eAccessMode = TABRead); ~TABMAPObjectBlock(); virtual int CommitToFile(); virtual int InitBlockFromData(GByte *pabyBuf, int nSize, GBool bMakeCopy = TRUE, FILE *fpSrc = NULL, int nOffset = 0); virtual int InitNewBlock(FILE *fpSrc, int nBlockSize, int nFileOffset=0); virtual int GetBlockClass() { return TABMAP_OBJECT_BLOCK; }; virtual int ReadIntCoord(GBool bCompressed, GInt32 &nX, GInt32 &nY); int WriteIntCoord(GInt32 nX, GInt32 nY, GBool bCompressed); int WriteIntMBRCoord(GInt32 nXMin, GInt32 nYMin, GInt32 nXMax, GInt32 nYMax, GBool bCompressed); int UpdateMBR(GInt32 nX, GInt32 nY); int AddObject(TABMAPObjHdr *poObjHdr); void AddCoordBlockRef(GInt32 nCoordBlockAddress); void GetMBR(GInt32 &nXMin, GInt32 &nYMin, GInt32 &nXMax, GInt32 &nYMax); int AdvanceToNextObject( TABMAPHeaderBlock * ); int GetCurObjectOffset() { return m_nCurObjectOffset; } int GetCurObjectId() { return m_nCurObjectId; } int GetCurObjectType() { return m_nCurObjectType; }#ifdef DEBUG virtual void Dump(FILE *fpOut = NULL) { Dump(fpOut, FALSE); }; void Dump(FILE *fpOut, GBool bDetails);#endif};/*--------------------------------------------------------------------- * class TABMAPCoordBlock * * Class to handle Read/Write operation on .MAP Coordinate Blocks (Type 03) *--------------------------------------------------------------------*/class CPL_DLL TABMAPCoordBlock: public TABRawBinBlock{ protected: int m_numDataBytes; /* Excluding first 8 bytes header */ GInt32 m_nNextCoordBlock; int m_numBlocksInChain; GInt32 m_nComprOrgX; GInt32 m_nComprOrgY; // In order to compute block center, we need to keep track of MBR GInt32 m_nMinX; GInt32 m_nMinY; GInt32 m_nMaxX; GInt32 m_nMaxY; TABBinBlockManager *m_poBlockManagerRef; int m_nTotalDataSize; // Num bytes in whole chain of blocks int m_nFeatureDataSize; // Num bytes for current feature coords GInt32 m_nFeatureXMin; // Used to keep track of current GInt32 m_nFeatureYMin; // feature MBR. GInt32 m_nFeatureXMax; GInt32 m_nFeatureYMax; public: TABMAPCoordBlock(TABAccess eAccessMode = TABRead); ~TABMAPCoordBlock(); virtual int InitBlockFromData(GByte *pabyBuf, int nSize, GBool bMakeCopy = TRUE, FILE *fpSrc = NULL, int nOffset = 0); virtual int InitNewBlock(FILE *fpSrc, int nBlockSize, int nFileOffset=0); virtual int CommitToFile(); virtual int GetBlockClass() { return TABMAP_COORD_BLOCK; }; void SetMAPBlockManagerRef(TABBinBlockManager *poBlockManager); virtual int ReadBytes(int numBytes, GByte *pabyDstBuf); virtual int WriteBytes(int nBytesToWrite, GByte *pBuf); void SetComprCoordOrigin(GInt32 nX, GInt32 nY); int ReadIntCoord(GBool bCompressed, GInt32 &nX, GInt32 &nY); int ReadIntCoords(GBool bCompressed, int numCoords, GInt32 *panXY); int ReadCoordSecHdrs(GBool bCompressed, GBool bV450Hdr, int numSections, TABMAPCoordSecHdr *pasHdrs, GInt32 &numVerticesTotal); int WriteCoordSecHdrs(GBool bV450Hdr, int numSections, TABMAPCoordSecHdr *pasHdrs, GBool bCompressed); void SetNextCoordBlock(GInt32 nNextCoordBlockAddress); int WriteIntCoord(GInt32 nX, GInt32 nY, GBool bCompressed); int GetNumBlocksInChain() { return m_numBlocksInChain; }; void ResetTotalDataSize() {m_nTotalDataSize = 0;}; int GetTotalDataSize() {return m_nTotalDataSize;}; void StartNewFeature(); int GetFeatureDataSize() {return m_nFeatureDataSize;};//__TODO__ Can we flush GetFeatureMBR() and all MBR tracking in this class??? void GetFeatureMBR(GInt32 &nXMin, GInt32 &nYMin, GInt32 &nXMax, GInt32 &nYMax);#ifdef DEBUG virtual void Dump(FILE *fpOut = NULL);#endif};/*--------------------------------------------------------------------- * class TABMAPToolBlock * * Class to handle Read/Write operation on .MAP Drawing Tool Blocks (Type 05) * * In addition to handling the I/O, this class also maintains the list * of Tool definitions in memory. *--------------------------------------------------------------------*/class CPL_DLL TABMAPToolBlock: public TABRawBinBlock{ protected: int m_numDataBytes; /* Excluding first 8 bytes header */ GInt32 m_nNextToolBlock; int m_numBlocksInChain; TABBinBlockManager *m_poBlockManagerRef; public: TABMAPToolBlock(TABAccess eAccessMode = TABRead); ~TABMAPToolBlock(); virtual int InitBlockFromData(GByte *pabyBuf, int nSize, GBool bMakeCopy = TRUE, FILE *fpSrc = NULL, int nOffset = 0); virtual int InitNewBlock(FILE *fpSrc, int nBlockSize, int nFileOffset=0); virtual int CommitToFile(); virtual int GetBlockClass() { return TABMAP_TOOL_BLOCK; }; void SetMAPBlockManagerRef(TABBinBlockManager *poBlockManager); virtual int ReadBytes(int numBytes, GByte *pabyDstBuf); virtual int WriteBytes(int nBytesToWrite, GByte *pBuf); void SetNextToolBlock(GInt32 nNextCoordBlockAddress); GBool EndOfChain(); int GetNumBlocksInChain() { return m_numBlocksInChain; }; int CheckAvailableSpace(int nToolType);#ifdef DEBUG virtual void Dump(FILE *fpOut = NULL);#endif};/*===================================================================== Classes to deal with .MAP files at the MapInfo object level =====================================================================*//*--------------------------------------------------------------------- * class TABIDFile * * Class to handle Read/Write operation on .ID files... the .ID file * contains an index to the objects in the .MAP file by object id. *--------------------------------------------------------------------*/class CPL_DLL TABIDFile{ private: char *m_pszFname; FILE *m_fp; TABAccess m_eAccessMode; TABRawBinBlock *m_poIDBlock; int m_nBlockSize; GInt32 m_nMaxId; public: TABIDFile(); ~TABIDFile(); int Open(const char *pszFname, const char *pszAccess); int Close(); GInt32 GetObjPtr(GInt32 nObjId); int SetObjPtr(GInt32 nObjId, GInt32 nObjPtr); GInt32 GetMaxObjId();#ifdef DEBUG void Dump(FILE *fpOut = NULL);#endif};/*--------------------------------------------------------------------- * class TABMAPFile * * Class to handle Read/Write operation on .MAP files... this class hides * all the dealings with blocks, indexes, etc. * Use this class to deal with MapInfo objects directly. *--------------------------------------------------------------------*/class CPL_DLL TABMAPFile{ private: int m_nMinTABVersion; char *m_pszFname; FILE *m_fp; TABAccess m_eAccessMode; TABBinBlockManager m_oBlockManager; TABMAPHeaderBlock *m_poHeader; // Members used to access objects using the spatial index TABMAPIndexBlock *m_poSpIndex; // Member used to access objects using the object ids (.ID file) TABIDFile *m_poIdIndex; // Current object data block. TABMAPObjectBlock *m_poCurObjBlock; int m_nCurObjPtr; int m_nCurObjType; int m_nCurObjId; TABMAPCoordBlock *m_poCurCoordBlock; // Drawing Tool Def. table (takes care of all drawing tools in memory) TABToolDefTable *m_poToolDefTable; // Coordinates filter... default is MBR of the whole file TABVertex m_sMinFilter; TABVertex m_sMaxFilter; GInt32 m_XMinFilter; GInt32 m_YMinFilter; GInt32 m_XMaxFilter; GInt32 m_YMaxFilter; int CommitObjBlock(GBool bInitNewBlock =TRUE); int InitDrawingTools(); int CommitDrawingTools(); int CommitSpatialIndex(); // Stuff related to traversing spatial index. TABMAPIndexBlock *m_poSpIndexLeaf; int LoadNextMatchingObjectBlock(int bFirstObject); TABRawBinBlock *PushBlock( int nFileOffset ); public: TABMAPFile(); ~TABMAPFile(); int Open(const char *pszFname, const char *pszAccess, GBool bNoErrorMsg = FALSE ); int Close(); int Int2Coordsys(GInt32 nX, GInt32 nY, double &dX, double &dY); int Coordsys2Int(double dX, double dY, GInt32 &nX, GInt32 &nY, GBool bIgnoreOveflow=FALSE); int Int2CoordsysDist(GInt32 nX, GInt32 nY, double &dX, double &dY); int Coordsys2IntDist(double dX, double dY, GInt32 &nX, GInt32 &nY); void SetCoordFilter(TABVertex sMin, TABVertex sMax);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -