Exemplo n.º 1
0
void Writer::writeBegin(boost::uint64_t /*targetNumPointsToWrite*/)
{
    std::string block_table = getOptions().getValueOrThrow<std::string>("block_table");
    std::string cloud_table = getOptions().getValueOrThrow<std::string>("cloud_table");
    std::string cloud_column = getOptions().getValueOrDefault<std::string>("cloud_column", "id");

    m_block_insert_query << "INSERT INTO " << boost::to_lower_copy(block_table)
                         << " ("<< boost::to_lower_copy(cloud_column) <<", block_id, num_points, points, extent, bbox) VALUES ("
                         << " :obj_id, :block_id, :num_points, decode(:hex, 'hex'), ST_Force_2D(ST_GeometryFromText(:extent,:srid)), :bbox)";

    m_session->begin();

    bool bHaveBlockTable = CheckTableExists(block_table);
    bool bHaveCloudTable = CheckTableExists(cloud_table);

    if (getOptions().getValueOrDefault<bool>("overwrite", true))
    {
        if (bHaveBlockTable)
        {
            DeleteBlockTable(cloud_table, cloud_column, block_table);
            bHaveBlockTable = false;
        }
        if (bHaveCloudTable)
        {
            DeleteCloudTable(cloud_table, cloud_column);
            bHaveCloudTable = false;
        }
    }

    std::string pre_sql = getOptions().getValueOrDefault<std::string>("pre_sql", "");
    if (pre_sql.size())
    {
        std::string sql = FileUtils::readFileAsString(pre_sql);
        if (!sql.size())
        {
            // if there was no file to read because the data in pre_sql was
            // actually the sql code the user wanted to run instead of the
            // filename to open, we'll use that instead.
            sql = pre_sql;
        }
        m_session->once << sql;
    }

    if (!bHaveCloudTable)
    {
        CreateCloudTable(cloud_table, getOptions().getValueOrDefault<boost::uint32_t>("srid", 4326));
    }

    if (!bHaveBlockTable)
    {
        m_doCreateIndex = true;
        CreateBlockTable(block_table, getOptions().getValueOrDefault<boost::uint32_t>("srid", 4326));
    }

    return;
}
Exemplo n.º 2
0
void Writer::writeBegin(boost::uint64_t)
{

    bool bHaveOutputTable = BlockTableExists();

    if (getDefaultedOption<bool>("overwrite"))
    {
        if (bHaveOutputTable)
        {
            WipeBlockTable();
        }
    }

    RunFileSQL("pre_sql");
    if (!bHaveOutputTable)
    {
        m_doCreateIndex = true;
        CreateBlockTable();
    }
    // 
    // CreatePCEntry();
    // m_trigger_name = ShutOff_SDO_PC_Trigger();
    return;
}