Esempio n. 1
0
  void runCombineMapTest()
  {
    OsmXmlReader reader;
    OsmMapPtr referenceMap(new OsmMap());
    reader.setDefaultStatus(Status::Unknown1);
    reader.setUseDataSourceIds(true);
    reader.read(
      inputPath + "PertyMatchScorerTest-reference-out-1.osm", referenceMap);
    CPPUNIT_ASSERT_EQUAL(44, (int)referenceMap->getElementCount());

    PertyMatchScorer matchScorer;
    matchScorer.setSearchDistance(15.0);
    matchScorer.setApplyRubberSheet(false);
    OsmMapPtr combinedMap =
      matchScorer._combineMapsAndPrepareForConflation(
        referenceMap,
        inputPath + "PertyMatchScorerTest-perturbed-out-1.osm");

    //can't do a file comparison on the output here since the UUID's added to the file will be
    //different with each run
    CPPUNIT_ASSERT_EQUAL(100, (int)combinedMap->getElementCount());
    boost::shared_ptr<TagKeyCountVisitor> tagKeyCountVisitorRef1(new TagKeyCountVisitor(MetadataTags::Ref1()));
    combinedMap->visitRo(*tagKeyCountVisitorRef1);
    CPPUNIT_ASSERT_EQUAL(8, (int)tagKeyCountVisitorRef1->getStat());
    boost::shared_ptr<TagKeyCountVisitor> tagKeyCountVisitorRef2(new TagKeyCountVisitor(MetadataTags::Ref2()));
    combinedMap->visitRo(*tagKeyCountVisitorRef2);
    CPPUNIT_ASSERT_EQUAL(10, (int)tagKeyCountVisitorRef2->getStat());
  }
Esempio n. 2
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");
  }
Esempio n. 3
0
  void runUseIdTest()
  {
    OsmXmlReader uut;

    OsmMapPtr map(new OsmMap());
    uut.setUseDataSourceIds(true);
    uut.read("test-files/ToyTestA.osm", map);

    CPPUNIT_ASSERT_EQUAL(36,(int)map->getNodes().size());
    CPPUNIT_ASSERT_EQUAL(4, (int)map->getWays().size());

    long min = 1e9;
    long max = -1e9;
    for (NodeMap::const_iterator it = map->getNodes().begin();
         it != map->getNodes().end(); ++it)
    {
      const ConstNodePtr& n = it->second;
      min = std::min(min, n->getId());
      max = std::max(max, n->getId());
    }

    CPPUNIT_ASSERT_EQUAL(-1669793l, min);
    CPPUNIT_ASSERT_EQUAL(-1669723l, max);

    CPPUNIT_ASSERT(map->containsWay(-1669801));
    CPPUNIT_ASSERT(map->containsWay(-1669799));
    CPPUNIT_ASSERT(map->containsWay(-1669797));
    CPPUNIT_ASSERT(map->containsWay(-1669795));
  }
Esempio n. 4
0
  void runUseStatusTest()
  {
    OsmXmlReader uut;

    OsmMapPtr map(new OsmMap());
    uut.setUseDataSourceIds(true);
    uut.setUseFileStatus(true);
    uut.setDefaultStatus(Status::Invalid);
    uut.read("test-files/io/OsmXmlReaderUseStatusTest.osm", map);

    CPPUNIT_ASSERT_EQUAL(104, (int)map->getNodes().size());
    CPPUNIT_ASSERT_EQUAL(17, (int)map->getWays().size());

    HOOT_STR_EQUALS(Status::Unknown1, map->getWay(-12)->getStatus().getEnum());
    HOOT_STR_EQUALS(Status::Conflated, map->getWay(-13)->getStatus().getEnum());
    HOOT_STR_EQUALS(Status::Unknown2, map->getWay(-51)->getStatus().getEnum());
    HOOT_STR_EQUALS(Status::EnumEnd + 1, map->getWay(-14)->getStatus().getEnum());
    HOOT_STR_EQUALS(Status::EnumEnd + 2, map->getWay(-15)->getStatus().getEnum());

    HOOT_STR_EQUALS(0, map->getWay(-12)->getStatus().getInput());
    HOOT_STR_EQUALS(1, map->getWay(-51)->getStatus().getInput());
    HOOT_STR_EQUALS(2, map->getWay(-14)->getStatus().getInput());
    HOOT_STR_EQUALS(3, map->getWay(-15)->getStatus().getInput());

    HOOT_STR_EQUALS("Unknown1", map->getWay(-12)->getStatus().toString());
    HOOT_STR_EQUALS("Unknown2", map->getWay(-51)->getStatus().toString());
    HOOT_STR_EQUALS("Input003", map->getWay(-14)->getStatus().toString());
    HOOT_STR_EQUALS("Input004", map->getWay(-15)->getStatus().toString());
  }
Esempio n. 5
0
  void runUncompressTest()
  {
    const std::string cmd(
      "gzip -c test-files/ToyTestA.osm > test-output/ToyTestA_compressed.osm.gz");
    LOG_DEBUG("Running compress command: " << cmd);

    int retVal;
    if ((retVal = std::system(cmd.c_str())) != 0)
    {
      QString error = QString("Error %1 returned from compress command: %2").arg(retVal).
        arg(QString::fromStdString(cmd));
      throw HootException(error);
    }

    OsmXmlReader uut;
    OsmMapPtr map(new OsmMap());
    uut.setUseDataSourceIds(true);

    // Excercise the code
    uut.read("test-output/ToyTestA_compressed.osm.gz", map);

    // Check a few things
    CPPUNIT_ASSERT_EQUAL(36,(int)map->getNodes().size());
    CPPUNIT_ASSERT_EQUAL(4, (int)map->getWays().size());

    QFile f("test-output/ToyTestA_compressed.osm.gz");
    CPPUNIT_ASSERT(f.exists());
    CPPUNIT_ASSERT(f.remove());
  }