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

📄 tabmapobjpline.cpp

📁 linux下一款GIS程序源码
💻 CPP
字号:
// tabmapobjpline.cpp: implementation of the TABMAPObjPLine class.////////////////////////////////////////////////////////////////////////#include "tabmapobjpline.h"#include "ugk_errhandle.h"/********************************************************************** *                   TABMAPObjPLine::ReadObj() * * Read Object information starting after the object id which should  * have been read by TABMAPObjHdr::ReadNextObj() already. * This function should be called only by TABMAPObjHdr::ReadNextObj(). * * Returns 0 on success, -1 on error. **********************************************************************/int TABMAPObjPLine::ReadObj(TABMAPObjectBlock *poObjBlock){    m_nCoordBlockPtr = poObjBlock->ReadInt32();    m_nCoordDataSize = poObjBlock->ReadInt32();    if (m_nCoordDataSize & 0x80000000)    {        m_bSmooth = TRUE;        m_nCoordDataSize &= 0x7FFFFFFF; //Take smooth flag out of the value    }    else    {        m_bSmooth = FALSE;    }    // Number of line segments applies only to MULTIPLINE/REGION but not PLINE    if (m_nType == TAB_GEOM_PLINE_C ||        m_nType == TAB_GEOM_PLINE )    {        m_numLineSections = 1;    }    else    {        m_numLineSections = poObjBlock->ReadInt16();    }#ifdef TABDUMP    printf("PLINE/REGION: id=%d, type=%d, "           "CoordBlockPtr=%d, CoordDataSize=%d, numLineSect=%d, bSmooth=%d\n",           m_nId, m_nType, m_nCoordBlockPtr, m_nCoordDataSize,            m_numLineSections, m_bSmooth);#endif    if (IsCompressedType())    {        // Region center/label point, relative to compr. coord. origin        // No it's not relative to the Object block center        m_nLabelX = poObjBlock->ReadInt16();        m_nLabelY = poObjBlock->ReadInt16();        // Compressed coordinate origin (present only in compressed case!)        m_nComprOrgX = poObjBlock->ReadInt32();        m_nComprOrgY = poObjBlock->ReadInt32();        m_nLabelX += m_nComprOrgX;        m_nLabelY += m_nComprOrgY;        m_nMinX = m_nComprOrgX + poObjBlock->ReadInt16();  // Read MBR        m_nMinY = m_nComprOrgY + poObjBlock->ReadInt16();        m_nMaxX = m_nComprOrgX + poObjBlock->ReadInt16();        m_nMaxY = m_nComprOrgY + poObjBlock->ReadInt16();    }    else    {        // Region center/label point, relative to compr. coord. origin        // No it's not relative to the Object block center        m_nLabelX = poObjBlock->ReadInt32();        m_nLabelY = poObjBlock->ReadInt32();        m_nMinX = poObjBlock->ReadInt32();    // Read MBR        m_nMinY = poObjBlock->ReadInt32();        m_nMaxX = poObjBlock->ReadInt32();        m_nMaxY = poObjBlock->ReadInt32();    }    if ( ! IsCompressedType() )    {        // Init. Compr. Origin to a default value in case type is ever changed        m_nComprOrgX = (m_nMinX + m_nMaxX) / 2;        m_nComprOrgY = (m_nMinY + m_nMaxY) / 2;    }    m_nPenId = poObjBlock->ReadByte();      // Pen index    if (m_nType == TAB_GEOM_REGION ||        m_nType == TAB_GEOM_REGION_C ||        m_nType == TAB_GEOM_V450_REGION ||        m_nType == TAB_GEOM_V450_REGION_C )    {        m_nBrushId = poObjBlock->ReadByte();    // Brush index... REGION only    }    else    {        m_nBrushId = 0;    }    if (UGKGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                   TABMAPObjPLine::WriteObj() * * Write Object information with the type+object id * * Returns 0 on success, -1 on error. **********************************************************************/int TABMAPObjPLine::WriteObj(TABMAPObjectBlock *poObjBlock){    // Write object type and id    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);    poObjBlock->WriteInt32(m_nCoordBlockPtr);    // Combine smooth flag in the coord data size.    if (m_bSmooth)        poObjBlock->WriteInt32( m_nCoordDataSize | 0x80000000 );    else        poObjBlock->WriteInt32( m_nCoordDataSize );    // Number of line segments applies only to MULTIPLINE/REGION but not PLINE    if (m_nType != TAB_GEOM_PLINE_C &&        m_nType != TAB_GEOM_PLINE )    {        poObjBlock->WriteInt16(m_numLineSections);    }    if (IsCompressedType())    {        // Region center/label point, relative to compr. coord. origin        // No it's not relative to the Object block center        poObjBlock->WriteInt16(m_nLabelX - m_nComprOrgX);        poObjBlock->WriteInt16(m_nLabelY - m_nComprOrgY);        // Compressed coordinate origin (present only in compressed case!)        poObjBlock->WriteInt32(m_nComprOrgX);        poObjBlock->WriteInt32(m_nComprOrgY);    }    else    {        // Region center/label point        poObjBlock->WriteInt32(m_nLabelX);        poObjBlock->WriteInt32(m_nLabelY);    }    // MBR    if (IsCompressedType())    {        // MBR relative to PLINE origin (and not object block center)        poObjBlock->WriteInt16(m_nMinX - m_nComprOrgX);        poObjBlock->WriteInt16(m_nMinY - m_nComprOrgY);        poObjBlock->WriteInt16(m_nMaxX - m_nComprOrgX);        poObjBlock->WriteInt16(m_nMaxY - m_nComprOrgY);    }    else    {        poObjBlock->WriteInt32(m_nMinX);        poObjBlock->WriteInt32(m_nMinY);        poObjBlock->WriteInt32(m_nMaxX);        poObjBlock->WriteInt32(m_nMaxY);    }    poObjBlock->WriteByte(m_nPenId);      // Pen index    if (m_nType == TAB_GEOM_REGION ||        m_nType == TAB_GEOM_REGION_C ||        m_nType == TAB_GEOM_V450_REGION ||        m_nType == TAB_GEOM_V450_REGION_C )    {        poObjBlock->WriteByte(m_nBrushId);    // Brush index... REGION only    }    if (UGKGetLastErrorNo() != 0)        return -1;    return 0;}

⌨️ 快捷键说明

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