Esempio n. 1
0
  @Override
  public void visit(Way w) {
    if (!w.isUsable()) return;

    Map<String, String> tags = w.getKeys();
    if (!tags.isEmpty()) {
      String highway = tags.get("highway");
      if (highway != null && NAMED_WAYS.contains(highway)) {
        if (!tags.containsKey("name") && !tags.containsKey("ref")) {
          boolean isRoundabout = false;
          boolean hasName = false;
          for (String key : w.keySet()) {
            hasName = key.startsWith("name:") || key.endsWith("_name") || key.endsWith("_ref");
            if (hasName) {
              break;
            }
            if (key.equals("junction")) {
              isRoundabout = w.get("junction").equals("roundabout");
              break;
            }
          }

          if (!hasName && !isRoundabout) {
            errors.add(new TestError(this, Severity.WARNING, tr("Unnamed ways"), UNNAMED_WAY, w));
          } else if (isRoundabout) {
            errors.add(
                new TestError(this, Severity.WARNING, tr("Unnamed junction"), UNNAMED_JUNCTION, w));
          }
        }
      }
    }

    if (!w.isTagged() && !multipolygonways.contains(w)) {
      if (w.hasKeys()) {
        errors.add(
            new TestError(
                this, Severity.WARNING, tr("Untagged ways (commented)"), COMMENTED_WAY, w));
      } else {
        errors.add(new TestError(this, Severity.WARNING, tr("Untagged ways"), UNTAGGED_WAY, w));
      }
    }

    if (w.getNodesCount() == 0) {
      errors.add(new TestError(this, Severity.ERROR, tr("Empty ways"), EMPTY_WAY, w));
    } else if (w.getNodesCount() == 1) {
      errors.add(new TestError(this, Severity.ERROR, tr("One node ways"), ONE_NODE_WAY, w));
    }
  }