コード例 #1
0
    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());

    }
コード例 #2
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);
  }
コード例 #3
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;
  }