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 testAll() { srand(0); OsmMap::resetCounters(); Settings::getInstance().clear(); conf().set(ConfigOptions().getUuidHelperRepeatableKey(), true); conf().set(ConfigOptions().getUnifyOptimizerTimeLimitKey(), -1); string outDir = "test-output/hadoop/HadoopTileWorkerTest/"; Hdfs fs; if (fs.exists(outDir)) { fs.deletePath(outDir, true); } fs.copyFromLocal("test-files/DcTigerRoads.pbf", outDir + "in1.pbf/DcTigerRoads.pbf"); fs.copyFromLocal("test-files/DcGisRoads.pbf", outDir + "in2.pbf/DcGisRoads.pbf"); shared_ptr<TileWorker> worker(new HadoopTileWorker()); TileConflator uut(worker); // ~240m uut.setBuffer(8.0 / 3600.0); uut.setMaxNodesPerBox(5000); uut.setSources(QString::fromStdString(outDir) + "in1.pbf", QString::fromStdString(outDir) + "in2.pbf"); uut.conflate(QString::fromStdString(outDir) + "HadoopTileWorkerTest.pbf"); shared_ptr<OsmMap> map(new OsmMap); PbfReader reader(true); reader.setUseFileStatus(true); std::vector<FileStatus> status = fs.listStatus(outDir + "HadoopTileWorkerTest.pbf", true); for (size_t i = 0; i < status.size(); i++) { const string& path = status[i].getPath(); LOG_INFO(path); if (QString::fromStdString(path).endsWith(".pbf")) { shared_ptr<istream> is(fs.open(path)); reader.parse(is.get(), map); } } QDir().mkpath(QString::fromStdString(outDir)); OsmWriter writer; writer.setIncludeHootInfo(true); writer.write(map, QString::fromStdString(outDir + "/result.osm")); HOOT_FILE_EQUALS("test-files/hadoop/HadoopTileWorkerTest/result.osm", "test-output/hadoop/HadoopTileWorkerTest/result.osm"); }
void testAll() { string outDir = "test-output/hadoop/HadoopTileWorker2Test/"; Hdfs fs; if (fs.exists(outDir)) { fs.deletePath(outDir, true); } fs.copyFromLocal("test-files/DcTigerRoads.pbf", outDir + "in1.pbf/DcTigerRoads.pbf"); fs.copyFromLocal("test-files/DcGisRoads.pbf", outDir + "in2.pbf/DcGisRoads.pbf"); shared_ptr<TileWorker2> worker(new HadoopTileWorker2()); FourPassManager uut(worker); // ~240m uut.setBuffer(8.0 / 3600.0); uut.setMaxNodesPerBox(5000); uut.setSources(QString::fromStdString(outDir) + "in1.pbf", QString::fromStdString(outDir) + "in2.pbf"); Envelope env(-77.039, -77.033, 38.892, 38.896); shared_ptr<OpList> op(new OpList()); op->addOp(shared_ptr<OsmMapOperation>(new MapCropper(env))); op->addOp(shared_ptr<OsmMapOperation>(new MergeNearbyNodes(10))); uut.setOperation(op); uut.apply(QString::fromStdString(outDir) + "HadoopTileWorker2Test.pbf"); shared_ptr<OsmMap> map(new OsmMap); PbfReader reader(true); reader.setUseFileStatus(true); std::vector<FileStatus> status = fs.listStatus(outDir + "HadoopTileWorker2Test.pbf"); for (size_t i = 0; i < status.size(); i++) { const string& path = status[i].getPath(); LOG_INFO(path); if (QString::fromStdString(path).endsWith(".pbf")) { shared_ptr<istream> is(fs.open(path)); reader.parse(is.get(), map); } } QDir().mkpath(QString::fromStdString(outDir)); OsmWriter writer; writer.setIncludeHootInfo(true); writer.write(map, QString::fromStdString(outDir + "/result.osm")); HOOT_FILE_EQUALS("test-files/hadoop/HadoopTileWorker2Test/result.osm", "test-output/hadoop/HadoopTileWorker2Test/result.osm"); }
void runFactoryReadMapTest() { OsmMap::resetCounters(); shared_ptr<OsmMap> map(new OsmMap()); OsmMapReaderFactory::read(map, "test-files/ToyTestA.osm.pbf", false, Status::Unknown1); QDir().mkpath("test-output/io/"); OsmWriter writer; writer.setIncludeHootInfo(false); writer.write(map, "test-output/io/PbfReaderTest.osm"); HOOT_FILE_EQUALS("test-files/io/PbfReaderTest.osm", "test-output/io/PbfReaderTest.osm"); }
void runReadMapPartialMultipleBlobsTest() { OsmMap::resetCounters(); PbfReader reader(false); const int chunkSize = 40; reader.setMaxElementsPerMap(chunkSize); reader.open("test-files/ToyTestCombined.pbf"); reader.initializePartial(); QDir().mkpath("test-output/io/"); OsmWriter writer; writer.setIncludeHootInfo(false); //Suppress the warning from the OsmReader about missing nodes for ways by temporarily changing //the log level. We expect the nodes to be missing since we're doing partial map reads and //don't need to see the messages. Log::WarningLevel loglLevel = Log::getInstance().getLevel(); Log::getInstance().setLevel(Log::Error); int ctr = 0; while (reader.hasMoreElements()) { shared_ptr<OsmMap> map(new OsmMap()); reader.readPartial(map); //some of these before the last one don't read out the full buffer size..not sure why CPPUNIT_ASSERT( (int)(map->getNodeMap().size() + map->getWays().size() + map->getRelationMap().size()) <= chunkSize); QString outputFile( "test-output/io/PbfPartialReaderMultipleBlobsTest" + QString::number(ctr + 1) + ".osm"); writer.write(map, outputFile); HOOT_FILE_EQUALS( "test-files/io/PbfPartialReaderMultipleBlobsTest" + QString::number(ctr + 1) + ".osm", outputFile); ctr++; CPPUNIT_ASSERT(ctr < 5); //to prevent an infinite loop if hasMoreElements fails } Log::getInstance().setLevel(loglLevel); reader.finalizePartial(); CPPUNIT_ASSERT_EQUAL(4, ctr); }
void runReadMapTest() { OsmMap::resetCounters(); PbfReader reader(false); shared_ptr<OsmMap> map(new OsmMap()); reader.open("test-files/ToyTestA.osm.pbf"); reader.read(map); reader.close(); QDir().mkpath("test-output/io/"); OsmWriter writer; writer.setIncludeHootInfo(false); writer.write(map, "test-output/io/PbfReaderTest.osm"); HOOT_FILE_EQUALS("test-files/io/PbfReaderTest.osm", "test-output/io/PbfReaderTest.osm"); }
void runToyTest() { OsmMap::resetCounters(); PbfReader uut(false); fstream input("test-files/ToyTestA.osm.pbf", ios::in | ios::binary); shared_ptr<OsmMap> map(new OsmMap()); uut.parse(&input, map); QDir().mkpath("test-output/io/"); OsmWriter writer; writer.setIncludeHootInfo(false); writer.write(map, "test-output/io/PbfReaderTest.osm"); HOOT_FILE_EQUALS("test-files/io/PbfReaderTest.osm", "test-output/io/PbfReaderTest.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); }