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

📄 mitab_mapobjectblock.cpp

📁 mitab,读取MapInfo的地图文件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
}


/**********************************************************************
 *                   class TABMAPObjPoint
 *
 **********************************************************************/

/**********************************************************************
 *                   TABMAPObjPoint::ReadObj()
 *
 * Read Object information starting after the object id
 **********************************************************************/
int TABMAPObjPoint::ReadObj(TABMAPObjectBlock *poObjBlock)
{
    poObjBlock->ReadIntCoord(IsCompressedType(), m_nX, m_nY);

    m_nSymbolId = poObjBlock->ReadByte();      // Symbol index

    SetMBR(m_nX, m_nY, m_nX, m_nY);

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}

/**********************************************************************
 *                   TABMAPObjPoint::WriteObj()
 *
 * Write Object information with the type+object id
 *
 * Returns 0 on success, -1 on error.
 **********************************************************************/
int TABMAPObjPoint::WriteObj(TABMAPObjectBlock *poObjBlock)
{
    // Write object type and id
    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);

    poObjBlock->WriteIntCoord(m_nX, m_nY, IsCompressedType());

    poObjBlock->WriteByte(m_nSymbolId);      // Symbol index

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}


/**********************************************************************
 *                   class TABMAPObjFontPoint
 *
 **********************************************************************/

/**********************************************************************
 *                   TABMAPObjFontPoint::ReadObj()
 *
 * Read Object information starting after the object id
 **********************************************************************/
int TABMAPObjFontPoint::ReadObj(TABMAPObjectBlock *poObjBlock)
{
    m_nSymbolId  = poObjBlock->ReadByte();      // Symbol index
    m_nPointSize = poObjBlock->ReadByte();
    m_nFontStyle = poObjBlock->ReadInt16();     // font style

    m_nR = poObjBlock->ReadByte();
    m_nG = poObjBlock->ReadByte();
    m_nB = poObjBlock->ReadByte();

    poObjBlock->ReadByte();         // ??? BG Color ???
    poObjBlock->ReadByte();         // ???
    poObjBlock->ReadByte();         // ???

    m_nAngle = poObjBlock->ReadInt16();

    poObjBlock->ReadIntCoord(IsCompressedType(), m_nX, m_nY);

    m_nFontId  = poObjBlock->ReadByte();      // Font name index

    SetMBR(m_nX, m_nY, m_nX, m_nY);

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}

/**********************************************************************
 *                   TABMAPObjFontPoint::WriteObj()
 *
 * Write Object information with the type+object id
 *
 * Returns 0 on success, -1 on error.
 **********************************************************************/
int TABMAPObjFontPoint::WriteObj(TABMAPObjectBlock *poObjBlock)
{
    // Write object type and id
    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);

    poObjBlock->WriteByte(m_nSymbolId);   // symbol shape
    poObjBlock->WriteByte(m_nPointSize);
    poObjBlock->WriteInt16(m_nFontStyle);            // font style

    poObjBlock->WriteByte( m_nR );
    poObjBlock->WriteByte( m_nG );
    poObjBlock->WriteByte( m_nB );

    poObjBlock->WriteByte( 0 );
    poObjBlock->WriteByte( 0 );
    poObjBlock->WriteByte( 0 );
    
    poObjBlock->WriteInt16(m_nAngle);

    poObjBlock->WriteIntCoord(m_nX, m_nY, IsCompressedType());

    poObjBlock->WriteByte(m_nFontId);      // Font name index

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}


/**********************************************************************
 *                   class TABMAPObjCustomPoint
 *
 **********************************************************************/

/**********************************************************************
 *                   TABMAPObjCustomPoint::ReadObj()
 *
 * Read Object information starting after the object id
 **********************************************************************/
