Exemplo n.º 1
0
// run ffts, keep certain results, combine into feature descriptor
void 
Auvsi_Fft::computeFeatureDescriptor()
{
	clearFeatureDescriptor();
	Complex * currentColumn;	// current values to compute
	Complex * currentResults;	// current FFT results
	
	if (!COMPUTE_ROW) {		// compute each column
		
		// loop through columns
		for (int i = 0; i < inputImage.size().width; i++) {
			currentColumn = getColumn(i);								// get column
			currentResults = computeFFT(currentColumn, HEIGHT_INPUT);	// take fft of column
			addToFeatureDescriptor(currentResults, i);					// add results to feature descriptor
		}
	}
	
	// we are done! 
	
}
Exemplo n.º 2
0
/** @cond doxygenLibsbmlInternal */
SBase*
Curve::createObject (XMLInputStream& stream)
{

  const std::string& name   = stream.peek().getName();
  SBase*        object = 0;

  if (name == "listOfCurveSegments")
  {
    if (mCurveSegments.size() != 0)
    {
      getErrorLog()->logPackageError("layout", LayoutCurveAllowedElements, 
        getPackageVersion(), getLevel(), getVersion(), "", getLine(), getColumn());
    }

    object = &mCurveSegments;
  }
 
  return object;
}
Exemplo n.º 3
0
BOOL LLNameListCtrl::addNameItem(LLScrollListItem* item, EAddPosition pos)
{
	//llinfos << "LLNameListCtrl::addNameItem " << item->getUUID() << llendl;

	std::string fullname;
	BOOL result = gCacheName->getFullName(item->getUUID(), fullname);

	LLScrollListCell* cell = (LLScrollListCell*)item->getColumn(mNameColumnIndex);
	((LLScrollListText*)cell)->setText( fullname );

	addItem(item, pos);

	// this column is resizable
	LLScrollListColumn* columnp = getColumn(mNameColumnIndex);
	if (columnp && columnp->mHeader)
	{
		columnp->mHeader->setHasResizableElement(TRUE);
	}

	return result;
}
Exemplo n.º 4
0
void Buttongrid::setNum(unsigned char id){
    int boundX1, boundX2, boundY1, boundY2;
    int btnWidth = w/columns;
    int btnHeight = h/rows;
    unsigned char colIndex = getColumn(id)-1;
    unsigned char rowIndex = getRow(id)-1;
    unsigned char digits = Tft.Get_Digits(id);

    //Calculates initial position of text inside the btnWidth
    //considering the number's width and font size.
    int xPos = btnWidth/2 - (digits*FONT_X*font_size)/2;//btnWidth/(2) - 6*digits -2;
    int yPos = btnHeight/(2) - 8;

    //Calculates position of the text considering
    //its column or row and the btnWidth.
    xPos = x+(colIndex*btnWidth)+xPos+borderWidth;
    yPos = y+yPos+(rowIndex*btnHeight);

    //Draw contents function
    Tft.drawNumber(id,xPos,yPos,font_size,BLACK);
}
Exemplo n.º 5
0
//
// _setColorSeriesStack(void);
//
void DataTable::_setColorSeriesStack(void){
	
	if(_iconColumns.size()){
		std::cout << " iconColumns size " << _iconColumns.size() << std::endl;
		//
		// Passing true to the ColorSeriesStack 
		// constructor creates bichromatic color series:
		//
		if(!_colorSeriesStack) _colorSeriesStack = new ColorSeriesStack(ColorSeriesStack::BICHROMATIC);
		if(!_blackAndWhiteSeriesStack) _blackAndWhiteSeriesStack = new ColorSeriesStack(ColorSeriesStack::BLACKANDWHITE);
		
		for(unsigned int i=0;i<_iconColumns.size();i++){
			
			unsigned levels = getColumn(_iconColumns[i])->getUniqueList()->getAllLevels();
			_colorSeriesStack->add(levels);
			_blackAndWhiteSeriesStack->add(levels);
			
		}
	}
	
}
Exemplo n.º 6
0
/**----------------------------------------------------------------
 * Create the output from a ChebfunVector.
 */
