bool TeOGRDriver::createAttributeTable(TeTable &table) { if(ogrLayer_ == 0) return false; TeAttributeList::iterator it; TeAttributeList list = table.attributeList(); for(it = list.begin(); it != list.end(); ++it) { OGRFieldDefn oField = Convert2OGR(*it); if((*it).rep_.type_ == TeSTRING) oField.SetWidth((*it).rep_.numChar_); if(ogrLayer_->CreateField(&oField) != OGRERR_NONE) return false; } return true; }
void VoronoiWindow::themeComboBox_activated(const QString& themeName) { TeTheme* theme = getTheme(themeName.latin1()); if(theme == 0) return; // Updates the combo box with delimiters... TeLayer* layer = theme->layer(); boxComboBox->setCurrentText(layer->name().c_str()); // Lists attributes on the weightComboBox weightComboBox->clear(); //if (text=="") text=themeComboBox->currentText().latin1(); TeTable *attrTable = &layer->attrTables()[0]; TeAttributeList * attrList=&attrTable->attributeList(); for (std::vector<TeAttribute>::iterator i=attrList->begin(); i!=attrList->end();++i) { cout<<i->rep_.name_<<endl; weightComboBox->insertItem(i->rep_.name_); } }
bool updateDB301To302(TeDatabase* db, string& errorMessage) { TeDatabasePortal* portal = db->getPortal(); if(!portal) return false; // ----- valid attribute table TeAttrTableVector attrTableVec; if(db->getAttrTables(attrTableVec)) { for(unsigned int i=0; i<attrTableVec.size(); ++i) { TeTable fromTable = attrTableVec[i]; bool flag = false; if(fromTable.tableType()==TeAttrMedia) continue; //verify if there is another table with the same name for(unsigned int j=0; j<i; ++j) { if(TeConvertToUpperCase(attrTableVec[j].name())==TeConvertToUpperCase(fromTable.name())) { flag = true; break; } } if(flag) continue; if(db->validTable(fromTable)) //fromTable was modified { TeAttributeList newAttrList = fromTable.attributeList(); TeAttributeList oldAttrList = attrTableVec[i].attributeList(); TeAttributeList::iterator newAttIt = newAttrList.begin(); TeAttributeList::iterator oldAttIt = oldAttrList.begin(); bool change = false; while(newAttIt!=newAttrList.end()) { if(((*oldAttIt).rep_.name_) != ((*newAttIt).rep_.name_)) { TeAttributeRep rep = (*newAttIt).rep_; if(db->alterTable(fromTable.name(), rep, (*oldAttIt).rep_.name_)) change = true; } ++newAttIt; ++oldAttIt; } if(change) { // update te_layer_table string upd = " UPDATE te_layer_table "; upd += " SET unique_id = '"+ fromTable.uniqueName() +"'"; upd += ", attr_link = '"+ fromTable.linkName() +"'"; upd += " WHERE attr_table = '"+ fromTable.name() +"'"; if(!db->execute (upd)) { delete portal; errorMessage = "Error updating te_layer_table!\n"; errorMessage += db->errorMessage(); return false; } } }//if }//for portal->freeResult(); } // ----- te_grouping table string sel = " SELECT theme_id, grouping_attr, grouping_attr_type FROM te_grouping "; if(!portal->query(sel)) { delete portal; return false; } while(portal->fetchRow()) { string themeId, gAttr; themeId = portal->getData(0); gAttr = portal->getData(1); int gTypr = portal->getInt(2); if(((gAttr.empty()) || (gAttr=="NONE")) && (gTypr==0)) { string del = " DELETE FROM te_grouping WHERE theme_id = "+ themeId; db->execute(del); } } // ----- te_grouping table delete portal; return true; }