Changeset 35292 in osm for applications/editors/josm/plugins/comfort0/src
- Timestamp:
- 2020-01-13T21:45:38+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/comfort0/src/net/simon04/comfort0/OsmToLevel0L.java
r35289 r35292 22 22 private final StringBuilder sb = new StringBuilder(); 23 23 24 public void visit(Collection<OsmPrimitive> primitives) { 24 /** 25 * Visits a collection of primitives 26 * @param primitives The collection of primitives 27 * @return {@code this} 28 */ 29 public OsmToLevel0L visit(Collection<OsmPrimitive> primitives) { 25 30 primitives.stream() 26 31 .sorted(OsmPrimitiveComparator.orderingWaysRelationsNodes().thenComparing(OsmPrimitiveComparator.comparingUniqueId())) 27 32 .forEachOrdered(p -> p.accept(this)); 33 return this; 28 34 } 29 35 … … 37 43 appendCommon(w); 38 44 for (Node node : w.getNodes()) { 39 sb.append(" n").append(node.getUniqueId()); 40 appendDisplayName(node); 45 appendRef(node, ""); 41 46 } 42 47 } … … 46 51 appendCommon(r); 47 52 for (RelationMember member : r.getMembers()) { 48 sb.append(" "); 49 switch (member.getType()) { 50 case NODE: 51 sb.append("nd "); 52 break; 53 case WAY: 54 sb.append("wy "); 55 break; 56 case RELATION: 57 sb.append("rel "); 58 break; 59 default: 60 break; 61 } 62 sb.append(member.getUniqueId()).append(" "); 63 sb.append(member.getRole()); 64 appendDisplayName(member.getMember()); 53 appendRef(member.getMember(), " " + member.getRole()); 65 54 } 55 } 56 57 private void appendRef(OsmPrimitive primitive, String mixin) { 58 sb.append(" "); 59 switch (primitive.getType()) { 60 case NODE: 61 sb.append("nd "); 62 break; 63 case WAY: 64 sb.append("wy "); 65 break; 66 case RELATION: 67 sb.append("rel "); 68 break; 69 default: 70 break; 71 } 72 sb.append(primitive.getUniqueId()); 73 sb.append(mixin); 74 appendDisplayName(primitive); 66 75 } 67 76 … … 93 102 @Override 94 103 public String toString() { 95 return sb.toString(). trim();104 return sb.toString().replaceFirst("^\\n", ""); 96 105 } 97 106 }
Note:
See TracChangeset
for help on using the changeset viewer.