예제 #1
0
  void runToyTest()
  {
    srand(0);
    OsmMap::resetCounters();
    Settings::getInstance().clear();

    FileUtils::removeDir("test-output/conflate/TileConflatorTest.osm-cache");

    shared_ptr<TileWorker2> worker(new LocalTileWorker2());
    FourPassManager uut(worker);
    // ~240m
    uut.setBuffer(8.0 / 3600.0);
    uut.setMaxNodesPerBox(5000);
    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 SuperfluousNodeRemover()));
    op->addOp(shared_ptr<OsmMapOperation>(new MergeNearbyNodes(10)));
    uut.setOperation(op);

    uut.setSources("test-files/DcGisRoads.osm", "test-files/DcTigerRoads.osm");

    uut.apply("test-output/fourpass/FourPassManagerTest.osm");

    HOOT_FILE_EQUALS("test-files/fourpass/FourPassManagerTest.osm",
                     "test-output/fourpass/FourPassManagerTest.osm");
  }
예제 #2
0
  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");
  }
예제 #3
0
  void runConflateTest()
  {
    Settings testSettings = conf();
    testSettings.set("conflate.enable.old.roads", "false");

    OsmXmlReader reader;
    OsmMapPtr combinedMap(new OsmMap());
    reader.setDefaultStatus(Status::Unknown1);
    reader.setUseDataSourceIds(true);
    reader.read(
      inputPath + "PertyMatchScorerTest-combined-out-1.osm", combinedMap);

    PertyMatchScorer matchScorer;
    matchScorer.setConfiguration(testSettings);
    matchScorer.setSearchDistance(15.0);
    matchScorer.setApplyRubberSheet(true);
    //matchScorer.setConfiguration(testSettings);
    /*boost::shared_ptr<MatchComparator> result =*/
    matchScorer._conflateAndScoreMatches(
      combinedMap,
      outputPath + "PertyMatchScorerTest-conflated-out-1.osm");
    //const double score = result->getPertyScore();

    //MatchComparator test already covers testing the scoring, so not doing that here.
    HOOT_FILE_EQUALS(
      inputPath + "PertyMatchScorerTest-conflated-out-1.osm",
      outputPath + "PertyMatchScorerTest-conflated-out-1.osm");
  }
  void individualManipulationsTest()
  {
    OsmReader reader;

    shared_ptr<OsmMap> map(new OsmMap());
    OsmMap::resetCounters();
    reader.read("test-files/manipulators/WayMergeManipulation.osm", map);

    MapReprojector::reprojectToOrthographic(map);

    long left = map->findWays("note", "3")[0];
    long right = map->findWays("note", "4")[0];

    map->getWay(left)->setStatus(Status::Unknown1);
    map->getWay(right)->setStatus(Status::Unknown2);

    WayMergeManipulation uut(left, right, map, 10.0);
    set<ElementId> ignored1, ignored2;
    shared_ptr<OsmMap> after(new OsmMap(map));
    uut.applyManipulation(after, ignored1, ignored2);

    MapReprojector::reprojectToWgs84(after);

    QDir().mkpath("test-output/manipulators/");

    OsmWriter writer;
    writer.setIncludeCompatibilityTags(false);
    writer.write(after, "test-output/manipulators/WayMergeManipulation.osm");

    HOOT_FILE_EQUALS("test-output/manipulators/WayMergeManipulation.osm",
                     "test-files/manipulators/WayMergeManipulationOutput.osm");
  }
예제 #5
0
 void runLoadReferenceMapTest()
 {
   PertyMatchScorer matchScorer;
   matchScorer.setSearchDistance(15.0);
   matchScorer.setApplyRubberSheet(true);
   matchScorer._loadReferenceMap(
     inputPath + "PertyMatchScorerTest-reference-in-1.osm",
     outputPath + "PertyMatchScorerTest-reference-out-1.osm");
   HOOT_FILE_EQUALS(
     inputPath + "PertyMatchScorerTest-reference-out-1.osm",
     outputPath + "PertyMatchScorerTest-reference-out-1.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");
  }
예제 #7
0
  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");
  }
예제 #8
0
  void runToyTest()
  {
    OsmReader reader;

    shared_ptr<OsmMap> map(new OsmMap());
    reader.read("test-files/ToyTestA.osm", map);

    PbfWriter writer;
    writer.write(map, "test-output/io/PbfWriterTest.pbf");

    HOOT_FILE_EQUALS("test-files/io/PbfWriterTest.pbf",
                     "test-output/io/PbfWriterTest.pbf");

  }
