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());
  }
예제 #2
0
  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");
  }
예제 #3
0
shared_ptr<MatchComparator> PertyMatchScorer::_conflateAndScoreMatches(
    shared_ptr<OsmMap> combinedDataToConflate, const QString conflatedMapOutputPath)
{
  LOG_DEBUG("Conflating the reference data with the perturbed data, scoring the matches, and " <<
            "saving the conflated output to: " << conflatedMapOutputPath);

  shared_ptr<MatchComparator> comparator(new MatchComparator());
  //shared_ptr<MatchThreshold> matchThreshold;
  OsmMapPtr conflationCopy(new OsmMap(combinedDataToConflate));

  ConfigOptions configOptions(_settings);
  if (configOptions.getConflateEnableOldRoads())
  {
    // call the old road conflation routine
    Conflator conflator;
    conflator.loadSource(conflationCopy);
    conflator.conflate();
    conflationCopy.reset(new OsmMap(conflator.getBestMap()));
  }

  UnifyingConflator conflator/*(matchThreshold)*/;
  conflator.setConfiguration(_settings);
  conflator.apply(conflationCopy);

  try
  {
    comparator->evaluateMatches(combinedDataToConflate, conflationCopy);
  }
  catch (const HootException& e)
  {
    // save map modifies the map so we want to make sure comparator runs first. 'finally' would be
    // nice.
    _saveMap(conflationCopy, conflatedMapOutputPath);
    throw e;
  }

  _saveMap(conflationCopy, conflatedMapOutputPath);

  return comparator;
}
  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");
  }
예제 #5
0
  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");
  }