예제 #1
0
int TranslateKernel::execute()
{
    std::ostream *metaOut(nullptr);

    if (m_metadataFile.size())
    {
        metaOut = FileUtils::createFile(m_metadataFile);
        if (! metaOut)
            throw pdal_error("Couldn't output metadata output file '" +
                m_metadataFile + "'.");
    }

    if (m_filterJSON.size() && m_filterType.size())
        throw pdal_error("Cannot set both --filter options and --json options");

    if (!m_filterJSON.empty())
        makeJSONPipeline();
    else
        makeArgPipeline();

    if (m_pipelineOutput.size() > 0)
        PipelineWriter::writePipeline(m_manager.getStage(), m_pipelineOutput);
    m_manager.execute();
    if (metaOut)
    {
        MetadataNode m = m_manager.getMetadata();
        *metaOut << Utils::toJSON(m);
        FileUtils::closeFile(metaOut);
    }

    return 0;
}
예제 #2
0
int TranslateKernel::execute()
{
    std::ostream *metaOut(nullptr);

    if (m_filterJSON.size() && m_filterType.size())
        throw pdal_error("Cannot set both --filter options and --json options");

    if (m_metadataFile.size())
    {
        if (m_pipelineOutputFile.size())
            m_log->get(LogLevel::Info) << "Metadata will not be written. "
                "'pipeline' option prevents execution.";
        else
        {
        metaOut = FileUtils::createFile(m_metadataFile);
        if (! metaOut)
            throw pdal_error("Couldn't output metadata output file '" +
                m_metadataFile + "'.");
        }
    }

    if (!m_filterJSON.empty())
        makeJSONPipeline();
    else
        makeArgPipeline();

    // If we write pipeline output, we don't run, and therefore don't write
    if (m_pipelineOutputFile.size() > 0)
    {
        PipelineWriter::writePipeline(m_manager.getStage(),
            m_pipelineOutputFile);
        return 0;
    }
    m_manager.execute();
    if (metaOut)
    {
        MetadataNode m = m_manager.getMetadata();
        *metaOut << Utils::toJSON(m);
        FileUtils::closeFile(metaOut);
    }

    return 0;
}