void ChebfunToTable::fromChebVector()
{
  ChebfunVector_sptr cws = getClass("InputWorkspace");

  Numeric::FunctionDomain1D_sptr domain;

  size_t n = (int)get("N");

  if (n < 2)
  {// if n has default value (0) use the x-points of the chebfuns
    domain = cws->fun(0).createDomainFromXPoints();
    n = domain->size();
  }
  else
  {// otherwise create a regular comb
    domain = cws->fun(0).createDomain( n );
  }

  auto tws = API::TableWorkspace_ptr(dynamic_cast<API::TableWorkspace*>(
    API::WorkspaceFactory::instance().create("TableWorkspace"))
    );

  tws->addColumn("double","x");
  tws->setRowCount(n);
  auto xColumn = tws->getColumn("x");
  xColumn->asNumeric()->setPlotRole(API::NumericColumn::X);
  auto& x = tws->getDoubleData("x");
  for(size_t i = 0; i < domain->size(); ++i)
  {
    x[i] = (*domain)[i];
  }

  for(size_t i = 0; i < cws->size(); ++i)
  {
    const std::string yColumn = "y" + boost::lexical_cast<std::string>( i );
    AddFunctionValuesToTable::addColumn( tws, "x", yColumn, cws->fun(i), API::NumericColumn::Y );
  }

  setProperty("OutputWorkspace",tws);
}
Exemplo n.º 7
0
void Noritake_VFD_GU7000::GU7000_defineCustomChar(uint8_t code, FontFormat format, const uint8_t *data) {
    command(0x1b, '&', 0x01);
    command(code);
    command(code);
    
    switch (format) {
    case CUUFormat:
        command(5);
        for (uint8_t i=0; i<5; i++)
            command(getColumn(data, i));
        break;
    
    case GU70005x7Format:
        command(5);
        print((const char*)data, 5);
        break;
    case GU70007x8Format:
        command(7);
        print((const char*)data, 7);
        break;
    }
}
Exemplo n.º 8
0
BlockInputStreams StorageODBC::read(
    const Names & column_names,
    const SelectQueryInfo & query_info,
    const Context & context,
    QueryProcessingStage::Enum & processed_stage,
    size_t max_block_size,
    unsigned /*num_streams*/)
{
    check(column_names);
    processed_stage = QueryProcessingStage::FetchColumns;
    String query = transformQueryForExternalDatabase(
        *query_info.query, getColumns().ordinary, remote_database_name, remote_table_name, context);

    Block sample_block;
    for (const String & name : column_names)
    {
        auto column_data = getColumn(name);
        sample_block.insert({ column_data.type, column_data.name });
    }

    return { std::make_shared<ODBCBlockInputStream>(pool->get(), query, sample_block, max_block_size) };
}
Exemplo n.º 9
0
void fp_AnnotationContainer::clearScreen(void)
{
	if(getPage() == NULL)
	{
		return;
	}
	fp_Container * pCon = NULL;
	if(getColumn() && (getHeight() != 0))
	{
		if(getPage() == NULL)
		{
			return;
		}
		fl_DocSectionLayout * pDSL = getPage()->getOwningSection();
		if(pDSL == NULL)
		{
			return;
		}
		UT_sint32 iLeftMargin = pDSL->getLeftMargin();
		UT_sint32 iRightMargin = pDSL->getRightMargin();
		UT_sint32 iWidth = getPage()->getWidth();
		iWidth = iWidth - iLeftMargin - iRightMargin;
		UT_sint32 xoff,yoff;
		pCon = static_cast<fp_Container *>(getNthCon(0));
		if(pCon == NULL)
		  return;
		getScreenOffsets(pCon,xoff,yoff);
		UT_sint32 srcX = getX();
		UT_sint32 srcY = getY();
		getFillType()->Fill(getGraphics(),srcX,srcY,xoff-m_iLabelWidth,yoff,iWidth,getHeight());
	}
	UT_sint32 i = 0;
	for(i=0; i< countCons(); i++)
	{
		pCon = static_cast<fp_Container *>(getNthCon(i));
		pCon->clearScreen();
	}
}
Exemplo n.º 10
0
LLScrollListItem* LLNameListCtrl::addElement(const LLSD& value, EAddPosition pos, void* userdata)
{
	LLScrollListItem* item = LLScrollListCtrl::addElement(value, pos, userdata);

	// use supplied name by default
	std::string fullname = value["name"].asString();
	if (value["target"].asString() == "GROUP")
	{
		gCacheName->getGroupName(item->getUUID(), fullname);
		// fullname will be "nobody" if group not found
	}
	else if (value["target"].asString() == "SPECIAL")
	{
		// just use supplied name
	}
	else // normal resident
	{
		std::string name;
		if (gCacheName->getFullName(item->getUUID(), name))
		{
			fullname = name;
		}
	}
	
	LLScrollListCell* cell = (LLScrollListCell*)item->getColumn(mNameColumnIndex);
	((LLScrollListText*)cell)->setText( fullname );

	dirtyColumns();

	// this column is resizable
	LLScrollListColumn* columnp = getColumn(mNameColumnIndex);
	if (columnp && columnp->mHeader)
	{
		columnp->mHeader->setHasResizableElement(TRUE);
	}

	return item;
}
Exemplo n.º 11
0
/*!
 * Get the page containing this container.
 */
