コード例 #1
0
  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);
  }
コード例 #2
0
  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);
  }
コード例 #3
0
  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"]);
  }
コード例 #4
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");
  }
コード例 #5
0
  void runTest()
  {
    QList<SingleStat> inputStats1;
    inputStats1.append(SingleStat("Total Feature Count", 6.0));
    QList<SingleStat> inputStats2;
    inputStats2.append(SingleStat("Total Feature Count", 4.0));
    QList<SingleStat> outputStats;
    outputStats.append(SingleStat("Total Feature Count", 12.0));
    QList<SingleStat> statsToUpdate;
    statsToUpdate.append(SingleStat("Some Stat", 0.0));

    ConflateStatsHelper uut1(inputStats1, inputStats2, outputStats);
    uut1.updateStats(statsToUpdate);

    CPPUNIT_ASSERT_EQUAL(1, inputStats1.size());
    CPPUNIT_ASSERT_EQUAL(1, inputStats2.size());
    CPPUNIT_ASSERT_EQUAL(1, outputStats.size());
    CPPUNIT_ASSERT_EQUAL(3, statsToUpdate.size());
    CPPUNIT_ASSERT_EQUAL(QString("Some Stat").toStdString(), statsToUpdate.at(0).name.toStdString());
    CPPUNIT_ASSERT_DOUBLES_EQUAL(
      2.0,
      uut1.getSingleStat("Difference Between Total Features in Output and Total Features in Inputs", statsToUpdate),
      1e-1);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(
      20.0,
      uut1.getSingleStat("Percentage Difference Between Total Features in Output and Total Features in Inputs", statsToUpdate),
      1e-1);

    statsToUpdate.clear();
    statsToUpdate.append(SingleStat("Some Stat 1", 0.0));
    statsToUpdate.append(SingleStat("Some Stat 2", 0.0));
    ConflateStatsHelper uut2(inputStats1, inputStats2, outputStats);
    uut2.updateStats(statsToUpdate, 1);

    CPPUNIT_ASSERT_EQUAL(4, statsToUpdate.size());
    CPPUNIT_ASSERT_EQUAL(QString("Some Stat 1").toStdString(), statsToUpdate.at(0).name.toStdString());
    CPPUNIT_ASSERT_EQUAL(QString("Some Stat 2").toStdString(), statsToUpdate.at(3).name.toStdString());
  }