int TABMAPObjCustomPoint::ReadObj(TABMAPObjectBlock *poObjBlock)
{
    m_nUnknown_ = poObjBlock->ReadByte();       // ??? 
    m_nCustomStyle = poObjBlock->ReadByte(); // 0x01=Show BG, 0x02=Apply Color

    poObjBlock->ReadIntCoord(IsCompressedType(), m_nX, m_nY);

    m_nSymbolId = poObjBlock->ReadByte();      // Symbol index
    m_nFontId   = poObjBlock->ReadByte();      // Font index

    SetMBR(m_nX, m_nY, m_nX, m_nY);

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}

/**********************************************************************
 *                   TABMAPObjCustomPoint::WriteObj()
 *
 * Write Object information with the type+object id
 *
 * Returns 0 on success, -1 on error.
 **********************************************************************/
int TABMAPObjCustomPoint::WriteObj(TABMAPObjectBlock *poObjBlock)
{
    // Write object type and id
    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);

    poObjBlock->WriteByte(m_nUnknown_);  // ??? 
    poObjBlock->WriteByte(m_nCustomStyle); // 0x01=Show BG, 0x02=Apply Color
    poObjBlock->WriteIntCoord(m_nX, m_nY, IsCompressedType());

    poObjBlock->WriteByte(m_nSymbolId);      // Symbol index
    poObjBlock->WriteByte(m_nFontId);      // Font index

  if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}

/**********************************************************************
 *                   class TABMAPObjRectEllipse
 *
 **********************************************************************/

/**********************************************************************
 *                   TABMAPObjRectEllipse::ReadObj()
 *
 * Read Object information starting after the object id
 **********************************************************************/
int TABMAPObjRectEllipse::ReadObj(TABMAPObjectBlock *poObjBlock)
{
    if (m_nType == TAB_GEOM_ROUNDRECT || 
        m_nType == TAB_GEOM_ROUNDRECT_C)
    {
        if (IsCompressedType())
        {
            m_nCornerWidth  = poObjBlock->ReadInt16();
            m_nCornerHeight = poObjBlock->ReadInt16();
        }
        else
        {
            m_nCornerWidth  = poObjBlock->ReadInt32();
            m_nCornerHeight = poObjBlock->ReadInt32();
        }
    }

    poObjBlock->ReadIntCoord(IsCompressedType(), m_nMinX, m_nMinY);
    poObjBlock->ReadIntCoord(IsCompressedType(), m_nMaxX, m_nMaxY);

    m_nPenId    = poObjBlock->ReadByte();      // Pen index
    m_nBrushId  = poObjBlock->ReadByte();      // Brush index

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}

/**********************************************************************
 *                   TABMAPObjRectEllipse::WriteObj()
 *
 * Write Object information with the type+object id
 *
 * Returns 0 on success, -1 on error.
 **********************************************************************/
int TABMAPObjRectEllipse::WriteObj(TABMAPObjectBlock *poObjBlock)
{
    // Write object type and id
    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);

    if (m_nType == TAB_GEOM_ROUNDRECT || 
        m_nType == TAB_GEOM_ROUNDRECT_C)
    {
        if (IsCompressedType())
        {
            poObjBlock->WriteInt16(m_nCornerWidth);
            poObjBlock->WriteInt16(m_nCornerHeight);
        }
        else
        {
            poObjBlock->WriteInt32(m_nCornerWidth);
            poObjBlock->WriteInt32(m_nCornerHeight);
        }
    }

    poObjBlock->WriteIntMBRCoord(m_nMinX, m_nMinY, m_nMaxX, m_nMaxY, 
                                 IsCompressedType());

    poObjBlock->WriteByte(m_nPenId);      // Pen index
    poObjBlock->WriteByte(m_nBrushId);      // Brush index

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}


/**********************************************************************
 *                   class TABMAPObjArc
 *
 **********************************************************************/

/**********************************************************************
 *                   TABMAPObjArc::ReadObj()
 *
 * Read Object information starting after the object id
 **********************************************************************/
