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

📄 tabmapfile.cpp

📁 linux下一款GIS程序源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
 * * Note that the returned index is a 1-based index.  A value of 0  * indicates "none" in MapInfo. * Returns a value >= 0 on success, -1 on error **********************************************************************/int   TABMAPFile::WritePenDef(TABPenDef *psDef){    if (psDef == NULL ||         (m_poToolDefTable == NULL && InitDrawingTools() != 0) ||        m_poToolDefTable==NULL )    {        return -1;    }    return m_poToolDefTable->AddPenDefRef(psDef);}/********************************************************************** *                   TABMAPFile::ReadBrushDef() * * Fill the TABBrushDef structure with the definition of the specified Brush * index... (1-based Brush index) * * If nBrushIndex==0 or is invalid, then the structure is cleared. * * Returns 0 on success, -1 on error (i.e. Brush not found). **********************************************************************/int   TABMAPFile::ReadBrushDef(int nBrushIndex, TABBrushDef *psDef){    TABBrushDef *psTmp;    if (m_poToolDefTable == NULL && InitDrawingTools() != 0)        return -1;    if (psDef && m_poToolDefTable &&        (psTmp = m_poToolDefTable->GetBrushDefRef(nBrushIndex)) != NULL)    {        *psDef = *psTmp;    }    else if (psDef)    {        /* Init to MapInfo default */        static const TABBrushDef csDefaultBrush = MITAB_BRUSH_DEFAULT;        *psDef = csDefaultBrush;        return -1;    }    return 0;}/********************************************************************** *                   TABMAPFile::WriteBrushDef() * * Write a Brush Tool to the map file and return the Brush index that has * been attributed to this Brush tool definition, or -1 if something went * wrong * * Note that the returned index is a 1-based index.  A value of 0  * indicates "none" in MapInfo. * Returns a value >= 0 on success, -1 on error **********************************************************************/int   TABMAPFile::WriteBrushDef(TABBrushDef *psDef){    if (psDef == NULL ||         (m_poToolDefTable == NULL && InitDrawingTools() != 0) ||        m_poToolDefTable==NULL )    {        return -1;    }    return m_poToolDefTable->AddBrushDefRef(psDef);}/********************************************************************** *                   TABMAPFile::ReadFontDef() * * Fill the TABFontDef structure with the definition of the specified Font * index... (1-based Font index) * * If nFontIndex==0 or is invalid, then the structure is cleared. * * Returns 0 on success, -1 on error (i.e. Font not found). **********************************************************************/int   TABMAPFile::ReadFontDef(int nFontIndex, TABFontDef *psDef){    TABFontDef *psTmp;    if (m_poToolDefTable == NULL && InitDrawingTools() != 0)        return -1;    if (psDef && m_poToolDefTable &&        (psTmp = m_poToolDefTable->GetFontDefRef(nFontIndex)) != NULL)    {        *psDef = *psTmp;    }    else if (psDef)    {        /* Init to MapInfo default */        static const TABFontDef csDefaultFont = MITAB_FONT_DEFAULT;        *psDef = csDefaultFont;        return -1;    }    return 0;}/********************************************************************** *                   TABMAPFile::WriteFontDef() * * Write a Font Tool to the map file and return the Font index that has * been attributed to this Font tool definition, or -1 if something went * wrong * * Note that the returned index is a 1-based index.  A value of 0  * indicates "none" in MapInfo. * Returns a value >= 0 on success, -1 on error **********************************************************************/int   TABMAPFile::WriteFontDef(TABFontDef *psDef){    if (psDef == NULL ||         (m_poToolDefTable == NULL && InitDrawingTools() != 0) ||        m_poToolDefTable==NULL )    {        return -1;    }    return m_poToolDefTable->AddFontDefRef(psDef);}/********************************************************************** *                   TABMAPFile::ReadSymbolDef() * * Fill the TABSymbolDef structure with the definition of the specified Symbol * index... (1-based Symbol index) * * If nSymbolIndex==0 or is invalid, then the structure is cleared. * * Returns 0 on success, -1 on error (i.e. Symbol not found). **********************************************************************/int   TABMAPFile::ReadSymbolDef(int nSymbolIndex, TABSymbolDef *psDef){    TABSymbolDef *psTmp;    if (m_poToolDefTable == NULL && InitDrawingTools() != 0)        return -1;    if (psDef && m_poToolDefTable &&        (psTmp = m_poToolDefTable->GetSymbolDefRef(nSymbolIndex)) != NULL)    {        *psDef = *psTmp;    }    else if (psDef)    {        /* Init to MapInfo default */        static const TABSymbolDef csDefaultSymbol = MITAB_SYMBOL_DEFAULT;        *psDef = csDefaultSymbol;        return -1;    }    return 0;}/********************************************************************** *                   TABMAPFile::WriteSymbolDef() * * Write a Symbol Tool to the map file and return the Symbol index that has * been attributed to this Symbol tool definition, or -1 if something went * wrong * * Note that the returned index is a 1-based index.  A value of 0  * indicates "none" in MapInfo. * Returns a value >= 0 on success, -1 on error **********************************************************************/int   TABMAPFile::WriteSymbolDef(TABSymbolDef *psDef){    if (psDef == NULL ||         (m_poToolDefTable == NULL && InitDrawingTools() != 0) ||        m_poToolDefTable==NULL )    {        return -1;    }    return m_poToolDefTable->AddSymbolDefRef(psDef);}#define ORDER_MIN_MAX(type,min,max)                                    \    {   if( (max) < (min) )                                            \          { type temp = (max); (max) = (min); (min) = temp; } }/********************************************************************** *                   TABMAPFile::SetCoordFilter() * * Set the MBR of the area of interest... only objects that at least  * overlap with that area will be returned. * * @param sMin minimum x/y the file's projection coord. * @param sMax maximum x/y the file's projection coord. **********************************************************************/void TABMAPFile::SetCoordFilter(TABVertex sMin, TABVertex sMax){    m_sMinFilter = sMin;    m_sMaxFilter = sMax;    Coordsys2Int(sMin.x, sMin.y, m_XMinFilter, m_YMinFilter, TRUE);    Coordsys2Int(sMax.x, sMax.y, m_XMaxFilter, m_YMaxFilter, TRUE);    ORDER_MIN_MAX(int,m_XMinFilter,m_XMaxFilter);    ORDER_MIN_MAX(int,m_YMinFilter,m_YMaxFilter);    ORDER_MIN_MAX(double,m_sMinFilter.x,m_sMaxFilter.x);    ORDER_MIN_MAX(double,m_sMinFilter.y,m_sMaxFilter.y);}/********************************************************************** *                   TABMAPFile::ResetCoordFilter() * * Reset the MBR of the area of interest to be the extents as defined * in the header.  **********************************************************************/void TABMAPFile::ResetCoordFilter(){    m_XMinFilter = m_poHeader->m_nXMin;    m_YMinFilter = m_poHeader->m_nYMin;    m_XMaxFilter = m_poHeader->m_nXMax;    m_YMaxFilter = m_poHeader->m_nYMax;    Int2Coordsys(m_XMinFilter, m_YMinFilter,                 m_sMinFilter.x, m_sMinFilter.y);    Int2Coordsys(m_XMaxFilter, m_YMaxFilter,                  m_sMaxFilter.x, m_sMaxFilter.y);    ORDER_MIN_MAX(int,m_XMinFilter,m_XMaxFilter);    ORDER_MIN_MAX(int,m_YMinFilter,m_YMaxFilter);    ORDER_MIN_MAX(double,m_sMinFilter.x,m_sMaxFilter.x);    ORDER_MIN_MAX(double,m_sMinFilter.y,m_sMaxFilter.y);}/********************************************************************** *                   TABMAPFile::GetCoordFilter() * * Get the MBR of the area of interest, as previously set by * SetCoordFilter(). * * @param sMin vertex into which the minimum x/y values put in coordsys space. * @param sMax vertex into which the maximum x/y values put in coordsys space. **********************************************************************/void TABMAPFile::GetCoordFilter(TABVertex &sMin, TABVertex &sMax){    sMin = m_sMinFilter;    sMax = m_sMaxFilter;}/********************************************************************** *                   TABMAPFile::CommitSpatialIndex() * * Write the spatial index blocks tree for this file. * * This function applies only to write access mode. *  * Returns 0 on success, -1 on error. **********************************************************************/int TABMAPFile::CommitSpatialIndex(){    if (m_eAccessMode != TABWrite || m_poHeader == NULL)    {        UGKError(ET_Failure, UGKErr_AssertionFailed,             "CommitSpatialIndex() failed: file not opened for write access.");        return -1;    }    if (m_poSpIndex == NULL)    {        return 0;       // Nothing to do!    }    /*-------------------------------------------------------------     * Update header fields and commit index block     * (it's children will be recursively committed as well)     *------------------------------------------------------------*/    // Add 1 to Spatial Index Depth to account to the MapObjectBlocks    m_poHeader->m_nMaxSpIndexDepth = MAX(m_poHeader->m_nMaxSpIndexDepth,                                         m_poSpIndex->GetCurMaxDepth()+1);    m_poSpIndex->GetMBR(m_poHeader->m_nXMin, m_poHeader->m_nYMin,                        m_poHeader->m_nXMax, m_poHeader->m_nYMax);    return m_poSpIndex->CommitToFile();}/********************************************************************** *                   TABMAPFile::GetMinTABFileVersion() * * Returns the minimum TAB file version number that can contain all the * objects stored in this file. **********************************************************************/int   TABMAPFile::GetMinTABFileVersion(){    int nToolVersion = 0;    if (m_poToolDefTable)        nToolVersion = m_poToolDefTable->GetMinVersionNumber();    return MAX(nToolVersion, m_nMinTABVersion);}/********************************************************************** *                   TABMAPFile::Dump() * * Dump block contents... available only in DEBUG mode. **********************************************************************/void TABMAPFile::Dump(FILE *fpOut /*=NULL*/){    if (fpOut == NULL)        fpOut = stdout;    fprintf(fpOut, "----- TABMAPFile::Dump() -----\n");    if (m_fp == NULL)    {        fprintf(fpOut, "File is not opened.\n");    }    else    {        fprintf(fpOut, "File is opened: %s\n", m_pszFname);        fprintf(fpOut, "Coordsys filter  = (%g,%g)-(%g,%g)\n",                 m_sMinFilter.x, m_sMinFilter.y, m_sMaxFilter.x,m_sMaxFilter.y);        fprintf(fpOut, "Int coord filter = (%d,%d)-(%d,%d)\n",                 m_XMinFilter, m_YMinFilter, m_XMaxFilter,m_YMaxFilter);        fprintf(fpOut, "\nFile Header follows ...\n\n");        m_poHeader->Dump(fpOut);        fprintf(fpOut, "... end of file header.\n\n");        fprintf(fpOut, "Associated .ID file ...\n\n");        m_poIdIndex->Dump(fpOut);        fprintf(fpOut, "... end of ID file dump.\n\n");    }    fflush(fpOut);}

⌨️ 快捷键说明

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