예제 #1
0
    /**
     * Extract and store relation information based on the relation member
     *
     * @param src The relation member to store information about
     */
    public RelMember(RelationMember src) {
      role = src.getRole();
      type = src.getType();
      rel_id = 0;
      coor = new ArrayList<LatLon>();

      if (src.isNode()) {
        Node r = src.getNode();
        tags = r.getKeys();
        coor = new ArrayList<LatLon>(1);
        coor.add(r.getCoor());
      }
      if (src.isWay()) {
        Way r = src.getWay();
        tags = r.getKeys();
        List<Node> wNodes = r.getNodes();
        coor = new ArrayList<LatLon>(wNodes.size());
        for (Node wNode : wNodes) {
          coor.add(wNode.getCoor());
        }
      }
      if (src.isRelation()) {
        Relation r = src.getRelation();
        tags = r.getKeys();
        rel_id = r.getId();
        coor = new ArrayList<LatLon>();
      }
    }
예제 #2
0
 /**
  * Creates new way objects for the way chunks and transfers the keys from the original way.
  *
  * @param way the original way whose keys are transferred
  * @param wayChunks the way chunks
  * @return the new way objects
  */
 protected static List<Way> createNewWaysFromChunks(Way way, Iterable<List<Node>> wayChunks) {
   final List<Way> newWays = new ArrayList<>();
   for (List<Node> wayChunk : wayChunks) {
     Way wayToAdd = new Way();
     wayToAdd.setKeys(way.getKeys());
     wayToAdd.setNodes(wayChunk);
     newWays.add(wayToAdd);
   }
   return newWays;
 }
예제 #3
0
 @Override
 public void visit(Way w) {
   if (!w.isUsable()) return;
   List<Node> wNodes = w.getNodes();
   List<LatLon> wLat = new ArrayList<LatLon>(wNodes.size());
   for (int i = 0; i < wNodes.size(); i++) {
     wLat.add(wNodes.get(i).getCoor());
   }
   Map<String, String> wkeys = w.getKeys();
   removeUninterestingKeys(wkeys);
   WayPair wKey = new WayPair(wLat, wkeys);
   ways.put(wKey, w);
   WayPairNoTags wKeyN = new WayPairNoTags(wLat);
   waysNoTags.put(wKeyN, w);
 }
예제 #4
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));
    }
  }