Changeset 5737 in josm for trunk/src/org
- Timestamp:
- 2013-02-21T02:30:26+01:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r5589 r5737 91 91 }; 92 92 93 protected Collection<OsmPrimitive> sortById(Collection<? extends OsmPrimitive> primitives) {94 List< OsmPrimitive> result = new ArrayList<OsmPrimitive>(primitives.size());93 protected <T extends OsmPrimitive> Collection<T> sortById(Collection<T> primitives) { 94 List<T> result = new ArrayList<T>(primitives.size()); 95 95 result.addAll(primitives); 96 96 Collections.sort(result, byIdComparator); … … 105 105 } 106 106 107 /** 108 * Writes the contents of the given dataset (nodes, then ways, then relations) 109 * @param ds The dataset to write 110 */ 107 111 public void writeContent(DataSet ds) { 108 for (OsmPrimitive n : sortById(ds.getNodes())) { 112 writeNodes(ds.getNodes()); 113 writeWays(ds.getWays()); 114 writeRelations(ds.getRelations()); 115 } 116 117 /** 118 * Writes the given nodes sorted by id 119 * @param nodes The nodes to write 120 * @since 5737 121 */ 122 public void writeNodes(Collection<Node> nodes) { 123 for (Node n : sortById(nodes)) { 109 124 if (shouldWrite(n)) { 110 visit((Node)n); 111 } 112 } 113 for (OsmPrimitive w : sortById(ds.getWays())) { 125 visit(n); 126 } 127 } 128 } 129 130 /** 131 * Writes the given ways sorted by id 132 * @param ways The ways to write 133 * @since 5737 134 */ 135 public void writeWays(Collection<Way> ways) { 136 for (Way w : sortById(ways)) { 114 137 if (shouldWrite(w)) { 115 visit((Way)w); 116 } 117 } 118 for (OsmPrimitive e: sortById(ds.getRelations())) { 119 if (shouldWrite(e)) { 120 visit((Relation)e); 138 visit(w); 139 } 140 } 141 } 142 143 /** 144 * Writes the given relations sorted by id 145 * @param relations The relations to write 146 * @since 5737 147 */ 148 public void writeRelations(Collection<Relation> relations) { 149 for (Relation r : sortById(relations)) { 150 if (shouldWrite(r)) { 151 visit(r); 121 152 } 122 153 }
Note:
See TracChangeset
for help on using the changeset viewer.