int TABMAPObjArc::ReadObj(TABMAPObjectBlock *poObjBlock)
{
    m_nStartAngle = poObjBlock->ReadInt16();
    m_nEndAngle   = poObjBlock->ReadInt16();

    // An arc is defined by its defining ellipse's MBR:
    poObjBlock->ReadIntCoord(IsCompressedType(), 
                             m_nArcEllipseMinX, m_nArcEllipseMinY);
    poObjBlock->ReadIntCoord(IsCompressedType(), 
                             m_nArcEllipseMaxX, m_nArcEllipseMaxY);

    // Read the Arc's actual MBR
    poObjBlock->ReadIntCoord(IsCompressedType(), m_nMinX, m_nMinY);
    poObjBlock->ReadIntCoord(IsCompressedType(), m_nMaxX, m_nMaxY);

    m_nPenId = poObjBlock->ReadByte();      // Pen index

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}

/**********************************************************************
 *                   TABMAPObjArc::WriteObj()
 *
 * Write Object information with the type+object id
 *
 * Returns 0 on success, -1 on error.
 **********************************************************************/
int TABMAPObjArc::WriteObj(TABMAPObjectBlock *poObjBlock)
{
    // Write object type and id
    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);

    poObjBlock->WriteInt16(m_nStartAngle);
    poObjBlock->WriteInt16(m_nEndAngle);
    
    // An arc is defined by its defining ellipse's MBR:
    poObjBlock->WriteIntMBRCoord(m_nArcEllipseMinX, m_nArcEllipseMinY, 
                                 m_nArcEllipseMaxX, m_nArcEllipseMaxY, 
                                 IsCompressedType());

    // Write the Arc's actual MBR
    poObjBlock->WriteIntMBRCoord(m_nMinX, m_nMinY, m_nMaxX, m_nMaxY, 
                                 IsCompressedType());

    poObjBlock->WriteByte(m_nPenId);      // Pen index

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}



/**********************************************************************
 *                   class TABMAPObjText
 *
 **********************************************************************/

/**********************************************************************
 *                   TABMAPObjText::ReadObj()
 *
 * Read Object information starting after the object id
 **********************************************************************/
int TABMAPObjText::ReadObj(TABMAPObjectBlock *poObjBlock)
{
    m_nCoordBlockPtr  = poObjBlock->ReadInt32();    // String position
    m_nCoordDataSize  = poObjBlock->ReadInt16();    // String length
    m_nTextAlignment  = poObjBlock->ReadInt16();    // just./spacing/arrow

    m_nAngle     = poObjBlock->ReadInt16();         // Tenths of degree

    m_nFontStyle = poObjBlock->ReadInt16();         // Font style/effect

    m_nFGColorR  = poObjBlock->ReadByte();
    m_nFGColorG  = poObjBlock->ReadByte();
    m_nFGColorB  = poObjBlock->ReadByte();

    m_nBGColorR  = poObjBlock->ReadByte();
    m_nBGColorG  = poObjBlock->ReadByte();
    m_nBGColorB  = poObjBlock->ReadByte();

    // Label line end point
    poObjBlock->ReadIntCoord(IsCompressedType(), m_nLineEndX, m_nLineEndY);

    // Text Height
    if (IsCompressedType())
        m_nHeight = poObjBlock->ReadInt16();
    else
        m_nHeight = poObjBlock->ReadInt32();

    // Font name
    m_nFontId = poObjBlock->ReadByte();      // Font name index

    // MBR after rotation
    poObjBlock->ReadIntCoord(IsCompressedType(), m_nMinX, m_nMinY);
    poObjBlock->ReadIntCoord(IsCompressedType(), m_nMaxX, m_nMaxY);

    m_nPenId = poObjBlock->ReadByte();      // Pen index

    if (CPLGetLastErrorNo() != 0)
        return -1;

    return 0;
}

/**********************************************************************
 *                   TABMAPObjText::WriteObj()
 *
 * Write Object information with the type+object id
 *
 * Returns 0 on success, -1 on error.

⌨️ 快捷键说明

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