Esempio n. 1
0
 /**
  * Remove all tags from the way
  *
  * @param x The Way to remove all tags from
  */
 private void stripTags(Way x) {
   Way y = new Way(x);
   for (String key : x.keySet()) {
     y.remove(key);
   }
   cmds.add(new ChangeCommand(x, y));
 }
Esempio n. 2
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));
    }
  }
  /**
   * Extracts the address information from the given primitive into a newly created {@link Node}.
   * The new node is added into the JOSM database.
   *
   * <p>If the extraction in not applicable, nothing happens.
   *
   * @param primitive the {@link Way} from which the address will be extracted
   */
  @Override
  public void apply(OsmPrimitive primitive) {

    if (!isApplicable(primitive)) return;

    Way way = (Way) primitive;

    BoundingXYVisitor visitor = new BoundingXYVisitor();
    way.accept(visitor);

    Node addrNode = new Node(visitor.getBounds().getCenter());

    for (String key : way.keySet()) if (key.startsWith("addr")) addrNode.put(key, way.get(key));

    for (String key : addrNode.keySet()) way.remove(key);

    Main.main.getCurrentDataSet().addPrimitive(addrNode);
  }