Ejemplo n.º 1
0
    void runTest()
    {
        OsmReader reader;

        srand(0);

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

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

        const WayMap& w1 = map->getWays();
        for (WayMap::const_iterator it = w1.begin(); it != w1.end(); ++it)
        {
          shared_ptr<Way> w = map->getWay(it->second->getId());
          w->setTag("highway", "road");
        }

        const WayMap& w2 = map2->getWays();
        for (WayMap::const_iterator it = w2.begin(); it != w2.end(); ++it)
        {
          shared_ptr<Way> w = map2->getWay(it->second->getId());
          w->setTag("highway", "road");
        }

        GraphComparator uut(map, map2);
        uut.setIterations(3);
        uut.setPixelSize(10);
        uut.compareMaps();
        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.973744272810634, uut.getMeanScore(), 0.00001);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00177888445763033, uut.getConfidenceInterval(), 0.00001);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.973924616144161, uut.getMedianScore(), 0.00001);
        CPPUNIT_ASSERT_DOUBLES_EQUAL(0.00187302021970233, uut.getStandardDeviation(), 0.00001);
    }
Ejemplo n.º 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");
  }
  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"]);
  }
  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);
  }
  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");
  }
  void runCombinedMatchCandidateCountTest()
  {
    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::BuildingMatchCreator");
    matchCreators.append("hoot::HighwayMatchCreator");
    matchCreators.append("hoot::PlacesPoiMatchCreator");
    matchCreators.append("hoot::CustomPoiMatchCreator");
    MatchFactory::getInstance().reset();
    MatchFactory::_setMatchCreators(matchCreators);
    MatchCandidateCountVisitor uut3(MatchFactory::getInstance().getCreators());
    map->visitRo(uut3);
    CPPUNIT_ASSERT_EQUAL((int)68, (int)uut3.getStat());
    QMap<QString, long> matchCandidateCountsByMatchCreator =
      any_cast<QMap<QString, long> >(uut3.getData());
    CPPUNIT_ASSERT_EQUAL(4, matchCandidateCountsByMatchCreator.size());
    //These don't add up to the total...is there some overlap here?
    CPPUNIT_ASSERT_EQUAL((long)18, matchCandidateCountsByMatchCreator["hoot::BuildingMatchCreator"]);
    CPPUNIT_ASSERT_EQUAL((long)8, matchCandidateCountsByMatchCreator["hoot::HighwayMatchCreator"]);
    CPPUNIT_ASSERT_EQUAL((long)21, matchCandidateCountsByMatchCreator["hoot::PlacesPoiMatchCreator"]);
    CPPUNIT_ASSERT_EQUAL((long)21, matchCandidateCountsByMatchCreator["hoot::CustomPoiMatchCreator"]);
  }
  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");
  }
  void runToyTest()
  {
    OsmReader reader;

    shared_ptr<OsmMap> map(new OsmMap());
    OsmMap::resetCounters();
    reader.setDefaultStatus(Status::Unknown1);
    reader.read("test-files/visitors/RemoveDuplicateAreaVisitorTest.osm", map);
    MapProjector::projectToPlanar(map);

    RemoveDuplicateAreaVisitor uut;
    map->visitRw(uut);

//#warning debug
//    MapProjector::reprojectToWgs84(map);
//    QDir().mkpath("test-output/visitors/");
//    OsmWriter writer;
//    writer.write(map, "test-output/visitors/RemoveDuplicateAreaVisitorTest.osm");

    // these "duplicates" should not be removed.
    CPPUNIT_ASSERT_EQUAL(2ul, map->findWays("note", "tag difference").size());
    CPPUNIT_ASSERT_EQUAL(2ul, map->findWays("note", "small difference").size());
    CPPUNIT_ASSERT_EQUAL(2ul, map->findWays("note", "different name").size());

    // these duplicates should be removed.
    CPPUNIT_ASSERT_EQUAL(1ul, map->findWays("note", "double").size());
    CPPUNIT_ASSERT_EQUAL(1ul, map->findWays("note", "triple").size());
  }
Ejemplo n.º 9
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);
  }
  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);
  }
