Ticket #19165: 19165.patch

File 19165.patch, 1.6 KB (added by GerdP, 6 years ago)
  • src/org/openstreetmap/josm/plugins/pbf/io/PbfWriter.java

     
    485485        public void process(DataSet ds) {
    486486            processor.processSources(ds.getDataSources());
    487487            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            ds.getNodes().stream().sorted(cmp).filter(n -> shouldWrite(n)).forEach(processor::processNode);
     489            ds.getWays().stream().sorted(cmp).filter(w -> shouldWrite(w)).forEach(processor::processWay);
     490            ds.getRelations().stream().sorted(cmp).filter(r -> shouldWrite(r)).forEach(processor::processRelation);
    491491        }
    492492
    493493        public void complete() {
     
    499499                throw new RuntimeException("Unable to complete the PBF file.", e);
    500500            }
    501501        }
     502
     503        private static boolean shouldWrite(OsmPrimitive osm) {
     504            // see OsmWriter
     505            return (!osm.isNewOrUndeleted() || !osm.isDeleted()) && !osm.isIncomplete();
     506        }
     507
    502508    }
    503509
    504510    /**