void runConflateTest() { OsmReader reader; 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); MapProjector::projectToPlanar(map); WayMap wm = map->getWays(); for (WayMap::const_iterator it = wm.begin(); it != wm.end(); ++it) { const ConstWayPtr& w = it->second; const Tags& t = w->getTags(); if (t["REF1"] != "Target" && t["REF2"] != "Target") { map->removeWay(it->first); } } Conflator uut; shared_ptr<Manipulator> m(new BuildingMergeManipulator()); deque< shared_ptr<Manipulator> > manipulators; manipulators.push_back(m); uut.setManipulators(manipulators); uut.loadSource(map); uut.conflate(); shared_ptr<OsmMap> out(new OsmMap(uut.getBestMap())); MapProjector::projectToWgs84(out); OsmWriter writer; writer.setIncludeIds(true); writer.write(out, "test-output/BuildingConflatorTest.osm"); ConstWayPtr cheddars = getWay(out, "REF1", "Cheddar's"); CPPUNIT_ASSERT_EQUAL(string("Cheddar's"), cheddars->getTags()["REF2"].toStdString()); HOOT_STR_EQUALS(Status::Conflated, cheddars->getStatus()); ConstWayPtr biondi = getWay(out, "REF1", "Biondi"); CPPUNIT_ASSERT_EQUAL(string("Biondi"), biondi->getTags()["REF2"].toStdString()); HOOT_STR_EQUALS(Status::Conflated, biondi->getStatus()); ConstWayPtr freddys = getWay(out, "REF1", "Freddy's"); CPPUNIT_ASSERT_EQUAL(false, freddys->getTags().contains("REF2")); HOOT_STR_EQUALS(Status::Unknown1, freddys->getStatus()); ConstWayPtr target = getWay(out, "REF1", "Target"); CPPUNIT_ASSERT_EQUAL(string("Target"), biondi->getTags()["REF2"].toStdString()); HOOT_STR_EQUALS(Status::Unknown1, target->getStatus()); CPPUNIT_ASSERT_EQUAL((size_t)9, out->getWays().size()); }
void Conflator::_saveMap(QString path) { LOG_INFO("Writing debug .osm file..." << path.toStdString()); shared_ptr<OsmMap> wgs84(new OsmMap(_map)); MapReprojector::reprojectToWgs84(wgs84); OsmWriter writer; writer.setIncludeHootInfo(true); writer.setIncludeIds(true); writer.write(wgs84, path); }
void funnyCurveTest() { OsmReader reader; OsmMap::resetCounters(); shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/MaximalNearestSubline2.osm", map); MapReprojector::reprojectToPlanar(map); long n1 = map->findWays("note", "1")[0]; long n2 = map->findWays("note", "2")[0]; shared_ptr<Way> left = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(n1), map->getWay(n2), 10.0, 10.0); left->setStatus(Status::Conflated); left->setTag("name", "left"); map->addWay(left); //cout << ElementConverter(map).convertToLineString(left)->toString() << endl; shared_ptr<Way> right = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(n2), map->getWay(n1), 10.0, 10.0); right->setStatus(Status::Conflated); left->setTag("name", "right"); map->addWay(right); //cout << ElementConverter(map).convertToLineString(right)->toString() << endl; shared_ptr<Way> w = WayAverager::average(map, right, left); w->setStatus(Status::Conflated); w->setTag("name", "average"); map->addWay(w); //map->removeWay(n1); //map->removeWay(n2); QDir().mkpath("test-output/algorithms/"); { shared_ptr<OsmMap> wgs84(new OsmMap(map)); MapReprojector::reprojectToWgs84(wgs84); OsmWriter writer; writer.setIncludeCompatibilityTags(false); writer.setIncludeHootInfo(false); writer.setIncludeIds(false); QString fn = QString("test-output/algorithms/MaximalNearestSubline2TestOutput.osm"); writer.write(wgs84, fn); } HOOT_FILE_EQUALS("test-files/algorithms/MaximalNearestSubline2TestOutput.osm", "test-output/algorithms/MaximalNearestSubline2TestOutput.osm"); }
void runPbfTest() { PbfReader reader(true); shared_ptr<OsmMap> map(new OsmMap()); reader.setUseFileStatus(true); reader.read("test-files/ToyTestCombined.pbf", map); Conflator uut; uut.loadSource(map); uut.conflate(); shared_ptr<OsmMap> out(new OsmMap(uut.getBestMap())); MapProjector::projectToWgs84(out); CPPUNIT_ASSERT_EQUAL((size_t)15, out->getWays().size()); OsmWriter writer; writer.setIncludeIds(true); writer.write(out, "test-output/ConflatorPbfTest.osm"); }
void runTest() { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/ToyTestA.osm", map); reader.setDefaultStatus(Status::Unknown2); reader.read("test-files/ToyTestB.osm", map); Conflator uut; uut.loadSource(map); uut.conflate(); shared_ptr<OsmMap> out(new OsmMap(uut.getBestMap())); MapProjector::projectToWgs84(out); CPPUNIT_ASSERT_EQUAL((size_t)9, out->getWays().size()); OsmWriter writer; writer.setIncludeIds(true); writer.write(out, "test-output/ConflatorTest.osm"); }
void preSplitTest() { OsmReader reader; OsmMap::resetCounters(); shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/DividedHighwayPreSplit.osm", map); reader.setDefaultStatus(Status::Unknown2); reader.read("test-files/UndividedHighwayPreSplit.osm", map); Conflator conflator; conflator.loadSource(map); conflator.conflate(); shared_ptr<OsmMap> after(new OsmMap(conflator.getBestMap())); MapReprojector::reprojectToWgs84(after); OsmWriter writer; writer.setIncludeIds(true); writer.write(after, "test-output/DividedHighwayMergerPreSplitTest.osm"); }