Exemple #1
0
AttributeList
OGR_Feature::getAttributes() const
{
    AttributeTable attrs;

    if ( !store_attrs_loaded )
    {
        const_cast<OGR_Feature*>(this)->loadAttributes();
    }

    // accumulate the attrs from the store:
    for( AttributeTable::const_iterator i = store_attrs.begin(); i != store_attrs.end(); i++ )
    {
        attrs[ (*i).first ] = (*i).second;
    }

    // finally add in the user attrs (overwriting the store attrs if necessary)
    for( AttributeTable::const_iterator i = getUserAttrs().begin(); i != getUserAttrs().end() ; i++ )
        attrs[ (*i).first ] = (*i).second;

    // shove it all into a list
    AttributeList result;
    for( AttributeTable::const_iterator i = attrs.begin(); i != attrs.end(); i++ )
        result.push_back( (*i).second );

    return result;
}
Exemple #2
0
/// Creates the attribute tables, and in the process creates a count Matrix (cAbove).
/// A dataset consisting of m input variables has m attribute tables.
/// [attribute | class/value | rid ]
void RFTrainer::createAttributeTables(Data<RealVector> const& dataset, AttributeTables& tables){
	std::size_t elements = dataset.numberOfElements();
	//Each entry in the outer vector is an attribute table
	AttributeTable table;
	RFAttribute a;
	//For each column
	for(std::size_t j=0; j<m_inputDimension; j++){
		table.clear();
		//For each row
		for(std::size_t i=0; i<elements; i++){
			//Store Attribute value, class and rid
			a.value = dataset.element(i)[j];
			a.id = i;
			table.push_back(a);
		}
		std::sort(table.begin(), table.end(), tableSort);
		//Store this attributes attribute table
		tables.push_back(table);
	}
}