Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadNextPoint fails when filtering and EOF is reached #122

Open
tcommandeur opened this issue Jun 20, 2017 · 0 comments
Open

ReadNextPoint fails when filtering and EOF is reached #122

tcommandeur opened this issue Jun 20, 2017 · 0 comments

Comments

@tcommandeur
Copy link

When using libLAS for reading LAS and LAZ files while filtering using the built in filters I ran into some issues.

If a filter is applied and a LAS is used the code (ReaderImpl::ReadNextPoint()) will return an out_of_range exception if the stream is EOF, this exception is caught by Reader::ReadNextPoint()

    try
    {
        m_pimpl->ReadNextPoint();
        return true;
    }
    catch (std::out_of_range const&)
    {
    }

If a filter is applied and a LAZ is used the code (ZipReaderImpl::ReadNextPoint()) will use ReadIdiom() with the following code:

    bool ok = m_unzipper->read(m_zipPoint->m_lz_point);

    if (!ok)
    {
        std::ostringstream oss;
        const char* errMsg = m_unzipper->get_error();
        oss << "Error reading compressed point data: " ;
        if (errMsg)
            oss << "'" << m_unzipper->get_error() <<"'";
        else
            oss << "no message from LASzip library";
        throw liblas_error(oss.str());
    }

This function throws a liblas_error and this exception is NOT caught by Reader::ReadNextPoint().

Neither implementation handle the out_of_bounds in a clean fashion since they read the next point before checking if the stream is EOF.

The code below is used for reading in zipreader, I was wondering why it has the if(!FilterPoint(*m_point)) in the first place?

    if (!FilterPoint(*m_point))
    {
        ReadIdiom();

        while (!FilterPoint(*m_point))
        {
            ReadIdiom();
            if (m_current == m_size) 
            {
                bLastPoint = true;
                break;
            }
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant