void runEmptyRelationNoMemberCountTagTest() { //add some nodes to a map OsmMapPtr map(new OsmMap()); ElementPtr n1(new Node(Status::Unknown1, 1, 0, 0, 0)); ElementPtr n2(new Node(Status::Unknown2, 2, 0, 0, 0)); ElementPtr n3(new Node(Status::Unknown1, 3, 0, 0, 0)); ElementPtr n4(new Node(Status::Unknown2, 4, 0, 0, 0)); map->addElement(n1); map->addElement(n2); map->addElement(n3); map->addElement(n4); //create two reviews involving the two pairs of nodes ReviewMarker reviewMarker; reviewMarker.mark(map, n1, n2, "note 1", "test 1"); reviewMarker.mark(map, n3, n4, "note 2", "test 2"); CPPUNIT_ASSERT_EQUAL((size_t)2, map->getRelations().size()); CPPUNIT_ASSERT(reviewMarker.isNeedsReview(map, n1, n2)); CPPUNIT_ASSERT(reviewMarker.isNeedsReview(map, n3, n4)); //get the review relations set<ElementId> review1 = reviewMarker._getReviewRelations(map, n1->getElementId()); CPPUNIT_ASSERT_EQUAL((size_t)1, review1.size()); const ElementId r1Id = *review1.begin()++; set<ElementId> review2 = reviewMarker._getReviewRelations(map, n3->getElementId()); CPPUNIT_ASSERT_EQUAL((size_t)1, review2.size()); const ElementId r2Id = *review2.begin()++; RelationPtr relation1 = map->getRelation(r1Id.getId()); RelationPtr relation2 = map->getRelation(r2Id.getId()); //go ahead and remove their review member count tags relation1->getTags().remove(MetadataTags::HootReviewMembers()); relation2->getTags().remove(MetadataTags::HootReviewMembers()); //remove all of one of the review relation's members RemoveElementOp::removeElement(map, n3->getElementId()); RemoveElementOp::removeElement(map, n4->getElementId()); relation2->removeElement(n3->getElementId()); relation2->removeElement(n4->getElementId()); //run the visitor RemoveInvalidReviewRelationsVisitor v; map->visitRw(v); //the empty review relation should have been removed CPPUNIT_ASSERT_EQUAL((size_t)1, map->getRelations().size()); CPPUNIT_ASSERT(map->containsElement(r1Id)); CPPUNIT_ASSERT(!map->containsElement(r2Id)); }
void MultiaryPoiMerger::_createReviews(const OsmMapPtr& map, QList<MultiaryClusterAlgorithm::ClusterLinkPtr> reviews) { ReviewMarker reviewMarker; foreach (MultiaryClusterAlgorithm::ClusterLinkPtr link, reviews) { // we aren't using the review score in the review mark b/c the review score is almost always // 0. We may be able to fudge a value based on the match/miss thresholds, but I'm not sure // the score is every really used so I'll just leave it the default value for now. reviewMarker.mark(map, map->getElement(link->a->mergedElement->getElementId()), map->getElement(link->b->mergedElement->getElementId()), link->explainText, "POI"); }