Exemplo n.º 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;
}
Exemplo n.º 2
0
bool IAttributes::isLockedAttributeColumn(const char *attribute)
{
   AttributeTable *table = (AttributeTable *)m_data;
   int n = table->getColumnIndex(pstring(attribute));
   if (n != -1 && !table->isColumnLocked(n)) {
      return table->isColumnLocked(n);
   }
   // n.b., this should really throw an exception:
   return false;
}
Exemplo n.º 3
0
bool IAttributes::renameAttributeColumn(const char *oldname, const char *newname)
{
   AttributeTable *table = (AttributeTable *)m_data;
   int n = table->getColumnIndex(pstring(oldname));
   if (n != -1 && !table->isColumnLocked(n)) {
      table->renameColumn(n,newname);
      return true;
   }
   return false;
}
Exemplo n.º 4
0
bool IAttributes::insertAttributeColumn(const char *attribute)
{
   if (strcmp(attribute,"Ref Number") != 0) {
      AttributeTable *table = (AttributeTable *)m_data;
      int n = table->getColumnIndex(pstring(attribute));
      if (n == -1 || !table->isColumnLocked(n)) {
         table->insertColumn(pstring(attribute));
         return true;
      }
   }
   return false;
}
Exemplo n.º 5
0
void RenderVDBFunc(openvdb::FloatGrid grid, VolumeColorPtr light, double step, double k, boost::shared_ptr<Image> image, boost::shared_ptr<DeepImage> deepimage, boost::shared_ptr<Camera> camera, std::string name, bool threaded) {
	const bool isLevelSet = (grid.getGridClass() == openvdb::GRID_LEVEL_SET);
	openvdb::FloatGrid::Ptr gridPtr = grid.copy();
	if (isLevelSet) {
		//convert to fog volume
		openvdb::tools::sdfToFogVolume<openvdb::FloatGrid>(*gridPtr);
	}
	openvdb::tools::VolumeRayIntersector<openvdb::FloatGrid> inter(*gridPtr);
	AttributeTable table;
	table.addDoubleAttr("step", step);
	table.addDoubleAttr("K", k);
	MeshPotato::MPVolume::VDBRayMarcher marcher = MeshPotato::MPVolume::VDBRayMarcher(gridPtr, light, camera, table);
	marcher.render(threaded);
	marcher.writeImage(name);
}
std::vector<AttributeIndexItem> makeAttributeIndex(AttributeTable &table, int colIndex)
{
    std::vector<AttributeIndexItem> index;
    size_t numRows = table.getNumRows();
    if (numRows == 0)
    {
        return index;
    }
    index.reserve(numRows);
    // perturb the values to be sorted by so same values will be in order of appearence in the map
    size_t idx = 0;
    if ( colIndex == -1 )
    {
        double perturbationFactor = 1e-9 / numRows;
        for (auto& item: table)
        {
            double value = (double)item.getKey().value;
            value += idx * perturbationFactor;

            index.push_back(AttributeIndexItem(item.getKey(), value, item.getRow()));
            ++idx;
        }
    }
    else if (colIndex >= 0 )
    {
        double perturbationFactor = table.getColumn(colIndex).getStats().max * 1e-9 / numRows;
        for (auto & item : table)
        {
            double value = item.getRow().getValue(colIndex);
            value += idx * perturbationFactor;

            index.push_back(AttributeIndexItem(item.getKey(), value, item.getRow()));
            ++idx;
        }
    }
    else
    {
        throw std::out_of_range("Column index out of range");
    }
    std::sort(index.begin(), index.end());
    return index;
}
Exemplo n.º 7
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);
	}
}
Exemplo n.º 8
0
bool IAttributes::deleteAttributeColumn(const char *attribute)
{
   AttributeTable *table = (AttributeTable *)m_data;
   int n = table->getColumnIndex(pstring(attribute));
   if (n != -1 && !table->isColumnLocked(n)) {
      table->removeColumn(n);
      if (n >= table->getDisplayColumn()) {
         // there is a problem here: the associated geometry layer will be out of step when it comes to display
         // this is corrected in "getDisplayedAttribute" (untidy, but works)
         table->setDisplayColumn(n-1,true);
      }
      return true;
   }
   return false;
}