Codebase list osmium-tool / b1cbd63
Merge tag 'debian/1.10.0-1' into stretch-backports Bas Couwenberg 5 years ago
97 changed file(s) with 1219 addition(s) and 444 deletion(s). Raw diff Collapse all Expand all
55
66 language: generic
77
8 sudo: false
8 dist: xenial
99
10 dist: trusty
10 #-----------------------------------------------------------------------------
11
12 # Save common build configurations as shortcuts, so we can reference them later.
13 addons_shortcuts:
14 addons_clang35: &clang35
15 apt:
16 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
17 packages: ['libboost1.55-all-dev', 'libboost-program-options1.55-dev', 'pandoc', 'clang-3.5']
18 addons_clang38: &clang38
19 apt:
20 packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'clang-3.8']
21 addons_clang39: &clang39
22 apt:
23 packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'clang-3.9']
24 addons_clang50: &clang50
25 apt:
26 sources: ['ubuntu-toolchain-r-test']
27 packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'clang-5.0']
28 addons_clang60: &clang60
29 apt:
30 sources: ['ubuntu-toolchain-r-test']
31 packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'clang-6.0']
32 addons_gcc48: &gcc48
33 apt:
34 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
35 packages: ['libboost1.55-all-dev', 'libboost-program-options1.55-dev', 'pandoc', 'g++-4.8', 'gcc-4.8']
36 addons_gcc49: &gcc49
37 apt:
38 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
39 packages: ['libboost1.55-all-dev', 'libboost-program-options1.55-dev', 'pandoc', 'g++-4.9', 'gcc-4.9']
40 addons_gcc5: &gcc5
41 apt:
42 packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'g++-5', 'gcc-5']
43 addons_gcc6: &gcc6
44 apt:
45 sources: ['ubuntu-toolchain-r-test']
46 packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'g++-6', 'gcc-6']
47 addons_gcc7: &gcc7
48 apt:
49 sources: ['ubuntu-toolchain-r-test']
50 packages: ['libboost-all-dev', 'libboost-program-options-dev', 'pandoc', 'g++-7', 'gcc-7']
1151
1252 #-----------------------------------------------------------------------------
1353
1454 matrix:
1555 include:
1656
17 # 1/ Linux Clang Builds
18 - os: linux
19 compiler: linux-clang35-release
20 addons:
21 apt:
22 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
23 packages: ['clang-3.5', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
24 env: CC='clang-3.5' CXX='clang++-3.5' BUILD_TYPE='Release'
57 # Linux Clang Builds
2558
2659 - os: linux
2760 compiler: linux-clang35-dev
28 addons:
29 apt:
30 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
31 packages: ['clang-3.5', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
61 addons: *clang35
3262 env: CC='clang-3.5' CXX='clang++-3.5' BUILD_TYPE='Dev'
33
34
35 - os: linux
36 compiler: linux-clang38-release
37 addons:
38 apt:
39 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
40 packages: ['clang-3.8', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
41 env: CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Release'
63 dist: trusty
4264
4365 - os: linux
4466 compiler: linux-clang38-dev
45 addons:
46 apt:
47 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
48 packages: ['clang-3.8', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
67 addons: *clang38
4968 env: CC='clang-3.8' CXX='clang++-3.8' BUILD_TYPE='Dev'
50
51
52 - os: linux
53 compiler: linux-clang39-release
54 addons:
55 apt:
56 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
57 packages: ['clang-3.9', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
58 env: CC='clang-3.9' CXX='clang++-3.9' BUILD_TYPE='Release'
5969
6070 - os: linux
6171 compiler: linux-clang39-dev
62 addons:
63 apt:
64 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
65 packages: ['clang-3.9', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
72 addons: *clang39
6673 env: CC='clang-3.9' CXX='clang++-3.9' BUILD_TYPE='Dev'
67
68
69 - os: linux
70 compiler: linux-clang40-release
71 addons:
72 apt:
73 sources: ['llvm-toolchain-trusty-4.0', 'ubuntu-toolchain-r-test', 'boost-latest']
74 packages: ['clang-4.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
75 env: CC='clang-4.0' CXX='clang++-4.0' BUILD_TYPE='Release'
76
77 - os: linux
78 compiler: linux-clang40-dev
79 addons:
80 apt:
81 sources: ['llvm-toolchain-trusty-4.0', 'ubuntu-toolchain-r-test', 'boost-latest']
82 packages: ['clang-4.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
83 env: CC='clang-4.0' CXX='clang++-4.0' BUILD_TYPE='Dev'
84
85
86 - os: linux
87 compiler: linux-clang50-release
88 addons:
89 apt:
90 sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test', 'boost-latest']
91 packages: ['clang-5.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
92 env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Release'
9374
9475 - os: linux
9576 compiler: linux-clang50-dev
96 addons:
97 apt:
98 sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test', 'boost-latest']
99 packages: ['clang-5.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
77 addons: *clang50
10078 env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Dev'
10179
102 # Disabled because it creates false-positives on the old travis systems
103 # - os: linux
104 # compiler: linux-clang50-debug
105 # addons:
106 # apt:
107 # sources: ['llvm-toolchain-trusty-5.0', 'ubuntu-toolchain-r-test', 'boost-latest']
108 # packages: ['clang-5.0', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc', 'g++-6', 'gcc-6']
109 # env: CC='clang-5.0' CXX='clang++-5.0' BUILD_TYPE='Debug'
80 - os: linux
81 compiler: linux-clang60-dev
82 addons: *clang60
83 env: CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='Dev'
84
85 # Disabled, because it is triggered by the rapidjson library
86 # - os: linux
87 # compiler: linux-clang60-debug
88 # addons: *clang60
89 # env: CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='Debug'
11090 # CXXFLAGS="-fsanitize=address,undefined,integer -fno-sanitize-recover=all -fno-omit-frame-pointer"
11191 # LDFLAGS="-fsanitize=address,undefined,integer"
112 # # LSAN doesn't work on container-based system
113 # sudo: required
92
93 - os: linux
94 compiler: linux-clang60-release
95 addons: *clang60
96 env: CC='clang-6.0' CXX='clang++-6.0' BUILD_TYPE='Release'
11497
11598
116 # 2/ Linux GCC Builds
117 - os: linux
118 compiler: linux-gcc48-release
119 addons:
120 apt:
121 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
122 packages: ['g++-4.8', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
123 env: CC='gcc-4.8' CXX='g++-4.8' CXXFLAGS='-Wno-return-type' BUILD_TYPE='Release'
99 # Linux GCC Builds
124100
125101 - os: linux
126102 compiler: linux-gcc48-dev
127 addons:
128 apt:
129 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
130 packages: ['g++-4.8', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
103 addons: *gcc48
131104 env: CC='gcc-4.8' CXX='g++-4.8' CXXFLAGS='-Wno-return-type' BUILD_TYPE='Dev'
132
133
134 - os: linux
135 compiler: linux-gcc49-release
136 addons:
137 apt:
138 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
139 packages: ['g++-4.9', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
140 env: CC='gcc-4.9' CXX='g++-4.9' BUILD_TYPE='Release'
105 dist: trusty
141106
142107 - os: linux
143108 compiler: linux-gcc49-dev
144 addons:
145 apt:
146 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
147 packages: ['g++-4.9', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
109 addons: *gcc49
148110 env: CC='gcc-4.9' CXX='g++-4.9' BUILD_TYPE='Dev'
149
150
151 - os: linux
152 compiler: linux-gcc5-release
153 addons:
154 apt:
155 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
156 packages: ['g++-5', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
157 env: CC='gcc-5' CXX='g++-5' BUILD_TYPE='Release'
111 dist: trusty
158112
159113 - os: linux
160114 compiler: linux-gcc5-dev
161 addons:
162 apt:
163 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
164 packages: ['g++-5', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
115 addons: *gcc5
165116 env: CC='gcc-5' CXX='g++-5' BUILD_TYPE='Dev'
166
167
168 - os: linux
169 compiler: linux-gcc6-release
170 addons:
171 apt:
172 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
173 packages: ['g++-6', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
174 env: CC='gcc-6' CXX='g++-6' BUILD_TYPE='Release'
175117
176118 - os: linux
177119 compiler: linux-gcc6-dev
178 addons:
179 apt:
180 sources: ['ubuntu-toolchain-r-test', 'boost-latest']
181 packages: ['g++-6', 'libboost1.55-dev', 'libboost-program-options1.55-dev', 'pandoc']
120 addons: *gcc6
182121 env: CC='gcc-6' CXX='g++-6' BUILD_TYPE='Dev'
183122
123 - os: linux
124 compiler: linux-gcc7-dev
125 addons: *gcc7
126 env: CC='gcc-7' CXX='g++-7' BUILD_TYPE='Dev'
184127
185 # 3/ OSX Clang Builds
186 - os: osx
187 osx_image: xcode6.4
188 compiler: xcode64-clang-release
189 env: CXX='clang++' BUILD_TYPE='Release'
190
191 - os: osx
192 osx_image: xcode6.4
193 compiler: xcode64-clang-dev
194 env: CXX='clang++' BUILD_TYPE='Dev'
128 - os: linux
129 compiler: linux-gcc7-release
130 addons: *gcc7
131 env: CC='gcc-7' CXX='g++-7' BUILD_TYPE='Release'
195132
196133
197 - os: osx
198 osx_image: xcode7
199 compiler: xcode7-clang-release
200 env: CXX='clang++' BUILD_TYPE='Release'
201
202 - os: osx
203 osx_image: xcode7
204 compiler: xcode7-clang-dev
205 env: CXX='clang++' BUILD_TYPE='Dev'
206
207
208 - os: osx
209 osx_image: xcode8.3
210 compiler: xcode8-clang-release
211 env: CXX='clang++' BUILD_TYPE='Release'
134 # OSX Clang Builds
212135
213136 - os: osx
214137 osx_image: xcode8.3
215138 compiler: xcode8-clang-dev
139 env: CXX='clang++' BUILD_TYPE='Dev'
140
141 - os: osx
142 osx_image: xcode9.4
143 compiler: xcode9-clang-dev
144 env: CXX='clang++' BUILD_TYPE='Dev'
145
146 - os: osx
147 osx_image: xcode10.1
148 compiler: xcode10-clang-release
149 env: CXX='clang++' BUILD_TYPE='Release'
150
151 - os: osx
152 osx_image: xcode10.1
153 compiler: xcode10-clang-dev
216154 env: CXX='clang++' BUILD_TYPE='Dev'
217155
218156 #-----------------------------------------------------------------------------
1010 ### Changed
1111
1212 ### Fixed
13
14
15 ## [1.10.0] - 2018-12-10
16
17 ### Added
18
19 * The `fileinfo` command now has an `--object-type`/`-t` option like some
20 other commands.
21 * Extended `fileinfo` command to show internal buffer counts and sizes.
22 * Add `--strategy` option to `sort` command. New `multipass` strategy which
23 reads the input file(s) three times making the sort a bit slower, but also
24 using less memory.
25 * New option `--remove-tags`/`-t` to `tags-filter` command. When used the
26 tags of all objects that are not matching the filter expression but are
27 included as references are removed.
28 * New option for smart extract strategy: `complete-partial-relations=X` will
29 complete all relations with at least X percent of their members already in
30 the extract.
31 * New export format "pg" creates a file in the PostgreSQL COPY text format
32 with the GEOMETRY as WKB and the tags in JSON(B) format. This can be
33 imported into a PostgreSQL/PostGIS database very quickly.
34
35 ### Changed
36
37 * Show better error message if output directory is missing for `extract`
38 command.
39
40 ### Fixed
41
42 * Several fixes for the `tags-filter` command which could lead to wrong
43 results.
1344
1445
1546 ## [1.9.1] - 2018-08-18
443474 - Minor updates to documentation and build system
444475
445476
446 [unreleased]: https://github.com/osmcode/osmium-tool/compare/v1.9.1...HEAD
477 [unreleased]: https://github.com/osmcode/osmium-tool/compare/v1.10.0...HEAD
478 [1.10.0]: https://github.com/osmcode/osmium-tool/compare/v1.9.1...v1.10.0
447479 [1.9.1]: https://github.com/osmcode/osmium-tool/compare/v1.9.0...v1.9.1
448480 [1.9.0]: https://github.com/osmcode/osmium-tool/compare/v1.8.0...v1.9.0
449481 [1.8.0]: https://github.com/osmcode/osmium-tool/compare/v1.7.1...v1.8.0
2424 project(osmium)
2525
2626 set(OSMIUM_VERSION_MAJOR 1)
27 set(OSMIUM_VERSION_MINOR 9)
28 set(OSMIUM_VERSION_PATCH 1)
27 set(OSMIUM_VERSION_MINOR 10)
28 set(OSMIUM_VERSION_PATCH 0)
2929
3030 set(OSMIUM_VERSION ${OSMIUM_VERSION_MAJOR}.${OSMIUM_VERSION_MINOR}.${OSMIUM_VERSION_PATCH})
3131
4343 find_package(Boost 1.55.0 REQUIRED COMPONENTS program_options)
4444 include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
4545
46 find_package(Osmium 2.14.2 REQUIRED COMPONENTS io)
46 find_package(Osmium 2.15.0 REQUIRED COMPONENTS io)
4747 include_directories(SYSTEM ${OSMIUM_INCLUDE_DIRS})
4848
4949
230230 util.cpp
231231 command_help.cpp
232232 export/export_format_json.cpp
233 export/export_format_pg.cpp
233234 export/export_format_text.cpp
234235 export/export_handler.cpp
235236 extract/extract_bbox.cpp
1515
1616 You also need the following libraries:
1717
18 Libosmium (>= 2.14.2)
18 Libosmium (>= 2.15.0)
1919 https://osmcode.org/libosmium
2020 Debian/Ubuntu: libosmium2-dev
2121 Fedora/CentOS: libosmium-devel
107107 Please read the CMake documentation and get familiar with the `cmake` and
108108 `ccmake` tools which have many more options.
109109
110 On Windows you can compile with the Visual Studio C++ compiler using the
111 batch script `build-local.bat`. This script calls `build-appveyor.bat`
112 which downloads some precompiled libraries. You can also download and
113 compile all the prerequisites yourself.
110 On Windows you can compile with the Visual Studio C++ compiler and nmake.
111 The necessary dependencies can be installed with [conda](https://conda.io).
112 See `appveyor.yml` for the necessary commands to compile osmium-tool.
114113
115114
116115 ## Documentation
7070
7171 # Check libosmium version number
7272 if(Osmium_FIND_VERSION)
73 if(NOT EXISTS "${OSMIUM_INCLUDE_DIR}/osmium/version.hpp")
74 message(FATAL_ERROR "Missing ${OSMIUM_INCLUDE_DIR}/osmium/version.hpp. Either your libosmium version is too old, or libosmium wasn't found in the place you said.")
75 endif()
7376 file(STRINGS "${OSMIUM_INCLUDE_DIR}/osmium/version.hpp" _libosmium_version_define REGEX "#define LIBOSMIUM_VERSION_STRING")
7477 if("${_libosmium_version_define}" MATCHES "#define LIBOSMIUM_VERSION_STRING \"([0-9.]+)\"")
7578 set(_libosmium_version "${CMAKE_MATCH_1}")
0 osmium-tool (1.10.0-1) unstable; urgency=medium
1
2 * New upstream release.
3 * Drop patches, included upstream.
4
5 -- Bas Couwenberg <sebastic@debian.org> Mon, 10 Dec 2018 16:54:26 +0100
6
7 osmium-tool (1.9.1-2) unstable; urgency=medium
8
9 * Bump Standards-Version to 4.2.1, no changes.
10 * Add upstream patches to fix FTBFS with libosmium 2.15.0.
11 (closes: #916109)
12 * Bump minimum required libosmium2-dev to 2.15.0.
13
14 -- Bas Couwenberg <sebastic@debian.org> Mon, 10 Dec 2018 12:20:36 +0100
15
016 osmium-tool (1.9.1-1~bpo9+1) stretch-backports; urgency=medium
117
218 * Rebuild for stretch-backports.
88 libboost-program-options-dev,
99 libbz2-dev,
1010 libexpat1-dev,
11 libosmium2-dev (>= 2.14.2),
11 libosmium2-dev (>= 2.15.0),
1212 pandoc,
1313 zlib1g-dev
14 Standards-Version: 4.2.0
14 Standards-Version: 4.2.1
1515 Vcs-Browser: https://salsa.debian.org/debian-gis-team/osmium-tool/
1616 Vcs-Git: https://salsa.debian.org/debian-gis-team/osmium-tool.git -b stretch-backports
1717 Homepage: https://osmcode.org/osmium-tool/
00 {
1 "directory": "/tmp/",
1 "directory": "/tmp/foobar",
22 "extracts": [
33 {
44 "output": "dresden.osm.pbf",
286286 * `geojsonseq` (alias: `jsonseq`): GeoJSON Text Sequence (RFC8142). Each line
287287 (beginning with a RS (0x1e, record separator) and ending in a linefeed
288288 character) contains one GeoJSON object. Used for streaming GeoJSON.
289 * `pg`: PostgreSQL COPY text format. One line per object containing the
290 WGS84 geometry as WKB, the tags in JSON format and, optionally, more columns
291 for id and attributes. You have to create the table manually, then use the
292 PostgreSQL COPY command to import the data. Enable verbose output to see
293 the SQL commands needed to create the table and load the data.
289294 * `text` (alias: `txt`): A simple text format with the geometry in WKT format
290295 followed by the comma-delimited tags. This is mainly intended for debugging
291296 at the moment. THE FORMAT MIGHT CHANGE WITHOUT NOTICE!
328328 relations can be huge, so if you include them, be aware your result might be
329329 huge.
330330
331 The **smart** strategy allows another option "-S complete-partial-relations=X".
332 If this is set, all relations that have more than X percent of their members
333 already in the extract will have their full set of members in the extract. So
334 this allows completing almost complete relations. It can be useful for instance
335 to make sure a boundary relation is complete even if some of it is outside the
336 polygon used for extraction.
337
331338
332339 # DIAGNOSTICS
333340
351358 extracts times the highest node ID used divided by 8. For the *complete_ways*
352359 twice that and for the *smart* strategy a bit more.
353360
361 If you want to split a large file into many extracts, do this in several
362 steps. First create several larger extracts and then split them again and
363 again into smaller pieces.
364
354365
355366 # EXAMPLES
356367
7171 -j, --json
7272 : Output in JSON format. Can not be used together with --get.
7373
74 -t, --object-type=TYPE
75 : Read only objects of given type (*node*, *way*, *relation*, *changeset*).
76 By default all types are read. This option can be given multiple times.
77 This only takes effect if the **--extended** option is also used.
78
7479 @MAN_COMMON_OPTIONS@
7580 @MAN_PROGRESS_OPTIONS@
7681 @MAN_INPUT_OPTIONS@
110115 data.maxid.ways - INTEGER
111116 data.maxid.relations - INTEGER
112117 data.maxid.changesets - INTEGER
118 data.buffers.count - INTEGER
119 data.buffers.size - INTEGER
120 data.buffers.capcity - INTEGER
113121 metadata.all_objects.version - BOOL (yes|no)
114122 metadata.all_objects.timestamp - BOOL (yes|no)
115123 metadata.all_objects.changeset - BOOL (yes|no)
2828
2929 This commands reads its input file(s) only once and writes its output file
3030 in one go so it can be streamed, ie. it can read from STDIN and write to
31 STDOUT.
31 STDOUT. (Unless the *multipass* strategy is used.)
32
33 # OPTIONS
34
35 -s, --strategy=STRATEGY
36 : Sorting strategy. The "simple" strategy reads all input files into memory,
37 does the sorting and writes everything out. The "multipass" strategy reads
38 the input files in three passes, one for nodes, one for ways, and one for
39 relations. After reading all objects of each type, they are sorted and
40 written out. This is a bit slower than the "simple" strategy, but uses
41 less memory. The "multi" strategy doesn't work when reading from STDIN.
42 Default: "simple".
3243
3344
3445 @MAN_COMMON_OPTIONS@
3434
3535 -e FILE, --expressions=FILE
3636 : Read expressions from the specified file, one per line. Empty lines are
37 ignored. Everything after the comment character (#) is also ignored. The
37 ignored. Everything after the comment character (#) is also ignored. See
3838 the **FILTER EXPRESSIONS** section for further details.
3939
4040 -i, --invert-match
4343 -R, --omit-referenced
4444 : Omit the nodes referenced from matching ways and members referenced from
4545 matching relations.
46
47 -t, --remove-tags
48 : Remove tags from objects that are not matching the filter expression but
49 are included to complete references (nodes in ways and members of
50 relations). If an object is both matching the filter and used as a
51 reference it will keep its tags.
4652
4753 @MAN_COMMON_OPTIONS@
4854 @MAN_PROGRESS_OPTIONS@
2020 : Allow an existing output file to be overwritten. Normally **osmium** will
2121 refuse to write over an existing file.
2222
23 --output-header=OPTION
24 : Add output header option. This option can be given several times. See the
25 *libosmium manual* for a list of allowed header options.
23 --output-header=OPTION=VALUE
24 : Add output header option. This command line option can be used multiple
25 times for different OPTIONs. See the *libosmium manual* for a list of
26 available header options.
2929 #include <cstdlib>
3030 #include <iostream>
3131
32 po::options_description Command::add_common_options(bool with_progress) {
33 po::options_description options("COMMON OPTIONS");
32 po::options_description Command::add_common_options(const bool with_progress) {
33 po::options_description options{"COMMON OPTIONS"};
3434
3535 auto opts = options.add_options()
3636 ("help,h", "Show usage help")
8686 } else if (t == "c" || t == "changeset") {
8787 m_osm_entity_bits |= osmium::osm_entity_bits::changeset;
8888 } else {
89 throw argument_error{std::string{"Unknown object type '"} + t + "' (Allowed are 'node', 'way', 'relation', and 'changeset')."};
89 throw argument_error{std::string{"Unknown object type '"}
90 + t
91 + "' (Allowed are 'node', 'way', 'relation', and 'changeset')."};
9092 }
9193 }
9294 } else {
2323 */
2424
2525 #include <osmium/io/file.hpp>
26 #include <osmium/io/header.hpp>
2627 #include <osmium/io/writer_options.hpp>
2728 #include <osmium/osm/entity_bits.hpp>
2829 #include <osmium/util/file.hpp>
4041 const char* get_osmium_version() noexcept;
4142 const char* get_osmium_long_version() noexcept;
4243 const char* get_libosmium_version() noexcept;
43
44 namespace osmium {
45
46 namespace io {
47 class Header;
48 } // namespace io
49
50 } // namespace osmium
5144
5245 class CommandFactory;
5346
2626
2727 #include <osmium/handler/node_locations_for_ways.hpp>
2828 #include <osmium/index/map/all.hpp>
29
30 namespace osmium {
31
32 namespace io {
33 class Reader;
34 class Writer;
35 } // namespace io
36
37 class ProgressBar;
38
39 } // namespace osmium
29 #include <osmium/io/reader.hpp>
30 #include <osmium/io/writer.hpp>
31 #include <osmium/util/progress_bar.hpp>
4032
4133 #include <string>
4234 #include <vector>
4638
4739 class CommandAddLocationsToWays : public Command, public with_multiple_osm_inputs, public with_osm_output {
4840
49 void copy_data(osmium::ProgressBar& progress_bar, osmium::io::Reader& reader, osmium::io::Writer& writer, location_handler_type& location_handler);
50
5141 std::string m_index_type_name;
5242 bool m_keep_untagged_nodes = false;
5343 bool m_ignore_missing_nodes = false;
44
45 void copy_data(osmium::ProgressBar& progress_bar, osmium::io::Reader& reader, osmium::io::Writer& writer, location_handler_type& location_handler);
5446
5547 public:
5648
3333
3434 class CommandChangesetFilter : public Command, public with_single_osm_input, public with_osm_output {
3535
36 std::string m_user;
37 osmium::Box m_box;
38 osmium::Timestamp m_after = osmium::start_of_time();
39 osmium::Timestamp m_before = osmium::end_of_time();
40 osmium::user_id_type m_uid = 0;
41
3642 bool m_with_discussion = false;
3743 bool m_without_discussion = false;
3844 bool m_with_changes = false;
3945 bool m_without_changes = false;
4046 bool m_open = false;
4147 bool m_closed = false;
42 osmium::user_id_type m_uid = 0;
43 std::string m_user;
44 osmium::Timestamp m_after = osmium::start_of_time();
45 osmium::Timestamp m_before = osmium::end_of_time();
46 osmium::Box m_box;
4748
4849 public:
4950
2424
2525 #include "cmd.hpp" // IWYU pragma: export
2626
27 #include <osmium/io/writer.hpp>
2728 #include <osmium/memory/buffer.hpp>
28
29 namespace osmium {
30
31 namespace io {
32 class Writer;
33 } // namespace io
34
35 class OSMObject;
36
37 } // namespace osmium
29 #include <osmium/osm/object.hpp>
3830
3931 #include <string>
4032 #include <vector>
2424 #include "util.hpp"
2525
2626 #include "export/export_format_json.hpp"
27 #include "export/export_format_pg.hpp"
2728 #include "export/export_format_text.hpp"
2829 #include "export/export_handler.hpp"
2930
194195
195196 void CommandExport::canonicalize_output_format() {
196197 for (auto& c : m_output_format) {
197 c = std::tolower(c);
198 c = static_cast<char>(std::tolower(c));
198199 }
199200
200201 if (m_output_format == "json") {
364365
365366 canonicalize_output_format();
366367
367 if (m_output_format != "geojson" && m_output_format != "geojsonseq" && m_output_format != "text") {
368 throw argument_error{"Set output format with --output-format or -f to 'geojson', 'geojsonseq', or 'text'."};
368 if (m_output_format != "geojson" && m_output_format != "geojsonseq" && m_output_format != "pg" && m_output_format != "text") {
369 throw argument_error{"Set output format with --output-format or -f to 'geojson', 'geojsonseq', 'pg', or 'text'."};
369370 }
370371
371372 if (vm.count("overwrite")) {
489490 return std::unique_ptr<ExportFormat>{new ExportFormatJSON{output_format, output_filename, overwrite, fsync, options}};
490491 }
491492
493 if (output_format == "pg") {
494 return std::unique_ptr<ExportFormat>{new ExportFormatPg{output_format, output_filename, overwrite, fsync, options}};
495 }
496
492497 if (output_format == "text") {
493498 return std::unique_ptr<ExportFormat>{new ExportFormatText{output_format, output_filename, overwrite, fsync, options}};
494499 }
510515 m_area_ruleset.init_filter();
511516
512517 auto handler = create_handler(m_output_format, m_output_filename, m_output_overwrite, m_fsync, m_options);
518 if (m_vout.verbose()) {
519 handler->debug_output(m_vout, m_output_filename);
520 }
521
513522 ExportHandler export_handler{std::move(handler), m_linear_ruleset, m_area_ruleset, m_geometry_types, m_show_errors, m_stop_on_error};
514523 osmium::handler::CheckOrder check_order_handler;
515524
5555 #include <iostream>
5656 #include <memory>
5757 #include <string>
58 #include <sys/stat.h>
59 #include <sys/types.h>
5860 #include <vector>
61
62 #ifdef _WIN32
63 # ifndef WIN32_LEAN_AND_MEAN
64 # define WIN32_LEAN_AND_MEAN // Prevent winsock.h inclusion; avoid winsock2.h conflict
65 # endif
66 # include <io.h>
67 #endif
68
69 #ifndef _MSC_VER
70 # include <unistd.h>
71 #endif
5972
6073 namespace {
6174
196209
197210 } // anonymous namespace
198211
212 static bool is_existing_directory(const char* name) {
213 #ifdef _MSC_VER
214 // Windows implementation
215 // https://msdn.microsoft.com/en-us/library/14h5k7ff.aspx
216 struct _stat64 s{};
217 if (::_stati64(name, &s) != 0) {
218 return false;
219 }
220 return s.st_mode & _S_IFDIR;
221 #else
222 // Unix implementation
223 struct stat s; // NOLINT clang-tidy
224 if (::stat(name, &s) != 0) {
225 return false;
226 }
227 return S_ISDIR(s.st_mode); // NOLINT(hicpp-signed-bitwise)
228 #endif
229 }
230
199231 void CommandExtract::set_directory(const std::string& directory) {
232 if (!is_existing_directory(directory.c_str())) {
233 throw config_error{"Output directory is missing or not accessible: " + directory};
234 }
200235 m_output_directory = directory;
201236 if (m_output_directory.empty() || m_output_directory.back() != '/') {
202237 m_output_directory += '/';
3838
3939 static const std::size_t initial_buffer_size = 10 * 1024;
4040
41 std::vector<std::unique_ptr<Extract>> m_extracts;
42 osmium::Options m_options;
4143 std::string m_config_file_name;
4244 std::string m_config_directory;
4345 std::string m_output_directory;
44 osmium::Options m_options;
4546 std::string m_strategy_name;
47 osmium::memory::Buffer m_buffer{initial_buffer_size, osmium::memory::Buffer::auto_grow::yes};
4648 std::unique_ptr<ExtractStrategy> m_strategy;
47 std::vector<std::unique_ptr<Extract>> m_extracts;
48 osmium::memory::Buffer m_buffer{initial_buffer_size, osmium::memory::Buffer::auto_grow::yes};
4949 bool m_with_history = false;
5050 bool m_set_bounds = false;
5151
4545 #include <boost/program_options.hpp>
4646
4747 #include <algorithm>
48 #include <cmath>
4849 #include <cstdint>
4950 #include <iostream>
5051 #include <iterator>
6970 uint64_t ways = 0;
7071 uint64_t relations = 0;
7172
73 uint64_t buffers_count = 0;
74 uint64_t buffers_size = 0;
75 uint64_t buffers_capacity = 0;
76
7277 osmium::min_op<osmium::object_id_type> smallest_changeset_id{};
7378 osmium::min_op<osmium::object_id_type> smallest_node_id{};
7479 osmium::min_op<osmium::object_id_type> smallest_way_id{};
286291
287292 std::cout << " All objects have following metadata attributes: " << info_handler.metadata_all_objects << "\n";
288293 std::cout << " Some objects have following metadata attributes: " << info_handler.metadata_some_objects << "\n";
294
295 const auto num_objects = info_handler.changesets + info_handler.nodes + info_handler.ways + info_handler.relations;
296 std::cout << " Number of buffers: " << info_handler.buffers_count;
297 if (num_objects != 0) {
298 std::cout << " (avg " << (num_objects / info_handler.buffers_count) << " objects per buffer)\n";
299 } else {
300 std::cout << '\n';
301 }
302
303 const auto buffers_size = static_cast<double>(info_handler.buffers_size / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division)
304 std::cout << " Sum of buffer sizes: " << info_handler.buffers_size << " (" << buffers_size << " GB)\n";
305
306 const auto buffers_capacity= static_cast<double>(info_handler.buffers_capacity / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division)
307
308 if (info_handler.buffers_capacity != 0) {
309 const auto fill_factor = std::round(100 * static_cast<double>(info_handler.buffers_size) / static_cast<double>(info_handler.buffers_capacity));
310 std::cout << " Sum of buffer capacities: " << info_handler.buffers_capacity << " (" << buffers_capacity << " GB, " << fill_factor << "% full)\n";
311 } else {
312 std::cout << " Sum of buffer capacities: 0 (0 GB)\n";
313 }
289314 }
290315
291316 }; // class HumanReadableOutput
429454 m_writer.Int64(get_largest(info_handler.largest_way_id()));
430455 m_writer.String("relations");
431456 m_writer.Int64(get_largest(info_handler.largest_relation_id()));
457 m_writer.EndObject();
458
459 m_writer.String("buffers");
460 m_writer.StartObject();
461 m_writer.String("count");
462 m_writer.Int64(get_largest(info_handler.buffers_count));
463 m_writer.String("size");
464 m_writer.Int64(get_largest(info_handler.buffers_size));
465 m_writer.String("capacity");
466 m_writer.Int64(get_largest(info_handler.buffers_capacity));
432467 m_writer.EndObject();
433468
434469 m_writer.String("metadata");
613648 return;
614649 }
615650
651 if (m_get_value == "data.buffers.count") {
652 std::cout << info_handler.buffers_count << "\n";
653 return;
654 }
655 if (m_get_value == "data.buffers.size") {
656 std::cout << info_handler.buffers_size << "\n";
657 return;
658 }
659 if (m_get_value == "data.buffers.capacity") {
660 std::cout << info_handler.buffers_capacity << "\n";
661 return;
662 }
663
616664 if (m_get_value == "metadata.all_objects.version") {
617665 std::cout << (info_handler.metadata_all_objects.version() ? "yes\n" : "no\n");
618666 return;
669717 ("json,j", "JSON output")
670718 ("crc,c", "Calculate CRC")
671719 ("no-crc", "Do not calculate CRC")
720 ("object-type,t", po::value<std::vector<std::string>>(), "Read only objects of given type (node, way, relation, changeset)")
672721 ;
673722
674723 po::options_description opts_common{add_common_options()};
694743
695744 setup_common(vm, desc);
696745 setup_progress(vm);
746 setup_object_type_nwrc(vm);
697747
698748 if (vm.count("extended")) {
699749 m_extended = true;
742792 "data.maxid.ways",
743793 "data.maxid.relations",
744794 "data.maxid.changesets",
795 "data.buffers.count",
796 "data.buffers.size",
797 "data.buffers.capacity",
745798 "metadata.all_objects.version",
746799 "metadata.all_objects.timestamp",
747800 "metadata.all_objects.changeset",
790843 show_single_input_arguments(m_vout);
791844
792845 m_vout << " other options:\n";
846 show_object_types(m_vout);
793847 m_vout << " extended output: " << (m_extended ? "yes\n" : "no\n");
794848 m_vout << " calculate CRC: " << (m_calculate_crc ? "yes\n" : "no\n");
795849 }
807861 output->set_crc(m_calculate_crc);
808862 output->file(m_input_filename, m_input_file);
809863
810 osmium::io::Reader reader{m_input_file, m_extended ? osmium::osm_entity_bits::all : osmium::osm_entity_bits::nothing};
864 osmium::io::Reader reader{m_input_file, m_extended ? osm_entity_bits() : osmium::osm_entity_bits::nothing};
811865 osmium::io::Header header{reader.header()};
812866 output->header(header);
813867
816870 osmium::ProgressBar progress_bar{reader.file_size(), display_progress()};
817871 while (osmium::memory::Buffer buffer = reader.read()) {
818872 progress_bar.update(reader.offset());
873 ++info_handler.buffers_count;
874 info_handler.buffers_size += buffer.committed();
875 info_handler.buffers_capacity += buffer.capacity();
819876 osmium::apply(buffer, info_handler);
820877 }
821878 progress_bar.done();
2929
3030 class CommandFileinfo : public Command, public with_single_osm_input {
3131
32 std::string m_get_value;
3233 bool m_extended = false;
3334 bool m_json_output = false;
3435 bool m_calculate_crc = false;
35 std::string m_get_value;
3636
3737 public:
3838
2727 #include <osmium/fwd.hpp>
2828 #include <osmium/index/id_set.hpp>
2929 #include <osmium/index/nwr_array.hpp>
30 #include <osmium/index/relations_map.hpp>
3031 #include <osmium/osm/entity_bits.hpp>
3132 #include <osmium/osm/item_type.hpp>
3233 #include <osmium/osm/types.hpp>
3637 #include <string>
3738 #include <vector>
3839
39 namespace osmium {
40 class CommandGetId : public Command, public with_single_osm_input, public with_osm_output {
4041
41 namespace index {
42 class RelationsMapIndex;
43 } // namespace index
44
45 } // namespace osmium
46
47 class CommandGetId : public Command, public with_single_osm_input, public with_osm_output {
42 osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids;
4843
4944 osmium::item_type m_default_item_type = osmium::item_type::node;
5045
5146 bool m_add_referenced_objects = false;
5247 bool m_work_with_history = false;
5348 bool m_verbose_ids = false;
54
55 osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids;
5649
5750 osmium::osm_entity_bits::type get_needed_types() const;
5851 std::size_t count_ids() const noexcept;
2727 #include <osmium/fwd.hpp>
2828 #include <osmium/index/id_set.hpp>
2929 #include <osmium/index/nwr_array.hpp>
30 #include <osmium/index/relations_map.hpp>
3031 #include <osmium/osm/entity_bits.hpp>
3132 #include <osmium/osm/item_type.hpp>
3233 #include <osmium/osm/types.hpp>
3637 #include <string>
3738 #include <vector>
3839
39 namespace osmium {
40 class CommandGetParents : public Command, public with_single_osm_input, public with_osm_output {
4041
41 namespace index {
42 class RelationsMapIndex;
43 } // namespace index
44
45 } // namespace osmium
46
47 class CommandGetParents : public Command, public with_single_osm_input, public with_osm_output {
42 osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids;
4843
4944 osmium::item_type m_default_item_type = osmium::item_type::node;
5045
5146 bool m_add_self = false;
5247 bool m_verbose_ids = false;
53
54 osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids;
5548
5649 osmium::osm_entity_bits::type get_needed_types() const;
5750
4949 }
5050
5151 bool CommandHelp::run() {
52 auto commands = m_command_factory.help();
52 const auto commands = m_command_factory.help();
5353
5454 if (m_topic == "help") {
5555 std::cout << "Usage: " << synopsis()
7777 return true;
7878 }
7979
80 std::string description = m_command_factory.get_description(m_topic);
80 const auto description = m_command_factory.get_description(m_topic);
8181 if (!description.empty()) {
8282 show_help(m_topic, std::string{"osmium "} + m_topic + ": " + description);
8383 return true;
2222 #include "command_merge.hpp"
2323 #include "util.hpp"
2424
25 #include <osmium/io/file.hpp>
2526 #include <osmium/io/header.hpp>
2627 #include <osmium/io/input_iterator.hpp>
2728 #include <osmium/io/output_iterator.hpp>
4344 #include <utility>
4445 #include <vector>
4546
46 namespace osmium {
47
48 namespace io {
49 class File;
50 } // namespace io
51
52 } // namespace osmium
53
5447 bool CommandMerge::setup(const std::vector<std::string>& arguments) {
5548 po::options_description opts_cmd{"COMMAND OPTIONS"};
5649
2222 #include "command_merge_changes.hpp"
2323 #include "util.hpp"
2424
25 #include <osmium/io/file.hpp>
2526 #include <osmium/io/header.hpp>
2627 #include <osmium/io/output_iterator.hpp>
2728 #include <osmium/io/reader.hpp>
4041 #include <string>
4142 #include <utility>
4243 #include <vector>
43
44 namespace osmium {
45
46 namespace io {
47 class File;
48 } // namespace io
49
50 } // namespace osmium
5144
5245 bool CommandMergeChanges::setup(const std::vector<std::string>& arguments) {
5346 po::options_description opts_cmd{"COMMAND OPTIONS"};
2222 #include "exception.hpp"
2323
2424 #include <osmium/io/detail/read_write.hpp>
25 #include <osmium/io/file.hpp>
2526 #include <osmium/io/header.hpp>
2627 #include <osmium/io/input_iterator.hpp>
2728 #include <osmium/io/reader.hpp>
5354 #ifdef _WIN32
5455 # include <io.h>
5556 #endif
56
57 namespace osmium {
58
59 namespace io {
60 class File;
61 } // namespace io
62
63 } // namespace osmium
6457
6558 osmium::object_id_type id_map::add_offset_to_id(osmium::object_id_type id) const noexcept {
6659 if (m_start_id < 0) {
2020 */
2121
2222 #include "command_sort.hpp"
23 #include "exception.hpp"
2324 #include "util.hpp"
2425
2526 #include <osmium/io/header.hpp>
5051 po::options_description hidden;
5152 hidden.add_options()
5253 ("input-filenames", po::value<std::vector<std::string>>(), "OSM input files")
54 ("strategy,s", po::value<std::string>(), "Strategy (default: simple)")
5355 ;
5456
5557 po::options_description desc;
7476 m_filenames = vm["input-filenames"].as<std::vector<std::string>>();
7577 }
7678
79 if (vm.count("strategy")) {
80 m_strategy = vm["strategy"].as<std::string>();
81 if (m_strategy != "simple" && m_strategy != "multipass") {
82 throw argument_error{"Unknown strategy: " + m_strategy};
83 }
84 }
85
7786 return true;
7887 }
7988
8089 void CommandSort::show_arguments() {
8190 show_multiple_inputs_arguments(m_vout);
8291 show_output_arguments(m_vout);
83 }
84
85 bool CommandSort::run() {
92
93 m_vout << " other options:\n";
94 m_vout << " strategy: " << m_strategy << "\n";
95 }
96
97 bool CommandSort::run_single_pass() {
8698 std::vector<osmium::memory::Buffer> data;
8799 osmium::ObjectPointerCollection objects;
88100
89101 osmium::Box bounding_box;
102
103 uint64_t buffers_count = 0;
104 uint64_t buffers_size = 0;
105 uint64_t buffers_capacity = 0;
90106
91107 m_vout << "Reading contents of input files...\n";
92108 osmium::ProgressBar progress_bar{file_size_sum(m_input_files), display_progress()};
95111 osmium::io::Header header{reader.header()};
96112 bounding_box.extend(header.joined_boxes());
97113 while (osmium::memory::Buffer buffer = reader.read()) {
114 ++buffers_count;
115 buffers_size += buffer.committed();
116 buffers_capacity += buffer.capacity();
98117 progress_bar.update(reader.offset());
99118 osmium::apply(buffer, objects);
100119 data.push_back(std::move(buffer));
103122 reader.close();
104123 }
105124 progress_bar.done();
125
126 m_vout << "Number of buffers: " << buffers_count << "\n";
127
128 const auto buffers_size_rounded = static_cast<double>(buffers_size / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division)
129 m_vout << "Sum of buffer sizes: " << buffers_size << " (" << buffers_size_rounded << " GB)\n";
130
131 const auto buffers_capacity_rounded = static_cast<double>(buffers_capacity / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division)
132
133 if (buffers_capacity != 0) {
134 const auto fill_factor = std::round(100 * static_cast<double>(buffers_size) / static_cast<double>(buffers_capacity));
135 m_vout << "Sum of buffer capacities: " << buffers_capacity << " (" << buffers_capacity_rounded << " GB, " << fill_factor << "% full)\n";
136 } else {
137 m_vout << "Sum of buffer capacities: 0 (0 GB)\n";
138 }
106139
107140 m_vout << "Opening output file...\n";
108141 osmium::io::Header header;
129162 return true;
130163 }
131164
165 bool CommandSort::run_multi_pass() {
166 osmium::Box bounding_box;
167
168 m_vout << "Reading input file headers...\n";
169 for (const std::string& file_name : m_filenames) {
170 osmium::io::Reader reader{file_name, osmium::osm_entity_bits::nothing};
171 osmium::io::Header header{reader.header()};
172 bounding_box.extend(header.joined_boxes());
173 reader.close();
174 }
175
176 m_vout << "Opening output file...\n";
177 osmium::io::Header header;
178 setup_header(header);
179 if (bounding_box) {
180 header.add_box(bounding_box);
181 }
182
183 osmium::io::Writer writer{m_output_file, header, m_output_overwrite, m_fsync};
184
185 osmium::ProgressBar progress_bar{file_size_sum(m_input_files) * 3, display_progress()};
186
187 int pass = 1;
188 for (const auto entity : {osmium::osm_entity_bits::node, osmium::osm_entity_bits::way, osmium::osm_entity_bits::relation}) {
189 std::vector<osmium::memory::Buffer> data;
190 osmium::ObjectPointerCollection objects;
191
192 uint64_t buffers_count = 0;
193 uint64_t buffers_size = 0;
194 uint64_t buffers_capacity = 0;
195
196 m_vout << "Pass " << pass++ << "...\n";
197 m_vout << "Reading contents of input files...\n";
198 for (const std::string& file_name : m_filenames) {
199 osmium::io::Reader reader{file_name, entity};
200 osmium::io::Header header{reader.header()};
201 bounding_box.extend(header.joined_boxes());
202 while (osmium::memory::Buffer buffer = reader.read()) {
203 ++buffers_count;
204 buffers_size += buffer.committed();
205 buffers_capacity += buffer.capacity();
206 progress_bar.update(reader.offset());
207 osmium::apply(buffer, objects);
208 data.push_back(std::move(buffer));
209 }
210 progress_bar.file_done(reader.file_size());
211 reader.close();
212 }
213
214 if (m_vout.verbose()) {
215 progress_bar.remove();
216 }
217
218 m_vout << "Number of buffers: " << buffers_count << "\n";
219
220 const auto buffers_size_rounded = static_cast<double>(buffers_size / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division)
221 m_vout << "Sum of buffer sizes: " << buffers_size << " (" << buffers_size_rounded << " GB)\n";
222
223 const auto buffers_capacity_rounded = static_cast<double>(buffers_capacity / (1000 * 1000)) / 1000; // NOLINT(bugprone-integer-division)
224
225 if (buffers_capacity != 0) {
226 const auto fill_factor = std::round(100 * static_cast<double>(buffers_size) / static_cast<double>(buffers_capacity));
227 m_vout << "Sum of buffer capacities: " << buffers_capacity << " (" << buffers_capacity_rounded << " GB, " << fill_factor << "% full)\n";
228 } else {
229 m_vout << "Sum of buffer capacities: 0 (0 GB)\n";
230 }
231
232 m_vout << "Sorting data...\n";
233 objects.sort(osmium::object_order_type_id_version());
234
235 m_vout << "Writing out sorted data...\n";
236 auto out = osmium::io::make_output_iterator(writer);
237 std::copy(objects.begin(), objects.end(), out);
238 }
239
240 progress_bar.done();
241
242 m_vout << "Closing output file...\n";
243 writer.close();
244
245 show_memory_used();
246 m_vout << "Done.\n";
247
248 return true;
249 }
250
251 bool CommandSort::run() {
252 if (m_strategy == "simple") {
253 return run_single_pass();
254 }
255 return run_multi_pass();
256 }
257
3030 class CommandSort : public Command, public with_multiple_osm_inputs, public with_osm_output {
3131
3232 std::vector<std::string> m_filenames;
33 std::string m_strategy{"simple"};
3334
3435 public:
3536
4041 bool setup(const std::vector<std::string>& arguments) override final;
4142
4243 void show_arguments() override final;
44
45 bool run_single_pass();
46
47 bool run_multi_pass();
4348
4449 bool run() override final;
4550
8888 ("expressions,e", po::value<std::string>(), "Read filter expressions from file")
8989 ("invert-match,i", "Invert the sense of matching, exclude objects with matching tags")
9090 ("omit-referenced,R", "Omit referenced objects")
91 ("remove-tags,t", "Remove tags from non-matching objects")
9192 ;
9293
9394 po::options_description opts_common{add_common_options()};
127128
128129 if (vm.count("invert-match")) {
129130 m_invert_match = true;
131 }
132
133 if (vm.count("remove-tags")) {
134 m_remove_tags = true;
130135 }
131136
132137 if (vm.count("expression-list")) {
155160 }
156161
157162 osmium::osm_entity_bits::type CommandTagsFilter::get_needed_types() const {
163 if (m_invert_match) {
164 return osmium::osm_entity_bits::nwr;
165 }
166
158167 osmium::osm_entity_bits::type types = osmium::osm_entity_bits::nothing;
159168
160 if (!m_ids(osmium::item_type::node).empty() || !m_filters(osmium::item_type::node).empty()) {
169 if (!m_referenced_ids(osmium::item_type::node).empty() || !m_filters(osmium::item_type::node).empty()) {
161170 types |= osmium::osm_entity_bits::node;
162171 }
163 if (!m_ids(osmium::item_type::way).empty() || !m_filters(osmium::item_type::way).empty() || !m_area_filters.empty()) {
172 if (!m_referenced_ids(osmium::item_type::way).empty() || !m_filters(osmium::item_type::way).empty() || !m_area_filters.empty()) {
164173 types |= osmium::osm_entity_bits::way;
165174 }
166 if (!m_ids(osmium::item_type::relation).empty() || !m_filters(osmium::item_type::relation).empty() || !m_area_filters.empty()) {
175 if (!m_referenced_ids(osmium::item_type::relation).empty() || !m_filters(osmium::item_type::relation).empty() || !m_area_filters.empty()) {
167176 types |= osmium::osm_entity_bits::relation;
168177 }
169178
172181
173182 void CommandTagsFilter::add_nodes(const osmium::Way& way) {
174183 for (const auto& nr : way.nodes()) {
175 m_ids(osmium::item_type::node).set(nr.positive_ref());
184 m_referenced_ids(osmium::item_type::node).set(nr.positive_ref());
176185 }
177186 }
178187
179188 void CommandTagsFilter::add_members(const osmium::Relation& relation) {
180189 for (const auto& member : relation.members()) {
181 m_ids(member.type()).set(member.positive_ref());
190 m_referenced_ids(member.type()).set(member.positive_ref());
182191 }
183192 }
184193
224233
225234 void CommandTagsFilter::mark_rel_ids(const osmium::index::RelationsMapIndex& rel_in_rel, osmium::object_id_type parent_id) {
226235 rel_in_rel.for_each(parent_id, [&](osmium::unsigned_object_id_type member_id) {
227 if (m_ids(osmium::item_type::relation).check_and_set(member_id)) {
236 if (m_referenced_ids(osmium::item_type::relation).check_and_set(member_id)) {
228237 mark_rel_ids(rel_in_rel, member_id);
229238 }
230239 });
234243 m_vout << " Reading input file to find relations in relations...\n";
235244 osmium::index::RelationsMapStash stash;
236245
246 ++m_count_passes;
237247 osmium::io::Reader reader{m_input_file, osmium::osm_entity_bits::relation};
238248 while (osmium::memory::Buffer buffer = reader.read()) {
239249 for (const auto& relation : buffer.select<osmium::Relation>()) {
240250 stash.add_members(relation);
241251 if (matches_relation(relation) != m_invert_match) {
242 m_ids(osmium::item_type::relation).set(relation.positive_id());
252 m_matching_ids(osmium::item_type::relation).set(relation.positive_id());
253 for (const auto& member : relation.members()) {
254 if (member.type() == osmium::item_type::node) {
255 m_referenced_ids(osmium::item_type::node).set(member.positive_ref());
256 } else if (member.type() == osmium::item_type::way) {
257 m_referenced_ids(osmium::item_type::way).set(member.positive_ref());
258 }
259 }
243260 }
244261 }
245262 }
250267 }
251268
252269 const auto rel_in_rel = stash.build_parent_to_member_index();
253 for (const osmium::unsigned_object_id_type id : m_ids(osmium::item_type::relation)) {
270 for (const osmium::unsigned_object_id_type id : m_referenced_ids(osmium::item_type::relation)) {
254271 mark_rel_ids(rel_in_rel, id);
255272 }
256273
260277 void CommandTagsFilter::find_nodes_and_ways_in_relations() {
261278 m_vout << " Reading input file to find nodes/ways in relations...\n";
262279
280 ++m_count_passes;
263281 osmium::io::Reader reader{m_input_file, osmium::osm_entity_bits::relation};
264282 while (osmium::memory::Buffer buffer = reader.read()) {
265283 for (const auto& relation : buffer.select<osmium::Relation>()) {
266 if (m_ids(osmium::item_type::relation).get(relation.positive_id())) {
284 if (m_referenced_ids(osmium::item_type::relation).get(relation.positive_id())) {
267285 for (const auto& member : relation.members()) {
268286 if (member.type() == osmium::item_type::node) {
269 m_ids(osmium::item_type::node).set(member.positive_ref());
287 m_referenced_ids(osmium::item_type::node).set(member.positive_ref());
270288 } else if (member.type() == osmium::item_type::way) {
271 m_ids(osmium::item_type::way).set(member.positive_ref());
289 m_referenced_ids(osmium::item_type::way).set(member.positive_ref());
272290 }
273291 }
274292 }
280298 void CommandTagsFilter::find_nodes_in_ways() {
281299 m_vout << " Reading input file to find nodes in ways...\n";
282300
301 ++m_count_passes;
283302 osmium::io::Reader reader{m_input_file, osmium::osm_entity_bits::way};
284303 while (osmium::memory::Buffer buffer = reader.read()) {
285304 for (const auto& way : buffer.select<osmium::Way>()) {
286 if (m_ids(osmium::item_type::way).get(way.positive_id())) {
305 if (m_referenced_ids(osmium::item_type::way).get(way.positive_id())) {
287306 add_nodes(way);
288307 } else if (matches_way(way) != m_invert_match) {
289 m_ids(osmium::item_type::way).set(way.positive_id());
308 m_matching_ids(osmium::item_type::way).set(way.positive_id());
290309 add_nodes(way);
291310 }
292311 }
296315
297316 void CommandTagsFilter::find_referenced_objects() {
298317 m_vout << "Following references...\n";
299 bool todo = !m_filters(osmium::item_type::relation).empty() || !m_area_filters.empty();
318 bool todo = !m_filters(osmium::item_type::relation).empty() || !m_area_filters.empty() || m_invert_match;
300319 if (todo) {
301320 todo = find_relations_in_relations();
302321 }
305324 find_nodes_and_ways_in_relations();
306325 }
307326
308 if (!m_ids(osmium::item_type::way).empty() || !m_filters(osmium::item_type::way).empty() || !m_area_filters.empty()) {
327 if (!m_referenced_ids(osmium::item_type::way).empty() || !m_filters(osmium::item_type::way).empty() || !m_area_filters.empty()) {
309328 find_nodes_in_ways();
310329 }
311330 m_vout << "Done following references.\n";
317336 }
318337
319338 m_vout << "Opening input file...\n";
339 ++m_count_passes;
320340 osmium::io::Reader reader{m_input_file, get_needed_types()};
321341
322342 m_vout << "Opening output file...\n";
329349 osmium::ProgressBar progress_bar{reader.file_size(), display_progress()};
330350 while (osmium::memory::Buffer buffer = reader.read()) {
331351 progress_bar.update(reader.offset());
332 for (const auto& object : buffer.select<osmium::OSMObject>()) {
333 if (m_ids(object.type()).get(object.positive_id())) {
352 for (auto& object : buffer.select<osmium::OSMObject>()) {
353 if (m_matching_ids(object.type()).get(object.positive_id())) {
334354 writer(object);
335 } else if (!m_add_referenced_objects || object.type() == osmium::item_type::node) {
336 if (matches_object(object) != m_invert_match) {
337 writer(object);
355 } else if ((!m_add_referenced_objects || object.type() == osmium::item_type::node) && matches_object(object) != m_invert_match) {
356 writer(object);
357 } else if (m_referenced_ids(object.type()).get(object.positive_id())) {
358 if (m_remove_tags) {
359 object.remove_tags();
338360 }
361 writer(object);
339362 }
340363 }
341364 }
349372
350373 show_memory_used();
351374
375 m_vout << "Needed " << m_count_passes << " passes through the input file.\n";
352376 m_vout << "Done.\n";
353377
354378 return true;
2727 #include <osmium/fwd.hpp>
2828 #include <osmium/index/id_set.hpp>
2929 #include <osmium/index/nwr_array.hpp>
30 #include <osmium/index/relations_map.hpp>
3031 #include <osmium/osm/entity_bits.hpp>
3132 #include <osmium/osm/item_type.hpp>
3233 #include <osmium/osm/types.hpp>
3536 #include <string>
3637 #include <vector>
3738
38 namespace osmium {
39
40 namespace index {
41 class RelationsMapIndex;
42 } // namespace index
43
44 } // namespace osmium
45
4639 class CommandTagsFilter : public Command, public with_single_osm_input, public with_osm_output {
47
48 bool m_add_referenced_objects = true;
49 bool m_invert_match = false;
5040
5141 osmium::nwr_array<osmium::TagsFilter> m_filters;
5242 osmium::TagsFilter m_area_filters;
5343
54 osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_ids;
44 osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_matching_ids;
45 osmium::nwr_array<osmium::index::IdSetDense<osmium::unsigned_object_id_type>> m_referenced_ids;
46
47 int m_count_passes = 0;
48 bool m_add_referenced_objects = true;
49 bool m_invert_match = false;
50 bool m_remove_tags = false;
5551
5652 osmium::osm_entity_bits::type get_needed_types() const;
5753
2727 #include <osmium/fwd.hpp>
2828 #include <osmium/io/writer_options.hpp>
2929 #include <osmium/osm/object.hpp>
30 #include <osmium/util/verbose_output.hpp>
3031
3132 #include <cstdint>
3233
6263 virtual void area(const osmium::Area&) = 0;
6364
6465 virtual void close() = 0;
66
67 virtual void debug_output(osmium::VerboseOutput& /*out*/, const std::string& /*filename*/) {
68 }
6569
6670 template <typename TFunc>
6771 bool add_tags(const osmium::OSMObject& object, TFunc&& func) {
105105
106106 if (!options().version.empty()) {
107107 m_writer.String(options().version);
108 m_writer.Int(object.version());
108 m_writer.Int64(object.version());
109109 }
110110
111111 if (!options().changeset.empty()) {
112112 m_writer.String(options().changeset);
113 m_writer.Int(object.changeset());
113 m_writer.Int64(object.changeset());
114114 }
115115
116116 if (!options().uid.empty()) {
117117 m_writer.String(options().uid);
118 m_writer.Int(object.uid());
118 m_writer.Int64(object.uid());
119119 }
120120
121121 if (!options().user.empty()) {
0 /*
1
2 Osmium -- OpenStreetMap data manipulation command line tool
3 http://osmcode.org/osmium-tool/
4
5 Copyright (C) 2013-2018 Jochen Topf <jochen@topf.org>
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <https://www.gnu.org/licenses/>.
19
20 */
21
22 #include "export_format_pg.hpp"
23
24 #include <osmium/io/detail/read_write.hpp>
25 #include <osmium/io/detail/string_util.hpp>
26
27 #ifndef RAPIDJSON_HAS_STDSTRING
28 # define RAPIDJSON_HAS_STDSTRING 1
29 #endif
30 #include <rapidjson/writer.h>
31 #include <rapidjson/stringbuffer.h>
32
33 #include <limits>
34 #include <string>
35
36 enum {
37 initial_buffer_size = 1024u * 1024u
38 };
39
40 enum {
41 flush_buffer_size = 800u * 1024u
42 };
43
44 ExportFormatPg::ExportFormatPg(const std::string& /*output_format*/,
45 const std::string& output_filename,
46 osmium::io::overwrite overwrite,
47 osmium::io::fsync fsync,
48 const options_type& options) :
49 ExportFormat(options),
50 m_fd(osmium::io::detail::open_for_writing(output_filename, overwrite)),
51 m_fsync(fsync) {
52 m_buffer.reserve(initial_buffer_size);
53 }
54
55 void ExportFormatPg::flush_to_output() {
56 osmium::io::detail::reliable_write(m_fd, m_buffer.data(), m_buffer.size());
57 m_buffer.clear();
58 m_commit_size = 0;
59 }
60
61 void ExportFormatPg::start_feature(const char type, const osmium::object_id_type id) {
62 m_buffer.resize(m_commit_size);
63 if (options().unique_id == unique_id_type::counter) {
64 m_buffer.append(std::to_string(m_count + 1));
65 m_buffer += '\t';
66 } else if (options().unique_id == unique_id_type::type_id) {
67 m_buffer += type;
68 m_buffer.append(std::to_string(id));
69 m_buffer += '\t';
70 }
71 }
72
73 void ExportFormatPg::append_pg_escaped(const char* str, std::size_t size = std::numeric_limits<std::size_t>::max()) {
74 while (size-- > 0 && *str != '\0') {
75 switch (*str) {
76 case '\\':
77 m_buffer += '\\';
78 m_buffer += '\\';
79 break;
80 case '\n':
81 m_buffer += '\\';
82 m_buffer += 'n';
83 break;
84 case '\r':
85 m_buffer += '\\';
86 m_buffer += 'r';
87 break;
88 case '\t':
89 m_buffer += '\\';
90 m_buffer += 't';
91 break;
92 default:
93 m_buffer += *str;
94 }
95 ++str;
96 }
97 }
98
99 void ExportFormatPg::add_attributes(const osmium::OSMObject& object) {
100 if (!options().type.empty()) {
101 if (object.type() == osmium::item_type::area) {
102 if (static_cast<const osmium::Area&>(object).from_way()) {
103 m_buffer.append("way");
104 } else {
105 m_buffer.append("relation");
106 }
107 } else {
108 m_buffer.append(osmium::item_type_to_name(object.type()));
109 }
110 m_buffer += '\t';
111 }
112
113 if (!options().id.empty()) {
114 m_buffer.append(std::to_string(object.type() == osmium::item_type::area ? osmium::area_id_to_object_id(object.id()) : object.id()));
115 m_buffer += '\t';
116 }
117
118 if (!options().version.empty()) {
119 m_buffer.append(std::to_string(object.version()));
120 m_buffer += '\t';
121 }
122
123 if (!options().changeset.empty()) {
124 m_buffer.append(std::to_string(object.changeset()));
125 m_buffer += '\t';
126 }
127
128 if (!options().uid.empty()) {
129 m_buffer.append(std::to_string(object.uid()));
130 m_buffer += '\t';
131 }
132
133 if (!options().user.empty()) {
134 append_pg_escaped(object.user());
135 m_buffer += '\t';
136 }
137
138 if (!options().timestamp.empty()) {
139 m_buffer.append(object.timestamp().to_iso());
140 m_buffer += '\t';
141 }
142
143 if (!options().way_nodes.empty()) {
144 if (object.type() == osmium::item_type::way) {
145 m_buffer += '{';
146 for (const auto& nr : static_cast<const osmium::Way&>(object).nodes()) {
147 m_buffer.append(std::to_string(nr.ref()));
148 m_buffer += ',';
149 }
150 if (m_buffer.back() == ',') {
151 m_buffer.back() = '}';
152 } else {
153 m_buffer += '}';
154 }
155 } else {
156 m_buffer += '\\';
157 m_buffer += 'N';
158 }
159 m_buffer += '\t';
160 }
161 }
162
163 bool ExportFormatPg::add_tags(const osmium::OSMObject& object) {
164 bool has_tags = false;
165
166 rapidjson::StringBuffer stream;
167 rapidjson::Writer<rapidjson::StringBuffer> writer{stream};
168
169 writer.StartObject();
170 for (const auto& tag : object.tags()) {
171 if (options().tags_filter(tag)) {
172 has_tags = true;
173 writer.Key(tag.key());
174 writer.String(tag.value());
175 }
176 }
177 writer.EndObject();
178
179 append_pg_escaped(stream.GetString(), stream.GetSize());
180
181 return has_tags;
182 }
183
184 void ExportFormatPg::finish_feature(const osmium::OSMObject& object) {
185 m_buffer += '\t';
186 add_attributes(object);
187
188 if (add_tags(object) || options().keep_untagged) {
189 m_buffer += '\n';
190
191 m_commit_size = m_buffer.size();
192
193 ++m_count;
194
195 if (m_buffer.size() > flush_buffer_size) {
196 flush_to_output();
197 }
198 }
199 }
200
201 void ExportFormatPg::node(const osmium::Node& node) {
202 start_feature('n', node.id());
203 m_buffer.append(m_factory.create_point(node));
204 finish_feature(node);
205 }
206
207 void ExportFormatPg::way(const osmium::Way& way) {
208 start_feature('w', way.id());
209 m_buffer.append(m_factory.create_linestring(way));
210 finish_feature(way);
211 }
212
213 void ExportFormatPg::area(const osmium::Area& area) {
214 start_feature('a', area.id());
215 m_buffer.append(m_factory.create_multipolygon(area));
216 finish_feature(area);
217 }
218
219 void ExportFormatPg::close() {
220 if (m_fd > 0) {
221 flush_to_output();
222 if (m_fsync == osmium::io::fsync::yes) {
223 osmium::io::detail::reliable_fsync(m_fd);
224 }
225 ::close(m_fd);
226 m_fd = -1;
227 }
228 }
229
230 void ExportFormatPg::debug_output(osmium::VerboseOutput& out, const std::string& filename) {
231 out << '\n';
232 out << "Create table with something like this:\n";
233 out << "CREATE TABLE osmdata (\n";
234
235 if (options().unique_id == unique_id_type::counter) {
236 out << " id BIGINT PRIMARY KEY,\n";
237 } else if (options().unique_id == unique_id_type::type_id) {
238 out << " id VARCHAR PRIMARY KEY,\n";
239 }
240
241 out << " geom GEOMETRY,\n";
242
243 if (!options().type.empty()) {
244 out << " osm_type VARCHAR,\n";
245 }
246
247 if (!options().id.empty()) {
248 out << " osm_id BIGINT,\n";
249 }
250
251 if (!options().version.empty()) {
252 out << " version INTEGER,\n";
253 }
254
255 if (!options().changeset.empty()) {
256 out << " changeset INTEGER,\n";
257 }
258
259 if (!options().uid.empty()) {
260 out << " uid INTEGER,\n";
261 }
262
263 if (!options().user.empty()) {
264 out << " user VARCHAR,\n";
265 }
266
267 if (!options().timestamp.empty()) {
268 out << " timestamp TIMESTAMP (0) WITH TIME ZONE,\n";
269 }
270
271 if (!options().way_nodes.empty()) {
272 out << " way_nodes BIGINT[],\n";
273 }
274
275 out << " tags JSON -- or JSONB\n";
276 out << ");\n";
277 out << "Then load data with something like this:\n";
278 out << "\\copy osmdata FROM '" << filename << "'\n";
279 out << '\n';
280 }
281
0 #ifndef EXPORT_EXPORT_FORMAT_PG_HPP
1 #define EXPORT_EXPORT_FORMAT_PG_HPP
2
3 /*
4
5 Osmium -- OpenStreetMap data manipulation command line tool
6 http://osmcode.org/osmium-tool/
7
8 Copyright (C) 2013-2018 Jochen Topf <jochen@topf.org>
9
10 This program is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <https://www.gnu.org/licenses/>.
22
23 */
24
25 #include "export_format.hpp"
26
27 #include <osmium/fwd.hpp>
28 #include <osmium/geom/wkb.hpp>
29 #include <osmium/io/writer_options.hpp>
30
31 #include <string>
32
33 class ExportFormatPg : public ExportFormat {
34
35 osmium::geom::WKBFactory<> m_factory{osmium::geom::wkb_type::ewkb, osmium::geom::out_type::hex};
36 std::string m_buffer;
37 std::size_t m_commit_size = 0;
38 int m_fd;
39 osmium::io::fsync m_fsync;
40
41 void flush_to_output();
42
43 void start_feature(char type, osmium::object_id_type id);
44 void add_attributes(const osmium::OSMObject& object);
45 bool add_tags(const osmium::OSMObject& object);
46 void finish_feature(const osmium::OSMObject& object);
47 void append_pg_escaped(const char* str, std::size_t size);
48
49 public:
50
51 ExportFormatPg(const std::string& output_format,
52 const std::string& output_filename,
53 osmium::io::overwrite overwrite,
54 osmium::io::fsync fsync,
55 const options_type& options);
56
57 ~ExportFormatPg() override {
58 try {
59 close();
60 } catch(...) {
61 }
62 }
63
64 void node(const osmium::Node& node) override;
65
66 void way(const osmium::Way& way) override;
67
68 void area(const osmium::Area& area) override;
69
70 void close() override;
71
72 void debug_output(osmium::VerboseOutput& out, const std::string& filename) override;
73
74 }; // class ExportFormatPg
75
76 #endif // EXPORT_EXPORT_FORMAT_PG_HPP
2323 #include "../util.hpp"
2424
2525 #include <osmium/handler/check_order.hpp>
26 #include <osmium/util/misc.hpp>
2627 #include <osmium/util/string.hpp>
2728
2829 namespace strategy_smart {
2930
30 void Data::add_relation(const osmium::Relation& relation) {
31 void Data::add_relation_members(const osmium::Relation& relation) {
3132 for (const auto& member : relation.members()) {
3233 const auto ref = member.positive_ref();
3334 switch (member.type()) {
5960 m_extracts.emplace_back(*extract);
6061 }
6162
63 m_types = {"multipolygon"};
6264 for (const auto& option : options) {
63 if (std::string{"types"} != option.first) {
65 if (option.first == "types") {
66 if (option.second.empty() || option.second == "any" || option.second == "true") {
67 m_types.clear();
68 } else {
69 m_types = osmium::split_string(option.second, ',', true);
70 }
71 } else if (option.first == "complete-partial-relations") {
72 if (!option.second.empty()) {
73 m_complete_partial_relations_percentage = osmium::detail::str_to_int<std::size_t>(option.second.c_str());
74 if (m_complete_partial_relations_percentage <= 0 ||
75 m_complete_partial_relations_percentage > 100) {
76 m_complete_partial_relations_percentage = 100;
77 }
78 }
79 } else {
6480 warning(std::string{"Ignoring unknown option '"} + option.first + "' for 'smart' strategy.\n");
6581 }
66 }
67
68 const auto types = options.get("types");
69 if (types.empty()) {
70 m_types = {"multipolygon"};
71 } else if (types != "any") {
72 m_types = osmium::split_string(types, ',', true);
7382 }
7483 }
7584
7685 const char* Strategy::name() const noexcept {
7786 return "smart";
87 }
88
89 bool Strategy::check_members_count(const std::size_t size, const std::size_t wanted_members) const noexcept {
90 return wanted_members * 100 >= size * m_complete_partial_relations_percentage;
7891 }
7992
8093 bool Strategy::check_type(const osmium::Relation& relation) const noexcept {
93106 void Strategy::show_arguments(osmium::VerboseOutput& vout) {
94107 vout << "Additional strategy options:\n";
95108 if (m_types.empty()) {
96 vout << " types: any\n";
109 vout << " - [types] relation types: any\n";
97110 } else {
98 vout << " types:\n";
111 std::string typelist;
99112 for (const auto& type : m_types) {
100 vout << " " << type << '\n';
101 }
113 if (!typelist.empty()) {
114 typelist += ", ";
115 }
116 typelist += type;
117 }
118 vout << " - [types] relation types: " << typelist << '\n';
119 }
120 if (m_complete_partial_relations_percentage == 100) {
121 vout << " - [complete-partial-relations] do not complete partial relations\n";
122 } else {
123 vout << " - [complete-partial-relations] complete partial relations when " << m_complete_partial_relations_percentage << "% or more members are in extract\n";
102124 }
103125 vout << '\n';
104126 }
143165 }
144166
145167 void erelation(extract_data& e, const osmium::Relation& relation) {
168 std::size_t wanted_members = 0;
146169 for (const auto& member : relation.members()) {
147170 switch (member.type()) {
148171 case osmium::item_type::node:
149172 if (e.node_ids.get(member.positive_ref())) {
150 e.relation_ids.set(relation.positive_id());
151 if (strategy().check_type(relation)) {
152 e.add_relation(relation);
173 if (wanted_members == 0) {
174 e.relation_ids.set(relation.positive_id());
175 if (strategy().check_type(relation)) {
176 e.add_relation_members(relation);
177 return;
178 }
153179 }
154 return;
180 ++wanted_members;
155181 }
156182 break;
157183 case osmium::item_type::way:
158184 if (e.way_ids.get(member.positive_ref())) {
159 e.relation_ids.set(relation.positive_id());
160 if (strategy().check_type(relation)) {
161 e.add_relation(relation);
185 if (wanted_members == 0) {
186 e.relation_ids.set(relation.positive_id());
187 if (strategy().check_type(relation)) {
188 e.add_relation_members(relation);
189 return;
190 }
162191 }
163 return;
192 ++wanted_members;
164193 }
165194 break;
166195 default:
167196 break;
168197 }
198 }
199
200 if (strategy().check_members_count(relation.members().size(), wanted_members)) {
201 e.add_relation_members(relation);
169202 }
170203 }
171204
4141 osmium::index::IdSetDense<osmium::unsigned_object_id_type> relation_ids;
4242 osmium::index::IdSetDense<osmium::unsigned_object_id_type> extra_relation_ids;
4343
44 void add_relation(const osmium::Relation& relation);
44 void add_relation_members(const osmium::Relation& relation);
4545 void add_relation_parents(osmium::unsigned_object_id_type id, const osmium::index::RelationsMapIndex& map);
4646 };
4747
5555
5656 std::vector<std::string> m_types;
5757
58 std::size_t m_complete_partial_relations_percentage = 100;
59
60 bool check_members_count(const std::size_t size, const std::size_t wanted_members) const noexcept;
5861 bool check_type(const osmium::Relation& relation) const noexcept;
5962
6063 public:
3939 if (p.second < 0) {
4040 throw std::runtime_error{"This command does not work with negative IDs"};
4141 }
42 ids(p.first).set(p.second);
42 ids(p.first).set(static_cast<osmium::unsigned_object_id_type>(p.second));
4343 }
4444
4545 void read_id_file(std::istream& stream, ids_type& ids, osmium::item_type default_item_type) {
175175 }
176176
177177 po::options_description with_osm_output::add_output_options() {
178 po::options_description options("OUTPUT OPTIONS");
178 po::options_description options{"OUTPUT OPTIONS"};
179179
180180 options.add_options()
181181 ("output-format,f", po::value<std::string>(), "Format of output file")
2222
2323 */
2424
25 #include <osmium/io/file.hpp>
2526 #include <osmium/osm/box.hpp>
2627 #include <osmium/osm/entity_bits.hpp>
2728 #include <osmium/tags/matcher.hpp>
29 #include <osmium/tags/tags_filter.hpp>
2830 #include <osmium/util/string_matcher.hpp>
2931
3032 #include <string>
3133 #include <utility>
3234 #include <vector>
33
34 namespace osmium {
35
36 class TagsFilter;
37
38 namespace io {
39 class File;
40 } // namespace io
41
42 } // namespace osmium
4335
4436 std::string get_filename_suffix(const std::string& file_name);
4537 const char* yes_no(bool choice) noexcept;
66 #-----------------------------------------------------------------------------
77
88 function(check_add_locations_to_ways _name _options _input _output)
9 check_output(add-locations-to-ways ${_name} "add-locations-to-ways ${_options} --generator=test --output-format=xml add-locations-to-ways/${_input}" "add-locations-to-ways/${_output}")
9 check_output(add-locations-to-ways ${_name} "add-locations-to-ways ${_options} --generator=test --output-header=xml_josm_upload=false --output-format=xml add-locations-to-ways/${_input}" "add-locations-to-ways/${_output}")
1010 endfunction()
1111
1212 check_add_locations_to_ways(taggednodes "" input.osm output.osm)
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
33 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
44 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1">
33 <tag k="some" v="tag"/>
44 </node>
1919 check_cat(cat12 input1.osm input2.osm output-cat12.osm)
2020 check_cat(cat21 input2.osm input1.osm output-cat21.osm)
2121
22 check_convert(osm2opl input1.osm output1.osm.opl opl)
22 check_convert(osm input1.osm output1.osm.opl opl)
23 check_convert(gzip input1.osm.gz output1.osm.opl opl)
24 check_convert(bzip2 input1.osm.bz2 output1.osm.opl opl)
25 check_convert(pbf input1.osm.pbf output1.osm.opl opl)
26 check_convert(opl output1.osm.opl output1.osm.opl opl)
2327
2428
2529 #-----------------------------------------------------------------------------
Binary diff not shown
Binary diff not shown
Binary diff not shown
55 #
66 #-----------------------------------------------------------------------------
77
8 function(check_fileinfo _name _options _input _output)
9 check_output(fileinfo ${_name} "fileinfo ${_options} fileinfo/${_input}" "fileinfo/${_output}")
10 endfunction()
8 if(NOT WIN32)
9 function(check_fileinfo _name _options _input _output)
10 check_output(fileinfo ${_name} "fileinfo ${_options} fileinfo/${_input}" "fileinfo/${_output}")
11 endfunction()
12
13 check_fileinfo(fi1-extended "--extended --crc" fi1.osm fi1-result.txt)
14 endif()
1115
1216 #-----------------------------------------------------------------------------
13
14 check_fileinfo(fi1-extended "--extended --crc" fi1.osm fi1-result.txt)
1517
1618 add_test(NAME fileinfo-g-generator COMMAND osmium fileinfo ${CMAKE_SOURCE_DIR}/test/fileinfo/fi1.osm -g header.option.generator)
1719 set_tests_properties(fileinfo-g-generator PROPERTIES PASS_REGULAR_EXPRESSION "^testdata\n$")
88 Options:
99 generator=testdata
1010 version=0.6
11 xml_josm_upload=false
1112 Data:
1213 Bounding box: (1,1,1,3)
1314 Timestamps:
3031 Largest relation ID: 0
3132 All objects have following metadata attributes: all
3233 Some objects have following metadata attributes: all
34 Number of buffers: 1 (avg 5 objects per buffer)
35 Sum of buffer sizes: 224 (0 GB)
36 Sum of buffer capacities: 1048576 (0.001 GB, 0% full)
66 #-----------------------------------------------------------------------------
77
88 function(check_getid _name _input _output)
9 check_output(getid ${_name} "getid --generator=test -f osm getid/${_input} n11,n12 w21" "getid/${_output}")
9 check_output(getid ${_name} "getid --generator=test --output-header=xml_josm_upload=false -f osm getid/${_input} n11,n12 w21" "getid/${_output}")
1010 endfunction()
1111
1212 function(check_getid_file _name _file _input _output)
13 check_output(getid ${_name} "getid --generator=test -i getid/${_file} -f osm getid/${_input}" "getid/${_output}")
13 check_output(getid ${_name} "getid --generator=test --output-header=xml_josm_upload=false -i getid/${_file} -f osm getid/${_input}" "getid/${_output}")
1414 endfunction()
1515
1616 check_getid(n input.osm output.osm)
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
33 </osm>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
33 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
44 <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
33 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
44 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
33 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
44 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
33 <relation id="32" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
44 <member type="node" ref="13" role=""/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
33 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
44 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
33 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
44 <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
33 <member type="relation" ref="31" role=""/>
44 </relation>
66 #-----------------------------------------------------------------------------
77
88 function(check_getparents _name _input _ids _output)
9 check_output(getparents ${_name} "getparents --generator=test -f osm getparents/${_input} ${_ids}" "getparents/${_output}")
9 check_output(getparents ${_name} "getparents --generator=test --output-header=xml_josm_upload=false -f osm getparents/${_input} ${_ids}" "getparents/${_output}")
1010 endfunction()
1111
1212 function(check_getparents_r _name _input _ids _output)
13 check_output(getparents ${_name}-s "getparents --generator=test -f osm --add-self getparents/${_input} ${_ids}" "getparents/${_output}")
13 check_output(getparents ${_name}-s "getparents --generator=test --output-header=xml_josm_upload=false -f osm --add-self getparents/${_input} ${_ids}" "getparents/${_output}")
1414 endfunction()
1515
1616 #-----------------------------------------------------------------------------
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
33 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
44 <nd ref="10"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
33 <nd ref="10"/>
44 <nd ref="11"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
33 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
44 <nd ref="10"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
33 <nd ref="10"/>
44 <nd ref="11"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
33 <nd ref="10"/>
44 <nd ref="11"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
33 <member type="node" ref="12" role="m1"/>
44 <member type="way" ref="20" role="m2"/>
77
88 function(check_sort2 _name _in1 _in2 _output)
99 check_output(sort ${_name} "sort --generator=test -f osm sort/${_in1} sort/${_in2}" "sort/${_output}")
10 check_output(sort ${_name}_mp "sort --generator=test -f osm -s multipass sort/${_in1} sort/${_in2}" "sort/${_output}")
1011 endfunction()
1112
1213 function(check_sort1 _name _input _output _format)
1314 check_output(sort ${_name} "sort --generator=test -f ${_format} sort/${_input}" "sort/${_output}")
15 check_output(sort ${_name}_mp "sort --generator=test -f ${_format} -s multipass sort/${_input}" "sort/${_output}")
1416 endfunction()
1517
1618
55 #
66 #-----------------------------------------------------------------------------
77
8 function(check_tags_filter_R _name _input _expressions _output)
9 check_output(tags-filter ${_name} "tags-filter --generator=test -f osm -R tags-filter/${_input} ${_expressions}" "tags-filter/${_output}")
8 function(check_tags_filter _name _flags _input _expressions _output)
9 check_output(tags-filter ${_name} "tags-filter --generator=test --output-header=xml_josm_upload=false -f osm ${_flags} tags-filter/${_input} ${_expressions}" "tags-filter/${_output}")
1010 endfunction()
1111
12 function(check_tags_filter_i _name _input _expressions _output)
13 check_output(tags-filter ${_name} "tags-filter --generator=test -f osm -i -R tags-filter/${_input} ${_expressions}" "tags-filter/${_output}")
14 endfunction()
12 check_tags_filter(node "" input.osm n/amenity output-amenity.osm)
13 check_tags_filter(node-R "-R" input.osm n/amenity output-amenity.osm)
1514
16 function(check_tags_filter _name _input _expressions _output)
17 check_output(tags-filter ${_name} "tags-filter --generator=test -f osm tags-filter/${_input} ${_expressions}" "tags-filter/${_output}")
18 endfunction()
15 check_tags_filter(highway-R "-R" input.osm w/highway output-highway-R.osm)
16 check_tags_filter(note-R "-R" input.osm note output-note-R.osm)
1917
20 check_tags_filter_R(node input.osm n/amenity output-amenity.osm)
21 check_tags_filter_R(highway input.osm w/highway output-highway.osm)
22 check_tags_filter_R(note input.osm note output-note.osm)
18 check_tags_filter(note-iR "-i -R" input.osm note output-note-iR.osm)
2319
24 check_tags_filter_i(note-i input.osm note output-no-note.osm)
20 check_tags_filter(highway "" input.osm w/highway output-highway.osm)
2521
26 check_tags_filter(highway-r input.osm w/highway output-highway-r.osm)
22 check_tags_filter(highway-i "-i" input.osm w/highway output-highway-i.osm)
2723
24 check_tags_filter(highway-n-i "-i" input-nodes.osm w/highway output-nodes-highway-i.osm)
25
26 check_tags_filter(note-rel "" input.osm r/note output-note-rel.osm)
27
28 check_tags_filter(highway-t "-t" input.osm w/highway output-highway-t.osm)
29 check_tags_filter(highway-it "-i -t" input.osm w/highway output-highway-it.osm)
30 check_tags_filter(note-rel-t "-t" input.osm r/note output-note-rel-t.osm)
2831
2932 #-----------------------------------------------------------------------------
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="testdata">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1">
4 <tag k="barrier" v="gate"/>
5 </node>
6 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
7 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
8 <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1">
9 <tag k="amenity" v="post_box"/>
10 </node>
11 <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1">
12 <tag k="highway" v="traffic_signals"/>
13 </node>
14 </osm>
00 <?xml version='1.0' encoding='UTF-8'?>
11 <osm version="0.6" upload="false" generator="testdata">
22 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1">
4 <tag k="barrier" v="gate"/>
5 </node>
46 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
57 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
68 <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1">
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1">
33 <tag k="amenity" v="post_box"/>
44 </node>
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="test">
2 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
3 <nd ref="10"/>
4 <nd ref="11"/>
5 <nd ref="12"/>
6 <tag k="highway" v="primary"/>
7 </way>
8 <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
9 <nd ref="12"/>
10 <nd ref="13"/>
11 <tag k="highway" v="residential"/>
12 <tag k="note" v="test"/>
13 </way>
14 </osm>
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1">
4 <tag k="barrier" v="gate"/>
5 </node>
6 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
7 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
8 <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1">
9 <tag k="amenity" v="post_box"/>
10 </node>
11 <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1">
12 <tag k="highway" v="traffic_signals"/>
13 </node>
14 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
15 <nd ref="10"/>
16 <nd ref="11"/>
17 <nd ref="12"/>
18 <tag k="highway" v="primary"/>
19 </way>
20 <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
21 <member type="node" ref="12" role="m1"/>
22 <member type="way" ref="20" role="m2"/>
23 <tag k="note" v="test"/>
24 </relation>
25 </osm>
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1">
4 <tag k="barrier" v="gate"/>
5 </node>
6 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
7 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
8 <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1">
9 <tag k="amenity" v="post_box"/>
10 </node>
11 <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1">
12 <tag k="highway" v="traffic_signals"/>
13 </node>
14 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
15 <nd ref="10"/>
16 <nd ref="11"/>
17 <nd ref="12"/>
18 </way>
19 <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
20 <member type="node" ref="12" role="m1"/>
21 <member type="way" ref="20" role="m2"/>
22 <tag k="note" v="test"/>
23 </relation>
24 </osm>
+0
-19
test/tags-filter/output-highway-r.osm less more
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
4 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
5 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
6 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
7 <nd ref="10"/>
8 <nd ref="11"/>
9 <nd ref="12"/>
10 <tag k="highway" v="primary"/>
11 </way>
12 <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
13 <nd ref="12"/>
14 <nd ref="13"/>
15 <tag k="highway" v="residential"/>
16 <tag k="note" v="test"/>
17 </way>
18 </osm>
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
4 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
5 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
6 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
7 <nd ref="10"/>
8 <nd ref="11"/>
9 <nd ref="12"/>
10 <tag k="highway" v="primary"/>
11 </way>
12 <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
13 <nd ref="12"/>
14 <nd ref="13"/>
15 <tag k="highway" v="residential"/>
16 <tag k="note" v="test"/>
17 </way>
18 </osm>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1">
4 <tag k="barrier" v="gate"/>
5 </node>
6 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
7 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
28 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
39 <nd ref="10"/>
410 <nd ref="11"/>
+0
-19
test/tags-filter/output-no-note.osm less more
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
4 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
5 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
6 <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1">
7 <tag k="amenity" v="post_box"/>
8 </node>
9 <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1">
10 <tag k="highway" v="traffic_signals"/>
11 </node>
12 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
13 <nd ref="10"/>
14 <nd ref="11"/>
15 <nd ref="12"/>
16 <tag k="highway" v="primary"/>
17 </way>
18 </osm>
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1">
4 <tag k="barrier" v="gate"/>
5 </node>
6 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
7 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
8 <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1">
9 <tag k="amenity" v="post_box"/>
10 </node>
11 <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1">
12 <tag k="highway" v="traffic_signals"/>
13 </node>
14 </osm>
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="test">
2 <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
3 <nd ref="12"/>
4 <nd ref="13"/>
5 <tag k="highway" v="residential"/>
6 <tag k="note" v="test"/>
7 </way>
8 <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
9 <member type="node" ref="12" role="m1"/>
10 <member type="way" ref="20" role="m2"/>
11 <tag k="note" v="test"/>
12 </relation>
13 </osm>
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1">
4 <tag k="barrier" v="gate"/>
5 </node>
6 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
7 <node id="13" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="4" lon="1"/>
8 <node id="14" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="5" lon="1">
9 <tag k="amenity" v="post_box"/>
10 </node>
11 <node id="15" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="6" lon="1">
12 <tag k="highway" v="traffic_signals"/>
13 </node>
14 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
15 <nd ref="10"/>
16 <nd ref="11"/>
17 <nd ref="12"/>
18 <tag k="highway" v="primary"/>
19 </way>
20 </osm>
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
4 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
5 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
6 <nd ref="10"/>
7 <nd ref="11"/>
8 <nd ref="12"/>
9 </way>
10 <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
11 <member type="node" ref="12" role="m1"/>
12 <member type="way" ref="20" role="m2"/>
13 <tag k="note" v="test"/>
14 </relation>
15 </osm>
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" upload="false" generator="test">
2 <node id="10" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
3 <node id="11" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1">
4 <tag k="barrier" v="gate"/>
5 </node>
6 <node id="12" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
7 <way id="20" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
8 <nd ref="10"/>
9 <nd ref="11"/>
10 <nd ref="12"/>
11 <tag k="highway" v="primary"/>
12 </way>
13 <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
14 <member type="node" ref="12" role="m1"/>
15 <member type="way" ref="20" role="m2"/>
16 <tag k="note" v="test"/>
17 </relation>
18 </osm>
+0
-14
test/tags-filter/output-note.osm less more
0 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
2 <way id="21" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
3 <nd ref="12"/>
4 <nd ref="13"/>
5 <tag k="highway" v="residential"/>
6 <tag k="note" v="test"/>
7 </way>
8 <relation id="30" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1">
9 <member type="node" ref="12" role="m1"/>
10 <member type="way" ref="20" role="m2"/>
11 <tag k="note" v="test"/>
12 </relation>
13 </osm>
66 #-----------------------------------------------------------------------------
77
88 function(check_time_filter _name _type _from _to _output)
9 check_output(time-filter ${_name} "time-filter --generator=test -f ${_type} time-filter/input.osh ${_from} ${_to}" "time-filter/output-${_output}.${_type}")
9 check_output(time-filter ${_name} "time-filter --generator=test --output-header=xml_josm_upload=false -f ${_type} time-filter/input.osh ${_from} ${_to}" "time-filter/output-${_output}.${_type}")
1010 endfunction()
1111
1212 #-----------------------------------------------------------------------------
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="2" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="3" lat="2" lon="3"/>
33 <node id="3" version="4" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" lat="3" lon="3"/>
44 </osm>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="1" lon="1"/>
33 <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/>
44 <node id="1" version="3" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" visible="true" lat="1" lon="3"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="1" lon="1"/>
33 <node id="2" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="2" lon="1"/>
44 <node id="3" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="3" lon="1"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="1" lon="1"/>
33 <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/>
44 <node id="2" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" visible="true" lat="2" lon="1"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/>
33 <node id="2" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="2" lon="2"/>
44 <node id="2" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="3" visible="true" lat="2" lon="3"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/>
33 <node id="1" version="3" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" visible="true" lat="1" lon="3"/>
44 <node id="2" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="2" lon="2"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="1" lon="2"/>
33 <node id="1" version="3" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" visible="true" lat="1" lon="3"/>
44 <node id="2" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" visible="true" lat="2" lon="2"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="1" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="1" lon="1"/>
33 <node id="2" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="2" lon="1"/>
44 <node id="3" version="1" timestamp="2015-01-01T01:00:00Z" uid="1" user="test" changeset="1" lat="3" lon="1"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="1" version="2" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" lat="1" lon="2"/>
33 <node id="2" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="3" lat="2" lon="3"/>
44 <node id="3" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="2" lat="3" lon="2"/>
00 <?xml version='1.0' encoding='UTF-8'?>
1 <osm version="0.6" generator="test">
1 <osm version="0.6" upload="false" generator="test">
22 <node id="1" version="3" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" lat="1" lon="3"/>
33 <node id="2" version="3" timestamp="2015-01-01T02:00:00Z" uid="1" user="test" changeset="3" lat="2" lon="3"/>
44 <node id="3" version="4" timestamp="2015-01-01T03:00:00Z" uid="1" user="test" changeset="3" lat="3" lon="3"/>