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

📄 mitab_mapfile.cpp

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        {            // Failed... an error has already been reported.            delete poBlock;            return -1;        }        poBlock->GotoByteInBlock(8);        nStatus = m_poToolDefTable->ReadAllToolDefs(poBlock);        delete poBlock;    }    return nStatus;}/********************************************************************** *                   TABMAPFile::CommitDrawingTools() * * Write the drawing tools for this file. * * This function applies only to write access mode. *  * Returns 0 on success, -1 on error. **********************************************************************/int TABMAPFile::CommitDrawingTools(){    int nStatus = 0;    if (m_eAccessMode != TABWrite || m_poHeader == NULL)    {        CPLError(CE_Failure, CPLE_AssertionFailed,            "CommitDrawingTools() failed: file not opened for write access.");        return -1;    }    if (m_poToolDefTable == NULL ||        (m_poToolDefTable->GetNumPen() +         m_poToolDefTable->GetNumBrushes() +         m_poToolDefTable->GetNumFonts() +         m_poToolDefTable->GetNumSymbols()) == 0)    {        return 0;       // Nothing to do!    }    /*-------------------------------------------------------------     * Create a new TABMAPToolBlock and update header fields     *------------------------------------------------------------*/    TABMAPToolBlock *poBlock;        poBlock = new TABMAPToolBlock(m_eAccessMode);    poBlock->InitNewBlock(m_fp, 512, m_oBlockManager.AllocNewBlock());    poBlock->SetMAPBlockManagerRef(&m_oBlockManager);    m_poHeader->m_nFirstToolBlock = poBlock->GetStartAddress();    m_poHeader->m_numPenDefs = m_poToolDefTable->GetNumPen();    m_poHeader->m_numBrushDefs = m_poToolDefTable->GetNumBrushes();    m_poHeader->m_numFontDefs = m_poToolDefTable->GetNumFonts();    m_poHeader->m_numSymbolDefs = m_poToolDefTable->GetNumSymbols();    /*-------------------------------------------------------------     * Do the actual work and delete poBlock     * (Note that poBlock will have already been committed to the file     * by WriteAllToolDefs() )     *------------------------------------------------------------*/    nStatus = m_poToolDefTable->WriteAllToolDefs(poBlock);        m_poHeader->m_numMapToolBlocks = poBlock->GetNumBlocksInChain();    delete poBlock;    return nStatus;}/********************************************************************** *                   TABMAPFile::ReadPenDef() * * Fill the TABPenDef structure with the definition of the specified pen * index... (1-based pen index) * * If nPenIndex==0 or is invalid, then the structure is cleared. * * Returns 0 on success, -1 on error (i.e. Pen not found). **********************************************************************/int   TABMAPFile::ReadPenDef(int nPenIndex, TABPenDef *psDef){    TABPenDef *psTmp;    if (m_poToolDefTable == NULL && InitDrawingTools() != 0)        return -1;    if (psDef && m_poToolDefTable &&        (psTmp = m_poToolDefTable->GetPenDefRef(nPenIndex)) != NULL)    {        *psDef = *psTmp;    }    else if (psDef)    {        /* Init to MapInfo default */        static const TABPenDef csDefaultPen = MITAB_PEN_DEFAULT;        *psDef = csDefaultPen;        return -1;    }    return 0;}/********************************************************************** *                   TABMAPFile::WritePenDef() * * Write a Pen Tool to the map file and return the pen index that has * been attributed to this Pen 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::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, TABVerte

⌨️ 快捷键说明

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