Ejemplo n.º 1
0
 public void addStringsToStringtable() {
   StringTable stable = serializer.getStringTable();
   super.addStringsToStringtable();
   for (Relation i : contents) {
     for (Member j : i.getMembers()) {
       stable.incr(j.getRole());
     }
   }
 }
Ejemplo n.º 2
0
      public Osmformat.PrimitiveGroup serialize() {
        if (contents.size() == 0) {
          return null;
        }

        // System.out.format("%d Relations  ",contents.size());
        StringTable stable = serializer.getStringTable();
        Osmformat.PrimitiveGroup.Builder builder = Osmformat.PrimitiveGroup.newBuilder();
        for (Relation i : contents) {
          Osmformat.Relation.Builder bi = Osmformat.Relation.newBuilder();
          bi.setId(i.getId());
          Member[] arr = new Member[i.getMembers().size()];
          i.getMembers().toArray(arr);
          long lastid = 0;
          for (Member j : i.getMembers()) {
            long id = j.getRef();
            bi.addMemids(id - lastid);
            lastid = id;
            if (j.getType().equals("node")) {
              bi.addTypes(MemberType.NODE);
            } else if (j.getType().equals("way")) {
              bi.addTypes(MemberType.WAY);
            } else if (j.getType().equals("relation")) {
              bi.addTypes(MemberType.RELATION);
            } else {
              assert (false); // Software bug: Unknown entity.
            }
            bi.addRolesSid(stable.getIndex(j.getRole()));
          }

          Iterator<Element.Tag> tags = i.tagsIterator();
          while (tags.hasNext()) {
            Element.Tag t = tags.next();
            bi.addKeys(stable.getIndex(t.getKey()));
            bi.addVals(stable.getIndex(t.getValue()));
          }
          if (!omit_metadata) {
            bi.setInfo(serializeMetadata(i));
          }
          builder.addRelations(bi);
        }
        return builder.build();
      }