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

📄 mitab_mapobjectblock.cpp

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 CPP
📖 第 1 页 / 共 4 页
字号:
 **********************************************************************/GBool TABMAPObjHdr::IsCompressedType(){    // Compressed types are 1, 4, 7, etc.    return ((m_nType % 3) == 1 ? TRUE : FALSE);}/********************************************************************** *                   TABMAPObjHdr::WriteObjTypeAndId() * * Writetype+object id information... should be called only by the derived * classes' WriteObj() methods. * * Returns 0 on success, -1 on error. **********************************************************************/int TABMAPObjHdr::WriteObjTypeAndId(TABMAPObjectBlock *poObjBlock){    poObjBlock->WriteByte(m_nType);    return poObjBlock->WriteInt32(m_nId);}/********************************************************************** *                   TABMAPObjHdr::SetMBR() * **********************************************************************/void TABMAPObjHdr::SetMBR(GInt32 nMinX, GInt32 nMinY,                           GInt32 nMaxX, GInt32 nMaxY){    m_nMinX = MIN(nMinX, nMaxX);    m_nMinY = MIN(nMinY, nMaxY);    m_nMaxX = MAX(nMinX, nMaxX);    m_nMaxY = MAX(nMinY, nMaxY);}/********************************************************************** *                   class TABMAPObjLine * * Applies to 2-points LINEs only **********************************************************************//********************************************************************** *                   TABMAPObjLine::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 TABMAPObjLine::ReadObj(TABMAPObjectBlock *poObjBlock){    poObjBlock->ReadIntCoord(IsCompressedType(), m_nX1, m_nY1);    poObjBlock->ReadIntCoord(IsCompressedType(), m_nX2, m_nY2);    m_nPenId = poObjBlock->ReadByte();      // Pen index    SetMBR(m_nX1, m_nY1, m_nX2, m_nY2);    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                   TABMAPObjLine::WriteObj() * * Write Object information with the type+object id * * Returns 0 on success, -1 on error. **********************************************************************/int TABMAPObjLine::WriteObj(TABMAPObjectBlock *poObjBlock){    // Write object type and id    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);    poObjBlock->WriteIntCoord(m_nX1, m_nY1, IsCompressedType());    poObjBlock->WriteIntCoord(m_nX2, m_nY2, IsCompressedType());    poObjBlock->WriteByte(m_nPenId);      // Pen index    if (CPLGetLastErrorNo() != 0)        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

⌨️ 快捷键说明

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