Ejemplo n.º 11
0
  void runTagTest()
  {
    OsmReader reader;

    OsmMap::resetCounters();
    shared_ptr<OsmMap> map(new OsmMap());
    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);

    vector<long> wids1 = map->findWays("REF1", "Panera");
    vector<long> wids2 = map->findWays("REF2", "Panera");
    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])));
    }

    RemoveMissVisitor v(map, "Panera");
    map->visitRw(v);

    vector< pair<ElementId, ElementId> > replaced;

    BuildingMerger bm(pairs);
    bm.apply(map, replaced);

//    QDir(".").mkpath("test-output/conflate/polygon");
//    OsmWriter writer;
//    writer.write(map, "test-output/conflate/polygon/BuildingTagTest.osm");

    HOOT_STR_EQUALS("[3]{(Way:-26, Relation:-1), (Way:-25, Relation:-1), (Way:-14, Relation:-1)}",
                    replaced);
    HOOT_STR_EQUALS("{\"version\": 0.6,\"generator\": \"Hootenanny\",\"elements\": [\n"
                    "{\"type\":\"node\",\"id\":-218,\"lat\":39.593278,\"lon\":-104.80656},\n"
                    "{\"type\":\"node\",\"id\":-219,\"lat\":39.593114,\"lon\":-104.80653},\n"
                    "{\"type\":\"node\",\"id\":-220,\"lat\":39.593124,\"lon\":-104.80645},\n"
                    "{\"type\":\"node\",\"id\":-221,\"lat\":39.593106,\"lon\":-104.80644},\n"
                    "{\"type\":\"node\",\"id\":-222,\"lat\":39.593114,\"lon\":-104.8064},\n"
                    "{\"type\":\"node\",\"id\":-223,\"lat\":39.593115,\"lon\":-104.80635},\n"
                    "{\"type\":\"node\",\"id\":-224,\"lat\":39.593291,\"lon\":-104.80637},\n"
                    "{\"type\":\"node\",\"id\":-225,\"lat\":39.593307,\"lon\":-104.80638},\n"
                    "{\"type\":\"node\",\"id\":-226,\"lat\":39.593279,\"lon\":-104.80647},\n"
                    "{\"type\":\"node\",\"id\":-227,\"lat\":39.593297,\"lon\":-104.80625},\n"
                    "{\"type\":\"node\",\"id\":-228,\"lat\":39.593303,\"lon\":-104.80612},\n"
                    "{\"type\":\"node\",\"id\":-229,\"lat\":39.593127,\"lon\":-104.80609},\n"
                    "{\"type\":\"node\",\"id\":-230,\"lat\":39.593124,\"lon\":-104.80611},\n"
                    "{\"type\":\"node\",\"id\":-231,\"lat\":39.593152,\"lon\":-104.80613},\n"
                    "{\"type\":\"node\",\"id\":-232,\"lat\":39.593143,\"lon\":-104.80622},\n"
                    "{\"type\":\"node\",\"id\":-233,\"lat\":39.593122,\"lon\":-104.80621},\n"
                    "{\"type\":\"way\",\"id\":-26,\"nodes\":[-224,-227,-228,-229,-230,-231,-232,-233,-223,-224],\"tags\":{\"building:part\":\"yes\",\"error:circular\":\"15\"},\n"
                    "{\"type\":\"way\",\"id\":-25,\"nodes\":[-218,-219,-220,-221,-222,-223,-224,-225,-226,-218],\"tags\":{\"building:part\":\"yes\",\"error:circular\":\"15\"},\n"
                    "{\"type\":\"relation\",\"id\":-1,\"members\":[\n"
                    "{\"type\":\"way\",\"ref\":-26,\"role\":\"part\"},\n"
                    "{\"type\":\"way\",\"ref\":-25,\"role\":\"part\"}],\"tags\":{\"REF1\":\"Panera\",\"REF2\":\"Panera\",\"hoot:building:match\":\"true\",\"alt_name\":\"Maid-Rite;Maid-Rite Diner\",\"building\":\"yes\",\"name\":\"Panera Bread\",\"error:circular\":\"-1\"}]\n"
                    "}\n",
                    OsmJsonWriter(8).toString(map));
  }
  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());
  }