fp_Page * fp_Container::getPage(void) const
{
	fp_Container * pCon = getColumn();
	if(pCon == NULL)
	{
		return NULL;
	}
	if(pCon->getContainerType() == FP_CONTAINER_COLUMN)
	{
		return static_cast<fp_Column *>(pCon)->getPage();
	}
	if(pCon->getContainerType() == FP_CONTAINER_COLUMN_POSITIONED)
	{
		return static_cast<fp_Column *>(pCon)->getPage();
	}
	if(pCon->getContainerType() == FP_CONTAINER_FRAME)
	{
		return static_cast<fp_FrameContainer *>(pCon)->getPage();
	}
	if(pCon->getContainerType() == FP_CONTAINER_COLUMN_SHADOW)
	{
		return static_cast<fp_ShadowContainer *>(pCon)->getPage();
	}
	if(pCon->getContainerType() == FP_CONTAINER_HDRFTR)
	{
		return NULL;
	}
	if(pCon->getContainerType() == FP_CONTAINER_FOOTNOTE)
	{
		return static_cast<fp_FootnoteContainer *>(pCon)->getPage();
	}
	if(pCon->getContainerType() == FP_CONTAINER_ANNOTATION)
	{
		return static_cast<fp_AnnotationContainer *>(pCon)->getPage();
	}
	UT_ASSERT(UT_SHOULD_NOT_HAPPEN);
	return NULL;
}
Exemplo n.º 12
0
void StorageMerge::convertingSourceStream(const Block & header, const Context & context, ASTPtr & query,
                                          BlockInputStreamPtr & source_stream, QueryProcessingStage::Enum processed_stage)
{
    Block before_block_header = source_stream->getHeader();
    source_stream = std::make_shared<ConvertingBlockInputStream>(context, source_stream, header, ConvertingBlockInputStream::MatchColumnsMode::Name);

    ASTPtr where_expression = typeid_cast<ASTSelectQuery *>(query.get())->where_expression;

    if (!where_expression)
        return;

    for (size_t column_index : ext::range(0, header.columns()))
    {
        ColumnWithTypeAndName header_column = header.getByPosition(column_index);
        ColumnWithTypeAndName before_column = before_block_header.getByName(header_column.name);
        /// If the processed_stage greater than FetchColumns and the block structure between streams is different.
        /// the where expression maybe invalid because of convertingBlockInputStream.
        /// So we need to throw exception.
        if (!header_column.type->equals(*before_column.type.get()) && processed_stage > QueryProcessingStage::FetchColumns)
        {
            NamesAndTypesList source_columns = getSampleBlock().getNamesAndTypesList();
            NameAndTypePair virtual_column = getColumn("_table");
            source_columns.insert(source_columns.end(), virtual_column);
            auto syntax_result = SyntaxAnalyzer(context).analyze(where_expression, source_columns);
            ExpressionActionsPtr actions = ExpressionAnalyzer{where_expression, syntax_result, context}.getActions(false, false);
            Names required_columns = actions->getRequiredColumns();

            for (const auto & required_column : required_columns)
            {
                if (required_column == header_column.name)
                    throw Exception("Block structure mismatch in Merge Storage: different types:\n" + before_block_header.dumpStructure()
                                    + "\n" + header.dumpStructure(), ErrorCodes::BLOCKS_HAVE_DIFFERENT_STRUCTURE);
            }
        }

    }
}
Exemplo n.º 13
0
void TextGlyph::readAttributes (const XMLAttributes& attributes,
                                const ExpectedAttributes& expectedAttributes)
{
  GraphicalObject::readAttributes(attributes,expectedAttributes);

  const unsigned int sbmlLevel   = getLevel  ();
  const unsigned int sbmlVersion = getVersion();

  bool assigned = attributes.readInto("graphicalObject", mGraphicalObject, getErrorLog(), false, getLine(), getColumn());
  if (assigned && mGraphicalObject.empty())
  {
    logEmptyString(mGraphicalObject, sbmlLevel, sbmlVersion, "<" + getElementName() + ">");
  }
  if (!SyntaxChecker::isValidInternalSId(mGraphicalObject)) logError(InvalidIdSyntax);

  assigned = attributes.readInto("originOfText", mOriginOfText, getErrorLog(), false, getLine(), getColumn());
  if (assigned && mOriginOfText.empty())
  {
    logEmptyString(mOriginOfText, sbmlLevel, sbmlVersion, "<" + getElementName() + ">");
  }
  if (!SyntaxChecker::isValidInternalSId(mOriginOfText)) logError(InvalidIdSyntax);  

  attributes.readInto("text", mText, getErrorLog(), false, getLine(), getColumn());
}
Exemplo n.º 14
0
void Buttongrid::printName(unsigned char id){
    const char* name = names[id];
    // Calculate characters in name
    int n;
    for(n=0;n<8;n++){
        if(name[n] == 0) break;
    }

    Serial.print(n);
    Serial.print(" characters for id: ");
    Serial.print(id);
    Serial.print(" ");
    Serial.println(names[id]);

    // If name is empty draw the id, else draw the name
    if(n==0){
        setNum(id);
    }else{
        //i++;
        int boundX1, boundX2, boundY1, boundY2;
        int btnWidth = w/columns;
        int btnHeight = h/rows;
        unsigned char colIndex = getColumn(id)-1;
        unsigned char rowIndex = getRow(id)-1;

        int xPos = btnWidth/2 - (n*FONT_X*font_size)/2;
        int yPos = btnHeight/(2) - 8;

        xPos = x+(colIndex*btnWidth)+xPos+3*borderWidth;
        yPos = y+yPos+(rowIndex*btnHeight);

        Tft.drawString((char*)names[id],xPos, yPos, font_size, fgColor);
    }

    return;
}
Exemplo n.º 15
0
/** @cond doxygenLibsbmlInternal */
void Curve::readAttributes (const XMLAttributes& attributes,
                            const ExpectedAttributes& expectedAttributes)
{
  const unsigned int sbmlLevel   = getLevel  ();
  const unsigned int sbmlVersion = getVersion();

  unsigned int numErrs;

  SBase::readAttributes(attributes, expectedAttributes);

  // look to see whether an unknown attribute error was logged
  if (getErrorLog() != NULL)
  {
    numErrs = getErrorLog()->getNumErrors();
    for (int n = (int)numErrs-1; n >= 0; n--)
    {
      if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownPackageAttribute)
      {
        const std::string details =
                          getErrorLog()->getError((unsigned int)n)->getMessage();
        getErrorLog()->remove(UnknownPackageAttribute);
        getErrorLog()->logPackageError("layout", LayoutCurveAllowedAttributes,
                       getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
      }
      else if (getErrorLog()->getError((unsigned int)n)->getErrorId() == UnknownCoreAttribute)
      {
        const std::string details =
                          getErrorLog()->getError((unsigned int)n)->getMessage();
        getErrorLog()->remove(UnknownCoreAttribute);
        getErrorLog()->logPackageError("layout", 
                       LayoutCurveAllowedCoreAttributes,
                       getPackageVersion(), sbmlLevel, sbmlVersion, details, getLine(), getColumn());
      }
    }
  }
}
Exemplo n.º 16
0
 Matrix4x4 transpose() const
 {
   return Matrix4x4(getColumn(0), getColumn(1), 
                     getColumn(2), getColumn(3));
 }
