Modify

Opened 5 weeks ago

Closed 5 weeks ago

Last modified 5 weeks ago

#23599 closed defect (fixed)

Error opening osm.pbf if way has negative ID or incomplete metadata

Reported by: *Martin* Owned by: GerdP
Priority: normal Milestone: 24.03
Component: Core Version: latest
Keywords: pbf Cc:

Description

If a way in osm.pbf has negative ID then JOSM shows misleading error message "A primitive with ID = 0 cannot be invisible."

I think the problem is at https://github.com/JOSM/josm/blob/3c8e28b1d30cddae371d607b27f64fa9db13b808/src/org/openstreetmap/josm/io/OsmPbfReader.java#L798 where the value should be compared if it is equal to 1 and not to 0.

Attachments (6)

23599.osm.pbf (385 bytes ) - added by taylor.smock 5 weeks ago.
test.osm.pbf (306 bytes ) - added by GerdP 5 weeks ago.
This file was created with osmconvert command osmconvert64.exe test.osm -o=test.osm.pbf No idea if it is correct or not
test.osm (429 bytes ) - added by GerdP 5 weeks ago.
original file created by JOSM
23599.osm (635 bytes ) - added by taylor.smock 5 weeks ago.
xxx1.osm.pbf (567 bytes ) - added by *Martin* 5 weeks ago.
sample file created with https://github.com/navigatorsguild/osm-io
23599.patch (3.3 KB ) - added by GerdP 5 weeks ago.

Download all attachments as: .zip

Change History (20)

comment:1 by taylor.smock, 5 weeks ago

Owner: changed from team to *Martin*
Status: newneedinfo

I was unable to reproduce with attachment:23599.osm.pbf (which has negative nodes, ways, and relations).


Thanks for your report, however your ticket is incomplete and therefore not helpful in its current form.

Please add all needed information according to this list:

  • The required parts of the Status Report from your JOSM.
  • Describe what behaviour you expected.
  • Describe what did happen instead.
  • Describe if and how the issue is reproducible.
  • Add any relevant information like error messages or screenshots.

To ensure that all technical relevant information is contained, create new tickets by clicking in JOSMs Main Menu on Helpsource:trunk/resources/images/bug.svg Report Bug.


by taylor.smock, 5 weeks ago

Attachment: 23599.osm.pbf added

comment:2 by taylor.smock, 5 weeks ago

To add on, I suspect the primitive has a negative id and is deleted.

A small sample file would be appreciated.

Also, please check with josm-latest. r19024 made some changes to PBF parsing.

by GerdP, 5 weeks ago

Attachment: test.osm.pbf added

This file was created with osmconvert command osmconvert64.exe test.osm -o=test.osm.pbf No idea if it is correct or not

comment:3 by GerdP, 5 weeks ago

Error message is "Cannot assign a changeset id > 0 to a new primitive. Value of changesetId is 1"

comment:4 by GerdP, 5 weeks ago

You can also try the commands

osmconvert64 test.osm --drop-version -o=test.osm.pbf
osmconvert64 test.osm --drop-author -o=test.osm.pbf

Each output gives a different error message in JOSM. I think the pbf plugin was a bit more tolerant regarding incomplete meta info.

by GerdP, 5 weeks ago

Attachment: test.osm added

original file created by JOSM

comment:5 by taylor.smock, 5 weeks ago

Hrm. attachment:test.osm is very similar to my test data, only I had a few more primitives. I did try with both visible='true' and visible='false' versions to see if that made a difference.

I think the pbf plugin was a bit more tolerant regarding incomplete meta info.

Probably.

by taylor.smock, 5 weeks ago

Attachment: 23599.osm added

comment:6 by taylor.smock, 5 weeks ago

OK. I know why I wasn't able to reproduce with my test data now. osmium does something different from osmconvert64.

comment:7 by GerdP, 5 weeks ago

FYI: The tool splitter from https://www.mkgmap.org.uk/download/mkgmap.html
also writes incomplete meta data. Normal input are the downloads from geofabrik.

comment:8 by taylor.smock, 5 weeks ago

Good to know.

I'll try to remember to take a look once I fix the codesigning for mac problem I introduced in r19030.

by *Martin*, 5 weeks ago

Attachment: xxx1.osm.pbf added

comment:9 by *Martin*, 5 weeks ago

Note that osmium cat xxx1.osm.pbf -o xxx1.osm converts the file successfully and the result can be then opened in JOSM.

I can also open the original xxx1.osm.pbf if I change the line to visible = protobufRecord.asUnsignedVarInt().byteValue() == 1;.

comment:10 by GerdP, 5 weeks ago

Yes, that change seems to be OK.
BTW: If you rename the file to e.g. xxx1.osm_.pbf JOSM will use the pbf plugin (if installed) to read the file and that plugin accepts it.

by GerdP, 5 weeks ago

Attachment: 23599.patch added

comment:11 by GerdP, 5 weeks ago

The patch fixes

  • handling of visible flag as proposed by *Martin*
  • handling of completely missing denseinfo (ids are always delta encoded)
  • handling of denseinfo which only contains version data

Not sure what to do with the line

        throw new IllegalDataException("OSM PBF has mismatched DenseInfo lengths");

TODO: add unit tests

comment:12 by GerdP, 5 weeks ago

Owner: changed from *Martin* to GerdP
Status: needinfoassigned

comment:13 by GerdP, 5 weeks ago

Resolution: fixed
Status: assignedclosed

In 19033/josm:

fix #23599: Error opening osm.pbf if way has negative ID or incomplete metadata
This fixes

  • handling of visible flag as proposed by *Martin*
  • handling of completely missing denseinfo (ids are always delta encoded), upload is discouraged
  • handling of denseinfo which only contains version data

comment:14 by GerdP, 5 weeks ago

Milestone: 24.03
Summary: Error opening osm.pbf if way has negative IDError opening osm.pbf if way has negative ID or incomplete metadata

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain GerdP.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.