void PertyRemoveTagVisitor::visit(const shared_ptr<Element>& e) { boost::uniform_real<> uni(0.0, 1.0); Tags t = e->getTags(); for (Tags::const_iterator it = t.constBegin(); it != t.constEnd(); ++it) { const QString tagKey = it.key(); if (uni(*_rng) <= _p && !_exemptTagKeys.contains(tagKey)) { if (!_replacementTagKeys.contains(tagKey)) { LOG_DEBUG("Removing tag with key: " << tagKey << " ..."); e->getTags().remove(tagKey); } else { const int tagIndex = _replacementTagKeys.indexOf(tagKey); const QString tagValue = _replacementTagValues.at(tagIndex); LOG_DEBUG("Substituting value: " << tagValue << " for tag with key: " << tagKey); e->getTags().set(tagKey, tagValue); } } } }
void OgrWriter::writeElement(ElementPtr &element, bool debug) { //Unfortunately, this check also has to happen in addition to checking hasMoreElements. See //explanation in ServicesDbReader::readNextElement. if (element.get()) { Tags sourceTags = element->getTags(); Tags destTags; for (Tags::const_iterator it = element->getTags().begin(); it != element->getTags().end(); ++it) { if (sourceTags[it.key()] != "") { destTags.appendValue(it.key(), it.value()); } } // Now that all the empties are gone, update our element element->setTags(destTags); if ( debug == true ) { LOG_DEBUG(element->toString()); } PartialOsmMapWriter::writePartial(element); } }
//------------------------------------------------------------------------------------------------------------------------------------ // Helper for ErrorMessenger. //------------------------------------------------------------------------------------------------------------------------------------ LogMgr::ErrorDialogResult LogMgr::Error(const std::string& errorMessage, bool isFatal, const char* funcName, const char* sourceFile, unsigned int lineNum) { string tag = ((isFatal) ? ("FATAL") : ("ERROR")); // buffer for our final output string string buffer; GetOutputBuffer(buffer, tag, errorMessage, funcName, sourceFile, lineNum); // write the final buffer to all the various logs m_tagCriticalSection.Lock(); Tags::iterator findIt = m_tags.find(tag); if (findIt != m_tags.end()) OutputFinalBufferToLogs(buffer, findIt->second); m_tagCriticalSection.Unlock(); // show the dialog box int result = ::MessageBoxA(NULL, buffer.c_str(), tag.c_str(), MB_ABORTRETRYIGNORE|MB_ICONERROR|MB_DEFBUTTON3); // act upon the choice switch (result) { case IDIGNORE : return LogMgr::LOGMGR_ERROR_IGNORE; case IDABORT : __debugbreak(); return LogMgr::LOGMGR_ERROR_RETRY; // assembly language instruction to break into the debugger case IDRETRY : return LogMgr::LOGMGR_ERROR_RETRY; default : return LogMgr::LOGMGR_ERROR_RETRY; } }
ItemTagsLoader::Tags ItemTagsLoader::toTags(const QStringList &tagList) { Tags tags; for (const auto &tagText : tagList) { QString tagName = tagText.trimmed(); Tag tag = findMatchingTag(tagName, m_tags); if (isTagValid(tag)) { if (tag.match.isEmpty()) { tag.name = tagName; } else { const QRegExp re(tag.match); tag.name = QString(tagName).replace(re, tag.name); } } else { tag.name = tagName; // Get default tag style from theme. const QSettings settings; tag.color = settings.value("Theme/num_fg").toString(); } tags.append(tag); } return tags; }
void runEscapeTags() { OsmMapPtr map(new OsmMap()); Coordinate coords[] = { Coordinate(0, 0), Coordinate(0, 1), Coordinate(1, 1), Coordinate(1, 0), Coordinate::getNull() }; Tags tags; tags.set("note", "<2>"); tags.set("aerialway", "t-bar"); tags.set("first name", "first name goes here"); tags.set("full_name", "\"Hacksaw\" Jim Duggan"); WayPtr way = TestUtils::createWay(map, Status::Unknown1, coords); way->setTags(tags); QList<ElementPtr> nodes; NodePtr node1(new Node(Status::Unknown1, map->createNextNodeId(), Coordinate(0.0, 0.1), 15)); node1->getTags().appendValue("name", "test1"); nodes.append(node1); NodePtr node2(new Node(Status::Unknown1, map->createNextNodeId(), Coordinate(0.1, 0.0), 15)); node2->getTags().appendValue("name", "test2"); nodes.append(node2); RelationPtr relation = TestUtils::createRelation(map, nodes); relation->setType("review"); relation->getTags().appendValue("name", "Test Review"); std::vector<RelationData::Entry> members = relation->getMembers(); members[0].role = "reviewee"; members[1].role = "reviewee"; relation->setMembers(members); QString output = OsmPgCsvWriter::toString(map); // Compare the results HOOT_STR_EQUALS(expected_runEscapeTags, output); }
void TagComparator::_addNonConflictingTags(Tags& t1, const Tags& t2, Tags& result) { OsmSchema& schema = OsmSchema::getInstance(); // we're deleting as we iterate so be careful making changes. for (Tags::iterator it1 = t1.begin(); it1 != t1.end(); ) { QString kvp1 = it1.key() + "=" + it1.value(); bool conflict = false; for (Tags::const_iterator it2 = t2.begin(); it2 != t2.end(); ++it2) { QString kvp2 = it2.key() + "=" + it2.value(); if (schema.score(kvp1, kvp2) > 0.0) { conflict = true; break; } } if (conflict) { ++it1; } else { result[it1.key()] = it1.value(); t1.erase(it1++); } } }
void TagComparator::_overwriteUnrecognizedTags(Tags& t1, Tags& t2, Tags& result) { OsmSchema& schema = OsmSchema::getInstance(); const Tags t1Copy = t1; for (Tags::ConstIterator it1 = t1Copy.begin(); it1 != t1Copy.end(); ++it1) { // if this is an unknown type if (schema.getTagVertex(it1.key() + "=" + it1.value()).isEmpty() && schema.getTagVertex(it1.key()).isEmpty()) { // if this is also in t2. if (t2.contains(it1.key())) { result[it1.key()] = it1.value(); t1.remove(it1.key()); t2.remove(it1.key()); } } } // go through any remaining tags in t2 const Tags t2Copy = t2; for (Tags::ConstIterator it2 = t2Copy.begin(); it2 != t2Copy.end(); ++it2) { // if this is an unknown type if (schema.getTagVertex(it2.key() + "=" + it2.value()).isEmpty()) { // we know it isn't in t1, or it would have been handled in the above loop so just deal with // t2 t2.remove(it2.key()); result[it2.key()] = it2.value(); } } }
bool ExportMultiple::DoExport(bool stereo, wxString name, bool selectedOnly, double t0, double t1, int trackNumber) { wxFileName fn(mDir->GetValue(), name, mPlugins[mFormatIndex]->GetExtension()); // Generate a unique name if we're not allowed to overwrite if (!mOverwrite->GetValue()) { int i = 2; while (fn.FileExists()) { fn.SetName(wxString::Format(wxT("%s-%d"), name.c_str(), i++)); } } // If the format supports tags, then set the name and track number if (mPlugins[mFormatIndex]->GetCanMetaData()) { Tags *tags = mProject->GetTags(); tags->SetTitle(name); tags->SetTrackNumber(trackNumber); } // Call the format export routine return mPlugins[mFormatIndex]->Export(mProject, stereo ? 2 : 1, fn.GetFullPath(), selectedOnly, t0, t1); }
QString MostEnglishName::getMostEnglishName(const Tags& tags) { if (tags.contains("name:en") && tags.get("name:en").isEmpty() == false) { return tags.get("name:en"); } QStringList names = tags.getNames(); double bestScore = -numeric_limits<double>::max(); QString bestName; for (int i = 0; i < names.size(); i++) { double score = scoreName(names[i]); if (score > bestScore) { bestScore = score; bestName = names[i]; } } return bestName; }
void TranslatedTagCountVisitor::visit(ElementType type, long id) { shared_ptr<const Element> e = _map->getElement(type, id); if (e->getTags().getInformationCount() > 0) { shared_ptr<Geometry> g = ElementConverter(_map->shared_from_this()).convertToGeometry(e); Tags t = e->getTags(); t["error:circular"] = QString::number(e->getCircularError()); t["hoot:status"] = e->getStatusString(); // remove all the empty tags. for (Tags::const_iterator it = e->getTags().begin(); it != e->getTags().end(); ++it) { if (t[it.key()] == "") { t.remove(it.key()); } } QString layerName; vector<ScriptToOgrTranslator::TranslatedFeature> f = _translator->translateToOgr(t, e->getElementType(), g->getGeometryTypeId()); // only write the feature if it wasn't filtered by the translation script. for (size_t i = 0; i < f.size(); i++) { _countTags(f[i].feature); } } }
void TestTags::test_item_tags_model() { Tags tags; tags.append("Work"); tags.append("Home"); Person *person = new Person; person->setName("Moe stein"); person->save(); RelationalObjectRef person_ref(person); RelationalObjectRef tag1 = tags.getObjectRef(0); RelationalObjectRef tag2 = tags.getObjectRef(1); ItemTags *item_tags = tags.itemTagsModelFactory(person_ref); item_tags->tag(tag1); QCOMPARE(item_tags->rowCount(), 1); item_tags->untag(tag2); QCOMPARE(item_tags->rowCount(), 1); item_tags->tag(tag2); QCOMPARE(item_tags->rowCount(), 2); item_tags->untag(tag1); QCOMPARE(item_tags->rowCount(), 1); item_tags->untag(tag2); QCOMPARE(item_tags->rowCount(), 0); delete item_tags; delete person; }
inline Tags parseTags(DBFHandle dbfFile, int k) const { char title[12]; int fieldCount = DBFGetFieldCount(dbfFile); Tags tags; tags.reserve(fieldCount); for (int i = 0; i < fieldCount; i++) { if (DBFIsAttributeNULL(dbfFile, k, i)) continue; utymap::formats::Tag tag; int width, decimals; DBFFieldType eType = DBFGetFieldInfo(dbfFile, i, title, &width, &decimals); tag.key = std::string(title); { switch (eType) { case FTString: tag.value = DBFReadStringAttribute(dbfFile, k, i); break; case FTInteger: tag.value = to_string(DBFReadIntegerAttribute(dbfFile, k, i)); break; case FTDouble: tag.value = to_string(DBFReadDoubleAttribute(dbfFile, k, i)); break; default: break; } } tags.push_back(tag); } return std::move(tags); }
void SplitNameVisitor::_addExtraNames(Tags& t, const QStringList& extraNames) { int lastNameId = -1; int size = 0; QStringList names; for (int i = 0; i < extraNames.size(); i++) { int thisSize = extraNames[i].size(); if (size + thisSize > _maxSize) { lastNameId = _getNextNameId(t, lastNameId); QString k = QString("name:%1").arg(lastNameId); t.setList(k, names); names.clear(); size = 0; } names.append(extraNames[i]); size += thisSize + 1; } if (names.size() > 0) { lastNameId = _getNextNameId(t, lastNameId); QString k = QString("name:%1").arg(lastNameId); t.setList(k, names); } }
ItemWidget *ItemTagsLoader::transform(ItemWidget *itemWidget, const QVariantMap &data) { const Tags tags = toTags(::tags(data)); if ( tags.isEmpty() ) return nullptr; itemWidget->setTagged(true); return new ItemTags(itemWidget, tags); }
Tags List::SelectedItems(int group) const { Tags selItems; for (ListItems::const_iterator i = items.begin(); i != items.end(); ++i) if ((i->state == litPressed) && (i->group & group)) selItems.push_back(i->tag); return selItems; }
void TagComparator::_mergeText(Tags& t1, Tags& t2, Tags& result) { OsmSchema& schema = OsmSchema::getInstance(); const Tags t1Copy = t1; for (Tags::ConstIterator it1 = t1Copy.begin(); it1 != t1Copy.end(); ++it1) { const SchemaVertex& tv = schema.getTagVertex(it1.key()); // if this is a text field and it exists in both tag sets. if (tv.valueType == Text && t2.contains(it1.key())) { // only keep the unique text fields QStringList values = t1.getList(it1.key()); values.append(t2.getList(it1.key())); // append all unique values in the existing order. for (int i = 0; i < values.size(); i++) { if (values[i].isEmpty() == false) { result.appendValueIfUnique(it1.key(), values[i]); } } t1.remove(it1.key()); t2.remove(it1.key()); } } }
void OgrWriter::_writePartial(ElementProviderPtr& provider, const ConstElementPtr& e) { if (_translator.get() == 0) { throw HootException("You must call open before attempting to write."); } if (e->getTags().getInformationCount() > 0) { // There is probably a cleaner way of doing this. // convertToGeometry calls getGeometryType which will throw an exception if it gets a relation // that it doesn't know about. E.g. "route", "superroute", " turnlanes:turns" etc shared_ptr<Geometry> g; try { g = ElementConverter(provider).convertToGeometry(e); } catch (IllegalArgumentException& err) { LOG_WARN("Error converting geometry: " << err.getWhat() << " (" << e->toString() << ")"); g.reset((GeometryFactory::getDefaultInstance()->createEmptyGeometry())); } /* LOG_DEBUG("After conversion to geometry, element is now a " << g->getGeometryType() ); */ Tags t = e->getTags(); t["error:circular"] = QString::number(e->getCircularError()); t["hoot:status"] = e->getStatusString(); for (Tags::const_iterator it = e->getTags().begin(); it != e->getTags().end(); ++it) { if (t[it.key()] == "") { t.remove(it.key()); } } vector<ScriptToOgrTranslator::TranslatedFeature> tf = _translator->translateToOgr(t, e->getElementType(), g->getGeometryTypeId()); // only write the feature if it wasn't filtered by the translation script. for (size_t i = 0; i < tf.size(); i++) { OGRLayer* layer = _getLayer(tf[i].tableName); if (layer != 0) { _addFeature(layer, tf[i].feature, g); } } } }
void ItemTags::untag(RelationalObjectRef tag) { if (not m_item.isValid()) throw new InvalidObjectReference; Tags *tags = dynamic_cast<Tags*>(QObject::parent()); if (tags == NULL) throw new NoTaggingEngine; tags->untag(m_item, tag); }
void LogManager::Log(const std::string& tag, const std::string& msg, const char* funcName, const char* fileName, unsigned int lineNum) { m_CritSection.Lock(); Tags::iterator findIt = m_Tags.find(tag); if (findIt != m_Tags.end()) { std::string buffer; GetOutputBuffer(buffer, tag, msg, funcName, fileName, lineNum); OutputBufferToLogs(buffer, findIt->second); } m_CritSection.Unlock(); }
int main() { string dir,title; Equip_Necessary b; cout<<" \n *** ALANG CONVERTER ***\n"; cout<<"\n\n\nEnter Alang file path: "; string path; cin>>path; cout<<"\nEnter Website Title: "; cin>>title; cout<<"\nWhere do you Want to Create the Website Directory? (Eg: C:\\Test) : "; cin>>dir; b.create(dir); ofstream file; file.open("Index.html", ios:: out); string str,str1,str2,str3; provide_htmlcss a; str1=a.header(title); str2=a.footer(); /* Aniruddha's content goes here */ string text=getinputandsend(path); /*char *c=new char[text.size()+1]; memcpy(c,text.c_str(),text.size());*/ char *ch=&text[0] ; //char st[]="#1Head one\nThis is a paragraph with *bold*`code` and ~italics~\n "; string s=""; Tags t; int i=0; while(i<sizeof(text)){ s+=t.start_s(ch,i); } str=str1+s+str2; //+str3 - Body Contents file<<str; //file<<Body Contents of Index.html from Aniruddha// /*The Following code relates to the css style append fn alone*/ ofstream file1; string style="/* Style.css Generated by ALANG */"; //style string passes all the code file1.open("style.css", ios::out); //relatd to style.css a.File_append(style,file1); file1.close(); cout<<dir; move_file(dir, file); file.close(); }
void KeepTagsVisitor::visit(const shared_ptr<Element>& e) { //get a copy of the tags for modifying Tags tags; tags.addTags(e->getTags()); for (Tags::const_iterator it = e->getTags().begin(); it != e->getTags().end(); ++it) { if (!_keys.contains(it.key())) { tags.remove(it.key()); } } e->setTags(tags); }
QSet<QString> TagComparator::_toSet(const Tags& t, const QString& k) { Tags::const_iterator it = t.find(k); if (OsmSchema::getInstance().isList(k, *it)) { return QSet<QString>::fromList(t.getList(k)); } else { QSet<QString> result; result.insert(*it); return result; } }
/* topological (depth-first) sorting of operations */ static void sort_operations_recursive(NodeOperationBuilder::Operations &sorted, Tags &visited, NodeOperation *op) { if (visited.find(op) != visited.end()) return; visited.insert(op); for (int i = 0; i < op->getNumberOfInputSockets(); ++i) { NodeOperationInput *input = op->getInputSocket(i); if (input->isConnected()) sort_operations_recursive(sorted, visited, &input->getLink()->getOperation()); } sorted.push_back(op); }
bool BuildingPartMergeOp::_compareTags(Tags t1, Tags t2) { // remove all the building tags that are building:part=yes specific. for (set<QString>::const_iterator it = _buildingPartTagNames.begin(); it != _buildingPartTagNames.end(); it++) { t1.remove(*it); t2.remove(*it); } double score = TagComparator::getInstance().compareTags(t1, t2); // check for score near 1.0 return fabs(1.0 - score) < 0.001; }
void LogManager::SetDisplayFlags(const std::string& tag, unsigned char flag) { m_CritSection.Lock(); if (flag != 0) { Tags::iterator findIt = m_Tags.find(tag); if (findIt == m_Tags.end()) m_Tags.insert(std::make_pair(tag, flag)); else findIt->second = flag; } else m_Tags.erase(tag); m_CritSection.Unlock(); }
void ItemTags::reload() { if (not m_item.isValid()) { clear(); return; } Tags *tags = dynamic_cast<Tags*>(QObject::parent()); if (tags == NULL) throw new NoTaggingEngine; m_tags = tags->itemTags(item()); updateIndex(); reset(); }
void TagComparator::_addAsDefault(Tags& t, const QString& key, const QString& value) { if (t.contains(key) == false || t[key].isEmpty() == true) { t[key] = value; } }
static void add_group_operations_recursive(Tags &visited, NodeOperation *op, ExecutionGroup *group) { if (visited.find(op) != visited.end()) return; visited.insert(op); if (!group->addOperation(op)) return; /* add all eligible input ops to the group */ for (int i = 0; i < op->getNumberOfInputSockets(); ++i) { NodeOperationInput *input = op->getInputSocket(i); if (input->isConnected()) add_group_operations_recursive(visited, &input->getLink()->getOperation(), group); } }
void OgrWriter::writeElement(ElementInputStream& inputStream, bool debug) { // Make sure incoming element is in WGS84 assert( inputStream.getProjection()->IsSame(&_wgs84) == true ); ElementPtr nextElement = inputStream.readNextElement(); // TERRY TESTING COULD BE CATASTROPHIC Tags sourceTags = nextElement->getTags(); Tags destTags; for (Tags::const_iterator it = nextElement->getTags().begin(); it != nextElement->getTags().end(); ++it) { if (sourceTags[it.key()] != "") { destTags.appendValue(it.key(), it.value()); } } // Now that all the empties are gone, update our element nextElement->setTags(destTags); if ( debug == true ) { LOG_DEBUG(nextElement->toString()); } PartialOsmMapWriter::writePartial(nextElement); /* if ( nextElement->getElementType().getEnum() == ElementType::Node ) { //LOG_DEBUG("\n" << nextElement->toString()); const long nodeID = nextElement->getId(); if ( (nodeID >= -265198) && (nodeID <= -265167) ) { LOG_DEBUG("\n" << nextElement->toString()); PartialOsmMapWriter::writePartial(nextElement); } } else if ((nextElement->getElementType().getEnum() == ElementType::Way) && (nextElement->getId() == -23189) ) { LOG_DEBUG("Writing Little Mill Creek -23189"); LOG_DEBUG("\n" << nextElement->toString()); PartialOsmMapWriter::writePartial(nextElement); } */ }
RequestResponse TagsRequest::invoke(const QStringList &arguments, const QString &who, const RequestInvocationContext &context) { Q_UNUSED(who); const QString &id = arguments.join(QChar::Space); InformationResourceRepository &repository = context.informationResourceRepository(); IdGenerator &idGenerator = context.idGenerator(); IInformationResource *resource = repository.get(id); if (resource) { IIterator<Tag> *iterator = resource->iterator<Tag>(); if (iterator) { QList<QObject *> tags; for (int i = 0; i < 10; i++) { Tag *tag = iterator->next(resource, repository, idGenerator); if (!tag) { if (!i) { return RequestResponse("templates/NoMoreData.qml", nullptr); } break; } else { tags << tag; } } Tags *envelope = new Tags(); envelope->setTags(tags); return RequestResponse("templates/Tags.qml", envelope); } } return RequestResponse(); }