//operator=-----------------------------------------------------------------
 Matrix& Matrix::operator=( const Matrix& src )
 {
     REAL temp[ 6 ];
     if ( src.GetElements( temp ) == Ok )
         SetElements( temp[ 0 ], temp[ 1 ], temp[ 2 ], temp[ 3 ], temp[ 4 ], temp[ 5 ] );
     return *this;
 }
 Matrix::Matrix( REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy )
 {
     SetElements( m11, m12, m21, m22, dx, dy );
     mLastStatus = SetStatus( Ok );
 }
示例#3
0
bool Writer::WriteBlock(PointBuffer const& buffer)
{
    bool bUsePartition = m_block_table_partition_column.size() != 0;

    // Pluck the block id out of the first point in the buffer
    pdal::Schema const& schema = buffer.getSchema();
    Dimension const& blockDim = schema.getDimension("BlockID");

    boost::int32_t block_id  = buffer.getField<boost::int32_t>(blockDim, 0);

    std::ostringstream oss;
    std::ostringstream partition;

    if (bUsePartition)
    {
        partition << "," << m_block_table_partition_column;
    }

    oss << "INSERT INTO "<< m_block_table_name <<
        "(OBJ_ID, BLK_ID, NUM_POINTS, POINTS,   "
        "PCBLK_MIN_RES, BLK_EXTENT, PCBLK_MAX_RES, NUM_UNSORTED_POINTS, PT_SORT_DIM";
    if (bUsePartition)
        oss << partition.str();
    oss << ") "
        "VALUES ( :1, :2, :3, :4, 1, mdsys.sdo_geometry(:5, :6, null,:7, :8)"
        ", 1, 0, 1";
    if (bUsePartition)
        oss << ", :9";

    oss <<")";

    // TODO: If gotdata == false below, this memory probably leaks --mloskot
    OCILobLocator** locator =(OCILobLocator**) VSIMalloc(sizeof(OCILobLocator*) * 1);

    Statement statement = Statement(m_connection->CreateStatement(oss.str().c_str()));


    long* p_pc_id = (long*) malloc(1 * sizeof(long));
    p_pc_id[0] = m_pc_id;

    long* p_result_id = (long*) malloc(1 * sizeof(long));
    p_result_id[0] = (long)block_id;

    long* p_num_points = (long*) malloc(1 * sizeof(long));
    p_num_points[0] = (long)buffer.getNumPoints();

    // std::cout << "point count on write: " << buffer.getNumPoints() << std::endl;


    // :1
    statement->Bind(&m_pc_id);

    // :2
    statement->Bind(p_result_id);

    // :3
    statement->Bind(p_num_points);

    // :4
    statement->Define(locator, 1);


    // std::vector<liblas::uint8_t> data;
    // bool gotdata = GetResultData(result, reader, data, 3);
    // if (! gotdata) throw std::runtime_error("unable to fetch point data byte array");
    // boost::uint8_t* point_data = buffer.getData(0);
    boost::uint8_t* point_data;
    boost::uint32_t point_data_length;
    boost::uint32_t schema_byte_size;
    
    bool pack = getOptions().getValueOrDefault<bool>("pack_ignored_fields", true);
    if (pack)
        PackPointData(buffer, &point_data, point_data_length, schema_byte_size);
    else
    {
        point_data = buffer.getData(0);
        point_data_length = buffer.getSchema().getByteSize() * buffer.getNumPoints();
    }

    // statement->Bind((char*)point_data,(long)(buffer.getSchema().getByteSize()*buffer.getNumPoints()));
    statement->Bind((char*)point_data,(long)(point_data_length));

    // :5
    long* p_gtype = (long*) malloc(1 * sizeof(long));
    p_gtype[0] = m_gtype;

    statement->Bind(p_gtype);

    // :6
    long* p_srid  = 0;


    if (m_srid != 0)
    {
        p_srid = (long*) malloc(1 * sizeof(long));
        p_srid[0] = m_srid;
    }
    statement->Bind(p_srid);

    // :7
    OCIArray* sdo_elem_info=0;
    m_connection->CreateType(&sdo_elem_info, m_connection->GetElemInfoType());
    SetElements(statement, sdo_elem_info);
    statement->Bind(&sdo_elem_info, m_connection->GetElemInfoType());

    // :8
    OCIArray* sdo_ordinates=0;
    m_connection->CreateType(&sdo_ordinates, m_connection->GetOrdinateType());

    // x0, x1, y0, y1, z0, z1, bUse3d
    pdal::Bounds<double> bounds = CalculateBounds(buffer);
    SetOrdinates(statement, sdo_ordinates, bounds);
    statement->Bind(&sdo_ordinates, m_connection->GetOrdinateType());

    // :9
    long* p_partition_d = 0;
    if (bUsePartition)
    {
        p_partition_d = (long*) malloc(1 * sizeof(long));
        p_partition_d[0] = m_block_table_partition_value;
        statement->Bind(p_partition_d);
    }

    try
    {
        statement->Execute();
    }
    catch (std::runtime_error const& e)
    {
        std::ostringstream oss;
        oss << "Failed to insert block # into '" << m_block_table_name << "' table. Does the table exist? "  << std::endl << e.what() << std::endl;
        throw std::runtime_error(oss.str());
    }

    oss.str("");


    OWStatement::Free(locator, 1);

    if (p_pc_id != 0) free(p_pc_id);
    if (p_result_id != 0) free(p_result_id);
    if (p_num_points != 0) free(p_num_points);
    if (p_gtype != 0) free(p_gtype);
    if (p_srid != 0) free(p_srid);
    if (p_partition_d != 0) free(p_partition_d);

    m_connection->DestroyType(&sdo_elem_info);
    m_connection->DestroyType(&sdo_ordinates);




    return true;
}