Ejemplo n.º 13
0
 shared_ptr<OsmMap> _loadMap()
 {
   OsmReader reader;
   shared_ptr<OsmMap> map(new OsmMap());
   OsmMap::resetCounters();
   reader.setDefaultStatus(Status::Unknown1);
   reader.read("test-files/visitors/TagKeyCountVisitorTest.osm", map);
   return map;
 }
    void runTest()
    {
        OsmReader reader;

        shared_ptr<OsmMap> map(new OsmMap());
        reader.setDefaultStatus(Status::Unknown1);
        reader.setUseDataSourceIds(true);
        reader.read("test-files/MaximalNearestSubline.osm", map);

        shared_ptr<OsmMap> map2(new OsmMap(map->getProjection()));

        shared_ptr<OGRSpatialReference> srs =
            MapReprojector::createAeacProjection(map->calculateBounds());
        MapReprojector::reproject(map, srs);

        stringstream ss;

        shared_ptr<Way> w;
        w = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(-353),
                map->getWay(-313),
                10.0, 10.0);
        w->setStatus(Status::Conflated);
        ss << ElementConverter(map).convertToLineString(w)->toString() << endl;

        w = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(-313),
                map->getWay(-353),
                10.0, 10.0);
        w->setStatus(Status::Conflated);
        ss << ElementConverter(map).convertToLineString(w)->toString() << endl;

        w = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(-260),
                map->getWay(-247),
                10.0, 10.0);
        w->setStatus(Status::Conflated);
        ss << ElementConverter(map).convertToLineString(w)->toString() << endl;

        w = MaximalNearestSubline::getMaximalNearestSubline(map, map->getWay(-247),
                map->getWay(-260),
                10.0, 10.0);
        w->setStatus(Status::Conflated);
        ss << ElementConverter(map).convertToLineString(w)->toString() << endl;

//      {
//        shared_ptr<OsmMap> wgs84(new OsmMap(map2));
//        MapReprojector::reprojectToWgs84(wgs84);
//        OsmWriter writer;
//        QString fn = QString("test-output/algorithms/MaximalNearestSublineTestOutput.osm");
//        writer.write(wgs84, fn);
//      }

        QFile fp("test-files/algorithms/MaximalNearestSublineTest.txt");
        fp.open(QIODevice::ReadOnly);
        QString s = fp.readAll();
        CPPUNIT_ASSERT_EQUAL(s.toStdString(), ss.str());

    }
  void parallelFilterTest()
  {
    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 n0 = map->findWays("note", "0")[0];
    long n1 = map->findWays("note", "1")[0];
    long n2 = map->findWays("note", "2")[0];
    long n6 = map->findWays("note", "6")[0];
    long n8 = map->findWays("note", "8")[0];
    long n9 = map->findWays("note", "9")[0];
    long n10 = map->findWays("note", "10")[0];
    long n11 = map->findWays("note", "11")[0];
    long n12 = map->findWays("note", "12")[0];
    long n13 = map->findWays("note", "13")[0];
    long n14 = map->findWays("note", "14")[0];
    long n15 = map->findWays("note", "15")[0];
    long n16 = map->findWays("note", "16")[0];
    long n17 = map->findWays("note", "17")[0];
    long n18 = map->findWays("note", "18")[0];
    long n19 = map->findWays("note", "19")[0];

    ParallelWayFilter f1(map, map->getWay(n0));

    CPPUNIT_ASSERT_EQUAL(f1.isFiltered(map->getWay(n1)), false);
    CPPUNIT_ASSERT_EQUAL(f1.isFiltered(map->getWay(n2)), false);
    CPPUNIT_ASSERT_EQUAL(f1.isFiltered(map->getWay(n6)), true);
    CPPUNIT_ASSERT_EQUAL(f1.isFiltered(map->getWay(n8)), true);

    ParallelWayFilter f2(map, map->getWay(n9));

    CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n10)), false);
    CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n11)), false);
    CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n12)), true);
    CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n13)), true);
    CPPUNIT_ASSERT_EQUAL(f2.isFiltered(map->getWay(n14)), true);

    ParallelWayFilter f3(map, map->getWay(n15));

    CPPUNIT_ASSERT_EQUAL(f3.isFiltered(map->getWay(n16)), false);
    CPPUNIT_ASSERT_EQUAL(f3.isFiltered(map->getWay(n10)), true);

    ParallelWayFilter f17(map, map->getWay(n17));

    CPPUNIT_ASSERT_EQUAL(f17.isFiltered(map->getWay(n18)), false);
    CPPUNIT_ASSERT_EQUAL(f17.isFiltered(map->getWay(n19)), false);

  }
Ejemplo n.º 16
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);
  }
    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");
    }
