Example #1
0
bool WayCleaner::hasDuplicateCoords(ConstWayPtr way, const OsmMap& map, const bool logDetails)
{
  const vector<long> nodeIds = way->getNodeIds();

  if (nodeIds.size() == 2 &&
      map.getNode(nodeIds.at(0))->toCoordinate() == map.getNode(nodeIds.at(1))->toCoordinate())
  {
    if (logDetails)
    {
      LOG_WARN(
        "Duplicate coordinate " << map.getNode(nodeIds.at(0))->toCoordinate() <<
        " for node with ID:'s " << nodeIds[0] << " and " << nodeIds[1] <<
        " found at indexes 0 and 1; For way with ID: " << way->getElementId().getId());
      LOG_VARW(nodeIds);
    }
    return true;
  }

  bool found = false;
  QList<Coordinate> coords;
  for (size_t i = 0; i < nodeIds.size(); i++)
  {
    const Coordinate coord = map.getNode(nodeIds[i])->toCoordinate();
    if (coords.contains(coord))
    {
      //the only duplicated coords allowed are the first and last for a closed way, if the node ID's
      //match
      if (i == (nodeIds.size() - 1) && nodeIds[0] == nodeIds[i])
      {
        found = false;
      }
      else
      {
        found = true;
      }
      if (found)
      {
        if (logDetails)
        {
          LOG_WARN(
            "Duplicate coord " << map.getNode(nodeIds[i])->toCoordinate() << " for node with ID: " <<
            nodeIds[i] << " found at index: " << i << " For way with ID: " << way->getElementId().getId());
          LOG_VARW(nodeIds);
        }
        return found;
      }
    }
    else
    {
      coords.append(coord);
    }
  }
  return found;
}
Example #2
0
void Node::visitRo(const OsmMap& map, ElementVisitor& filter) const
{
  filter.visit(map.getNode(getId()));
}
Example #3
0
void Node::visitRw(OsmMap& map, ElementVisitor& filter)
{
  filter.visit(map.getNode(getId()));
}