Exemplo n.º 1
0
 /// 1. relations process function
 bool operator() (uint64_t /*id*/, RelationElement const & e)
 {
   if (e.GetType() != "multipolygon")
     return false;
   string role;
   if (e.FindWay(m_id, role) && (role == "outer"))
   {
     e.ForEachWay(*this);
     // stop processing (??? assume that "outer way" exists in one relation only ???)
     return true;
   }
   return false;
 }
Exemplo n.º 2
0
void RestrictionWriter::Write(RelationElement const & relationElement)
{
  if (!IsOpened())
    return;

  CHECK_EQUAL(relationElement.GetType(), "restriction", ());

  // Note. For the time being only line-point-line road restriction is supported.
  if (relationElement.nodes.size() != 1 || relationElement.ways.size() != 2)
    return;  // Unsupported restriction. For example line-line-line.

  // Extracting osm ids of lines and points of the restriction.
  auto const findTag = [&relationElement](vector<pair<uint64_t, string>> const & members,
                                          string const & tag) {
    auto const it = find_if(members.cbegin(), members.cend(),
                            [&tag](pair<uint64_t, string> const & p) { return p.second == tag; });
    return it;
  };

  auto const fromIt = findTag(relationElement.ways, "from");
  if (fromIt == relationElement.ways.cend())
    return;

  auto const toIt = findTag(relationElement.ways, "to");
  if (toIt == relationElement.ways.cend())
    return;

  if (findTag(relationElement.nodes, "via") == relationElement.nodes.cend())
    return;

  // Extracting type of restriction.
  auto const tagIt = relationElement.tags.find("restriction");
  if (tagIt == relationElement.tags.end())
    return;

  Restriction::Type type = Restriction::Type::No;
  if (!TagToType(tagIt->second, type))
    return;

  // Adding restriction.
  m_stream << ToString(type) << "," << fromIt->first << ", " << toIt->first << '\n';
}