Modify

Opened 5 weeks ago

Closed 3 weeks ago

#19165 closed defect (fixed)

pbf plugin removes empty relations when saving to file

Reported by: GerdP Owned by: Don-vip
Priority: normal Milestone:
Component: Plugin pbf Version:
Keywords: template_report Cc:

Description

What steps will reproduce the problem?

  1. Have a relation without members
  2. Save as xyz.osm.pbf
  3. Save as xyz.osm (xml format)
  4. Load both files

What is the expected result?

Loaded content should be equal

What happens instead?

The pbf data doesn't contain the empty relation.

Please provide any additional information below. Attach a screenshot if possible.

Noticed this while working on #19136.
When I use osmconvert to convert the osm xml file to osm.pbf and load that file with JOSM the empty relation is shown.

URL:https://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2020-04-06 02:17:07 +0200 (Mon, 06 Apr 2020)
Build-Date:2020-04-06 00:18:43
Revision:16239
Relative:URL: ^/trunk

Identification: JOSM/1.5 (16239 en) Windows 10 64-Bit
OS Build number: Windows 10 Home 1903 (18362)
Memory Usage: 811 MB / 1820 MB (612 MB allocated, but free)
Java version: 1.8.0_221-b11, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
Screen: \Display0 1920x1080
Maximum Screen Size: 1920x1080
VM arguments: [-XX:StartFlightRecording=name=MyRecording2,settings=d:\dbg\gerd.jfc, -XX:FlightRecorderOptions=defaultrecording=true,dumponexit=true,dumponexitpath=e:\ld\perf_20200428_140336.jfr]

Plugins:
+ OpeningHoursEditor (35414)
+ PolygonCutOut (v0.7)
+ apache-commons (35362)
+ buildings_tools (35405)
+ continuosDownload (91)
+ ejml (35313)
+ geotools (35169)
+ jaxb (35092)
+ jts (35122)
+ merge-overlap (35248)
+ o5m (35248)
+ opendata (35405)
+ pbf (35248)
+ poly (35248)
+ reverter (35409)
+ undelete (35405)
+ utilsplugin2 (35405)

Attachments (2)

19165.patch (1.6 KB) - added by GerdP 5 weeks ago.
19165.2.patch (1.2 KB) - added by GerdP 5 weeks ago.
OK, found out that OsmWriter is also used to write changesets, so it must write deleted objects. We must not write a deleted object to pbf because the status deleted is lost. So, isUsable() should be the right choice for pbf.

Download all attachments as: .zip

Change History (6)

comment:1 Changed 5 weeks ago by stoecker

Our importer strips invalid geometries. That's also the case when you load empty ways in XML format.

It probably should not do this silent, but the act itself is correct.

comment:2 Changed 5 weeks ago by GerdP

It's mot the importer, it's the exporter. Seems I coded this for #11169.

comment:3 Changed 5 weeks ago by GerdP

With the attached patch JOSM should write almost the same data to osm.pbf as to .osm.
AFAIK the pbf format still doesn't allow more than one bounds. The tool osmconvert simply calculates one bounds area which contains all data. The pbf plugin writes only the first. Maybe it should not write any bounds when there is more than one.
The pbf format also doesn't allow to store attributes like modified.
BTW: I wonder if anybody understands the filter that is used here:

private static boolean shouldWrite(OsmPrimitive osm) {
  return (!osm.isNewOrUndeleted() || !osm.isDeleted()) && !osm.isIncomplete();
}

I found similar logic in OsmWriter, but I have no idea why osm.isUsable() isn't enough.

Changed 5 weeks ago by GerdP

Attachment: 19165.patch added

Changed 5 weeks ago by GerdP

Attachment: 19165.2.patch added

OK, found out that OsmWriter is also used to write changesets, so it must write deleted objects. We must not write a deleted object to pbf because the status deleted is lost. So, isUsable() should be the right choice for pbf.

comment:4 Changed 3 weeks ago by GerdP

Resolution: fixed
Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Don-vip.
as The resolution will be set.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.