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

📄 mitab_mapobjectblock.cpp

📁 用于读取TAB、MIF、SHP文件的类
💻 CPP
📖 第 1 页 / 共 4 页
字号:
        return -1;    return 0;}/********************************************************************** *                   class TABMAPObjPLine * * Applies to PLINE, MULTIPLINE and REGION object types **********************************************************************//********************************************************************** *                   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 (CPLGetLastErrorNo() != 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 (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                   class TABMAPObjPoint * **********************************************************************//********************************************************************** *                   TABMAPObjPoint::ReadObj() * * Read Object information starting after the object id **********************************************************************/int TABMAPObjPoint::ReadObj(TABMAPObjectBlock *poObjBlock){//__TODO__  For now this is read directly in ReadGeometryFromMAPFile()//          This will be implemented the day we support random update.    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){//__TODO__  For now this is read directly in ReadGeometryFromMAPFile()//          This will be implemented the day we support random update.    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){//__TODO__  For now this is read directly in ReadGeometryFromMAPFile()//          This will be implemented the day we support random update.    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){//__TODO__  For now this is read directly in ReadGeometryFromMAPFile()//          This will be implemented the day we support random update.    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){//__TODO__  For now this is read directly in ReadGeometryFromMAPFile()//          This will be implemented the day we support random update.    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, 

⌨️ 快捷键说明

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