void OsmApiDbSqlChangesetFileWriter::_createRelationMembers(ConstRelationPtr relation) { LOG_TRACE("Creating relation members for: " << relation->getElementId()); const vector<RelationData::Entry> members = relation->getMembers(); for (size_t i = 0; i < members.size(); i++) { const RelationData::Entry member = members[i]; LOG_VART(member.getElementId()); QString values = QString( "(relation_id, member_type, member_id, member_role, version, sequence_id) VALUES (%1, '%2', %3, '%4', 1, %5);\n") .arg(relation->getId()) .arg(member.getElementId().getType().toString()) .arg(member.getElementId().getId()) .arg(member.getRole()) .arg(i + 1); _outputSql.write(("INSERT INTO " + ApiDb::getRelationMembersTableName() + " " + values).toUtf8()); values = QString( "(relation_id, member_type, member_id, member_role, sequence_id) VALUES (%1, '%2', %3, '%4', %5);\n") .arg(relation->getId()) .arg(member.getElementId().getType().toString()) .arg(member.getElementId().getId()) .arg(member.getRole()) .arg(i + 1); _outputSql.write( ("INSERT INTO " + ApiDb::getCurrentRelationMembersTableName() + " " + values).toUtf8()); } }
void ElementCacheLRU::addElement(ConstElementPtr &newElement) { ConstNodePtr newNode; ConstWayPtr newWay; ConstRelationPtr newRelation; switch ( newElement->getElementType().getEnum() ) { case ElementType::Node: newNode = dynamic_pointer_cast<const Node>(newElement); if ( newNode != ConstNodePtr() ) { // Do we have to replace an entry? if ( _nodes.size() == _maxCountPerType ) { _removeOldest(ElementType::Node); } _nodes.insert(std::make_pair(newNode->getId(), std::make_pair(newNode, boost::posix_time::microsec_clock::universal_time()))); //LOG_DEBUG("Added new node with ID " << newNode->getId() ); } break; case ElementType::Way: newWay = dynamic_pointer_cast<const Way>(newElement); if ( newWay != ConstWayPtr() ) { // Do we have to replace an entry? if ( _ways.size() == _maxCountPerType ) { _removeOldest(ElementType::Way); } _ways.insert(std::make_pair(newWay->getId(), std::make_pair(newWay, boost::posix_time::microsec_clock::universal_time()))); } break; case ElementType::Relation: newRelation = dynamic_pointer_cast<const Relation>(newElement); if ( newRelation != ConstRelationPtr() ) { // Do we have to replace an entry? if ( _relations.size() == _maxCountPerType ) { _removeOldest(ElementType::Relation); } _relations.insert(std::make_pair(newRelation->getId(), std::make_pair(newRelation, boost::posix_time::microsec_clock::universal_time()))); } break; default: throw HootException(QString("Unexpected element type: %1").arg( newElement->getElementType().toString())); break; } // Reset all iterators to maintain interface contract resetElementIterators(); }