#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)
Change History (20)
comment:1 by , 8 months ago
Owner: | changed from | to
---|---|
Status: | new → needinfo |
by , 8 months ago
Attachment: | 23599.osm.pbf added |
---|
comment:2 by , 8 months 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 , 8 months 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 , 8 months ago
Error message is "Cannot assign a changeset id > 0 to a new primitive. Value of changesetId is 1"
comment:4 by , 8 months 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.
comment:5 by , 8 months 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 , 8 months ago
comment:6 by , 8 months 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 , 8 months 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 , 8 months 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 , 8 months ago
Attachment: | xxx1.osm.pbf added |
---|
sample file created with https://github.com/navigatorsguild/osm-io
comment:9 by , 8 months 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 , 8 months 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 , 8 months ago
Attachment: | 23599.patch added |
---|
comment:11 by , 8 months 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 , 8 months ago
Owner: | changed from | to
---|---|
Status: | needinfo → assigned |
comment:14 by , 8 months ago
Milestone: | → 24.03 |
---|---|
Summary: | Error opening osm.pbf if way has negative ID → Error opening osm.pbf if way has negative ID or incomplete metadata |
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:
To ensure that all technical relevant information is contained, create new tickets by clicking in JOSMs Main Menu on Help → Report Bug.
Remember: This is a generic notice so we don't need to write the same stuff again and again. It may only apply in parts to the specific case!