Пример #1
0
void LASHeader::AddVLR(LASVariableRecord const& v) 
{
    m_vlrs.push_back(v);

    uint32_t end_size = 0;
    std::vector<LASVariableRecord>::const_iterator i;
        
    // Calculate a new data offset size
    for (i = m_vlrs.begin(); i != m_vlrs.end(); ++i) 
    {
        end_size += (*i).GetTotalSize();
    }

    uint32_t size = 0;
    uint32_t const dataSignatureSize = 2;
    
    // Add the signature if we're a 1.0 file    
    if (eVersionMinorMin == m_versionMinor) {
        size = end_size + dataSignatureSize; 
    } else {
        size = end_size;
    }

    SetDataOffset(GetHeaderSize()+size);

    // We're assuming that the reader or writer has reset 
    // the VLR count to 0 before adding them back with AddVLR  
    // FIXME I think this is still broken - hobu
    m_recordsCount += 1;
}
Пример #2
0
void LASHeader::DeleteVLR(uint32_t index) 
{    
    if (index >= m_vlrs.size())
        throw std::out_of_range("index is out of range");

    std::vector<LASVariableRecord>::iterator i = m_vlrs.begin() + index;

    // Deal with the dataoffset when deleting
    uint32_t size = (*i).GetTotalSize();

    m_vlrs.erase(i);
    m_recordsCount = static_cast<uint32_t>(m_vlrs.size());
    
    SetDataOffset(GetDataOffset() - size);
    
}
Пример #3
0
    BidirBuffer::BidirBuffer( IFixedMemBlockPool& alloc, Offset specOffset ) : m_alloc(alloc),
        m_pBlock(static_cast<byte*>( alloc.alloc(alloc.getBlockSize()) )),
        m_blockSize(m_alloc.getBlockSize())
    {
        int offset = 0;

        if (specOffset == CCenter) offset = m_blockSize / 2;
        else
        if (specOffset == CBegin) offset = 0;
        else
        if (specOffset == CEnd) offset = m_blockSize;        
        else
            ESS_ASSERT("Invalid offset");

        SetDataOffset(offset);
    }
Пример #4
0
void LASHeader::SetVersionMinor(uint8_t v)
{
    if (v > eVersionMinorMax)
        throw std::out_of_range("version minor out of range");
    
    m_versionMinor = v;
    
    uint32_t size = 0;
    uint32_t const dataSignatureSize = 2;
    
    // Add the signature if we're a 1.0 file    
    if (eVersionMinorMin == m_versionMinor) {
        size = dataSignatureSize; 
    } 

    SetDataOffset(GetHeaderSize()+size);
    
}
Пример #5
0
void LASHeader::ClearGeoKeyVLRs()
{
    std::string const uid("LASF_Projection");

    uint32_t beg_size = 0;
    uint32_t end_size = 0;

    std::vector<LASVariableRecord> vlrs = m_vlrs;
    std::vector<LASVariableRecord>::const_iterator i;
    std::vector<LASVariableRecord>::iterator j;

    for (i = m_vlrs.begin(); i != m_vlrs.end(); ++i)
    {
        LASVariableRecord record = *i;
        beg_size += (*i).GetTotalSize();

        std::string user = record.GetUserId(true);
        if (uid == user.c_str())
        {
            uint16_t id = record.GetRecordId();

            if (34735 == id)
            {
                // Geotiff SHORT key
                for(j = vlrs.begin(); j != vlrs.end(); ++j)
                {
                    if (*j == *i)
                    {
                        vlrs.erase(j);
                        break;
                    }
                }
            }
            else if (34736 == id)
            {
                // Geotiff DOUBLE key
                for(j = vlrs.begin(); j != vlrs.end(); ++j)
                {
                    if (*j == *i)
                    {
                        vlrs.erase(j);
                        break;
                    }
                }
            }        
            else if (34737 == id)
            {
                // Geotiff ASCII key
                for (j = vlrs.begin(); j != vlrs.end(); ++j)
                {
                    if (*j == *i)
                    {
                        vlrs.erase(j);
                        break;
                    }
                }
            }
        } // uid == user
    }
    
    // Copy our list of surviving VLRs back to our member variable
    // and update header information
    m_vlrs = vlrs;
    m_recordsCount = static_cast<uint32_t>(m_vlrs.size());
    
    // Calculate a new data offset size
    for (i = m_vlrs.begin(); i != m_vlrs.end(); ++i) 
    {
        end_size += (*i).GetTotalSize();
    }

    uint32_t size = 0;
    uint32_t const dataSignatureSize = 2;
    
    // Add the signature if we're a 1.0 file    
    if (eVersionMinorMin == m_versionMinor)
    {
        size = end_size + dataSignatureSize; 
    }
    else
    {
        size = end_size;
    }

    SetDataOffset(GetHeaderSize()+size);

}
Пример #6
0
 void BidirBuffer::PushFront(const void* pSrc, int size )
 {
     if (size == 0) return; // ignore
     SetDataOffset(GetDataOffset() - size, m_dataSize + size);
     memcpy(Front(), pSrc, size);
 }
Пример #7
0
 BidirBuffer::BidirBuffer( IFixedMemBlockPool& alloc, int offset ) : m_alloc(alloc),
     m_pBlock(static_cast<byte*>( alloc.alloc(alloc.getBlockSize()) )),
     m_blockSize(m_alloc.getBlockSize())
 {
     SetDataOffset(offset);
 }
Пример #8
0
 void BidirBuffer::Clear()
 {
     SetDataOffset(GetDataOffset());
 }
Пример #9
0
 byte BidirBuffer::PopFront()
 {
     byte result = *Front();
     SetDataOffset(GetDataOffset() + 1, m_dataSize - 1);
     return result;
 }
Пример #10
0
 byte BidirBuffer::PopBack()
 {
     byte result = *Back();
     SetDataOffset(GetDataOffset(), m_dataSize - 1);
     return result;
 }
Пример #11
0
 void BidirBuffer::AddSpaceFront( int distance ) /* size += distance */
 {
     SetDataOffset(GetDataOffset() - distance, m_dataSize + distance);
 }
Пример #12
0
 void BidirBuffer::AddSpaceBack( int distance ) /* size += distance */
 {
     SetDataOffset(GetDataOffset(), m_dataSize + distance);
 }