Exemplo n.º 17
0
size_t SimpleTable::numRows() const {
    return getColumn( 0 ).size();
}
Exemplo n.º 18
0
 double SimpleTable::get(size_t column  , size_t row) const {
     const auto& col = getColumn( column );
     return col[row];
 }
Exemplo n.º 19
0
std::vector<Move> Pawn::getPossibleMoves(){
	std::vector<Move> possible;
	if (isWhite()){
		if (getRow() == 6){
			if (getBoard()->board[getRow() - 2][getColumn()] == NULL){
				possible.push_back(Move(getRow() - 2, getColumn()));
			}

		}
		if (getRow() - 1 >= 0){
			if (getBoard()->board[getRow() - 1][getColumn()] == NULL){
				possible.push_back(Move(getRow() - 1, getColumn()));
			}
			if (getColumn() + 1 < 8){
				if (getBoard()->board[getRow() - 1][getColumn() + 1] != NULL && !(getBoard()->board[getRow() - 1][getColumn() + 1]->isWhite())){
					possible.push_back(Move(getRow() - 1, getColumn() + 1));
				}
			}
			if (getColumn() - 1 >= 0){
				if (getBoard()->board[getRow() - 1][getColumn() - 1] != NULL && !(getBoard()->board[getRow() - 1][getColumn() - 1]->isWhite())){
					possible.push_back(Move(getRow() - 1, getColumn() - 1));
				}
			}
			return possible;
		}
	}
	else{
		if (getRow() == 1){
			if (getBoard()->board[getRow() + 2][getColumn()] == NULL){
				possible.push_back(Move(getRow() + 2, getColumn()));
			}

		}
		if (getRow() + 1 < 8){
			if (getBoard()->board[getRow() + 1][getColumn()] == NULL){
				possible.push_back(Move(getRow() + 1, getColumn()));
			}
			if (getColumn() + 1 < 8){
				if (getBoard()->board[getRow() + 1][getColumn() + 1] != NULL && getBoard()->board[getRow() + 1][getColumn() + 1]->isWhite()){
					possible.push_back(Move(getRow() + 1, getColumn() + 1));
				}
			}
			if (getColumn() - 1 >= 0){
				if (getBoard()->board[getRow() + 1][getColumn() - 1] != NULL && getBoard()->board[getRow() + 1][getColumn() - 1]->isWhite()){
					possible.push_back(Move(getRow() + 1, getColumn() - 1));
				}
			}
			return possible;
		}
	}
	return possible;

}
Exemplo n.º 20
0
T Matrix::getEntry(int i, int j) const
{
	if(i < 0 || i >= getRow() || j < 0 || j >= getColumn())
		throw EntryNotFound();
	return mat[i][j];
}
Exemplo n.º 21
0
bool Ship::isAt(unsigned int row, unsigned int column) {
	return (getRow() == row && getColumn() == column);
}
  , set(set_)
  , tokenNames(tokenNames_)
  , numTokens(numTokens_)
{
}

