Commit 1b74639
committed
Refactor:maptool:Replace hand-written OSM parsers with libosmium
maptool has four hand-written OSM input parsers: osm_xml.c, osm_o5m.c,
osm_protobuf.c and osm_protobufdb.c. osm_xml.c scans XML line by line.
The two protobuf parsers use generated protobuf-c code. All four parsers
call the same eight osm_add_* and osm_end_* callbacks in osm.c.
This change replaces the four parsers with one libosmium handler in
osm_libosmium.cpp. The handler calls the same callbacks. The code after
the parse stage does not change: item_bin, the tiles and the zip
assembly stay the same. The change deletes about 2000 lines and adds
about 180 lines.
Reasons for the change:
- The build no longer needs protobuf-c. This change also deletes the
generated .pb-c sources, osmformat.proto and fileformat.proto.
- maptool detects the input format from the file name. A plain -i reads
.osm, .osm.gz, .osm.bz2, .pbf and .o5m files. Compressed XML no longer
needs an external bzcat pipeline.
- libosmium decodes PBF data with more than one thread. maptool parses
France in 280 s. The old parser needed 354 s. These values are the
medians of three runs.
- The old XML parser needed one element for each line. If a valid OSM
file contained an empty line, the parser stopped with a fatal error.
libosmium reads these files.
- maptool now reports progress during a PBF parse. osm_protobuf.c never
armed the progress alarm, so phase 1 was silent for minutes on a large
extract.
- One parser is easier to maintain than four.
Changes in behavior:
- The options -P and -M are now format hints for standard input only.
With -i, maptool detects the format from the file name.
- This change removes the undocumented options -B and -O. These options
only used osm_protobufdb.c, which has no replacement.
- maptool now needs a C++14 compiler. DISABLE_CXX therefore has no
effect if BUILD_MAPTOOL is on. All C++ code is in one file behind a C
interface.
- The old build excluded PBF on MSVC. libosmium supports MSVC, so this
restriction is gone.
- osm_psql.c (-d, HAVE_POSTGRESQL) does not change. libosmium has no
PostgreSQL reader.
Dependencies:
libosmium and protozero contain only headers. The build prefers the
system copies, libosmium2-dev and libprotozero-dev. The build downloads
them only if they are absent. Distribution builds and offline builds
therefore do not need the network. This change deletes
cmake/FindPROTOBUF_C.cmake. It also updates the dependency lists in
docs/development/targets, in scripts and in
CPACK_DEBIAN_PACKAGE_DEPENDS.
Verification:
A comparison of the maps byte by byte does not work. The threaded phases
of maptool put the items of a tile in a variable order. Two runs of the
same binary give maps that differ by some hundred bytes.
The comparison therefore ignores the order. Each tile becomes a multiset
of item type, coordinates and sorted attributes. The comparison includes
every per-phase counter.
- Geofabrik France, 5.05 GB. The input has 524,532,569 nodes,
73,128,562 ways and 1,098,637 relations. The map has 3.47 GB. All
114,981 members are identical. All counters are identical. Both maps
index the same five countries.
- BBBike Denver metro, 1.4 million split ways. All 330 members are
identical.
- Liechtenstein PBF and an Overpass XML extract. All members are
identical.
These input paths also give correct results: XML with -i, XML from
standard input, PBF with -i, PBF from standard input, .osm.gz with -i,
.osm.bz2 with -i, and bzcat into standard input.
Real o5m data is not tested. No o5m file and no converter were
available. The o5m reader starts and rejects a bad header correctly.1 parent 9f7ed95 commit 1b74639
20 files changed
Lines changed: 265 additions & 2005 deletions
File tree
- cmake
- docs
- development/targets
- user/configuration/maps
- man
- scripts
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
746 | 746 | | |
747 | 747 | | |
748 | 748 | | |
749 | | - | |
750 | | - | |
751 | | - | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | 749 | | |
756 | 750 | | |
757 | 751 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
| 21 | + | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
| 36 | + | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 10 | + | |
16 | 11 | | |
17 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
| |||
43 | 52 | | |
44 | 53 | | |
45 | 54 | | |
46 | | - | |
| 55 | + | |
| 56 | + | |
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
50 | 60 | | |
51 | 61 | | |
52 | | - | |
| 62 | + | |
| 63 | + | |
53 | 64 | | |
54 | 65 | | |
55 | 66 | | |
| |||
58 | 69 | | |
59 | 70 | | |
60 | 71 | | |
61 | | - | |
| 72 | + | |
| 73 | + | |
62 | 74 | | |
63 | 75 | | |
64 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
7 | 31 | | |
8 | 32 | | |
9 | 33 | | |
10 | 34 | | |
11 | 35 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
22 | 40 | | |
23 | 41 | | |
24 | 42 | | |
| |||
This file was deleted.
0 commit comments