当前位置: 首页>>代码示例>>C++>>正文


C++ OsmWriter类代码示例

本文整理汇总了C++中OsmWriter的典型用法代码示例。如果您正苦于以下问题:C++ OsmWriter类的具体用法?C++ OsmWriter怎么用?C++ OsmWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OsmWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: runToyTest

  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");
  }
开发者ID:drew-bower,项目名称:hootenanny,代码行数:25,代码来源:FindIntersectionsOpTest.cpp

示例2: runMatchTest

  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);
  }
开发者ID:drew-bower,项目名称:hootenanny,代码行数:35,代码来源:BuildingMergerTest.cpp

示例3: individualManipulationsTest

  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");
  }
开发者ID:drew-bower,项目名称:hootenanny,代码行数:32,代码来源:WayMergeManipulationTest.cpp

示例4: runTest

  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");
  }
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:28,代码来源:CookieCutterOpTest.cpp

示例5: runConflateTest

  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());
  }
开发者ID:mort85,项目名称:hootenanny,代码行数:58,代码来源:BuildingMergeManipulatorTest.cpp

示例6: runTest

  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);
  }
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:55,代码来源:MatchComparatorTest.cpp

示例7: LOG_INFO

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);
}
开发者ID:giserh,项目名称:hootenanny,代码行数:11,代码来源:Conflator.cpp

示例8: funnyCurveTest

    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");
    }
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:54,代码来源:MaximalNearestSublineTest.cpp

示例9: testAll

  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");
  }
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:52,代码来源:HadoopTileWorkerTest.cpp

示例10: testAll

  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");
  }
开发者ID:Nanonid,项目名称:hootenanny,代码行数:52,代码来源:HadoopTileWorker2Test.cpp

示例11: toString

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());
}
开发者ID:giserh,项目名称:hootenanny,代码行数:13,代码来源:OsmWriter.cpp

示例12: runFactoryReadMapTest

  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");
  }
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:15,代码来源:PbfReaderTest.cpp

示例13: runBasicTest

    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");

    }
开发者ID:Nanonid,项目名称:hootenanny,代码行数:16,代码来源:SmallWayMergerTest.cpp

示例14: individualManipulationsTest

  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");
  }
开发者ID:drew-bower,项目名称:hootenanny,代码行数:47,代码来源:DividedHighwayManipulationTest.cpp

示例15: runReadMapPartialMultipleBlobsTest

  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);
  }
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:46,代码来源:PbfReaderTest.cpp


注:本文中的OsmWriter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。