void runBuildingsTest() { OsmReader reader; OsmMap::resetCounters(); shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/ToyBuildingsTestA.osm", map); reader.setDefaultStatus(Status::Unknown2); reader.read("test-files/ToyBuildingsTestB.osm", map); MapReprojector::reprojectToPlanar(map); vector<long> r1 = map->findWays("REF1", "Target"); vector<long> r2 = map->findWays("name", "Target Grocery"); shared_ptr<const Way> w1 = map->getWay(r1[0]); shared_ptr<const Way> w2 = map->getWay(r2[0]); EdgeDistanceExtractor uut(new MeanAggregator(), 5.0); CPPUNIT_ASSERT_DOUBLES_EQUAL(28.9069, uut.distance(*map, w1, w2), 0.01); EdgeDistanceExtractor uut2(new RmseAggregator(), 5.0); CPPUNIT_ASSERT_DOUBLES_EQUAL(41.2179, uut2.distance(*map, w1, w2), 0.01); EdgeDistanceExtractor uut3(new MinAggregator(), 5.0); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.380561, uut3.distance(*map, w1, w2), 0.01); EdgeDistanceExtractor uut4(new QuantileAggregator(0.5), 5.0); CPPUNIT_ASSERT_DOUBLES_EQUAL(7.28364, uut4.distance(*map, w1, w2), 0.01); EdgeDistanceExtractor uut5(new QuantileAggregator(0.1), 5.0); CPPUNIT_ASSERT_DOUBLES_EQUAL(1.34317, uut5.distance(*map, w1, w2), 0.01); }
void runCombinedMatchCandidateCountTest() { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/conflate/unified/AllDataTypesA.osm", map); reader.setDefaultStatus(Status::Unknown2); reader.read("test-files/conflate/unified/AllDataTypesB.osm", map); MapProjector::projectToPlanar(map); QStringList matchCreators; matchCreators.clear(); matchCreators.append("hoot::BuildingMatchCreator"); matchCreators.append("hoot::HighwayMatchCreator"); matchCreators.append("hoot::PlacesPoiMatchCreator"); matchCreators.append("hoot::CustomPoiMatchCreator"); MatchFactory::getInstance().reset(); MatchFactory::_setMatchCreators(matchCreators); MatchCandidateCountVisitor uut3(MatchFactory::getInstance().getCreators()); map->visitRo(uut3); CPPUNIT_ASSERT_EQUAL((int)68, (int)uut3.getStat()); QMap<QString, long> matchCandidateCountsByMatchCreator = any_cast<QMap<QString, long> >(uut3.getData()); CPPUNIT_ASSERT_EQUAL(4, matchCandidateCountsByMatchCreator.size()); //These don't add up to the total...is there some overlap here? CPPUNIT_ASSERT_EQUAL((long)18, matchCandidateCountsByMatchCreator["hoot::BuildingMatchCreator"]); CPPUNIT_ASSERT_EQUAL((long)8, matchCandidateCountsByMatchCreator["hoot::HighwayMatchCreator"]); CPPUNIT_ASSERT_EQUAL((long)21, matchCandidateCountsByMatchCreator["hoot::PlacesPoiMatchCreator"]); CPPUNIT_ASSERT_EQUAL((long)21, matchCandidateCountsByMatchCreator["hoot::CustomPoiMatchCreator"]); }
void individualManipulationsTest() { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/DividedHighway.osm", map); reader.setDefaultStatus(Status::Unknown2); reader.read("test-files/UndividedHighway.osm", map); MapReprojector::reprojectToOrthographic(map); long left = map->findWays("note", "0")[0]; long right = map->findWays("note", "1")[0]; long mid = map->findWays("note", "2")[0]; DividedHighwayManipulation uut(left, right, mid, map, 10.0); qDebug() << uut.getScoreEstimate(); qDebug() << uut.calculateScore(map); set<ElementId> ignored1, ignored2; shared_ptr<OsmMap> after(new OsmMap(map)); uut.applyManipulation(after, ignored1, ignored2); left = map->findWays("note", "3")[0]; right = map->findWays("note", "4")[0]; mid = map->findWays("note", "5")[0]; DividedHighwayManipulation uut2(left, right, mid, after, 10.0); qDebug() << uut2.getScoreEstimate(); qDebug() << uut2.calculateScore(after); uut2.applyManipulation(after, ignored1, ignored2); left = map->findWays("note", "6")[0]; right = map->findWays("note", "7")[0]; mid = map->findWays("note", "8")[0]; DividedHighwayManipulation uut3(left, right, mid, after, 10.0); qDebug() << uut3.getScoreEstimate(); qDebug() << uut3.calculateScore(after); uut3.applyManipulation(after, ignored1, ignored2); MapReprojector::reprojectToWgs84(after); OsmWriter writer; writer.write(after, "test-output/DividedHighwayManipulatorTest.osm"); }