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


C++ ConstWayPtr::getTags方法代码示例

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


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

示例1: 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

示例2: toWay

WayPtr WaySubline::toWay(const OsmMapPtr& map, GeometryConverter::NodeFactory* nf) const
{
  ConstWayPtr way = _start.getWay();

  auto_ptr<GeometryConverter::NodeFactory> nfPtr;
  if (nf == 0)
  {
    nf = new FindNodesInWayFactory(way);
    // delete it automatically.
    nfPtr.reset(nf);
  }

  WayPtr result(new Way(way->getStatus(), map->createNextWayId(), way->getCircularError()));
  result->setTags(way->getTags());

  int includedStartIndex = _start.getSegmentIndex();
  if (_start.getSegmentFraction() > 0.0)
  {
    includedStartIndex += 1;
  }
  int includedEndIndex = _end.getSegmentIndex();
  if (_end.getSegmentFraction() >= 1.0)
  {
    includedEndIndex += 1;
  }

  if (!_start.isNode())
  {
    Coordinate c = _start.getCoordinate();
    shared_ptr<Node> n = nf->createNode(map, c, way->getStatus(),
      way->getCircularError());
    map->addNode(n);
    result->addNode(n->getId());
  }

  for (int i = includedStartIndex; i <= includedEndIndex; i++)
  {
    result->addNode(way->getNodeId(i));
  }

  if (!_end.isNode())
  {
    Coordinate c = _end.getCoordinate();
    shared_ptr<Node> n = nf->createNode(map, c, way->getStatus(), way->getCircularError());
    map->addNode(n);
    result->addNode(n->getId());
  }

  return result;
}
开发者ID:bpross-52n,项目名称:hootenanny,代码行数:50,代码来源:WaySubline.cpp

示例3: if

geos::geom::GeometryTypeId ElementConverter::getGeometryType(const ConstElementPtr& e,
  bool throwError, const bool statsFlag)
{
  ElementType t = e->getElementType();
  switch (t.getEnum())
  {
  case ElementType::Node:
    return GEOS_POINT;

  case ElementType::Way:
    {
      ConstWayPtr w = dynamic_pointer_cast<const Way>(e);
      assert(w);

      if(statsFlag)
      {
        if (w->isValidPolygon() && OsmSchema::getInstance().isAreaForStats(w->getTags(), ElementType::Way))
          return GEOS_POLYGON;
        else
          return GEOS_LINESTRING;
      } else {
        if (w->isValidPolygon() && OsmSchema::getInstance().isArea(w->getTags(), ElementType::Way))
          return GEOS_POLYGON;
        else
          return GEOS_LINESTRING;
      }

      break;
    }

  case ElementType::Relation:
    {
      ConstRelationPtr r = dynamic_pointer_cast<const Relation>(e);
      assert(r);
      if(statsFlag)
      {
        if (r->isMultiPolygon() || OsmSchema::getInstance().isAreaForStats(r->getTags(), ElementType::Relation))
          return GEOS_MULTIPOLYGON;
        else if (OsmSchema::getInstance().isLinear(*r))
          return GEOS_MULTILINESTRING;
      } else {
        if (r->isMultiPolygon() || OsmSchema::getInstance().isArea(r->getTags(), ElementType::Relation))
          return GEOS_MULTIPOLYGON;
        else if (OsmSchema::getInstance().isLinear(*r))
        {
          return GEOS_MULTILINESTRING;
        }
        else if (r->getMembers().size() == 0 ||
                 OsmSchema::getInstance().isCollection(*r))
        {
          // an empty geometry, pass back a collection
          return GEOS_GEOMETRYCOLLECTION;
        }
      }

      break;

    }

  default:
    LOG_ERROR("Element was not a node, way, or relation");
    break;
  }

  if (throwError)
  {
    throw IllegalArgumentException("Unknown geometry type.");
  }
  else
  {
    return GeometryTypeId(-1);
  }
}
开发者ID:BSteine,项目名称:hootenanny,代码行数:73,代码来源:ElementConverter.cpp


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