コード例 #1
0
  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");
  }
コード例 #2
0
  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);
  }
コード例 #3
0
  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");
  }
コード例 #4
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");
  }
コード例 #5
0
  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());
  }
コード例 #6
0
  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);
  }
コード例 #7
0
ファイル: Conflator.cpp プロジェクト: giserh/hootenanny
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);
}
コード例 #8
0
    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");
    }
コード例 #9
0
  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");
  }
コード例 #10
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");
  }
コード例 #11
0
ファイル: OsmWriter.cpp プロジェクト: giserh/hootenanny
QString OsmWriter::toString(const ConstOsmMapPtr& map)
{
  OsmWriter writer;
  // this will be deleted by the _fp auto_ptr
  QBuffer* buf = new QBuffer();
  writer._fp.reset(buf);
  if (!writer._fp->open(QIODevice::WriteOnly | QIODevice::Text))
  {
    throw InternalErrorException(QObject::tr("Error opening QBuffer for writing. Odd."));
  }
  writer.write(map);
  return QString::fromUtf8(buf->data(), buf->size());
}
コード例 #12
0
  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");
  }
コード例 #13
0
  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");
  }
コード例 #14
0
    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");

    }
コード例 #15
0
  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");
  }
コード例 #16
0
  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);
  }
コード例 #17
0
  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");
  }
コード例 #18
0
  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");
  }
コード例 #19
0
  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);
  }
コード例 #20
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");
  }
コード例 #21
0
ファイル: MapCleanerTest.cpp プロジェクト: Nanonid/hootenanny
    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");
    }
コード例 #22
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");
  }
コード例 #23
0
ファイル: ConflatorTest.cpp プロジェクト: Nanonid/hootenanny
  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");
  }
コード例 #24
0
  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");
  }
コード例 #25
0
ファイル: ConflatorTest.cpp プロジェクト: Nanonid/hootenanny
  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");
  }
コード例 #26
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");
  }
コード例 #27
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");
  }
コード例 #28
0
ファイル: PertyOpTest.cpp プロジェクト: Nanonid/hootenanny
  /**
   * Runs a debug version of perty for visualizing the results. Not necessary for normal testing.
   */
  void runDebugTest()
  {
    shared_ptr<OsmMap> map(new OsmMap());
    OGREnvelope env;
    env.MinX = 0;
    env.MinY = 0;
    env.MaxX = 1;
    env.MaxY = 1;
    map->setProjection(MapProjector::createAeacProjection(env));
    //OsmReader reader;
    //reader.read("test-files/ToyTestA.osm", map);
    // force the map bounds.
    NodePtr n1(new Node(Status::Unknown1, map->createNextNodeId(), 0, 0, 10));
    NodePtr n2(new Node(Status::Unknown1, map->createNextNodeId(), 100, 100, 10));
    map->addNode(n1);
    map->addNode(n2);

    double gridSpacing = 2.5;

    for (double x = 0.0; x < 200.0; x += gridSpacing / 4)
    {
      for (double y = 0.0; y < 100.0; y += gridSpacing / 4)
      {
        NodePtr n(new Node(Status::Unknown1, map->createNextNodeId(), x, y, 10));
        //n->setTag("note", QString::number(n->getId()));
        map->addNode(n);
      }
    }

    OsmWriter writer;
    QDir().mkpath("test-output/perty");

    shared_ptr<OsmMap> original(new OsmMap(map));
    MapProjector::projectToWgs84(original);
    writer.write(original, "test-output/perty/Original.osm");

    PertyOp uut;
    uut.setGridSpacing(gridSpacing);
    uut.setRandomError(0.0, 0.0);
    uut.setSeed(1);
    uut.setSystematicError(10.0, 10.0);
    uut.setCsmParameters(9, 10);
    //uut.apply(map);
//    for (int i = 0; i < 100; i++)
//    {
//      shared_ptr<OsmMap> tmp(new OsmMap(map));
//      uut.permute(tmp);
//    }
    //tbs::SampleStats ss(uut._x);
    //LOG_INFO("sd: " << ss.calculateUnbiasedStandardDeviation());
    shared_ptr<OsmMap> debug = uut.generateDebugMap(map);
    //    for (int i = 0; i < 100; i++)
    //    {
    //      shared_ptr<OsmMap> tmp(new OsmMap(map));
    //      uut.permute(tmp);
    //    }
        //tbs::SampleStats ss(uut._x);
        //LOG_INFO("sd: " << ss.calculateUnbiasedStandardDeviation


    MapProjector::projectToWgs84(debug);
    writer.write(debug, "test-output/perty/Debug.osm");
    MapProjector::projectToWgs84(map);
    writer.write(map, "test-output/perty/Permuted.osm");
  }
コード例 #29
0
    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());

    }