예제 #9
0
  void runBasic()
  {
    OsmXmlReader reader;
    OsmMapPtr map(new OsmMap());
    reader.setDefaultStatus(Status::Unknown1);
    reader.read("test-files/ScoreMatchRef1.osm", map);

    OsmPgCsvWriter writer;
    writer.open("test-output/io/PgCsvWriter/runBasic.pgcsv");
    writer.write(map);
    writer.close();

    //  Check the results
    HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-nodes.pgcsv"),
                     QString("test-output/io/PgCsvWriter/runBasic-nodes.pgcsv"));
    HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-ways.pgcsv"),
                     QString("test-output/io/PgCsvWriter/runBasic-ways.pgcsv"));
    HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-waynodes.pgcsv"),
                     QString("test-output/io/PgCsvWriter/runBasic-waynodes.pgcsv"));
    HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-relations.pgcsv"),
                     QString("test-output/io/PgCsvWriter/runBasic-relations.pgcsv"));
    HOOT_FILE_EQUALS(QString("test-files/io/PgCsvWriter/runBasic-relationmembers.pgcsv"),
                     QString("test-output/io/PgCsvWriter/runBasic-relationmembers.pgcsv"));
  }
  void _runTranslationTest(Settings config, const QString outputFile, const QString goldFile)
  {
    OsmMapPtr map(new OsmMap());
    OsmMapReaderFactory::read(
      map, testInputRoot + "/ToEnglishTranslationVisitorTest.osm", false, Status::Unknown1);

    ToEnglishTranslationVisitor visitor;
    visitor.setConfiguration(config);

    map->visitRw(visitor);

    OsmMapWriterFactory::write(map, outputFile);

    HOOT_FILE_EQUALS(goldFile, outputFile);
  }
예제 #11
0
 void runLoadPerturbedMapTest()
 {
   Settings testSettings = conf();
   testSettings.set("perty.seed", QString::number(1));
   testSettings.set("perty.systematic.error.x", QString::number(1));
   testSettings.set("perty.systematic.error.y", QString::number(1));
   PertyMatchScorer matchScorer;
   matchScorer.setConfiguration(testSettings);
   matchScorer.setSearchDistance(15.0);
   matchScorer.setApplyRubberSheet(true);
   matchScorer._loadPerturbedMap(
     inputPath + "PertyMatchScorerTest-reference-out-1.osm",
     outputPath + "PertyMatchScorerTest-perturbed-out-1.osm");
   HOOT_FILE_EQUALS(
     inputPath + "PertyMatchScorerTest-perturbed-out-1.osm",
     outputPath + "PertyMatchScorerTest-perturbed-out-1.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);
  }
예제 #13
0
  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");
  }
예제 #14
0
    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");
    }
예제 #15
0
  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 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 runBuildingTest()
  {
    // This test is primarily useful as an input to Weka for training models.
    MatchFeatureExtractor uut;
    uut.addMatchCreator(shared_ptr<MatchCreator>(new BuildingMatchCreator()));
    uut.processMap(load("test-files/conflate/extractor/BuildingsA.osm",
      "test-files/conflate/extractor/BuildingsB.osm"));

    //LOG_INFO(uut.getResults().toStdString());

    QDir().mkpath("test-output/conflate/extractor/MatchFeatureExtractorTest/");
    QFile fp("test-output/conflate/extractor/MatchFeatureExtractorTest/Buildings.arff");
    CPPUNIT_ASSERT(fp.open(QIODevice::WriteOnly | QIODevice::Text));
    QByteArray arr = uut.getResults().toUtf8();
    fp.write(arr);
    fp.close();

    // check for consistency with previous versions.
    HOOT_FILE_EQUALS(
      "test-files/conflate/extractor/MatchFeatureExtractorTest/Buildings.arff",
      "test-output/conflate/extractor/MatchFeatureExtractorTest/Buildings.arff");
  }
예제 #18
0
  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");
  }
예제 #19
0
  /*
   * In this test we add in some non-matching, non-name text tags for two ways, and since strict
   * matching is *off*, we *should* see those two ways get merged.
   */
  void runStrictTagMatchingOffTest()
  {
    QDir().mkdir("test-output/conflate");
    OsmMap::resetCounters();
    shared_ptr<OsmMap> map(new OsmMap());
    OsmMapReaderFactory::read(map, "test-files/DcTigerRoads.osm", true, Status::Unknown1);

    //create a non matching text tag between two of the ways that will be examined
    map->getWay(map->findWays("name", "Constitution Ave NW")[0])->getTags().set("email", "blah");

    DuplicateWayRemover dupeWayRemover;
    dupeWayRemover.setStrictTagMatching(false);

    MapProjector::projectToOrthographic(map);
    dupeWayRemover.apply(map);
    MapProjector::projectToWgs84(map);

    OsmWriter writer;
    writer.setIncludeCompatibilityTags(false);
    writer.write(map, "test-output/conflate/DuplicateWayRemoverStrictTagMatchingOffTest.osm");

    HOOT_FILE_EQUALS("test-files/conflate/DuplicateWayRemoverStrictTagMatchingOffTest.osm",
                     "test-output/conflate/DuplicateWayRemoverStrictTagMatchingOffTest.osm");
  }