Changeset 18702 in josm
- Timestamp:
- 2023-04-11T19:04:13+02:00 (23 months ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/pbf/BlobHeader.java
r18697 r18702 27 27 28 28 /** 29 * Get the blob type 29 30 * @return The blob type 30 31 */ … … 34 35 35 36 /** 37 * Get the blob metadata 36 38 * @return The blob metadata 37 39 */ … … 41 43 42 44 /** 45 * Get the blob size 43 46 * @return The blob size 44 47 */ -
trunk/src/org/openstreetmap/josm/data/osm/pbf/Info.java
r18697 r18702 36 36 37 37 /** 38 * Get the OSM version 38 39 * @return The version 39 40 */ … … 43 44 44 45 /** 46 * Get the OSM timestamp 45 47 * @return The timestamp 46 48 */ … … 50 52 51 53 /** 54 * Get the OSM changeset 52 55 * @return The changeset 53 56 */ … … 57 60 58 61 /** 62 * Get the OSM user id 59 63 * @return The user id 60 64 */ … … 64 68 65 69 /** 70 * Get the id for the username in the PBF 66 71 * @return The user string id (in PBF strings) 67 72 */ … … 71 76 72 77 /** 78 * Get the visibility of the object 73 79 * @return {@code false} if the object was deleted 74 80 */ -
trunk/src/org/openstreetmap/josm/io/OsmPbfReader.java
r18697 r18702 86 86 } 87 87 88 private DataSetparse(InputStream source) throws IllegalDataException, IOException {88 private void parse(InputStream source) throws IllegalDataException, IOException { 89 89 final CountingInputStream inputStream; 90 90 if (source.markSupported()) { … … 119 119 } 120 120 } 121 return this.getDataSet();122 121 } 123 122 … … 133 132 */ 134 133 @Nonnull 135 private BlobHeader parseBlobHeader(CountingInputStream cis, ByteArrayOutputStream baos, ProtobufParser parser) 134 private static BlobHeader parseBlobHeader(CountingInputStream cis, ByteArrayOutputStream baos, ProtobufParser parser) 136 135 throws IOException, IllegalDataException { 137 136 String type = null; … … 181 180 */ 182 181 @Nonnull 183 private Blob parseBlob(BlobHeader header, CountingInputStream cis, ProtobufParser parser, ByteArrayOutputStream baos) throws IOException { 182 private static Blob parseBlob(BlobHeader header, CountingInputStream cis, ProtobufParser parser, ByteArrayOutputStream baos) 183 throws IOException { 184 184 long start = cis.getBytesRead(); 185 185 int size = Integer.MIN_VALUE; … … 214 214 } 215 215 } 216 if (type == null) { 217 throw new IllegalStateException("Compression type not found, pbf may be malformed"); 218 } 216 219 return new Blob(size, type, current.getBytes()); 217 220 } … … 226 229 */ 227 230 @Nonnull 228 private HeaderBlock parseHeaderBlock(Blob blob, ByteArrayOutputStream baos) throws IOException { 231 private static HeaderBlock parseHeaderBlock(Blob blob, ByteArrayOutputStream baos) throws IOException { 229 232 try (InputStream blobInput = blob.inputStream(); 230 233 ProtobufParser parser = new ProtobufParser(blobInput)) { … … 334 337 dateGranularity); 335 338 final DataSet ds = getDataSet(); 336 if (!primitiveGroups.isEmpty()) { 339 if (!primitiveGroups.isEmpty() && headerBlock.bbox() != null) { 337 340 try { 338 341 ds.beginUpdate(); … … 406 409 */ 407 410 @Nonnull 408 private String[] parseStringTable(ByteArrayOutputStream baos, byte[] bytes) throws IOException { 411 private static String[] parseStringTable(ByteArrayOutputStream baos, byte[] bytes) throws IOException { 409 412 try (ByteArrayInputStream is = new ByteArrayInputStream(bytes); 410 413 ProtobufParser parser = new ProtobufParser(is)) { … … 681 684 * @throws IOException if something happened while reading a {@link ByteArrayInputStream} 682 685 */ 683 @Nonnull684 686 private void parseRelation(ByteArrayOutputStream baos, byte[] bytes, PrimitiveBlockRecord primitiveBlockRecord) 685 687 throws IllegalDataException, IOException { … … 758 760 */ 759 761 @Nonnull 760 private Info parseInfo(ByteArrayOutputStream baos, byte[] bytes) throws IOException { 762 private static Info parseInfo(ByteArrayOutputStream baos, byte[] bytes) throws IOException { 761 763 try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 762 764 ProtobufParser parser = new ProtobufParser(bais)) { … … 768 770 boolean visible = true; 769 771 while (parser.hasNext()) { 770 ProtobufRecord record = new ProtobufRecord(baos, parser);771 switch ( record.getField()) {772 ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 773 switch (protobufRecord.getField()) { 772 774 case 1: 773 version = record.asUnsignedVarInt().intValue();775 version = protobufRecord.asUnsignedVarInt().intValue(); 774 776 break; 775 777 case 2: 776 timestamp = record.asUnsignedVarInt().longValue();778 timestamp = protobufRecord.asUnsignedVarInt().longValue(); 777 779 break; 778 780 case 3: 779 changeset = record.asUnsignedVarInt().longValue();781 changeset = protobufRecord.asUnsignedVarInt().longValue(); 780 782 break; 781 783 case 4: 782 uid = record.asUnsignedVarInt().intValue();784 uid = protobufRecord.asUnsignedVarInt().intValue(); 783 785 break; 784 786 case 5: 785 userSid = record.asUnsignedVarInt().intValue();787 userSid = protobufRecord.asUnsignedVarInt().intValue(); 786 788 break; 787 789 case 6: 788 visible = record.asUnsignedVarInt().byteValue() == 0;790 visible = protobufRecord.asUnsignedVarInt().byteValue() == 0; 789 791 break; 790 792 default: // Fall through, since the PBF format could be extended … … 897 899 */ 898 900 @Nonnull 899 private Info[] parseDenseInfo(ByteArrayOutputStream baos, byte[] bytes) throws IllegalDataException, IOException { 901 private static Info[] parseDenseInfo(ByteArrayOutputStream baos, byte[] bytes) throws IllegalDataException, IOException { 900 902 long[] version = EMPTY_LONG; // technically ints 901 903 long[] timestamp = EMPTY_LONG;
Note:
See TracChangeset
for help on using the changeset viewer.