void runMatchTest() { 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> wids1 = map->findWays("REF1", "Target"); vector<long> wids2 = map->findWays("REF2", "Target"); set< pair<ElementId, ElementId> > pairs; for (size_t i = 0; i < wids2.size(); i++) { pairs.insert(pair<ElementId, ElementId>(ElementId::way(wids1[0]), ElementId::way(wids2[i]))); } vector< pair<ElementId, ElementId> > replaced; BuildingMerger bm(pairs); bm.apply(map, replaced); MapReprojector::reprojectToWgs84(map); QDir(".").mkpath("test-output/conflate/polygon"); OsmWriter writer; writer.write(map, "test-output/conflate/polygon/BuildingMergerTest.osm"); HOOT_STR_EQUALS("[3]{(Way:-15, Way:-7), (Way:-14, Way:-7), (Way:-13, Way:-7)}", replaced); }
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 runHighwayMatchCandidateCountTest() { 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::HighwayMatchCreator"); MatchFactory::getInstance().reset(); MatchFactory::_setMatchCreators(matchCreators); MatchCandidateCountVisitor uut2(MatchFactory::getInstance().getCreators()); map->visitRo(uut2); CPPUNIT_ASSERT_EQUAL((int)8, (int)uut2.getStat()); QMap<QString, long> matchCandidateCountsByMatchCreator = any_cast<QMap<QString, long> >(uut2.getData()); CPPUNIT_ASSERT_EQUAL(1, matchCandidateCountsByMatchCreator.size()); CPPUNIT_ASSERT_EQUAL((long)8, matchCandidateCountsByMatchCreator["hoot::HighwayMatchCreator"]); }
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 runRoadsTest() { OsmReader reader; OsmMap::resetCounters(); shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/conflate/extractor/EdgeDistanceExtractor/ToyTestA.osm", map); reader.setDefaultStatus(Status::Unknown2); reader.read("test-files/conflate/extractor/EdgeDistanceExtractor/ToyTestB.osm", map); MapReprojector::reprojectToPlanar(map); EdgeDistanceExtractor uut2(new RmseAggregator()); vector<long> r1 = map->findWays("note", "1"); vector<long> r2 = map->findWays("note", "b"); shared_ptr<const Way> w1 = map->getWay(r1[0]); shared_ptr<const Way> w2 = map->getWay(r2[0]); CPPUNIT_ASSERT_DOUBLES_EQUAL(3.50153, uut2.distance(*map, w1, w2), 0.01); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.978273, uut2.extract(*map, w1, w2), 0.01); vector<long> r3 = map->findWays("note", "25"); vector<long> r4 = map->findWays("note", "z"); shared_ptr<const Way> w3 = map->getWay(r3[0]); shared_ptr<const Way> w4 = map->getWay(r4[0]); CPPUNIT_ASSERT_DOUBLES_EQUAL(0, uut2.distance(*map, w3, w4), 0.01); CPPUNIT_ASSERT_DOUBLES_EQUAL(1, uut2.extract(*map, w3, w4), 0.01); }
void runTest() { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/ops/CookieCutterOp/DcTigerRoads-cropped.osm", map); reader.setDefaultStatus(Status::Unknown2); reader.read("test-files/DcGisRoads.osm", map); MapCleaner().apply(map); CookieCutterOp uut; uut.setAlpha(1000.0); uut.setAlphaShapeBuffer(0.0); uut.setCrop(false); uut.setOutputBuffer(0.0); uut.apply(map); MapProjector::projectToWgs84(map); QDir().mkpath("test-output/ops/CookieCutterOp"); OsmWriter writer; writer.write(map, "test-output/ops/CookieCutterOp/CookieCutterOpTest.osm"); HOOT_FILE_EQUALS("test-files/ops/CookieCutterOp/CookieCutterOpTest.osm", "test-output/ops/CookieCutterOp/CookieCutterOpTest.osm"); }
void runTagTest() { OsmReader reader; OsmMap::resetCounters(); shared_ptr<OsmMap> map(new OsmMap()); 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); vector<long> wids1 = map->findWays("REF1", "Panera"); vector<long> wids2 = map->findWays("REF2", "Panera"); set< pair<ElementId, ElementId> > pairs; for (size_t i = 0; i < wids2.size(); i++) { pairs.insert(pair<ElementId, ElementId>(ElementId::way(wids1[0]), ElementId::way(wids2[i]))); } RemoveMissVisitor v(map, "Panera"); map->visitRw(v); vector< pair<ElementId, ElementId> > replaced; BuildingMerger bm(pairs); bm.apply(map, replaced); // QDir(".").mkpath("test-output/conflate/polygon"); // OsmWriter writer; // writer.write(map, "test-output/conflate/polygon/BuildingTagTest.osm"); HOOT_STR_EQUALS("[3]{(Way:-26, Relation:-1), (Way:-25, Relation:-1), (Way:-14, Relation:-1)}", replaced); HOOT_STR_EQUALS("{\"version\": 0.6,\"generator\": \"Hootenanny\",\"elements\": [\n" "{\"type\":\"node\",\"id\":-218,\"lat\":39.593278,\"lon\":-104.80656},\n" "{\"type\":\"node\",\"id\":-219,\"lat\":39.593114,\"lon\":-104.80653},\n" "{\"type\":\"node\",\"id\":-220,\"lat\":39.593124,\"lon\":-104.80645},\n" "{\"type\":\"node\",\"id\":-221,\"lat\":39.593106,\"lon\":-104.80644},\n" "{\"type\":\"node\",\"id\":-222,\"lat\":39.593114,\"lon\":-104.8064},\n" "{\"type\":\"node\",\"id\":-223,\"lat\":39.593115,\"lon\":-104.80635},\n" "{\"type\":\"node\",\"id\":-224,\"lat\":39.593291,\"lon\":-104.80637},\n" "{\"type\":\"node\",\"id\":-225,\"lat\":39.593307,\"lon\":-104.80638},\n" "{\"type\":\"node\",\"id\":-226,\"lat\":39.593279,\"lon\":-104.80647},\n" "{\"type\":\"node\",\"id\":-227,\"lat\":39.593297,\"lon\":-104.80625},\n" "{\"type\":\"node\",\"id\":-228,\"lat\":39.593303,\"lon\":-104.80612},\n" "{\"type\":\"node\",\"id\":-229,\"lat\":39.593127,\"lon\":-104.80609},\n" "{\"type\":\"node\",\"id\":-230,\"lat\":39.593124,\"lon\":-104.80611},\n" "{\"type\":\"node\",\"id\":-231,\"lat\":39.593152,\"lon\":-104.80613},\n" "{\"type\":\"node\",\"id\":-232,\"lat\":39.593143,\"lon\":-104.80622},\n" "{\"type\":\"node\",\"id\":-233,\"lat\":39.593122,\"lon\":-104.80621},\n" "{\"type\":\"way\",\"id\":-26,\"nodes\":[-224,-227,-228,-229,-230,-231,-232,-233,-223,-224],\"tags\":{\"building:part\":\"yes\",\"error:circular\":\"15\"},\n" "{\"type\":\"way\",\"id\":-25,\"nodes\":[-218,-219,-220,-221,-222,-223,-224,-225,-226,-218],\"tags\":{\"building:part\":\"yes\",\"error:circular\":\"15\"},\n" "{\"type\":\"relation\",\"id\":-1,\"members\":[\n" "{\"type\":\"way\",\"ref\":-26,\"role\":\"part\"},\n" "{\"type\":\"way\",\"ref\":-25,\"role\":\"part\"}],\"tags\":{\"REF1\":\"Panera\",\"REF2\":\"Panera\",\"hoot:building:match\":\"true\",\"alt_name\":\"Maid-Rite;Maid-Rite Diner\",\"building\":\"yes\",\"name\":\"Panera Bread\",\"error:circular\":\"-1\"}]\n" "}\n", OsmJsonWriter(8).toString(map)); }
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 parallelFilterTest() { 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 n0 = map->findWays("note", "0")[0]; long n1 = map->findWays("note", "1")[0]; long n2 = map->findWays("note", "2")[0]; long n6 = map->findWays("note", "6")[0]; long n8 = map->findWays("note", "8")[0]; long n9 = map->findWays("note", "9")[0]; long n10 = map->findWays("note", "10")[0]; long n11 = map->findWays("note", "11")[0]; long n12 = map->findWays("note", "12")[0]; long n13 = map->findWays("note", "13")[0]; long n14 = map->findWays("note", "14")[0]; long n15 = map->findWays("note", "15")[0]; long n16 = map->findWays("note", "16")[0]; long n17 = map->findWays("note", "17")[0]; long n18 = map->findWays("note", "18")[0]; long n19 = map->findWays("note", "19")[0]; ParallelWayFilter f1(map, map->getWay(n0)); CPPUNIT_ASSERT_EQUAL(f1.isFiltered(map->getWay(n1)), false); CPPUNIT_ASSERT_EQUAL(f1.isFiltered(map->getWay(n2)), false); CPPUNIT_ASSERT_EQUAL(f1.isFiltered(map->getWay(n6)), true); CPPUNIT_ASSERT_EQUAL(f1.isFiltered(map->getWay(n8)), true); ParallelWayFilter f2(map, map->getWay(n9)); CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n10)), false); CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n11)), false); CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n12)), true); CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n13)), true); CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n14)), true); ParallelWayFilter f3(map, map->getWay(n15)); CPPUNIT_ASSERT_EQUAL(f3.isFiltered(map->getWay(n16)), false); CPPUNIT_ASSERT_EQUAL(f3.isFiltered(map->getWay(n10)), true); ParallelWayFilter f17(map, map->getWay(n17)); CPPUNIT_ASSERT_EQUAL(f17.isFiltered(map->getWay(n18)), false); CPPUNIT_ASSERT_EQUAL(f17.isFiltered(map->getWay(n19)), false); }
void runTest() { DisableLog dl; OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/ToyBuildingsTestA.osm", map); reader.setDefaultStatus(Status::Unknown2); reader.read("test-files/ToyBuildingsTestB.osm", map); // introduce a false positive in the test data. vector<long> wids = map->findWays("name", "Cheddar's Casual Cafe"); map->getWay(wids[0])->getTags()["REF1"] = "Bad REF1"; // introduce a false negative in the test data. wids = map->findWays("name", "Freddy's"); map->getWay(wids[0])->getTags()["REF1"] = "Biondi"; // add a uuid to all buildings. HasTagCriterion filter("REF1", "REF2"); AddUuidVisitor uuid("uuid"); FilteredVisitor v(filter, uuid); map->visitRw(v); shared_ptr<OsmMap> copy(new OsmMap(map)); /*#warning Remove this custom configuration that keeps the test from erroring out Settings testSettings = conf(); testSettings.set("conflate.match.threshold", QString::number(0.6)); testSettings.set("conflate.miss.threshold", QString::number(0.6)); testSettings.set("conflate.review.threshold", QString::number(0.6));*/ UnifyingConflator conflator; //conflator.setConfiguration(testSettings); conflator.apply(copy); MatchComparator comparator; double tpr = comparator.evaluateMatches(map, copy); LOG_INFO(comparator.toString()); // for debugging MapProjector::projectToWgs84(copy); QDir(".").mkpath("test-output/scoring"); OsmWriter writer; writer.write(copy, "test-output/scoring/MatchComparatorTest.osm"); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75, tpr, 0.001); CPPUNIT_ASSERT_EQUAL(6, comparator.getTp()); CPPUNIT_ASSERT_EQUAL(1, comparator.getFn()); CPPUNIT_ASSERT_EQUAL(1, comparator.getFp()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.857143, comparator.getPertyScore(), 0.000001); }
void runToyTest() { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/ToyTestA.osm", map); FindIntersectionsOp op; op.apply(map); // RefRemoveOp uut; // uut.addCriterion(ElementCriterionPtr(new BuildingCriterion())); // uut.apply(map); LOG_VAR(TestUtils::toQuotedString(OsmJsonWriter(5).toString(map))); MapReprojector::reprojectToWgs84(map); QDir().mkpath("test-output/ops/FindIntersectionsOp/"); OsmWriter writer; writer.write(map, "test-output/ops/FindIntersectionsOp/Toy_intersections.osm"); HOOT_FILE_EQUALS("test-files/ops/FindIntersectionsOp/ToyTestA_intersections.osm", "test-output/ops/FindIntersectionsOp/Toy_intersections.osm"); }
void runToyTest() { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/visitors/RemoveDuplicateAreaVisitorTest.osm", map); MapProjector::projectToPlanar(map); RemoveDuplicateAreaVisitor uut; map->visitRw(uut); //#warning debug // MapProjector::reprojectToWgs84(map); // QDir().mkpath("test-output/visitors/"); // OsmWriter writer; // writer.write(map, "test-output/visitors/RemoveDuplicateAreaVisitorTest.osm"); // these "duplicates" should not be removed. CPPUNIT_ASSERT_EQUAL(2ul, map->findWays("note", "tag difference").size()); CPPUNIT_ASSERT_EQUAL(2ul, map->findWays("note", "small difference").size()); CPPUNIT_ASSERT_EQUAL(2ul, map->findWays("note", "different name").size()); // these duplicates should be removed. CPPUNIT_ASSERT_EQUAL(1ul, map->findWays("note", "double").size()); CPPUNIT_ASSERT_EQUAL(1ul, map->findWays("note", "triple").size()); }
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"); }
shared_ptr<OsmMap> _loadMap() { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/visitors/TagKeyCountVisitorTest.osm", map); return map; }
void runTest() { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.setUseDataSourceIds(true); reader.read("test-files/MaximalNearestSubline.osm", map); shared_ptr<OsmMap> map2(new OsmMap(map->getProjection())); shared_ptr<OGRSpatialReference> srs = MapReprojector::createAeacProjection(map->calculateBounds()); MapReprojector::reproject(map, srs); stringstream ss; shared_ptr<Way> w; w = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(-353), map->getWay(-313), 10.0, 10.0); w->setStatus(Status::Conflated); ss << ElementConverter(map).convertToLineString(w)->toString() << endl; w = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(-313), map->getWay(-353), 10.0, 10.0); w->setStatus(Status::Conflated); ss << ElementConverter(map).convertToLineString(w)->toString() << endl; w = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(-260), map->getWay(-247), 10.0, 10.0); w->setStatus(Status::Conflated); ss << ElementConverter(map).convertToLineString(w)->toString() << endl; w = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(-247), map->getWay(-260), 10.0, 10.0); w->setStatus(Status::Conflated); ss << ElementConverter(map).convertToLineString(w)->toString() << endl; // { // shared_ptr<OsmMap> wgs84(new OsmMap(map2)); // MapReprojector::reprojectToWgs84(wgs84); // OsmWriter writer; // QString fn = QString("test-output/algorithms/MaximalNearestSublineTestOutput.osm"); // writer.write(wgs84, fn); // } QFile fp("test-files/algorithms/MaximalNearestSublineTest.txt"); fp.open(QIODevice::ReadOnly); QString s = fp.readAll(); CPPUNIT_ASSERT_EQUAL(s.toStdString(), ss.str()); }
shared_ptr<OsmMap> load(QString s1, QString s2) { OsmReader reader; Tgs::Random::instance()->seed(0); OsmMap::resetCounters(); shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read(s1, map); reader.setDefaultStatus(Status::Unknown2); reader.read(s2, map); // make the results consistent. MapProjector::projectToAeac(map); MapCleaner().apply(map); return map; }
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 allManipulationsTest() { 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); Conflator conflator; conflator.loadSource(map); conflator.conflate(); shared_ptr<OsmMap> after(new OsmMap(conflator.getBestMap())); MapReprojector::reprojectToWgs84(after); OsmWriter writer; writer.write(after, "test-output/DividedHighwayMergerTest.osm"); writer.write(map, "test-output/DividedHighwayMergerTestPre.osm"); }
void runIsCandidateTest() { HighwayMatchCreator uut; OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/ToyBuildingsTestA.osm", map); MapProjector::projectToPlanar(map); CPPUNIT_ASSERT(!uut.isMatchCandidate(map->getWay(map->findWays("name", "Panera Bread")[0]), map)); OsmMap::resetCounters(); map.reset(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/ToyTestA.osm", map); MapProjector::projectToPlanar(map); CPPUNIT_ASSERT(uut.isMatchCandidate(map->getWay(map->findWays("note", "1")[0]), map)); }
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 runBasicTest() { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/conflate/SmallWayMergerInput1.osm", map); MapProjector::projectToPlanar(map); SmallWayMerger::mergeWays(map, 15.0); MapProjector::projectToWgs84(map); OsmWriter writer; writer.write(map, "test-output/conflate/SmallWayMergerOutput1.osm"); }
void runWaySplitTest() { //Log::WarningLevel levelBefore = Log::getInstance().getLevel(); //Log::getInstance().setLevel(Log::Debug); OsmMap::resetCounters(); OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.setUseDataSourceIds(true); reader.read("test-files/perty/PertyWaySplitVisitorTest/PertyWaySplitVisitorTest-in-1.osm", map); const int numNodesBeforeSplitting = map->getNodeMap().size(); LOG_VARD(numNodesBeforeSplitting); const int numWaysBeforeSplitting = map->getWays().size(); LOG_VARD(numWaysBeforeSplitting) MapProjector::projectToPlanar(map); PertyWaySplitVisitor waySplitVisitor; boost::minstd_rand rng; rng.seed(1); waySplitVisitor.setRng(rng); waySplitVisitor.setWaySplitProbability(0.5); waySplitVisitor.setMinNodeSpacing(1.0); map->visitRw(waySplitVisitor); MapProjector::projectToWgs84(map); const int numNewNodesCreatedBySpliting = map->getNodeMap().size() - numNodesBeforeSplitting; LOG_VARD(numNewNodesCreatedBySpliting); const int numNewWaysCreatedBySpliting = map->getWays().size() - numWaysBeforeSplitting; LOG_VARD(numNewWaysCreatedBySpliting); const QString outDir = "test-output/perty/PertyWaySplitVisitorTest/"; QDir().mkpath(outDir); OsmWriter writer; writer.setIncludeHootInfo(true); const QString outFile = outDir + "/PertyWaySplitVisitorTest-out-1.osm"; writer.write(map, outFile); HOOT_FILE_EQUALS( "test-files/perty/PertyWaySplitVisitorTest/PertyWaySplitVisitorTest-out-1.osm", outFile); //Log::getInstance().setLevel(levelBefore); }
shared_ptr<CalculateStatsOp> _calcStats(const QString& inputFile) { OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.setUseStatusFromFile(true); reader.setUseDataSourceIds(true); reader.read(inputFile, map); shared_ptr<CalculateStatsOp> calcStatsOp(new CalculateStatsOp()); //If we figure out the error messages logged by the script translator related stats are //invalid and fix them, then this log disablement can be removed. { DisableLog dl(Log::Fatal); calcStatsOp->apply(map); } //calcStatsOp->printStats(); return calcStatsOp; }
void runTest() { OsmReader reader; OsmMap::resetCounters(); shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/algorithms/LongestCommonNodeStringTest.osm", map); MapProjector::projectToOrthographic(map); DuplicateWayRemover::removeDuplicates(map); MapProjector::projectToWgs84(map); OsmWriter writer; writer.setIncludeCompatibilityTags(false); writer.write(map, "test-output/conflate/LongestCommonNodeStringTest.osm"); HOOT_FILE_EQUALS("test-files/conflate/LongestCommonNodeStringTest.osm", "test-output/conflate/LongestCommonNodeStringTest.osm"); }
void runBufferTest() { Settings::getInstance().clear(); OsmReader reader; OsmMap::resetCounters(); OsmSchema::getInstance().loadDefault(); shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/DcTigerRoads.osm", map); OsmMapPtr cutShapeMap = AlphaShapeGenerator(1000.0, 500.0).generate(map); MapReprojector::reprojectToWgs84(cutShapeMap); QDir().mkpath("test-output/conflate"); OsmWriter writer; writer.write(cutShapeMap, "test-output/conflate/AlphaShapeGeneratorBufferTest.osm"); HOOT_FILE_EQUALS("test-files/conflate/AlphaShapeGeneratorBufferTest.osm", "test-output/conflate/AlphaShapeGeneratorBufferTest.osm"); }
void runBasicTest() { Settings::getInstance().clear(); OsmReader reader; OsmMap::resetCounters(); OsmSchema::getInstance().loadDefault(); shared_ptr<OsmMap> map(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/DcTigerRoads.osm", map); MapCleaner().apply(map); MapProjector::projectToWgs84(map); QDir().mkpath("test-output/conflate"); OsmWriter writer; writer.write(map, "test-output/conflate/MapCleaner.osm"); HOOT_FILE_EQUALS("test-files/conflate/MapCleaner.osm", "test-output/conflate/MapCleaner.osm"); }
void runSelfIntersectingRelationTest() { DisableLog dl; OsmReader reader; shared_ptr<OsmMap> map(new OsmMap()); OsmMap::resetCounters(); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/ops/BuildingOutlineRemoveOp/SelfIntersectingRelationsIn.osm", map); BuildingOutlineRemoveOp myOp; myOp.apply(map); MapProjector::projectToWgs84(map); QDir().mkpath("test-output/ops/BuildingOutlineRemoveOp/"); OsmWriter writer; writer.write(map, "test-output/ops/BuildingOutlineRemoveOp/SelfIntersectingRelationsOut.osm"); HOOT_FILE_EQUALS("test-files/ops/BuildingOutlineRemoveOp/SelfIntersectingRelationsOut.osm", "test-output/ops/BuildingOutlineRemoveOp/SelfIntersectingRelationsOut.osm"); }
void runCropTest() { Settings::getInstance().clear(); OsmReader reader; OsmMap::resetCounters(); OsmSchema::getInstance().loadDefault(); shared_ptr<OsmMap> doughMap(new OsmMap()); reader.setDefaultStatus(Status::Unknown1); reader.read("test-files/DcTigerRoads.osm", doughMap); shared_ptr<OsmMap> cutShapeMap(new OsmMap()); reader.read("test-files/conflate/AlphaShapeGeneratorNegativeBufferTest.osm", cutShapeMap); CookieCutter(true).cut(cutShapeMap, doughMap); OsmMapPtr cookieCutMap = doughMap; MapReprojector::reprojectToWgs84(cookieCutMap); QDir().mkpath("test-output/conflate"); OsmWriter writer; writer.write(cookieCutMap, "test-output/conflate/CookieCutterCropTest.osm"); HOOT_FILE_EQUALS("test-files/conflate/CookieCutterCropTest.osm", "test-output/conflate/CookieCutterCropTest.osm"); }
void oneShortTest() { 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 n3 = map->findWays("note", "3")[0]; long n4 = map->findWays("note", "4")[0]; shared_ptr<Way> left = MaximalNearestSubline::getMaximalNearestSubline( map, map->getWay(n3), map->getWay(n4), 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(n4), map->getWay(n3), 10.0, 10.0); right->setStatus(Status::Conflated); right->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; QString fn = QString("test-output/algorithms/MaximalNearestSublineOneShortTestOutput.osm"); writer.write(wgs84, fn); } // QFile fp("test-files/algorithms/MaximalNearestSublineOneShortTestOutput.osm"); // fp.open(QIODevice::ReadOnly); // QString s1 = fp.readAll(); // QFile fp2("test-output/algorithms/MaximalNearestSublineOneShortTestOutput.osm"); // fp2.open(QIODevice::ReadOnly); // QString s2 = fp2.readAll(); // CPPUNIT_ASSERT_EQUAL(s1.toStdString(), s2.toStdString()); }