Ejemplo n.º 18
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");

  }
Ejemplo n.º 19
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");

    }
  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");
  }
  shared_ptr<OsmMap> load(QString s1, QString s2)
  {
    OsmReader reader;

    Tgs::Random::instance()->seed(0);
    OsmMap::resetCounters();

    shared_ptr<OsmMap> map(new OsmMap());
    reader.setDefaultStatus(Status::Unknown1);
    reader.read(s1, map);
    reader.setDefaultStatus(Status::Unknown2);
    reader.read(s2, map);

    // make the results consistent.
    MapProjector::projectToAeac(map);
    MapCleaner().apply(map);

    return map;
  }
Ejemplo n.º 22
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);
  }
Ejemplo n.º 23
0
  shared_ptr<CalculateStatsOp> _calcStats(const QString& inputFile)
  {
    OsmReader reader;
    shared_ptr<OsmMap> map(new OsmMap());
    OsmMap::resetCounters();
    reader.setDefaultStatus(Status::Unknown1);
    reader.setUseStatusFromFile(true);
    reader.setUseDataSourceIds(true);
    reader.read(inputFile, map);

    shared_ptr<CalculateStatsOp> calcStatsOp(new CalculateStatsOp());
    //If we figure out the error messages logged by the script translator related stats are
    //invalid and fix them, then this log disablement can be removed.
    {
      DisableLog dl(Log::Fatal);
      calcStatsOp->apply(map);
    }
    //calcStatsOp->printStats();
    return calcStatsOp;
  }
Ejemplo n.º 24
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");
  }
Ejemplo n.º 25
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");
  }
Ejemplo n.º 26
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");
    }
Ejemplo n.º 27
0
    void runDenverDistanceTest()
    {
        OsmReader reader;

        srand(0);

//        int argc = 0;
//        char* argv[] = {""};
//        QCoreApplication a(argc, argv);
        LOG_WARN("Starting...");

        shared_ptr<OsmMap> map(new OsmMap());
        reader.read("/home/jason.surratt/geoeye/src/hootenanny/tmp/denver-cleanup.osm", map);
        //reader.read("/home/jason.surratt/geoeye/src/hootenanny/test-files/jakarta-easy-osm.osm", map);
        IntersectionSplitter::splitIntersections(map);

        GraphComparator uut(map, map);
        uut.setIterations(3);
        uut.setPixelSize(10);

        vector<Coordinate> v;

        MapReprojector::reprojectToPlanar(map);

        LOG_WARN("Computing...");
        //v.push_back(Coordinate(-104.77236, 39.71378));
        // Mississippi
        //v.push_back(MapReprojector::reprojectFromWgs84(Coordinate(-104.77236, 39.71378), map->getSrs()));
        // Natural History Museum
        v.push_back(MapReprojector::reprojectFromWgs84(Coordinate(-104.94057, 39.74748), map->getProjection()));
        // Kelly
        //v.push_back(MapReprojector::reprojectFromWgs84(Coordinate(-105.03129, 39.74912), map->getSrs()));
        // jakarta easy
        //v.push_back(MapReprojector::reprojectFromWgs84(Coordinate(106.7838233, -6.2014298), map->getSrs()));
        //v.push_back(Coordinate(106.7838233, -6.2014298));

        uut.drawCostDistance(map, v, "tmp/denver.png");
        LOG_WARN("Done.");
    }
  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");
  }
Ejemplo n.º 29
0
  void runIsCandidateTest()
  {
    HighwayMatchCreator uut;

    OsmReader reader;
    shared_ptr<OsmMap> map(new OsmMap());

    OsmMap::resetCounters();
    reader.setDefaultStatus(Status::Unknown1);
    reader.read("test-files/ToyBuildingsTestA.osm", map);
    MapProjector::projectToPlanar(map);

    CPPUNIT_ASSERT(!uut.isMatchCandidate(map->getWay(map->findWays("name", "Panera Bread")[0]), map));

    OsmMap::resetCounters();
    map.reset(new OsmMap());
    reader.setDefaultStatus(Status::Unknown1);
    reader.read("test-files/ToyTestA.osm", map);
    MapProjector::projectToPlanar(map);

    CPPUNIT_ASSERT(uut.isMatchCandidate(map->getWay(map->findWays("note", "1")[0]), map));
  }
  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");
  }