// Expected range / not range
MismatchedTokenException::MismatchedTokenException(
	const char* const* tokenNames_,
	const int numTokens_,
	RefToken token_,
	int lower,
	int upper_,
	bool matchNot,
	const ANTLR_USE_NAMESPACE(std)string& fileName_
) : RecognitionException("Mismatched Token",fileName_,token_->getLine(),token_->getColumn())
  , token(token_)
  , node(nullASTptr)
  , tokenText(token_->getText())
  , mismatchType(matchNot ? NOT_RANGE : RANGE)
  , expecting(lower)
  , upper(upper_)
  , tokenNames(tokenNames_)
  , numTokens(numTokens_)
{
}

// Expected token / not token
MismatchedTokenException::MismatchedTokenException(
	const char* const* tokenNames_,
	const int numTokens_,
Exemplo n.º 23
0
/**
 * Sort.
 * @param criteria : a vector with a list of pairs: column name, bool;
 *        where bool = true for ascending, false for descending sort.
 */
void TableWorkspace::sort(std::vector<std::pair<std::string, bool>> &criteria) {
  if (criteria.empty())
    return;

  if (criteria.size() > columnCount()) {
    throw std::runtime_error("Too many column names given.");
  }

  const size_t nRows = rowCount();
  if (nRows == 0)
    return;

  // first sort an array of indices according to criteria then put the rows
  // in order of the sorted indices

  std::vector<size_t> indexVec(nRows);
  // initialize the index vector with consecutive numbers
  for (auto i = indexVec.begin() + 1; i != indexVec.end(); ++i) {
    *i = *(i - 1) + 1;
  }

  // dynamically populate and use a queue of records for iteratively sort all
  // rows
  std::queue<SortIterationRecord> sortRecords;
  // start with first pair in criteria and sort all rows
  sortRecords.push(SortIterationRecord(0, 0, nRows));

  // maximum possible number of calls to Column::sortIndex (I think)
  const size_t maxNLoops = criteria.size() * nRows / 2;
  // loop over sortRecords and sort indexVec
  for (size_t counter = 0; counter < maxNLoops; ++counter) {
    // get the record from the front of the queue
    SortIterationRecord record = sortRecords.front();
    sortRecords.pop();
    // define the arguments for Column::sortIndex
    auto &crt = criteria[record.keyIndex];
    const std::string columnName = crt.first;
    const bool ascending = crt.second;
    auto &column = *getColumn(columnName);
    std::vector<std::pair<size_t, size_t>> equalRanges;

    // sort indexVec
    column.sortIndex(ascending, record.iStart, record.iEnd, indexVec,
                     equalRanges);

    // if column had 1 or more ranges of equal values and there is next item in
    // criteria
    // add more records to the back of the queue
    if (record.keyIndex < criteria.size() - 1) {
      size_t keyIndex = record.keyIndex + 1;
      for (auto &equalRange : equalRanges) {
        sortRecords.push(
            SortIterationRecord(keyIndex, equalRange.first, equalRange.second));
      }
    }

    if (sortRecords.empty()) {
      // there is nothing to do
      break;
    }
  }

  // finally sort the rows
  const size_t nCols = columnCount();
  for (size_t i = 0; i < nCols; ++i) {
    getColumn(i)->sortValues(indexVec);
  }
}
Exemplo n.º 24
0
//
// getDataAtIndex:
//
Data* DataTable::getDataAtIndex(const std::string name, unsigned long index) const{
	
	return getColumn(name)->getDataAtIndex(index);
	
}
Exemplo n.º 25
0
void Matrix::ero_1(int row, const T& scaler)
{
	if(row < 0 || row >= getRow()) throw RowNotFound();
	for(int j = 0; j < getColumn(); j++)
		setEntry(row, j, getEntry(row, j) * scaler);
}
Exemplo n.º 26
0
//
// getDataAtIndex:
//
Data* DataTable::getDataAtIndex(unsigned columnIndex, unsigned long index) const{
	
	return getColumn(columnIndex)->getDataAtIndex(index);
	
}
Exemplo n.º 27
0
void Matrix::setEntry(int i, int j, const T & value)
{
	if(i < 0 || i >= getRow() || j < 0 || j >= getColumn())
		throw EntryNotFound();
	mat[i][j] = value;
}
Exemplo n.º 28
0
int main()
{
	MockDb db = {};
	MockDb::_serializer_context_t printer;

	test::TabFoo f; 
	test::TabBar t;

	getColumn(db, t.alpha);

	for (const auto& row : db(select(all_of(t)).from(t).where(true)))
	{
		int64_t a = row.alpha;
		const std::string b = row.beta;
		std::cout << a << ", " << b << std::endl;
	}

	for (const auto& row : db(select(all_of(t).as(t)).from(t).where(true)))
	{
		int64_t a = row.tabBar.alpha;
		const std::string b = row.tabBar.beta;
		std::cout << a << ", " << b << std::endl;
	}

	for (const auto& row : db(select(all_of(t).as(t), t.gamma).from(t).where(t.alpha > 7)))
	{
		int64_t a = row.tabBar.alpha;
		const std::string b = row.tabBar.beta;
		const bool g = row.gamma;
		std::cout << a << ", " << b << ", " << g << std::endl;
	}

	for (const auto& row : db(select(all_of(t), all_of(f)).from(t.join(f).on(t.alpha > f.omega and not t.gamma)).where(true)))
	{
		std::cout << row.alpha << std::endl;
	}

	for (const auto& row : db(select(count(t.alpha), avg(t.alpha)).from(t).where(true)))
	{
		std::cout << row.count << std::endl;
	}

	for (const auto& row : db(select(count(t.alpha), avg(t.alpha)).from(t).where(t.alpha == sqlpp::tvin(0))))
	{
		std::cout << row.count << std::endl;
	}

	auto stat = sqlpp::select().columns(all_of(t)).flags(sqlpp::all).from(t).extra_tables(f,t).where(t.alpha > 0).group_by(t.alpha).order_by(t.gamma.asc()).having(t.gamma).limit(7).offset(19);

	auto s = dynamic_select(db).dynamic_columns(all_of(t)).dynamic_flags().dynamic_from(t).extra_tables(f,t).dynamic_where().dynamic_group_by(t.alpha).dynamic_order_by().dynamic_having(t.gamma).dynamic_limit().dynamic_offset();
	s.select_flags.add(sqlpp::distinct);
	s.selected_columns.add(f.omega);
	s.from.add(f);
	s.where.add(t.alpha > 7);
	s.having.add(t.alpha > 7);
	s.limit.set(3);
	s.offset.set(3);
	s.group_by.add(t.beta);
	s.order_by.add(t.beta.asc());
	for (const auto& row : db(s))
	{
		int64_t a = row.alpha;
		std::cout << a << std::endl;
	}

	printer.reset();
	std::cerr << serialize(s, printer).str() << std::endl;
	printer.reset();
	std::cerr << serialize(stat, printer).str() << std::endl;

	select(sqlpp::value(7).as(t.alpha));

	return 0;
}
Exemplo n.º 29
0
bool
NIImporter_DlrNavteq::EdgesHandler::report(const std::string& result) {
    // parse version number from first comment line and initialize column definitions
    if (result[0] == '#') {
        if (!myColumns.empty()) {
            return true;
        }
        const double version = readVersion(result, myFile);
        if (version > 0) {
            myVersion = version;
            // init columns
            const int NUM_COLUMNS = 25; // @note arrays must match this size!
            const int MC = MISSING_COLUMN;
            if (myVersion < 3) {
                const int columns[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, MC, 12, 13, 14, 15, 16, 17, 18, 19, 20, MC, MC, -21};
                myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
            } else if (myVersion < 6) {
                const int columns[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, MC, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, -23};
                myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
            } else {
                const int columns[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24};
                myColumns = std::vector<int>(columns, columns + NUM_COLUMNS);
            }
        }
        return true;
    }
    if (myColumns.empty()) {
        throw ProcessError("Missing version string in file '" + myFile + "'.");
    }
    // interpret link attributes
    StringTokenizer st(result, StringTokenizer::WHITECHARS);
    const std::string id = getColumn(st, LINK_ID);
    // form of way (for priority and permissions)
    int form_of_way;
    try {
        form_of_way = StringUtils::toInt(getColumn(st, FORM_OF_WAY));
    } catch (NumberFormatException&) {
        throw ProcessError("Non-numerical value for form_of_way of link '" + id + "'.");
    }
    // brunnel type (bridge/tunnel/ferry (for permissions)
    int brunnel_type;
    try {
        brunnel_type = StringUtils::toInt(getColumn(st, BRUNNEL_TYPE));
    } catch (NumberFormatException&) {
        throw ProcessError("Non-numerical value for brunnel_type of link '" + id + "'.");
    }
    // priority based on street_type / frc
    int priority;
    try {
        priority = -StringUtils::toInt(getColumn(st, FUNCTIONAL_ROAD_CLASS));
        // lower priority using form_of_way
        if (form_of_way == 11) {
            priority -= 1; // frontage road, very often with lowered curb
        } else if (form_of_way > 11) {
            priority -= 2; // parking/service access assume lowered curb
        }
    } catch (NumberFormatException&) {
        throw ProcessError("Non-numerical value for street_type of link '" + id + "').");
    }
    // street name
    std::string streetName = getStreetNameFromIDs(
                                 getColumn(st, NAME_ID1_REGIONAL),
                                 getColumn(st, NAME_ID2_LOCAL));
    // try to get the nodes
    const std::string fromID = getColumn(st, NODE_ID_FROM);
    const std::string toID = getColumn(st, NODE_ID_TO);
    NBNode* from = myNodeCont.retrieve(fromID);
    NBNode* to = myNodeCont.retrieve(toID);
    if (from == nullptr) {
        throw ProcessError("The from-node '" + fromID + "' of link '" + id + "' could not be found");
    }
    if (to == nullptr) {
        throw ProcessError("The to-node '" + toID + "' of link '" + id + "' could not be found");
    }
    // speed
    double speed;
    try {
        speed = StringUtils::toInt(getColumn(st, SPEED_RESTRICTION, "-1")) / 3.6;
    } catch (NumberFormatException&) {
        throw ProcessError("Non-numerical value for the SPEED_RESTRICTION of link '" + id + "'.");
    }
    if (speed < 0) {
        // speed category as fallback
        speed = NINavTeqHelper::getSpeed(id, getColumn(st, SPEED_CATEGORY));
    }
    // number of lanes
    int numLanes;
    try {
        // EXTENDED_NUMBER_OF_LANES is prefered but may not be defined
        numLanes = StringUtils::toInt(getColumn(st, EXTENDED_NUMBER_OF_LANES, "-1"));
        if (numLanes == -1) {
            numLanes = NINavTeqHelper::getLaneNumber(id, getColumn(st, NUMBER_OF_LANES), speed);
        }
    } catch (NumberFormatException&) {
        throw ProcessError("Non-numerical value for the number of lanes of link '" + id + "'.");
    }

    const std::string navTeqTypeId = getColumn(st, VEHICLE_TYPE) + "_" + getColumn(st, FORM_OF_WAY);
    // build the edge
    NBEdge* e = nullptr;
    const std::string interID = getColumn(st, BETWEEN_NODE_ID);
    if (interID == "-1") {
        e = new NBEdge(id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId : "", speed, numLanes, priority,
                       NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET, streetName);
    } else {
        PositionVector geoms = myGeoms[interID];
        if (getColumn(st, CONNECTION, "0") == "1") {
            geoms = geoms.reverse();
        }
        geoms.insert(geoms.begin(), from->getPosition());
        geoms.push_back(to->getPosition());
        const std::string origID = OptionsCont::getOptions().getBool("output.original-names") ? id : "";
        e = new NBEdge(id, from, to, myTypeCont.knows(navTeqTypeId) ? navTeqTypeId : "", speed, numLanes, priority,
                       NBEdge::UNSPECIFIED_WIDTH, NBEdge::UNSPECIFIED_OFFSET, geoms, streetName, origID, LANESPREAD_CENTER);
    }

    // NavTeq imports can be done with a typemap (if supplied), if not, the old defaults are used
    if (myTypeCont.knows(navTeqTypeId)) {
        e->setPermissions(myTypeCont.getPermissions(navTeqTypeId));
    } else {
        // add vehicle type information to the edge
        if (myVersion < 6.0) {
            NINavTeqHelper::addVehicleClasses(*e, getColumn(st, VEHICLE_TYPE));
        } else {
            NINavTeqHelper::addVehicleClassesV6(*e, getColumn(st, VEHICLE_TYPE));
        }
        if (e->getPermissions() == SVCAll) {
            e->setPermissions(myTypeCont.getPermissions(""));
        }
        // permission modifications based on form_of_way
        if (form_of_way == 14) { // pedestrian area (fussgaengerzone)
            // unfortunately, the veh_type string is misleading in this case
            e->disallowVehicleClass(-1, SVC_PASSENGER);
        }
        // permission modifications based on brunnel_type
        if (brunnel_type == 10) { // ferry
            e->setPermissions(SVC_SHIP, -1);
        }
    }

    // insert the edge to the network
    if (!myEdgeCont.insert(e)) {
        delete e;
        throw ProcessError("Could not add edge '" + id + "'.");
    }
    return true;
}
Exemplo n.º 30
0
//------------------------------------------------------------------------------
void GuiPopupTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver)
{
   Point2I size;
   getCellSize( size );

   // Render a background color for the cell
   if ( mouseOver )
   {      
      RectI cellR( offset.x, offset.y, size.x, size.y );
      GFX->getDrawUtil()->drawRectFill( cellR, mProfile->mFillColorHL );

   }
   else if ( selected )
   {
      RectI cellR( offset.x, offset.y, size.x, size.y );
      GFX->getDrawUtil()->drawRectFill( cellR, mProfile->mFillColorSEL );
   }

   //  Define the default x offset for the text
   U32 textXOffset = offset.x + mProfile->mTextOffset.x;

   //  Do we also draw a colored box beside the text?
   ColorI boxColor;
   bool drawbox = mPopUpCtrl->getColoredBox( boxColor, mList[cell.y].id);
   if(drawbox)
   {
      Point2I coloredboxsize(15,10);
      RectI r(offset.x + mProfile->mTextOffset.x, offset.y+2, coloredboxsize.x, coloredboxsize.y);
      GFX->getDrawUtil()->drawRectFill( r, boxColor);
      GFX->getDrawUtil()->drawRect( r, ColorI(0,0,0));

      textXOffset += coloredboxsize.x + mProfile->mTextOffset.x;
   }

   ColorI fontColor;
   mPopUpCtrl->getFontColor( fontColor, mList[cell.y].id, selected, mouseOver );

   GFX->getDrawUtil()->setBitmapModulation( fontColor );
   //GFX->drawText( mFont, Point2I( offset.x + 4, offset.y ), mList[cell.y].text );

   //  Get the number of columns in the cell
   S32 colcount = getColumnCount(mList[cell.y].text, "\t");

   //  Are there two or more columns?
   if(colcount >= 2)
   {
      char buff[256];

      // Draw the first column
      getColumn(mList[cell.y].text, buff, 0, "\t");
      GFX->getDrawUtil()->drawText( mFont, Point2I( textXOffset, offset.y ), buff ); //  Used mTextOffset as a margin for the text list rather than the hard coded value of '4'.

      // Draw the second column to the right
      getColumn(mList[cell.y].text, buff, 1, "\t");
      S32 txt_w = mFont->getStrWidth(buff);

      GFX->getDrawUtil()->drawText( mFont, Point2I( offset.x+size.x-mProfile->mTextOffset.x-txt_w, offset.y ), buff ); //  Used mTextOffset as a margin for the text list rather than the hard coded value of '4'.

   } else
   {
      GFX->getDrawUtil()->drawText( mFont, Point2I( textXOffset, offset.y ), mList[cell.y].text ); //  Used mTextOffset as a margin for the text list rather than the hard coded value of '4'.
   }
}