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

📄 mitab_mapobjectblock.cpp

📁 用于读取TAB、MIF、SHP文件的类
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                                 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){//__TODO__  For now this is read directly in ReadGeometryFromMAPFile()//          This will be implemented the day we support random update.    return 0;}/********************************************************************** *                   TABMAPObjText::WriteObj() * * Write Object information with the type+object id * * Returns 0 on success, -1 on error. **********************************************************************/int TABMAPObjText::WriteObj(TABMAPObjectBlock *poObjBlock){    // Write object type and id    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);    poObjBlock->WriteInt32(m_nCoordBlockPtr);     // String position    poObjBlock->WriteInt16(m_nCoordDataSize);     // String length    poObjBlock->WriteInt16(m_nTextAlignment);     // just./spacing/arrow    poObjBlock->WriteInt16(m_nAngle);             // Tenths of degree    poObjBlock->WriteInt16(m_nFontStyle);         // Font style/effect    poObjBlock->WriteByte(m_nFGColorR );    poObjBlock->WriteByte(m_nFGColorG );    poObjBlock->WriteByte(m_nFGColorB );    poObjBlock->WriteByte(m_nBGColorR );    poObjBlock->WriteByte(m_nBGColorG );    poObjBlock->WriteByte(m_nBGColorB );    // Label line end point    poObjBlock->WriteIntCoord(m_nLineEndX, m_nLineEndY, IsCompressedType());    // Text Height    poObjBlock->WriteInt32(m_nHeight);    // Font name    poObjBlock->WriteByte(m_nFontId);      // Font name index    // MBR after rotation    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 TABMAPObjMultiPoint * * Applies to PLINE, MULTIPLINE and REGION object types **********************************************************************//********************************************************************** *                   TABMAPObjMultiPoint::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 TABMAPObjMultiPoint::ReadObj(TABMAPObjectBlock *poObjBlock){    m_nCoordBlockPtr = poObjBlock->ReadInt32();    m_nNumPoints = poObjBlock->ReadInt32();    if (IsCompressedType())    {        m_nCoordDataSize = m_nNumPoints * 2 * 2;    }    else    {        m_nCoordDataSize = m_nNumPoints * 2 * 4;    }#ifdef TABDUMP    printf("MULTIPOINT: id=%d, type=%d, "           "CoordBlockPtr=%d, CoordDataSize=%d, numPoints=%d\n",           m_nId, m_nType, m_nCoordBlockPtr, m_nCoordDataSize, m_nNumPoints);#endif    // ?????    poObjBlock->ReadInt32();    poObjBlock->ReadInt32();    poObjBlock->ReadInt32();    poObjBlock->ReadByte();    poObjBlock->ReadByte();    poObjBlock->ReadByte();    m_nSymbolId = poObjBlock->ReadByte();    // ?????    poObjBlock->ReadByte();    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        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        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();        // 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;    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                   TABMAPObjMultiPoint::WriteObj() * * Write Object information with the type+object id * * Returns 0 on success, -1 on error. **********************************************************************/int TABMAPObjMultiPoint::WriteObj(TABMAPObjectBlock *poObjBlock){    // Write object type and id    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);    poObjBlock->WriteInt32(m_nCoordBlockPtr);    // Number of points    poObjBlock->WriteInt32(m_nNumPoints);//  unknown bytes    poObjBlock->WriteInt32(0);    poObjBlock->WriteInt32(0);    poObjBlock->WriteInt32(0);    poObjBlock->WriteByte(0);    poObjBlock->WriteByte(0);    poObjBlock->WriteByte(0);    // Symbol Id    poObjBlock->WriteByte(m_nSymbolId);    // ????    poObjBlock->WriteByte(0);    // MBR    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);        poObjBlock->WriteInt32(m_nComprOrgX);        poObjBlock->WriteInt32(m_nComprOrgY);        // MBR relative to object 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    {        // Region center/label point        poObjBlock->WriteInt32(m_nLabelX);        poObjBlock->WriteInt32(m_nLabelY);        poObjBlock->WriteInt32(m_nMinX);        poObjBlock->WriteInt32(m_nMinY);        poObjBlock->WriteInt32(m_nMaxX);        poObjBlock->WriteInt32(m_nMaxY);    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                   class TABMAPObjCollection * **********************************************************************//********************************************************************** *                   TABMAPObjCollection::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 TABMAPObjCollection::ReadObj(TABMAPObjectBlock *poObjBlock){    const int SIZE_OF_PLINE_HDR = 24;    const int SIZE_OF_REGION_HDR = 24;//    const int SIZE_OF_MULTI_PT_HDR = 24;      m_nCoordBlockPtr = poObjBlock->ReadInt32();    // pointer into coord block    m_nNumMultiPoints = poObjBlock->ReadInt32();   // no. points in multi point    m_nRegionDataSize = poObjBlock->ReadInt32();   // size of region data inc. section hdrs    m_nPolylineDataSize = poObjBlock->ReadInt32(); // size of multipline data inc. section hdrs    m_nNumRegSections = poObjBlock->ReadInt16();   // Num Region section headers    m_nNumPLineSections = poObjBlock->ReadInt16(); // Num Pline section headers    if (IsCompressedType())    {        m_nMPointDataSize = m_nNumMultiPoints * 2 * 2;    }    else    {        m_nMPointDataSize = m_nNumMultiPoints * 2 * 4;    }    /* NB. The Region and Pline section headers are supposed to be extended     * by 2 bytes to align with a 4 byte boundary.  This extension is included     * in the Region and Polyline data sizes read above. In reality the      * extension is nowhere to be found so the actual data sizes are     * two bytes shorter per section header.     */    m_nTotalRegDataSize = 0;    if(m_nNumRegSections > 0)    {        m_nTotalRegDataSize = SIZE_OF_REGION_HDR + m_nRegionDataSize -                            (2 * m_nNumRegSections);    }    m_nTotalPolyDataSize = 0;    if(m_nNumPLineSections > 0)    {        m_nTotalPolyDataSize = SIZE_OF_PLINE_HDR + m_nPolylineDataSize -                             (2 * m_nNumPLineSections);    }#ifdef TABDUMP    printf("COLLECTION: id=%d, type=%d (0x%x), "           "CoordBlockPtr=%d, numRegionSections=%d, "           "numPlineSections=%d, numPoints=%d\n",           m_nId, m_nType, m_nType, m_nCoordBlockPtr,            m_nNumRegSections, m_nNumPLineSections, m_nNumMultiPoints);#endif    // ??? All zeros ???    poObjBlock->ReadInt32();    poObjBlock->ReadInt32();    poObjBlock->ReadInt32();    poObjBlock->ReadByte();    poObjBlock->ReadByte();    poObjBlock->ReadByte();    m_nMultiPointSymbolId = poObjBlock->ReadByte();    poObjBlock->ReadByte();  // ???    m_nRegionPenId = poObjBlock->ReadByte();    m_nPolylinePenId = poObjBlock->ReadByte();    m_nRegionBrushId = poObjBlock->ReadByte();    if (IsCompressedType())    {#ifdef TABDUMP    printf("COLLECTION: READING ComprOrg @ %d\n",           poObjBlock->GetCurAddress());#endif        // Compressed coordinate origin        m_nComprOrgX = poObjBlock->ReadInt32();        m_nComprOrgY = poObjBlock->ReadInt32();        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();#ifdef TABDUMP    printf("COLLECTION: ComprOrgX,Y= (%d,%d)\n",           m_nComprOrgX, m_nComprOrgY);#endif    }    else    {        m_nMinX = poObjBlock->ReadInt32();    // Read MBR        m_nMinY = poObjBlock->ReadInt32();        m_nMaxX = poObjBlock->ReadInt32();        m_nMaxY = poObjBlock->ReadInt32();        // 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;    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                   TABMAPObjCollection::WriteObj() * * Write Object information with the type+object id * * Returns 0 on success, -1 on error. **********************************************************************/int TABMAPObjCollection::WriteObj(TABMAPObjectBlock *poObjBlock){    // Write object type and id    TABMAPObjHdr::WriteObjTypeAndId(poObjBlock);    poObjBlock->WriteInt32(m_nCoordBlockPtr);    // pointer into coord block    poObjBlock->WriteInt32(m_nNumMultiPoints);   // no. points in multi point    poObjBlock->WriteInt32(m_nRegionDataSize);   // size of region data inc. section hdrs    poObjBlock->WriteInt32(m_nPolylineDataSize); // size of Mpolyline data inc. sction hdrs    poObjBlock->WriteInt16(m_nNumRegSections);   // Num Region section headers    poObjBlock->WriteInt16(m_nNumPLineSections); // Num Pline section headers    // Unknown data ?????    poObjBlock->WriteInt32(0);    poObjBlock->WriteInt32(0);    poObjBlock->WriteInt32(0);    poObjBlock->WriteByte(0);    poObjBlock->WriteByte(0);    poObjBlock->WriteByte(0);    poObjBlock->WriteByte(m_nMultiPointSymbolId);    poObjBlock->WriteByte(0);    poObjBlock->WriteByte(m_nRegionPenId);    poObjBlock->WriteByte(m_nPolylinePenId);    poObjBlock->WriteByte(m_nRegionBrushId);    if (IsCompressedType())    {#ifdef TABDUMP    printf("COLLECTION: WRITING ComprOrgX,Y= (%d,%d) @ %d\n",           m_nComprOrgX, m_nComprOrgY, poObjBlock->GetCurAddress());#endif        // Compressed coordinate origin        poObjBlock->WriteInt32(m_nComprOrgX);        poObjBlock->WriteInt32(m_nComprOrgY);        poObjBlock->WriteInt16(m_nMinX - m_nComprOrgX);  // MBR        poObjBlock->WriteInt16(m_nMinY - m_nComprOrgY);        poObjBlock->WriteInt16(m_nMaxX - m_nComprOrgX);        poObjBlock->WriteInt16(m_nMaxY - m_nComprOrgY);    }    else    {        poObjBlock->WriteInt32(m_nMinX);    // MBR        poObjBlock->WriteInt32(m_nMinY);        poObjBlock->WriteInt32(m_nMaxX);        poObjBlock->WriteInt32(m_nMaxY);    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}

⌨️ 快捷键说明

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