Changeset 32865 in osm for applications
- Timestamp:
- 2016-08-21T23:36:28+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/pbf
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pbf/src/org/openstreetmap/josm/plugins/pbf/io/PbfWriter.java
r32862 r32865 7 7 import java.util.ArrayList; 8 8 import java.util.Collection; 9 import java.util.Comparator; 9 10 import java.util.List; 10 11 import java.util.Map.Entry; … … 98 99 stable.incr(tag.getValue()); 99 100 } 100 if (!omit_metadata && i.getUser() != null) { 101 stable.incr(i.getUser().getName()); 102 } 103 } 101 if (!omit_metadata) { 102 stable.incr(getUserId(i)); 103 } 104 } 105 } 106 107 private String getUserId(OsmPrimitive osm) { 108 String userId = osm.getUser() != null ? osm.getUser().getName() : null; 109 if (userId == null) 110 userId = ""; 111 return userId; 104 112 } 105 113 … … 117 125 118 126 int uid = e.getUser() == null ? -1 : (int) e.getUser().getId(); 119 int userSid = stable.getIndex( e.getUser() == null ? "" : e.getUser().getName());127 int userSid = stable.getIndex(getUserId(e)); 120 128 int timestamp = (int) (e.getTimestamp().getTime() / date_granularity); 121 129 int version = e.getVersion(); … … 187 195 188 196 for (Node i : contents) { 189 long id = i.getId(); 197 long id = i.getUniqueId(); 190 198 bi.addId(id - lastid); 191 199 lastid = id; … … 225 233 Osmformat.PrimitiveGroup.Builder builder = Osmformat.PrimitiveGroup.newBuilder(); 226 234 for (Node i : contents) { 227 long id = i.getId(); 235 long id = i.getUniqueId(); 228 236 LatLon coor = i.getCoor(); 229 237 int lat = mapDegrees(coor.lat()); … … 258 266 for (Way i : contents) { 259 267 Osmformat.Way.Builder bi = Osmformat.Way.newBuilder(); 260 bi.setId(i.getId()); 268 bi.setId(i.getUniqueId()); 261 269 long lastid = 0; 262 270 for (Node j : i.getNodes()) { 263 long id = j.getId(); 271 long id = j.getUniqueId(); 264 272 bi.addRefs(id - lastid); 265 273 lastid = id; … … 300 308 for (Relation i : contents) { 301 309 Osmformat.Relation.Builder bi = Osmformat.Relation.newBuilder(); 302 bi.setId(i.getId()); 310 bi.setId(i.getUniqueId()); 303 311 RelationMember[] arr = new RelationMember[i.getMembers().size()]; 304 312 i.getMembers().toArray(arr); 305 313 long lastid = 0; 306 314 for (RelationMember j : i.getMembers()) { 307 long id = j.getMember().getId(); 315 long id = j.getMember().getUniqueId(); 308 316 bi.addMemids(id - lastid); 309 317 lastid = id; … … 477 485 public void process(DataSet ds) { 478 486 processor.processSources(ds.dataSources); 479 for (Node n : ds.getNodes()) { 480 processor.processNode(n); 481 } 482 for (Way w : ds.getWays()) { 483 processor.processWay(w); 484 } 485 for (Relation r : ds.getRelations()) { 486 processor.processRelation(r); 487 } 487 Comparator<OsmPrimitive> cmp = Comparator.comparingLong(OsmPrimitive::getUniqueId); 488 ds.getNodes().stream().sorted(cmp).filter(n -> n.isLatLonKnown()).forEach(processor::processNode); 489 ds.getWays().stream().sorted(cmp).filter(w -> w.getNodesCount() > 0).forEach(processor::processWay); 490 ds.getRelations().stream().sorted(cmp).filter(r -> r.getMembersCount() > 0).forEach(processor::processRelation); 488 491 } 489 492 -
applications/editors/josm/plugins/pbf/test/unit/org/openstreetmap/josm/plugins/pbf/io/PbfExporterTest.java
r32862 r32865 7 7 import java.nio.file.Path; 8 8 9 import org.junit.Ignore;10 9 import org.junit.Rule; 11 10 import org.junit.Test; … … 33 32 */ 34 33 @Test 35 @Ignore("TODO: to fix")36 34 public void testTicket11169() throws Exception { 37 35 try (InputStream is = Compression.ZIP.getUncompressedInputStream(
Note:
See TracChangeset
for help on using the changeset viewer.